TL;DR
- Install with
pip install code2 - Configure via environment variables (Uses free models by default!)
- Create dynamic AI-powered workflows in minutes
- Full Python API + plugin system for customization
This is how this article was created in a minute:
code2 prompt new blog
code2 prompt blog render
code2 prompt blog send wholefile
code2 prompt blog send wholefile > ~/src/blog/content/posts/2025-04-06-code2-ai-assisted-code-cli.md
This is the prompt I typed as the first command asked me to:
Write a blog article in markdown about our new code2 software based on the documentation you see here
{{read('/home/jpic/src/cli2/docs/code2.rst')}}
Like it? read on!
Why code2?
Tired of juggling AI tools and scripting hacks? Meet code2 - the CLI that bridges natural language prompts with real-world development tasks through a powerful AI-assisted pipeline.
Key Features:
- 🚀 Prompt Engineering CLI
- 🤖 LiteLLM Integration (Supports any LLM provider)
- 🧩 Extensible Plugin System
- ⚡ Response Caching (Reduce API costs)
- 🔧 Jinja2 Templating in Prompts
Getting Started
Installation
pip install code2
export OPENROUTER_API_KEY=your_key_here # For default free tier
Your First AI-Powered Workflow
-
Create a new prompt:
(This opens your $EDITOR - enter “create a hello world in python”)
-
Generate code:
code2 prompt hello send wholefile > hello.py -
Iterate with context-awareness:
code2 prompt hello edit # Add: "Update to print sys args {{read('hello.py')}}" code2 prompt hello send wholefile > hello.py
Watch as code2 intelligently modifies your script while maintaining context!
Advanced Usage
Python API
from code2.model import Model
from code2.prompt import Prompt
async def main():
model = Model.get('architect')
prompt = Prompt('hello')
result = await model.process(prompt, 'wholefile')
# Write result to file...
asyncio.run(main())
Workflows (Alpha)
code2 cmd pytest -vv tests/test_models.py # AI fixes failing tests automatically!
Plugin Types
- Workflows - Add new CLI commands
- Parsers - Custom input/output handlers
- Jinja2 - Extend template capabilities
- Backends - Support custom LLM APIs
code2: the AI hacking assistant where YOU are the hero!
After extensive experience with aider-chat and similar tools, we built code2 to address key pain points:
- True Plugin System - Extend in ANY direction
- CLI-First Philosophy - Works with your existing shell workflow
- Transparent Operations - No surprise commits/file modifications
- 12Factor-App Compliant - Configuration through environment variables
- Air-Gapped Friendly - Custom backend support out-of-the-box
Troubleshooting Made Simple
DEBUG=1 code2 prompt hello send # See detailed execution flow
Join the Revolution
Whether you’re:
- Automating repetitive tasks
- Prototyping complex systems
- Creating smart dev tools
- Building AI-powered CI/CD pipelines
code2 adapts to YOUR workflow. Install today and experience the future of development tooling!
Read The Friendly Documentation
Supercharge your terminal. Command smarter, not harder. 💻🚀