|
| 1 | +# Custom Agents |
| 2 | + |
| 3 | +Create specialized agent workflows that coordinate multiple AI agents to tackle complex engineering tasks. Instead of a single agent trying to handle everything, you can orchestrate teams of focused specialists that work together. |
| 4 | + |
| 5 | +## Getting Started |
| 6 | + |
| 7 | +1. **Edit an existing agent**: Start with `my-custom-agent.ts` and modify it for your needs |
| 8 | +2. **Test your agent**: Run `codebuff --agent your-agent-name` |
| 9 | +3. **Publish your agent**: Run `codebuff publish your-agent-name` |
| 10 | + |
| 11 | +## Need Help? |
| 12 | + |
| 13 | +- For detailed documentation, see [agent-guide.md](./agent-guide.md). |
| 14 | +- For examples, check the `examples/` directory. |
| 15 | +- Join our [Discord community](https://codebuff.com/discord) and ask your questions! |
| 16 | + |
| 17 | +## Context Window Management |
| 18 | + |
| 19 | +### Why Agent Workflows? |
| 20 | + |
| 21 | +Modern software projects are complex ecosystems with thousands of files, multiple frameworks, intricate dependencies, and domain-specific requirements. A single AI agent trying to understand and modify such systems faces fundamental limitations—not just in knowledge, but in the sheer volume of information it can process at once. |
| 22 | + |
| 23 | +### The Solution: Focused Context Windows |
| 24 | + |
| 25 | +Agent workflows elegantly solve this by breaking large tasks into focused sub-problems. When working with large codebases (100k+ lines), each specialist agent receives only the narrow context it needs—a security agent sees only auth code, not UI components—keeping the context for each agent manageable while ensuring comprehensive coverage. |
| 26 | + |
| 27 | +### Why Not Just Mimic Human Roles? |
| 28 | + |
| 29 | +This is about efficient AI context management, not recreating a human department. Simply creating a "frontend-developer" agent misses the point. AI agents don't have human constraints like context-switching or meetings. Their power comes from hyper-specialization, allowing them to process a narrow domain more deeply than a human could, then coordinating seamlessly with other specialists. |
| 30 | + |
| 31 | +## Agent workflows in action |
| 32 | + |
| 33 | +Here's an example of a `git-committer` agent that creates good commit messages: |
| 34 | + |
| 35 | +```typescript |
| 36 | +export default { |
| 37 | + id: 'git-committer', |
| 38 | + displayName: 'Git Committer', |
| 39 | + model: 'openai/gpt-5-nano', |
| 40 | + toolNames: ['read_files', 'run_terminal_command', 'end_turn'], |
| 41 | + |
| 42 | + instructionsPrompt: |
| 43 | + 'You create meaningful git commits by analyzing changes, reading relevant files for context, and crafting clear commit messages that explain the "why" behind changes.', |
| 44 | + |
| 45 | + async *handleSteps() { |
| 46 | + // Analyze what changed |
| 47 | + yield { tool: 'run_terminal_command', command: 'git diff' } |
| 48 | + yield { tool: 'run_terminal_command', command: 'git log --oneline -5' } |
| 49 | + |
| 50 | + // Stage files and create commit with good message |
| 51 | + yield 'STEP_ALL' |
| 52 | + }, |
| 53 | +} |
| 54 | +``` |
| 55 | + |
| 56 | +This agent systematically analyzes changes, reads relevant files for context, then creates commits with clear, meaningful messages that explain the "why" behind changes. |
0 commit comments