AstraCode is an agentic coding CLI with a planner/executor architecture, provider-first model selection, local-runtime support (Ollama and llama.cpp), and an in-terminal TUI optimized for real coding workflows.
It is designed for a hybrid setup:
- Planner model for deeper reasoning and task decomposition.
- Executor model for fast file edits and command execution.
- Tool loop for shell, file, git, diagnostics, and web search actions.
- What AstraCode does
- Core features
- Architecture
- Install and setup
- Running AstraCode
- Configuration reference
- Provider and model management
- Interactive TUI and keybindings
- AstrAPI for remote/local GPU serving
- Tooling behavior
- Verification and git workflows
- Developer scripts and testing
- Troubleshooting
- Version notes
- License
AstraCode accepts natural-language coding requests, routes them to the right role (planner or executor), and performs end-to-end implementation using tools:
- edit/write files
- run shell commands
- inspect diagnostics
- search the codebase
- use internet search when needed
- run git operations
The output in chat is rendered with Markdown-aware code block styling, and file changes are shown in a dedicated in-place change review panel.
| Feature | Description |
|---|---|
| Smart router | Auto-decides planner vs executor based on request complexity. |
| Role-specific prompting | Planner and executor each use dedicated prompt behavior. |
| Provider-first model picker | /model-plan and /model-exe open provider-first model selection with filtering and scrolling. |
| Multi-provider support | Works with OpenAI-compatible providers (NVIDIA, Google, OpenRouter, Hugging Face, xAI, etc.). |
| Multi-language coding | Uses requested language or infers from project stack/necessity (Python, Java, C, C++, Go, Rust, TS/JS, etc.) instead of forcing one default. |
| Local runtime options | Native support for Ollama and llama.cpp execution paths. |
| AstrAPI integration | Connect to local/LAN OpenAI-compatible endpoint for remote GPU workflows. |
| Code-style output rendering | Shell and git outputs are shown in readable code-block style panels. |
| Change review panel | File edits update OLD/NEW review panel, navigable with [ and ]. |
| Verification guardrail | Optional auto-verify command after edits (/verify). |
| Auto peer review pass | For substantial/risky edits, AstraCode runs a git-diff peer review pass before finalizing. |
| Disposable shell session | /cmd and agent shell calls share a conversation-scoped working directory (cd persists until session ends). |
| Context efficiency guard | Long sessions are compacted to recent high-value context to keep task execution fast and stable. |
| Built-in git controls | /git status, /git diff, /git commit plus aliases. |
- User enters prompt in TUI.
- Router chooses role (
plannerorexecutor) when mode isauto. - Agent loop calls tools as needed.
- Tool outputs stream into chat with styled rendering.
- File changes are reflected in change-review panel.
- Planner
- best for architecture, decomposition, multi-step strategy
- typically a stronger reasoning model
- Executor
- best for concrete implementation, file edits, command execution
- can be a faster local model
auto(recommended)planner-onlyexecutor-only
Switch with slash commands:
/router auto
/router planner-only
/router executor-only
- Node.js 20+ recommended
- npm 10+
- Git
- Optional runtimes:
- Ollama
- llama.cpp (
llama-server)
git clone <your-repo-url>
cd astracode_main
npm install
npm run buildnpm run install:globalThis links:
astracode(main CLI)astrapi(node_runner launcher)
npm run alias:installThen restart the terminal.
On macOS, npm install now auto-runs alias setup and inserts an astracode shell function into ~/.zshrc and ~/.bashrc (idempotent marker block).
You can also run it manually:
npm run alias:install:macosastracodeor
astracode chat
astracode chat "Create a TypeScript script that parses CSV and run it"astracode chat --ollama
astracode chat --ollama qwen3.5:latest
astracode chat --llama
astracode chat --llama DeepSeek-R1-Distill-Qwen-7B-Q4_K_M.gguf
astracode chat --astrapi http://192.168.1.10:19090/v1Use these instead of awkward npm arg forwarding:
npm run dev:chat
npm run dev:ollama
npm run dev:llama
npm run dev:astrapiIf you use npm run dev directly:
npm run dev -- chat -- --ollama qwen3.5:latestDefault config location:
- Windows:
%USERPROFILE%\.astracode\config.json - macOS/Linux:
~/.astracode/config.json
{
"providers": {
"nvidia-plan": {
"baseUrl": "https://integrate.api.nvidia.com/v1",
"model": "minimaxai/minimax-m2.7",
"apiKeyEnv": "NVIDIA_API_KEY"
},
"ollama-executor": {
"baseUrl": "http://127.0.0.1:11434/v1",
"model": "qwen3.5:latest",
"apiKeyEnv": ""
}
},
"routing": {
"mode": "auto",
"planner": "nvidia-plan",
"executor": "ollama-executor"
},
"settings": {
"verboseToolOutput": false,
"liveToolRendering": true,
"confirmDestructiveCommands": true
},
"verification": {
"enabled": false,
"command": "npm test"
}
}Set provider keys in your shell profile, or place them in a workspace .env file (auto-loaded by AstraCode):
NVIDIA_API_KEY=...
GOOGLE_API_KEY=...Example .env:
NVIDIA_API_KEY=your_key_here
GOOGLE_API_KEY=your_key_hereOn startup, AstraCode auto-registers the built-in Gemini provider when GOOGLE_API_KEY is present and no Gemini-family provider is already configured.
Only keys referenced by apiKeyEnv are required.
If you want a fast default setup with free-tier endpoints:
| Role | Provider | Recommended model |
|---|---|---|
| Planner | NVIDIA (nvidia-plan) |
Use the top [free] model from /provider test nvidia-plan |
| Executor | OpenRouter (openrouter) |
google/gemma-4-31b-it:free |
GOOGLE_API_KEY auto-registers gemini with gemini-2.5-flash as its default model.
When you type /model-plan or /model-exe and press enter:
- AstraCode shows provider families first (nvidia/gemini/openrouter/huggingface/xai/...).
- After choosing a provider, it shows the discovered model pool from configured provider APIs, then applies the selected model to the chosen backend.
- Type to filter.
- Use arrow keys to scroll through the full list.
- Free-tier endpoints (when provider metadata exposes pricing/free-tier tags) are marked with
[free]. - Press enter to apply.
Escape behavior:
Escin model list: back to provider list.Escagain: close picker.
| Command | Description |
|---|---|
/help |
Show all available commands |
/status |
Show planner, executor, routing, session info |
/monitor |
Show AstraCode workload and CPU/memory usage |
/config |
Print full JSON configuration |
/verbose |
Toggle verbose tool output on/off |
/live on|off |
Toggle live tool/result rendering in chat |
/confirm on|off |
Toggle confirmation before destructive commands |
/verify on|off|status |
Control auto verification after file edits |
/verify cmd <command> |
Set verification command (default: npm test) |
/provider list |
List all registered providers |
/provider add <name> <url> <model> [apiKeyEnv] |
Add an OpenAI-compatible provider |
/provider test <name> |
Test provider connectivity and model catalog |
/provider use <planner|executor> <name> |
Assign a provider to a role |
/provider set url <name> <url> |
Set remote URL for a provider |
/astrapi connect <name> <url> [model] |
Register AstrAPI endpoint as provider |
/astrapi test <name> |
Test a registered AstrAPI provider |
/astrapi list |
List local/LAN-style providers |
/router auto |
Enable automatic smart routing |
/router planner-only |
Force all requests to planner |
/router executor-only |
Force all requests to executor |
/model-plan <model> |
Set planner model (no arg: list available models by provider) |
/model-exe <model> |
Set executor model (no arg: list available models by provider) |
/model planner <model> |
Legacy alias: change planner model |
/model executor <model> |
Legacy alias: change executor model |
/init |
Initialize .astracode workspace metadata in current directory |
/learn [focus] |
Generate/update .astracode/learn.md project design context |
/plan status |
Show pending implementation plan status |
/plan open |
Open pending implementation plan in your default editor |
/plan accept [index|plan-id] |
Accept pending plan or choose a saved plan from plan/ |
/plan reject |
Reject and clear pending implementation plan |
/plan <idea> |
Draft a plan immediately for the provided idea |
/models |
List available models from all configured provider APIs |
/workspace |
Set workspace directory <path> |
/workspace show |
Show current workspace path |
/git status |
Show git working tree status |
/git diff |
Show git diff (unstaged by default) |
/git commit <message> |
Commit all changes with a message |
/diff |
Alias for /git diff |
/commit <message> |
Alias for /git commit <message> |
/cmd <command> |
Run a native shell command directly |
/clear |
Clear the screen / reset UI |
/exit |
Quit AstraCode |
/quit |
Quit AstraCode |
No-argument behavior:
/model-planand/model-exeopen interactive selection./modelslists discovered models from configured provider APIs./initcreates a workspace.astracode/folder and registers.astracode/learn.mdas always-on context./learn [focus]generates/updates.astracode/learn.md(design-context document) for the current directory./plan <idea>drafts a plan immediately (saved underplan/), attempts to open it in your system default editor, and waits for/plan acceptor/plan reject./plan acceptnow browses saved plans when no pending in-memory plan exists, listing newest first./plan accept <index|plan-id>executes the selected saved plan fromplan/.- Website/scaffold-style requests can auto-approve and execute staged plan tasks, creating folder structure and starter files automatically.
/monitorshows live AstraCode workload plus CPU/memory/runtime telemetry.- Complex implementation requests now stage detailed markdown artifacts under
plan/using objective + session-linked names (for example:plan/<objective>__<session>__<timestamp>.plan.mdand.tasks.md) and wait for/plan acceptbefore execution.
- Header: app version, session, workspace, active planner/executor backend + model
- Conversation panel: scrollable middle viewport for full user/assistant/tool history
- Palette: slash command and model picker
- Change review panel: in-place OLD/NEW diff summary for file edits
- Status bar: route/activity hints
| Key | Behavior |
|---|---|
Enter |
Submit prompt / confirm picker choice. In command palette, auto-completes partial slash commands first. |
Tab |
Accept inline autocomplete suggestion (commands, provider names, model names) |
↑ / ↓ |
Navigate picker items; when picker is closed, recall previous/next input history |
Esc |
Close picker / step back in model picker / switch Insert → Normal (vim mode) |
PageUp / PageDown |
Scroll chat viewport up/down |
Ctrl+U / Ctrl+D |
Fast chat scroll up/down |
Home / End |
Jump chat scroll to oldest/newest |
i, a, A, h, l, 0, $, w, b, x, d{w,b,d}, j, k |
Vim-style normal mode editing/navigation |
[ / ] |
Navigate previous/next file-change preview |
a |
Accept current change review (hides it from panel) |
Ctrl+L |
Clear screen and redraw |
Ctrl+C |
Exit guard: requires 3 presses within short window to quit |
When command execution confirmation is enabled (/confirm on), shell commands require explicit y/n approval before running.
If /cmd exits non-zero, AstraCode now launches an automatic recovery pass to diagnose/fix and re-run.
By default, AstraCode uses the directory where you launched it as the active workspace (not a predefined path).
/cmd now uses a disposable shell session: cd updates session cwd and subsequent commands run from that directory for the rest of the active chat.
Ctrl+C now intentionally prevents accidental immediate exits:
- Press 1: warning
- Press 2: warning
- Press 3: exits
astrapi is a lightweight launcher/proxy in node_runner for exposing local runtimes as OpenAI-compatible endpoints.
-
On GPU laptop, run:
astrapi --llama
or
astrapi --ollama
to list models.
On Ubuntu, if
llama-serveris not in PATH, pass binary path directly:astrapi --llama --llama-bin ~/llama.cpp/build/bin/llama-server -
Start runtime with selected model:
astrapi --llama <model-file.gguf>
or
astrapi --ollama <ollama-model>
Example (Ubuntu + llama.cpp):
astrapi --llama qwen2.5-coder-7b-instruct-q4_k_m.gguf \ --model-dir ~/models \ --llama-bin ~/llama.cpp/build/bin/llama-server
- Enable reasoning mode when supported by your
llama-serverbuild:astrapi --llama <model.gguf> --thinking auto
- Pass any additional llama-server flags:
astrapi --llama <model.gguf> --extra-args "--jinja --no-webui"
- Environment variable equivalents:
ASTRAPI_LLAMA_BIN(orLLAMA_CPP_SERVER_PATH)ASTRAPI_REASONING_FORMAT(same as--thinking <format>)ASTRAPI_LLAMA_EXTRA_ARGS(same as--extra-args)
-
Copy emitted LAN URL (for example
http://192.168.1.44:19090/v1). -
On your coding machine:
- No token:
astracode chat --astrapi http://192.168.1.44:19090/v1
- Token-protected AstrAPI (set key in the same terminal session):
set "ASTRAPI_API_KEY=astracode123" && astracode chat --astrapi http://172.18.54.226:19090/v1
$env:ASTRAPI_API_KEY="astracode123"; astracode chat --astrapi http://172.18.54.226:19090/v1
export ASTRAPI_API_KEY=astracode123 && astracode chat --astrapi http://172.18.54.226:19090/v1
- No token:
This lets AstraCode use another device's local GPU inference as executor.
shellread_filewrite_fileeditdiagnosticsglobgreplsread_filessearch_webgit
The shell tool supports:
autocmdpwsh
When auto is used on Windows:
- PowerShell-style commands route to
pwsh(fallback to Windows PowerShell if needed) - generic commands route to
cmd
This improves "generate and run code automatically" behavior without manual runner switching.
Assistant messages and tool outputs render markdown/code blocks in framed code-style UI, making generated code and command output easier to read directly in chat.
/verify status
/verify on
/verify off
/verify cmd npm run build && npm test
When enabled, AstraCode runs the verification command after file write/edit operations.
/git status
/git diff
/git diff --staged
/git commit <message>
/diff
/commit <message>
| Script | Purpose |
|---|---|
npm test |
Run all unit tests (tsx --test) |
npm run build |
TypeScript compile to dist/ |
npm run dev |
Run CLI entry (tsx src/cli.ts) |
npm run dev:chat |
Direct chat boot |
npm run dev:ollama |
Chat with --ollama mode |
npm run dev:llama |
Chat with --llama mode |
npm run dev:astrapi |
Run node_runner/astrapi.js |
npm run install:global |
Link CLI globally (npm link) |
npm run alias:install |
Install PowerShell alias helper |
npm run alias:install:macos |
Install/update macOS shell alias in ~/.zshrc/~/.bashrc |
npm install |
Also runs macOS alias setup via postinstall |
npm run build
npm test- Run:
npm run build npm run install:global
- Restart terminal.
- Verify:
astracode --version
This was caused by Commander action argument parsing shape mismatch. Use the current build (v1.1.0+) and relink globally.
Run:
/status
to confirm planner/executor assignment and model values.
- Ensure provider endpoint supports
/models. - Run:
/provider test <name> /models - If endpoint changed, update URL:
/provider set url <name> <url>
AstraCode auto-falls back to powershell on Windows for PowerShell commands.
By design in v1.1.0, exiting requires 3 Ctrl+C presses to prevent accidental termination.
# Run AstraCode with Ollama and a specific model
astracode chat --ollama qwen3.5:latest
# Run AstraCode with llama.cpp and a specific model
astracode chat --llama qwen2.5-coder-7b-instruct-q4_k_m.gguf
# Run AstraCode with a local AstrAPI endpoint
astracode chat --astrapi http://192.168.1.44:19090/v1 Use these commands for your client terminal:
1. Windows CMD set "ASTRAPI_API_KEY=astracode123" && astracode chat --astrapi http://172.18.54.226:19090/v1
2. Windows PowerShell $env:ASTRAPI_API_KEY="astracode123"; astracode chat --astrapi http://172.18.54.226:19090/v1
3. Linux/macOS Bash export ASTRAPI_API_KEY=astracode123 && astracode chat --astrapi http://172.18.54.226:19090/v1- Added Ctrl+C exit guard (triple press required to quit).
- Unified CLI version display and command version metadata.
- Expanded README with full setup, architecture, runtime, model, TUI, and troubleshooting documentation.