What's New
OpenClaw-Inspired Features
Code Buddy incorporates advanced patterns from the OpenClaw project:
| Tool Policy System | β
100% | Fine-grained tool permissions with allowlist/denylist |
| Bash Allowlist | β
100% | Secure command execution with pattern matching |
| Context Window Guard | β
100% | Automatic context management with 34 test cases |
| Smart Compaction | β
100% | Multi-stage conversation compression |
| Context Pruning | β
100% | TTL-based message expiration |
| Hybrid Search | β
100% | Combined keyword + semantic search |
| Lifecycle Hooks | β
100% | Pre/post hooks with 52 test cases |
| Connection Profiles | β
100% | Multi-provider switching with 57 tests |
| Desktop Automation | β
100% | Screen capture, OCR, UI control |
| Gemini Vision | β
100% | Native image support via inlineData (base64 data URLs) |
| Auto-Capture Memory | β
100% | Pattern-based memory extraction |
| Memory Lifecycle | β
100% | Auto-recall and auto-capture hooks |
Phase 3 β Streaming & Security
| Middleware Pipeline | β
100% | Composable before/after turn hooks (cost limit, context warning, turn limit) |
| Reasoning Events | β
100% | Streaming chain-of-thought display with collapsible UI |
| Trust Folders | β
100% | Directory-level tool permissions via .codebuddy-trust.json |
| Agent Profiles | β
100% | Predefined agent configs (secure, minimal, power-user) |
| Tool Streaming | β
100% | Real-time bash output via AsyncGenerator |
| TabbedQuestion UI | β
100% | Multi-option interactive prompts |
Phase 4 β Autonomous Agent
| Daemon Mode | β
100% | Background process with PID management, auto-restart (max 3) |
| Cron-Agent Bridge | β
100% | Scheduled task execution via CodeBuddyAgent instances |
| Task Planner | β
100% | DAG-based decomposition with topological sort and parallel execution |
| Screen Observer | β
100% | Periodic screenshots, perceptual diff, event triggers |
| Proactive Agent | β
100% | Push notifications, question/response, rate limiting, quiet hours |
| Orchestrator | β
100% | Multi-agent supervisor (sequential/parallel/race/all strategies) |
| Self-Healing | β
100% | Error pattern recognition, auto-recovery with exponential backoff |
| Checkpoint Rollback | β
100% | Auto-checkpoint before risky ops, rollback to last good state |
| Shared Context | β
100% | Thread-safe key-value store with optimistic locking |
Phase 5 β OpenClaw-Inspired Platform
| Doctor Command | β
100% | Environment/deps/config diagnostics (buddy doctor) |
| Onboarding Wizard | β
100% | Interactive setup wizard (buddy onboard) |
| Model Failover Chain | β
100% | Cascading provider fallback with health tracking |
| Webhook Triggers | β
100% | HMAC-verified HTTP triggers + CLI + API routes |
| Typing Indicators | β
100% | Presence & typing events for channels |
| Live Canvas | β
100% | WebSocket-driven visual workspace (A2UI) |
| Docker Sandbox | β
100% | Containerized command execution with resource limits |
| Skills Registry | β
100% | Bundled/managed/workspace skills with YAML frontmatter |
| Media Pipeline | β
100% | Ingest, track, transcode with transcription hooks |
| ACP Protocol | β
100% | Inter-agent communication router with request/response |
| Extension System | β
100% | Manifest-based plugin loader with lifecycle hooks |
| Copilot Proxy | β
100% | IDE-compatible completions backend (/v1/completions) |
Phase 6 β Robustness & Developer Experience
| Web Search 5-Provider Chain | β
100% | Brave MCP β Brave API β Perplexity β Serper β DuckDuckGo with country/freshness/lang |
| Apply Patch Tool | β
100% | Unified diff parser and applier with fuzz factor (Codex-inspired) |
| Bash Parser | β
100% | AST-based command parsing via tree-sitter-bash with state-machine fallback |
| Per-Model Tool Config | β
100% | Capabilities, context window, patch format per model family |
| Head/Tail Truncation | β
100% | Smart output truncation keeping start + end of large results |
| Session Locks | β
100% | PID-based file locking with stale detection |
| Skill Scanner | β
100% | Static analysis of SKILL.md files for dangerous patterns (24 rules) |
| History Repair | β
100% | 5-pass self-repair for malformed LLM message sequences |
| Cache Trace | β
100% | Debug prompt construction stages (CACHE_TRACE=true) |
| Turn Diff Tracker | β
100% | Per-turn file change tracking with rollback capability |
| MCP Predefined Servers | β
100% | Brave Search, Playwright, Exa pre-configured in MCP |
| Headless Mode Fixes | β
100% | Clean JSON stdout, process.exit(0), Gemini message sanitization |
| Gemini Conversation Repair | β
100% | 3-pass sanitization after context compression (orphan cleanup, role merge, user-start) |
Phase 7 β Code Generation Security
| Centralized Dangerous Patterns | β
100% | Single registry for all dangerous patterns (bash, code, skills) with severity levels |
| Generated Code Validator | β
100% | Pre-write security scan for eval, XSS, SQL injection, hardcoded secrets, prototype pollution |
| Pre-Write Syntax Validator | β
100% | Balanced delimiters, template literals, indentation (JS/TS/Python/YAML/HTML/CSS/JSON) |
| Atomic Rollback (apply-patch) | β
100% | All-or-nothing patch application with full file state backup |
| Atomic Transactions (multi-edit) | β
100% | Multi-file edits rolled back on first failure |
| AST Bash Command Validation | β
100% | tree-sitter integration in command validator with centralized pattern checks |
| Bash Checkpoint | β
100% | Pre-snapshot of files targeted by destructive commands (rm, mv, truncate) |
| Shell Injection Fix | β
100% | Code formatter uses spawnSync stdin pipe instead of execSync echo |
| Diff Preview in Confirmation | β
100% | Shows actual diffs before approval, magnitude-based re-confirmation for large changes |
| Architect Parallel Execution | β
100% | Dependency-wave-based parallel step execution with DAG ordering |
| Semantic Truncation | β
100% | Error-preserving output truncation (keeps error lines, stack traces from middle sections) |
| Auto-Sandbox Router | β
100% | Automatic Docker routing for dangerous commands (npm, pip, cargo, make) |
| Security Audit Logging | β
100% | JSONL audit trail for all code generation security decisions |
| Copilot Proxy Hardening | β
100% | Per-IP rate limiting, token clamping, auth bypass fix, sanitized error messages |
Phase 8 β OpenClaw Parity (Final)
| Skills Auto-Discovery | β
100% | Agent auto-finds/installs skills from hub when tool confidence is low |
| Device Node Connectors | β
100% | Real SSH, ADB, and local transports with platform-specific commands |
| Canvas Bidirectional Events | β
100% | Browserβagent event routing, data binding observers, state queries |
Phase 9 β External Tool Integration
| RTK Output Compressor | β
100% | RTK integration β compresses bash output 60-90% via format-aware parsing, reducing token usage |
| ICM Memory Bridge | β
100% | ICM MCP server β persistent cross-session memory with episodic + semantic dual architecture |
| RTK Tool Hook | β
100% | After-hook at priority 90 auto-compresses bash results > 500 chars (configurable) |
| ICM MCP Predefined Server | β
100% | Pre-configured icm mcp stdio transport in MCP predefined servers |
| Integrations Config | β
100% | New [integrations] TOML section for RTK/ICM enable/disable and thresholds |
| Doctor RTK/ICM Checks | β
100% | buddy doctor reports RTK and ICM binary availability |
Installation
Prerequisites
- Node.js 18.0.0 or higher
- ripgrep (recommended for faster search)
- tree-sitter + tree-sitter-bash (optional, for AST-based bash command parsing)
brew install ripgrep
sudo apt-get install ripgrep
choco install ripgrep
npm install tree-sitter tree-sitter-bash
Install Code Buddy
npm install -g @phuetz/code-buddy
npx @phuetz/code-buddy@latest
Quick Start
export GROK_API_KEY=your_api_key
buddy
buddy --prompt "analyze the codebase structure"
buddy --base-url http://localhost:1234/v1 --api-key lm-studio
YOLO_MODE=true buddy
Headless Mode (CI / Scripting)
buddy -p "create a hello world Express app" --output-format json > result.json
buddy -p "explain this code" --output-format json 2>/dev/null | jq '.content'
buddy -p "run tests and fix failures" \
--dangerously-skip-permissions \
--output-format json \
--max-tool-rounds 30
buddy -p "fix lint errors" --auto-approve --output-format text
Headless mode exits cleanly after completion β safe for timeout, shell scripts, and CI pipelines.
Session Management
buddy --continue
buddy --resume abc123
buddy --max-price 5.00
Typical Project Workflow
buddy --setup
buddy onboard
buddy doctor
buddy
buddy --vim
> "Create a Node.js project with Express and Prisma"
> "Add Google OAuth authentication"
> "Write tests for the auth module"
> "Fix the typecheck errors"
> "Commit everything"
buddy --model gemini-2.5-flash
buddy --system-prompt architect
buddy --agent my-custom-agent
buddy speak
buddy daemon start
buddy server --port 3000
Code Buddy autonomously reads files, writes code, runs commands, and fixes errors β typically 5-15 tool calls per task (up to 50, or 400 in YOLO mode).
Architecture
Code Buddy uses a facade architecture for clean separation of concerns:
CodeBuddyAgent
β
βββ AgentContextFacade # Context window and memory management
β - Token counting, compression, memory retrieval
β
βββ SessionFacade # Session persistence and checkpoints
β - Save/load, checkpoint creation, rewind
β
βββ ModelRoutingFacade # Model routing and cost tracking
β - Provider selection, cost calculation
β
βββ InfrastructureFacade # MCP, sandbox, hooks, plugins
β - Hook execution, plugin loading
β
βββ MessageHistoryManager # Chat and LLM message history
Autonomy Layer (Phase 4)
CodeBuddyAgent
β
βββ TaskPlanner # DAG decomposition of complex requests
β - needsPlanning() heuristic
β - createPlan() β TaskGraph β parallel execution
β
βββ SupervisorAgent # Multi-agent orchestration
β - Sequential, parallel, race, all strategies
β - SharedContext with optimistic locking
β
βββ SelfHealing # Automatic error recovery
β - Pattern recognition (6 built-in patterns)
β - Retry with exponential backoff
β
βββ ScreenObserver # Environment monitoring
β - Periodic screenshots with perceptual diff
β - Event triggers (file_change, screen_change, time, webhook)
β
βββ ProactiveAgent # Agent-initiated communication
β - Push notifications with priority levels
β - Rate limiting and quiet hours
β
βββ DaemonManager # Background process lifecycle
- PID file management, auto-restart
- Service registry, health monitoring
Core Flow
User Input β ChatInterface (Ink/React) β CodeBuddyAgent β AI Provider
β
Tool Calls (max 50/400 rounds)
β
Tool Execution + Confirmation
β
Results back to API (loop)
CLI Reference
Global Options
--version | -V | Show version number | - |
--directory <dir> | -d | Set working directory | . |
--api-key <key> | -k | API key (or GROK_API_KEY env) | - |
--base-url <url> | -u | API base URL (or GROK_BASE_URL env) | - |
--model <model> | -m | AI model to use (or GROK_MODEL env) | auto-detect |
--prompt <prompt> | -p | Single prompt, headless mode | - |
--browser | -b | Launch browser UI instead of terminal | false |
--max-tool-rounds <n> | | Max tool execution rounds | 400 |
--security-mode <mode> | -s | suggest, auto-edit, or full-auto | suggest |
--output-format <fmt> | -o | Headless output: json, stream-json, text, markdown | json |
--context <patterns> | -c | Glob patterns to load into context | - |
Session & Cost
--continue | Resume the most recent saved session | - |
--resume <id> | Resume a specific session (supports partial ID matching) | - |
--max-price <dollars> | Maximum cost in dollars before stopping | 10.0 |
--no-cache | Disable response caching | - |
Autonomy & Permissions
--auto-approve | Automatically approve all tool executions | false |
--dangerously-skip-permissions | Bypass all permission checks (trusted containers only) | false |
--no-self-heal | Disable self-healing auto-correction | - |
--allow-outside | Allow file operations outside workspace directory | false |
Tool Control
--force-tools | Force-enable function calling for local models | - |
--probe-tools | Auto-detect tool support at startup | - |
--enabled-tools <patterns> | Only enable matching tools (glob, comma-separated) | bash,*file*,search |
--disabled-tools <patterns> | Disable matching tools (glob, comma-separated) | bash,web_* |
--allowed-tools <patterns> | Alias for --enabled-tools (Claude Code compat) | - |
Agent & Prompt Configuration
--system-prompt <id> | System prompt: default, minimal, secure, code-reviewer, architect (or custom from ~/.codebuddy/prompts/) | default |
--list-prompts | List available system prompts and exit | - |
--agent <name> | Use a custom agent from ~/.codebuddy/agents/ | - |
--list-agents | List available custom agents and exit | - |
Display & Debugging
--plain | Minimal formatting (plain text output) |
--no-color | Disable colored output |
--no-emoji | Disable emoji in output |
--vim | Enable Vim keybindings for input |
--mcp-debug | Enable MCP protocol debugging output |
Setup & Init
--init | Initialize .codebuddy/ directory with templates |
--dry-run | Preview changes without applying (simulation mode) |
--setup | Run interactive API key setup wizard |
--list-models | List available models from the API and exit |
AI Providers
Code Buddy supports multiple AI providers with automatic failover:
| Grok (xAI) | grok-4, grok-code-fast-1 | 128K | GROK_API_KEY |
| Claude (Anthropic) | claude-sonnet-4, opus | 200K | ANTHROPIC_API_KEY |
| ChatGPT (OpenAI) | gpt-4o, gpt-4-turbo | 128K | OPENAI_API_KEY |
| Gemini (Google) | gemini-2.0-flash (+ vision) | 2M | GOOGLE_API_KEY |
| LM Studio | Any local model | Varies | --base-url http://localhost:1234/v1 |
| Ollama | llama3, codellama, etc. | Varies | --base-url http://localhost:11434/v1 |
Connection Profiles
Switch between providers using CLI options or configuration:
buddy --base-url http://localhost:1234/v1 --api-key lm-studio
buddy --base-url http://localhost:11434/v1 --model llama3
buddy --model grok-code-fast-1
Profile Configuration
{
"connection": {
"activeProfileId": "grok",
"profiles": [
{
"id": "grok",
"name": "Grok API (xAI)",
"provider": "grok",
"baseURL": "https://api.x.ai/v1",
"model": "grok-4-latest"
},
{
"id": "lmstudio",
"name": "LM Studio Local",
"provider": "lmstudio",
"baseURL": "http://localhost:1234/v1",
"apiKey": "lm-studio"
}
]
}
}
Memory System
Code Buddy features a sophisticated memory system inspired by OpenClaw:
Three Memory Subsystems
| Persistent Memory | Markdown files | Project/user notes |
| Enhanced Memory | SQLite + embeddings | Semantic search |
| Prospective Memory | SQLite | Tasks, goals, reminders |
| ICM (optional) | ICM MCP server | Persistent cross-session memory via episodic + semantic dual architecture |
Auto-Capture (OpenClaw Pattern)
Automatically detects and stores important information:
"Remember that..." β Stored as instruction
"I prefer..." β Stored as preference
"This project uses..." β Stored as project fact
"My email is..." β Stored as contact info
"We decided to..." β Stored as decision
Memory Lifecycle Hooks
beforeExecute(context) β { injectedContext, recalledMemories }
afterResponse(context) β { capturedCount, capturedMemories }
sessionEnd(sessionId) β { summaryId, memoriesStored }
Deduplication
- Jaccard similarity threshold: 0.95
- Hash-based recent capture cache
- Automatic duplicate detection
Multi-Channel Support
Code Buddy supports multiple messaging channels:
| Terminal | β
Full | Native CLI interface (Ink/React) |
| HTTP API | β
Full | REST + WebSocket |
| WebChat | β
Full | Built-in HTTP + WebSocket with browser UI |
| Discord | π‘ Base | Bot integration, slash commands |
| Telegram | π‘ Base | Bot API, message handlers |
| Slack | π‘ Base | Bolt framework, events |
| WhatsApp | π‘ Base | Baileys (QR pairing, media, reconnect) |
| Signal | π‘ Base | signal-cli REST API (polling, groups) |
| Google Chat | π‘ Base | Workspace API (JWT auth, webhook events) |
| Microsoft Teams | π‘ Base | Bot Framework (OAuth2, adaptive cards) |
| Matrix | π‘ Base | matrix-js-sdk (E2EE, threads, media) |
Channel Configuration
const discord = new DiscordChannel({
token: process.env.DISCORD_TOKEN,
allowedGuilds: ['guild-id'],
});
await discord.connect();
Security
Tool Policy System
Fine-grained control over tool execution:
const policy = new ToolPolicy({
allowlist: ['read_file', 'search', 'web_fetch'],
denylist: ['bash', 'write_file'],
requireConfirmation: ['delete_file'],
});
Bash Allowlist
Secure command execution:
const bashPolicy = new BashAllowlist({
patterns: [
/^npm (install|test|run)/,
/^git (status|diff|log)/,
/^ls -la?/,
],
blocked: [
/rm -rf/,
/sudo/,
/curl.*\|.*sh/,
],
});
Security Modes
suggest | Confirm all operations |
auto-edit | Auto-approve safe ops |
full-auto | Full autonomy (YOLO) |
/mode suggest
/mode full-auto
Sandbox Isolation
Docker-based execution environment:
const sandbox = new DockerSandbox({
image: 'codebuddy/sandbox:latest',
memoryLimit: '512m',
networkMode: 'none',
timeout: 30000,
});
Context Management
Context Window Guard
Automatic context management with configurable thresholds:
const guard = new ContextWindowGuard({
maxTokens: 128000,
warningThreshold: 0.8,
compactionThreshold: 0.9,
});
Smart Compaction
Multi-stage compression:
- Stage 1: Remove tool results older than TTL
- Stage 2: Summarize older messages
- Stage 3: Aggressive truncation if needed
Hybrid Search
Combined keyword + semantic search:
const results = await hybridSearch({
query: "authentication flow",
keywordWeight: 0.3,
semanticWeight: 0.7,
});
Tools
Built-in Tools
| File Operations | view_file, create_file, str_replace_editor, edit_file, multi_edit |
| Search | search, codebase_map |
| System | bash, docker, kubernetes |
| Web | web_search, web_fetch, browser |
| Patching | apply_patch (unified diff) |
| Planning | create_todo_list, get_todo_list, update_todo_list |
| Media | screenshot, audio, video, ocr, clipboard |
| Documents | pdf, document, archive |
Web Search (5-Provider Fallback Chain)
Code Buddy automatically cascades through available search providers:
| 1 | Brave MCP | BRAVE_API_KEY + MCP enabled | Full MCP integration, richest results |
| 2 | Brave API | BRAVE_API_KEY | Country, language, freshness filters |
| 3 | Perplexity | PERPLEXITY_API_KEY or OPENROUTER_API_KEY | AI-synthesized answers with citations |
| 4 | Serper | SERPER_API_KEY | Google Search results |
| 5 | DuckDuckGo | None | Free fallback (no API key needed) |
Search parameters: country (ISO 3166), search_lang, ui_lang, freshness (pd/pw/pm/py or date range), provider (force specific).
MCP Predefined Servers
Four MCP servers are pre-configured (disabled by default):
buddy mcp add brave-search
buddy mcp add playwright
buddy mcp add exa-search
buddy mcp add icm
buddy mcp list
RAG-Based Tool Selection
Tools are selected based on query relevance:
API Server
REST API with WebSocket support:
Starting the Server
buddy server --port 3000
Endpoints
/api/health | GET | Health check |
/api/metrics | GET | Prometheus metrics |
/api/chat | POST | Chat completion |
/api/chat/completions | POST | OpenAI-compatible |
/api/tools | GET | List tools |
/api/tools/{name}/execute | POST | Execute tool |
/api/sessions | GET/POST | Session management |
/api/memory | GET/POST | Memory entries |
/api/daemon/status | GET | Daemon status |
/api/daemon/health | GET | Health metrics (CPU, memory) |
/api/cron/jobs | GET | List cron jobs |
/api/cron/jobs/{id}/trigger | POST | Trigger a cron job |
/api/notifications/preferences | GET/POST | Notification settings |
/api/heartbeat/status | GET | Heartbeat engine status |
/api/heartbeat/start | POST | Start heartbeat |
/api/heartbeat/stop | POST | Stop heartbeat |
/api/heartbeat/tick | POST | Trigger a single tick |
/api/hub/search?q=... | GET | Search skills marketplace |
/api/hub/installed | GET | List installed hub skills |
/api/hub/install | POST | Install a skill |
/api/hub/{name} | DELETE | Uninstall a skill |
/api/identity | GET | List loaded identity files |
/api/identity/prompt | GET | Combined identity prompt |
/api/identity/{name} | PUT | Update an identity file |
/api/groups/status | GET | Group security status |
/api/groups/list | GET | List configured groups |
/api/groups/block | POST | Block a user globally |
/api/groups/block/{userId} | DELETE | Unblock a user |
/api/auth-profiles | GET/POST/DELETE | Auth profile CRUD |
/api/auth-profiles/reset | POST | Reset all cooldowns |
WebSocket Events
const ws = new WebSocket('ws://localhost:3000/ws');
ws.send(JSON.stringify({
type: 'authenticate',
payload: { token: 'jwt-token' }
}));
ws.send(JSON.stringify({
type: 'chat_stream',
payload: { messages: [{ role: 'user', content: 'Hello' }] }
}));
Slash Commands
/help | Show help |
/model [name] | Change model |
/mode [mode] | Change security mode |
/profile [id] | Switch connection profile |
/think | Enable reasoning (4K tokens) |
/megathink | Deep reasoning (10K tokens) |
/ultrathink | Exhaustive reasoning (32K tokens) |
/cost | Show cost dashboard |
/memory | Memory management |
/hooks list | List lifecycle hooks |
/plugin list | List plugins |
Daemon Commands
buddy daemon start [--detach]
buddy daemon stop
buddy daemon restart
buddy daemon status
buddy daemon logs [--lines N]
Trigger Commands
buddy trigger list
buddy trigger add <spec>
buddy trigger remove <id>
Webhook Commands
buddy webhook list
buddy webhook add <name> <message> [opts]
buddy webhook remove <id>
Hub Commands (Skills Marketplace)
buddy hub search <query>
buddy hub install <name>
buddy hub uninstall <name>
buddy hub update [name]
buddy hub list
buddy hub info <name>
buddy hub publish <path>
buddy hub sync
Heartbeat Commands
buddy heartbeat start [opts]
buddy heartbeat stop
buddy heartbeat status
buddy heartbeat tick
Identity Commands
buddy identity show
buddy identity get <name>
buddy identity set <name> <c>
buddy identity prompt
Group Security Commands
buddy groups status
buddy groups list
buddy groups block <userId>
buddy groups unblock <userId>
Auth Profile Commands
buddy auth-profile list
buddy auth-profile add <id> <provider>
buddy auth-profile remove <id>
buddy auth-profile reset
Device Commands
buddy device list
buddy device pair --id <id> --name <name> --transport <ssh|adb|local>
buddy device remove <id>
buddy device snap <id> [-o output.png]
buddy device screenshot <id> [-o out.png]
buddy device record <id> [-d 10] [-o out]
buddy device run <id> -- <command>
Config Commands
buddy config show [--json]
buddy config validate
buddy config get <name>
Security Audit
buddy security-audit
buddy security-audit --deep
buddy security-audit --fix
buddy security-audit --json
Voice & TTS Commands
buddy speak "Bonjour, je suis Code Buddy"
buddy speak --voice af_bella "Hello world"
buddy speak --list-voices
buddy speak --speed 1.5 "Fast speech"
buddy speak --format mp3 "Hello"
buddy speak --url http://host:8000 "Hello"
In-chat voice commands:
/speak <text> | Speak text with current TTS provider |
/tts on|off | Enable/disable TTS |
/tts auto | Auto-speak all agent responses |
/tts provider audioreader | Switch to AudioReader (Kokoro-82M, local, free) |
/tts voice ff_siwis | Set voice (e.g., ff_siwis FR, af_bella EN) |
Supported TTS providers: Edge TTS, espeak, macOS say, Piper, OpenAI, ElevenLabs, AudioReader (Kokoro-82M)
Infinite voice conversation: Enable continuousListening + autoSpeak with AudioReader for a hands-free loop: listen β STT β agent β TTS β listen.
Plugin System
Plugin Structure
~/.codebuddy/plugins/
my-plugin/
manifest.json
index.js
Plugin Types
- Tool Plugins: Add custom tools
- Provider Plugins: Add LLM/embedding/search providers
- Command Plugins: Add slash commands
- Hook Plugins: Add lifecycle hooks
Example Plugin
const plugin: Plugin = {
async activate(context: PluginContext) {
context.registerTool({
name: 'my_tool',
description: 'Custom tool',
execute: async (args) => {
return { success: true, output: 'Done!' };
}
});
context.registerProvider({
id: 'my-llm',
type: 'llm',
async chat(messages) { return 'response'; }
});
}
};
Bundled Skills (40)
Code Buddy includes 40 built-in SKILL.md files that provide domain-specific knowledge, best practices, and MCP server integration for popular software. Skills are loaded contextually when relevant to your project.
| PR Workflow | review-pr | Code review checklist, inline comments, approval criteria |
| prepare-pr | Branch naming, commit cleanup, PR description template |
| merge-pr | Merge strategies, conflict resolution, post-merge cleanup |
| Dev Tools | github | Issues, releases, Actions workflows, gh CLI |
| gitlab | GitLab API, glab CLI, CI/CD pipelines, merge requests |
| session-logs | Export/search conversation history and session metadata |
| model-usage | Token tracking, cost analysis, provider comparison |
| tmux-sessions | Terminal multiplexing, pane layouts, session management |
| healthcheck | Service monitoring, endpoint checks, alerting |
| Project | project-best-practices | Project scaffolding, structure, linting, testing conventions |
| csharp-avalonia | Cross-platform desktop/mobile with C# and Avalonia UI |
| coding-agent | Autonomous multi-step coding with planning and validation |
| skill-creator | Author new SKILL.md files with YAML frontmatter |
| Creative & 3D | blender | Python bpy scripting, CLI rendering, Geometry Nodes |
| unreal-engine | Remote Control API, Python editor scripting, Movie Render Queue |
| davinci-resolve | DaVinciResolveScript Python API, color grading, render queue |
| ableton-live | OSC protocol, MIDI Remote Scripts, Max for Live |
| Design | figma | REST API, Plugin API, design tokens extraction |
| gimp | Python-Fu / Script-Fu scripting, batch image processing |
| inkscape | Extensions API, CLI export, SVG manipulation |
| DevOps & Infra | kubernetes | kubectl, Helm, ArgoCD GitOps |
| terraform-ansible | Terraform IaC + Ansible configuration management |
| grafana-prometheus | Grafana HTTP API, PromQL, alerting pipelines |
| jenkins-ci | Jenkins API, Groovy pipelines, shared libraries |
| Workflow & Data | n8n | REST API, webhook triggers, workflow automation |
| databases | PostgreSQL, MongoDB, Redis CLI and automation |
| game-engines | Unity C# + Godot GDScript, builds, scene management |
| Utilities | summarize | Text/file/URL summarization with configurable length |
| weather | Weather lookups via wttr.in and OpenWeatherMap |
| Media | image-gen | Image generation via DALL-E, Stable Diffusion, Midjourney |
| whisper-transcribe | Audio/video transcription with OpenAI Whisper |
| pdf-tools | PDF creation, merging, text extraction, conversion |
| screenshot | Screen capture, annotation, OCR text extraction |
| video-tools | FFmpeg video editing, conversion, thumbnails, GIFs |
| gif-search | GIF search via Giphy and Tenor APIs |
| Communication | email-tools | Email send/read via himalaya CLI and SMTP |
| notion | Notion API for pages, databases, search, content blocks |
| blog-watcher | RSS/Atom feed monitoring, web page change detection |
| Smart Home | spotify | Spotify playback control via spotify_player and Web API |
| smart-home | Philips Hue and Home Assistant control |
Each skill includes Direct Control (CLI/API/scripting commands), MCP Server Integration (config for .codebuddy/mcp.json), and Common Workflows (step-by-step recipes). Skills are stored in .codebuddy/skills/bundled/ and can be extended with managed or workspace skills via the Skills Registry.
Development
git clone https://github.com/phuetz/code-buddy.git
cd code-buddy
npm install
npm run dev
npm test
npm run validate
npm run build
Test Coverage
23,700+ tests across 554+ suites covering:
- Core: Tool Policy, Bash Allowlist, Context Window Guard, Compaction
- Agent: Middleware Pipeline, Profiles, Reasoning, Streaming
- Autonomy: Daemon, Cron Bridge, Task Planner, Delegation Engine
- Observation: Screen Observer, Triggers, Proactive Notifications
- Orchestration: Supervisor, Shared Context, Self-Healing, Rollback
- Providers: Gemini (vision + conversation), OpenAI-compat, Failover
- Security: Trust Folders, Skill Scanner, Bash Parser, Session Locks
- Infrastructure: MCP Client, Webhooks, Extensions, ACP Protocol, RTK Compressor, ICM Bridge
- Voice: Wake Word, TTS Providers, Voice Control Loop
- UI: ChatHistory, ChatInterface, TabbedQuestion
Configuration
Environment Variables
GROK_API_KEY | xAI API key | Required |
ANTHROPIC_API_KEY | Anthropic API key | - |
OPENAI_API_KEY | OpenAI API key | - |
GOOGLE_API_KEY | Google AI API key | - |
SERPER_API_KEY | Web search API key | - |
GROK_BASE_URL | Custom API endpoint | - |
GROK_MODEL | Default model | - |
BRAVE_API_KEY | Brave Search API key | - |
EXA_API_KEY | Exa neural search API key | - |
PERPLEXITY_API_KEY | Perplexity AI search key (pplx-...) | - |
OPENROUTER_API_KEY | OpenRouter key for Perplexity (sk-or-...) | - |
PERPLEXITY_MODEL | Perplexity model | perplexity/sonar-pro |
PICOVOICE_ACCESS_KEY | Porcupine wake word detection | - |
CACHE_TRACE | Debug prompt construction stages | false |
YOLO_MODE | Full autonomy | false |
MAX_COST | Cost limit ($) | 10 |
JWT_SECRET | API server auth | Required in prod |
Optional Rust tools (install via cargo install):
| RTK | cargo install rtk | Compresses bash output 60-90%, reducing token usage |
| ICM | cargo install icm | MCP server for persistent cross-session memory |
Project Settings
Create .codebuddy/settings.json:
{
"systemPrompt": "You are working on a TypeScript project.",
"tools": {
"enabled": ["read_file", "search", "bash"],
"disabled": ["web_search"]
},
"security": {
"mode": "auto-edit",
"bashAllowlist": ["npm *", "git *"]
}
}
Roadmap
Planned Features
| Daemon Mode (background agent) | HIGH | β
Done |
| Task Planner (DAG decomposition) | HIGH | β
Done |
| Screen Observer & Triggers | HIGH | β
Done |
| Proactive Agent (push notifications) | HIGH | β
Done |
| Multi-Agent Orchestrator | HIGH | β
Done |
| Self-Healing & Checkpoint Rollback | HIGH | β
Done |
| Canvas A2UI Visual Workspace | HIGH | β
Done |
| ClawHub Skills Registry | MEDIUM | β
Done |
| Web Search 5-Provider Chain | HIGH | β
Done |
| Apply Patch & Bash Parser | HIGH | β
Done |
| Per-Model Tool Config | MEDIUM | β
Done |
| Voice Wake Word Detection | MEDIUM | β
Done |
| TTS Providers (OpenAI, ElevenLabs, AudioReader) | MEDIUM | β
Done |
| Code Generation Security (Phase 7) | HIGH | β
Done |
| Auto-Sandbox Router | HIGH | β
Done |
| Semantic Output Truncation | MEDIUM | β
Done |
| Gateway WebSocket Control Plane | HIGH | π² Planned |
| OAuth Authentication | MEDIUM | π² Planned |
| Companion Apps (iOS, Android, macOS) | LOW | π² Planned |
| Tailscale Integration | LOW | π² Planned |
Troubleshooting
Common Issues
API key not working
echo $GROK_API_KEY
buddy --prompt "test"
Switching providers doesn't work
buddy --base-url http://localhost:1234/v1 --api-key lm-studio --prompt "test"
buddy --list-models
Memory not persisting
ls ~/.codebuddy/memory/
rm -rf ~/.codebuddy/memory/
buddy
High latency
- Use a faster model:
buddy --model grok-code-fast-1
- Use local LLM:
buddy --base-url http://localhost:11434/v1 --model llama3
Debug Mode
DEBUG=codebuddy:* buddy
License
MIT License - see LICENSE for details.