|
1 | | -# Codebuff Agents |
| 1 | +# Custom Agents |
2 | 2 |
|
3 | | -This directory contains your custom Codebuff agents. Each agent is a TypeScript file that defines an AI agent with specific capabilities and behavior. |
| 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 | 4 |
|
5 | 5 | ## Getting Started |
6 | 6 |
|
7 | 7 | 1. **Edit an existing agent**: Start with `my-custom-agent.ts` and modify it for your needs |
8 | | -2. **Check out the examples and types**: See the examples and types directories to draw inspiration and learn what's possible. |
9 | | -3. **Test your agent**: Run `codebuff --agent your-agent-name` |
10 | | -4. **Publish your agent**: Run `codebuff publish your-agent-name` |
| 8 | +2. **Test your agent**: Run `codebuff --agent your-agent-name` |
| 9 | +3. **Publish your agent**: Run `codebuff publish your-agent-name` |
11 | 10 |
|
12 | | -## File Structure |
| 11 | +## Need Help? |
13 | 12 |
|
14 | | -- `types/` - TypeScript type definitions |
15 | | -- `examples/` - Example agents for reference |
16 | | -- `my-custom-agent.ts` - Your first custom agent (edit this!) |
17 | | -- Add any new agents you wish to the .agents directory |
| 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! |
18 | 16 |
|
19 | | -## Agent Basics |
| 17 | +## Context Window Management |
20 | 18 |
|
21 | | -Each agent file exports an `AgentDefinition` object with: |
| 19 | +### Why Agent Workflows? |
22 | 20 |
|
23 | | -- `id`: Unique identifier (lowercase, hyphens only) |
24 | | -- `displayName`: Human-readable name |
25 | | -- `model`: AI model to use (see OpenRouter for options) |
26 | | -- `toolNames`: Tools the agent can use |
27 | | -- `instructionsPrompt`: Instructions for the agent's behavior |
28 | | -- `spawnerPrompt`: When other agents should spawn this one |
29 | | -- `spawnableAgents`: Which agents *this* agent can spawn |
| 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. |
30 | 22 |
|
31 | | -## Common Tools |
| 23 | +### The Solution: Focused Context Windows |
32 | 24 |
|
33 | | -- `read_files` - Read file contents |
34 | | -- `write_file` - Create or modify files |
35 | | -- `str_replace` - Make targeted edits |
36 | | -- `run_terminal_command` - Execute shell commands |
37 | | -- `code_search` - Search for code patterns |
38 | | -- `spawn_agents` - Delegate to other agents |
39 | | -- `end_turn` - Finish the response |
| 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. |
40 | 26 |
|
41 | | -See `types/tools.ts` for more information on each tool! |
| 27 | +### Why Not Just Mimic Human Roles? |
42 | 28 |
|
43 | | -## Need Help? |
| 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' } |
44 | 49 |
|
45 | | -- Check the type definitions in `types/agent-definition.ts` |
46 | | -- Look at examples in the `examples/` directory |
47 | | -- Join the Codebuff Discord community (https://discord.com/invite/mcWTGjgTj3) |
| 50 | + // Stage files and create commit with good message |
| 51 | + yield 'STEP_ALL' |
| 52 | + }, |
| 53 | +} |
| 54 | +``` |
48 | 55 |
|
49 | | -Happy agent building! 🤖 |
| 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