Skip to content

Custom Agents

Quick Reference

  • Who: Developer
  • Where: Terminal → .agents/ directory in your project
  • Time: ~10 minutes to create first agent
  • Prerequisites: Codebuff CLI installed, basic TypeScript knowledge
  • Installed Codebuff CLI
  • Familiarity with TypeScript
  • A project with .agents/ directory (run /init to create)
  1. Launch Codebuff in your project:

    Terminal window
    codebuff
  2. Run the init command:

    /init
  3. This creates the agent scaffolding:

    .agents/
    └── types/
    ├── agent-definition.ts
    ├── tools.ts
    └── util-types.ts

(cli/src/init/init-app.ts)

Create a new file in your project, e.g. my-agent.ts:

export default {
id: 'git-committer',
displayName: 'Git Committer',
model: 'openai/gpt-5-nano',
toolNames: ['read_files', 'run_terminal_command', 'end_turn'],
instructionsPrompt:
'You create meaningful git commits by analyzing changes.',
async *handleSteps() {
// Analyze what changed
yield { tool: 'run_terminal_command', command: 'git diff' }
yield { tool: 'run_terminal_command', command: 'git log --oneline -5' }
// Let the LLM craft a commit message and execute
yield 'STEP_ALL'
},
}

Your agent can use any of these 33 built-in tools:

CategoryTools
File Opsread_files, write_file, str_replace, apply_patch, find_files, glob, list_directory, read_subtree
Codecode_search, read_docs, web_search
Terminalrun_terminal_command, browser_logs
Agentspawn_agents, spawn_agent_inline, end_turn, task_completed
Planningcreate_plan, think_deeply, add_subgoal, update_subgoal, write_todos
Communicationask_user, add_message, suggest_followups

(common/src/tools/list.ts:41-76)

Any model available on OpenRouter:

ModelIdentifierBest For
Claude 3.5 Sonnetanthropic/claude-3.5-sonnetComplex coding
GPT-4oopenai/gpt-4oGeneral purpose
GPT-5 Nanoopenai/gpt-5-nanoFast, cost-effective
DeepSeek Coderdeepseek/deepseek-coderCode-focused
Qwen Coderqwen/qwen-2.5-coder-32bMultilingual code
Terminal window
codebuff --agent git-committer
  • ✅ Agent definition loads from your project
  • ✅ Agent executes with the specified model and tools
  • ✅ Programmatic steps run first, then LLM takes over for remaining work
Q: Can agents spawn other agents?

A: Yes! Use the spawn_agents or spawn_agent_inline tools in your agent definition. The spawned agents run independently with their own context.

Q: Can I publish my agent?

A: Yes! See the Agent Publishing guide to publish to the Agent Store.