An open, multi-model agentic coding CLI — inspired by Claude Code
Project description
AgentCode
An open, multi-model agentic coding assistant — available as a CLI and VS Code extension. Inspired by Claude Code.
Works with Claude, GPT, Gemini, and any model supported by LiteLLM.
Choose your setup
Option A: CLI only
pip install agentcode-cli
Add your API key to a .env file in your project:
ANTHROPIC_API_KEY=sk-ant-...
OPENAI_API_KEY=sk-... # optional
GEMINI_API_KEY=... # optional
Run:
agentcode # interactive REPL
agentcode "fix the failing tests" # one-shot mode
agentcode --model gpt-4o # use a specific model
Option B: VS Code Extension
The extension requires the CLI installed as a backend. Install it first.
Step 1 — Install the CLI:
pip install agentcode-cli
Step 2 — Install the extension:
- Search AgentCode in the VS Code Marketplace and install, or
- Download
agentcode-1.1.1.vsixfrom the GitHub releases page and install viaCmd+Shift+X→...→ Install from VSIX...
Step 3 — Add your API key:
Cmd+, → search AgentCode → paste your key into agentcode.anthropicApiKey
Step 4 — Open the chat panel:
Press Cmd+Shift+A
Extension settings
| Setting | Description |
|---|---|
agentcode.anthropicApiKey |
Anthropic API key |
agentcode.openaiApiKey |
OpenAI API key |
agentcode.geminiApiKey |
Google Gemini API key |
agentcode.model |
Default model (e.g. claude-sonnet-4-6) |
agentcode.executablePath |
Path to agentcode if not on PATH |
agentcode.inlineCompletions.enabled |
Enable/disable inline completions (default: true) |
Extension commands
| Command | Shortcut | Description |
|---|---|---|
AgentCode: Open |
Cmd+Shift+A |
Open the chat panel |
AgentCode: Ask about selection |
Right-click | Ask about highlighted code |
AgentCode: Explain this file |
Right-click | Explain the current file |
AgentCode: Toggle inline completions |
Command Palette | Enable or disable inline completions |
Extension features
- Inline completions — AI-powered ghost-text suggestions as you type, powered by Claude Haiku. Press
Tabto accept - Live streaming — responses stream in real time
- Model picker — switch between Claude, GPT, and Gemini models from the dropdown in the header
- Active file context — your current file is sent automatically, no copy-pasting needed
- Diff viewer — edit tool calls open VS Code's native diff viewer so you can review changes before applying
- Right-click actions — ask about selected code or explain a file directly from the editor
Supported Models
| Provider | Model | API Key |
|---|---|---|
| Anthropic | claude-sonnet-4-6 (default) |
ANTHROPIC_API_KEY |
| Anthropic | claude-opus-4-7 |
ANTHROPIC_API_KEY |
| Anthropic | claude-haiku-4-5-20251001 |
ANTHROPIC_API_KEY |
| OpenAI | gpt-4o, gpt-4o-mini, gpt-5.5 |
OPENAI_API_KEY |
gemini/gemini-2.5-pro, gemini/gemini-2.5-flash |
GEMINI_API_KEY |
Cost-Aware Routing
AgentCode automatically picks the cheapest model that can handle the task:
| Tier | Anthropic | OpenAI | Gemini |
|---|---|---|---|
| Light | Haiku 4.5 | GPT-4o Mini | Gemini 2.0 Flash |
| Medium | Sonnet 4.6 | GPT-4o | Gemini 2.5 Flash |
| Heavy | Opus 4.7 | GPT-5.5 | Gemini 2.5 Pro |
Simple questions go to cheap/fast models. Complex multi-file tasks go to powerful ones. Use --no-route to always use the specified model.
Tools
File & Shell
| Tool | Description | Permission |
|---|---|---|
read_file |
Read file contents with line numbers | Auto |
write_file |
Create or overwrite a file | Ask |
edit_file |
Surgical find-and-replace edit | Ask |
run_command |
Execute a bash command | Ask |
list_directory |
Tree view of directory structure | Auto |
search_files |
Find files by glob pattern | Auto |
search_text |
Grep for text across files | Auto |
Git
| Tool | Description | Permission |
|---|---|---|
git_status |
Show working tree status | Auto |
git_diff |
Show staged or unstaged changes | Auto |
git_log |
Show recent commit history | Auto |
git_commit |
Stage files and create a commit | Ask |
git_branch |
List, create, or switch branches | Ask |
git_push |
Push commits to a remote | Ask |
Subagents
| Tool | Description | Permission |
|---|---|---|
spawn_subagents |
Run multiple agents in parallel on subtasks | Auto |
Permission model: Read-only tools auto-approve. Write/execute tools ask before running (unless --auto-approve / -y is set).
Slash Commands (CLI only)
| Command | Description |
|---|---|
/model <name> |
Switch model on the fly |
/route |
Show or toggle cost-aware routing |
/cost |
Show session cost breakdown |
/mcp |
Manage MCP server connections |
/mcp list |
Show connected servers |
/mcp add <server> |
Connect a server |
/mcp remove <server> |
Disconnect a server |
/clear |
Reset conversation and delete saved session |
/compact |
Force LLM-powered context compaction |
/tokens |
Show estimated token usage |
/init |
Create an AGENTCODE.md template |
/settings |
Show resolved settings |
/help |
Show help |
/exit |
Quit |
Session Persistence
Conversations are automatically saved to .agentcode_session.json in your project directory and resumed on next launch. Use /clear to start fresh.
MCP Support (CLI only)
Connect to any MCP server using /mcp add:
/mcp add github # prompts for GitHub token
/mcp add filesystem # no credentials needed
/mcp add postgres # prompts for connection string
/mcp add sqlite # prompts for database path
Config is saved to .agentcode/mcp.json and reloaded on next launch.
Advanced — edit .agentcode/mcp.json directly for custom servers:
{
"mcpServers": {
"my-server": {
"command": "npx",
"args": ["-y", "@myorg/mcp-server"],
"env": {"API_KEY": "..."}
}
}
}
Global config goes in ~/.agentcode/mcp.json.
Hooks
Run shell commands before or after any tool call. Create .agentcode/hooks.json:
{
"post_edit_file": "prettier --write \"$AGENTCODE_PATH\"",
"post_write_file": "prettier --write \"$AGENTCODE_PATH\"",
"pre_run_command": "echo \"Running: $AGENTCODE_COMMAND\""
}
Supported keys: pre_<toolname>, post_<toolname>, pre_tool / post_tool (wildcard). Global hooks go in ~/.agentcode/hooks.json.
AGENTCODE.md
AgentCode loads project instructions from AGENTCODE.md in your project directory and injects them into the system prompt automatically. Run /init to generate a starter template.
Subagents
AgentCode can spawn parallel agents for independent subtasks:
"Analyze agent.py, router.py, and tools.py in parallel and summarize each one"
The agent calls spawn_subagents internally, runs up to 5 agents in parallel, and returns combined results.
Architecture
┌─────────────────────────────────────────────────┐
│ cli.py (UI) │
│ REPL loop · slash commands · Rich terminal UI │
│ AGENTCODE.md · session persistence │
└──────────────────────┬──────────────────────────┘
│
┌──────────────────────▼──────────────────────────┐
│ agent.py (Brain) │
│ Agentic loop · context management · permissions│
│ Hooks · subagents · LLM-powered compaction │
│ │
│ while needs_follow_up: │
│ 1. Send messages + tools → LLM │
│ 2. If tool_calls → execute, append, loop │
│ 3. If text only → done │
│ │
│ LiteLLM ──→ Claude / GPT / Gemini │
└──────────────────────┬──────────────────────────┘
│
┌────────────┴────────────┐
│ │
┌─────────▼───────────┐ ┌─────────▼───────────┐
│ tools.py (Hands) │ │ mcp_client.py │
│ read_file │ │ Connect to MCP │
│ write_file │ │ servers and expose │
│ edit_file │ │ their tools to the │
│ run_command │ │ agent loop. │
│ list_directory │ └─────────────────────┘
│ search_files │
│ search_text │
│ git_status/diff │
│ git_log/commit │
│ git_branch/push │
│ spawn_subagents │
└─────────────────────┘
Environment Variables
| Variable | Description | Default |
|---|---|---|
AGENTCODE_MODEL |
Default model | claude-sonnet-4-6 |
AGENTCODE_MAX_ITERATIONS |
Max tool-call iterations per turn | 25 |
ANTHROPIC_API_KEY |
Anthropic API key | — |
OPENAI_API_KEY |
OpenAI API key | — |
GEMINI_API_KEY |
Google Gemini API key | — |
How to Extend
Add a new tool
- Add the function schema to
TOOL_DEFINITIONSintools.py - Implement the function
- Register it in
TOOL_MAP - If it requires approval, omit it from
permissions.auto_approvein.agentcode/settings.json
Publishing to PyPI
pip install build twine
python -m build
twine upload dist/*
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agentcode_cli-1.3.1.tar.gz.
File metadata
- Download URL: agentcode_cli-1.3.1.tar.gz
- Upload date:
- Size: 38.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ad01f995327584b929b97e877528ae8368cb0c68c5b6ffc3e29576f17919f1d
|
|
| MD5 |
6cb7ac398c9508ded24b79736fc933de
|
|
| BLAKE2b-256 |
23c6a10af2f8282b8b2bab64a5eb2c8d056951229178af2360768e2d17e2422d
|
File details
Details for the file agentcode_cli-1.3.1-py3-none-any.whl.
File metadata
- Download URL: agentcode_cli-1.3.1-py3-none-any.whl
- Upload date:
- Size: 37.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e39b8063cc80297441e0893768f366b204e338d01528ee40687c70a4ffc1fba2
|
|
| MD5 |
bf5dc8fbcff1de69e3c2ab0021922390
|
|
| BLAKE2b-256 |
a2b17a4719b9ad8bb8b59c90804dabd5f086562fb353e05508f2479e6f5bab5e
|