20 releases
0.2.9 | Feb 21, 2025 |
---|---|
0.2.8 | Feb 20, 2025 |
0.1.9 | Feb 4, 2025 |
0.1.4 | Jan 31, 2025 |
#2404 in Command line utilities
1,657 downloads per month
90KB
2K
SLoC
π cchain
Automate like the future depends on it.
Replace brittle shell scripts with AI-powered, retry-aware workflows. Built in Rust for speed and reliability.
β‘ Quick Example
Automate Git commits with AI-generated messages (no more "fix typo" commits!):
cchain run ./cchain_git_commit.json # Using a pre-built workflow to commit changes with AI
JSON Workflow (cchain_git_commit.json
):
[
{
"command": "git",
"arguments": ["add", "--all"],
"retry": 3
},
{
"command": "git",
"arguments": [
"commit", "-m",
"llm_generate('Summarize these changes in 1 line', 'git diff --staged')"
],
"failure_handling_options": {
"exit_on_failure": true,
"remedy_command_line": { "command": "git", "arguments": ["reset"] }
}
},
{
"command": "git",
"arguments": ["push"],
"retry": 2
}
]
π Why Developers Love cchain
Problem | cchain Solution |
---|---|
"Bash scripts break at 3 AM" | β Declarative JSON workflows with built-in retries |
"Commit messages take forever" | β AI-generated inputs via LLMs |
"Why does CI/CD fail locally?!" | β Identical behavior across local/CI environments |
"Makefiles are so 1980" | β Simple syntax with concurrency (beta) |
"Dependency hell" | β Single binaryβzero runtime dependencies |
π οΈ Features
π Chain Commands Like a Pro
- Retry failed steps (up to
N
times, or use-1
to retry indefinitely until succeeded) - Pass outputs between commands via environment variables
- Fix failures automatically: Roll back with
remedy_command_line
π€ AI-Powered Automation
"arguments": ["llm_generate('Summarize this error', 'cat crash.log')"]
- Integrate LLMs (OpenAI, local models via Ollama, etc.)
- Generate commit messages, error summaries, test data on the fly
π Cross-Platform Consistency
- Works on Linux/macOS/Windows out of the box
- No more
if [[ "$OSTYPE" == "linux-gnu"* ]]; then...
β‘ Performance Youβll Notice
- Built in Rustβstarts faster than your shellβs
&&
chain - Uses 10x less memory than Python/Ruby scripts
π¦ Installation
One-line install (requires Rust):
cargo install cchain
Pre-built binaries (coming soon!)
Subscribe for updates
π Getting Started
1. Create Your First Workflow
cchain new deploy --prompt "Create a workflow to pull docker image from xxx, then run it in the background"
AI generates a starter cchain_deploy.json
!
2. Run It!
cchain run ./cchain_deploy.json
3. Save for Later
cchain add ./cchain_deploy.json # Bookmark it as workflow #0
cchain run 0 # Re-run anytime
𧩠Advanced Usage
Dynamic Environment Variables
{
"command": "echo",
"arguments": ["Building $APP_VERSION"],
"environment_variables_override": {
"APP_VERSION": "llm_generate('Generate a semantic version')"
},
"stdout_stored_to": "BUILD_ID" # Pass to next command!
}
Concurrent Tasks (Beta)
{
"command": "xh download http://example.com/large-asset.zip",
"concurrency_group": 1 # Download 3 files in parallel
}
You may find examples in the ./examples
directory of this repo. Also, you may use the following command to generate a template chain file:
cchain new your_file_name
π Comparison
cchain |
Bash | Just | Python | |
---|---|---|---|---|
Retry Logic | β Built-in | β Manual | β Manual | β Manual |
AI Integration | β Native | β None | β None | β Add-ons |
Cross-Platform | β Single Bin | β (Fragile) | β | β (If setup) |
Learning Curve | Low (JSON) | High | Medium | High |
π οΈ Use Cases
CI/CD Made Simple
[
{ "command": "cargo test", "retry": 2 },
{ "command": "llm_generate('Write release notes', 'git log') > CHANGELOG.md" },
{ "command": "docker build -t myapp ." }
]
Developer Onboarding
cchain new setup --prompt "Clone repo, install deps, start services"
AI-Augmented Debugging
{
"command": "llm_generate('Fix this error', './failing_script.sh 2>&1')",
"stdout_stored_to": "FIX_SUGGESTION"
}
π Documentation
Guides
π€ Contributing
We welcome PRs!
π License
MIT Β© 2024 Xinyu Bao "Do whatever you wantβjust donβt make CI pipelines cry."
Dependencies
~16β28MB
~400K SLoC