|
1 | 1 | # Codebuff |
2 | 2 |
|
3 | | -Codebuff is an AI-powered coding assistant that helps developers build apps faster and easier. It provides an interactive command-line interface for natural language interactions with your codebase. |
| 3 | +Codebuff is an AI coding assistant that edits your codebase through natural language instructions. Instead of using one model for everything, it coordinates specialized agents that work together to understand your project and make precise changes. |
4 | 4 |
|
5 | | -## Features |
| 5 | +Codebuff beats Claude Code at 61% vs 53% on [our internal evals](evals/README.md) across 200+ coding tasks over multiple open-source repos that simulate real-world tasks. |
6 | 6 |
|
7 | | -- AI-powered code generation and modification |
8 | | -- Real-time, interactive command-line interface |
9 | | -- Support for multiple programming languages |
10 | | -- File management and version control integration |
11 | | -- Web scraping capabilities for gathering external information |
12 | | -- Terminal command execution for various development tasks |
13 | | -- Knowledge management system for project-specific information |
| 7 | + |
14 | 8 |
|
15 | | -## How It Works |
| 9 | +## How it works |
16 | 10 |
|
17 | | -Codebuff uses advanced AI models to understand and generate code based on natural language instructions. Here's a brief overview of its operation: |
| 11 | +When you ask Codebuff to "add authentication to my API," it might invoke: |
18 | 12 |
|
19 | | -1. **Project Analysis**: Codebuff analyzes your project structure and files to gain context. |
| 13 | +1. A **File Explorer Agent** scans your codebase to understand the architecture and find relevant files |
| 14 | +2. An **Planner Agent** plans which files need changes and in what order |
| 15 | +3. An **Implementation Agents** make precise edits |
| 16 | +4. A **Review Agents** validate changes |
20 | 17 |
|
21 | | -2. **User Interaction**: You interact with Codebuff through a command-line interface, providing instructions or queries in natural language. |
| 18 | +<div align="center"> |
| 19 | + <img src="./assets/multi-agents.png" alt="Codebuff Multi-Agents" width="600"> |
| 20 | +</div> |
22 | 21 |
|
23 | | -3. **AI Processing**: Codebuff processes your input, considering the project context and your instructions. |
| 22 | +This multi-agent approach gives you better context understanding, more accurate edits, and fewer errors compared to single-model tools. |
24 | 23 |
|
25 | | -4. **Code Generation/Modification**: Based on its understanding, Codebuff generates new code or suggests modifications to existing files. |
| 24 | +## CLI: Install and start coding |
26 | 25 |
|
27 | | -5. **Real-time Feedback**: Changes are presented to you in real-time, allowing for immediate review and further refinement. |
28 | | - |
29 | | -6. **Knowledge Accumulation**: Codebuff learns from interactions and stores project-specific knowledge for future use. |
30 | | - |
31 | | -## How to Use Codebuff |
32 | | - |
33 | | -To get started with Codebuff, follow these steps: |
34 | | - |
35 | | -1. Install Codebuff globally using npm: |
36 | | - |
37 | | - ``` |
38 | | - npm install -g codebuff |
39 | | - ``` |
40 | | - |
41 | | -2. Navigate to your project directory in the terminal. |
42 | | - |
43 | | -3. Run Codebuff: |
44 | | - |
45 | | - ``` |
46 | | - codebuff |
47 | | - ``` |
48 | | - |
49 | | -4. Interact with Codebuff using natural language commands. For example: |
50 | | - |
51 | | - - "Add a new function to handle user authentication" |
52 | | - - "Refactor the database connection code for better performance" |
53 | | - - "Explain how the routing system works in this project" |
54 | | - |
55 | | -5. Review the suggested changes and approve or modify them as needed. |
56 | | - |
57 | | -6. Use the built-in commands for navigation and control: |
58 | | - - Type "help" or "h" for a list of available commands |
59 | | - - Use arrow keys to navigate through command history |
60 | | - - Press Ctrl+U to undo changes and Ctrl+R to redo |
61 | | - - Press Esc to toggle the menu or stop the current AI response |
62 | | - |
63 | | -## Setting Up Locally |
64 | | - |
65 | | -If you want to set up Codebuff for local development: |
66 | | - |
67 | | -### Prerequisites |
68 | | - |
69 | | -1. **Install Bun**: Follow the [Bun installation guide](https://bun.sh/docs/installation) |
70 | | - |
71 | | -2. **Install direnv**: This manages environment variables automatically |
72 | | - |
73 | | - - macOS: `brew install direnv` |
74 | | - - Ubuntu/Debian: `sudo apt install direnv` |
75 | | - - Other systems: See [direnv installation guide](https://direnv.net/docs/installation.html) |
76 | | - |
77 | | -3. **Hook direnv into your shell**: |
78 | | - - For zsh: |
79 | | - ```bash |
80 | | - echo 'eval "$(direnv hook zsh)"' >> ~/.zshrc && source ~/.zshrc |
81 | | - ``` |
82 | | - - For bash: |
83 | | - ```bash |
84 | | - echo 'eval "$(direnv hook bash)"' >> ~/.bashrc && source ~/.bashrc |
85 | | - ``` |
86 | | - - For fish: |
87 | | - ```bash |
88 | | - echo 'direnv hook fish | source' >> ~/.config/fish/config.fish && source ~/.config/fish/config.fish |
89 | | - ``` |
90 | | -4. **Restart your shell**: Run `exec $SHELL` (or manually kill and re-open your terminal). |
91 | | - |
92 | | -5. **Install Docker**: Required for the web server database |
93 | | - |
94 | | -### Setup Steps |
95 | | - |
96 | | -1. **Clone and navigate to the project**: |
97 | | - |
98 | | - ```bash |
99 | | - git clone <repository-url> |
100 | | - cd codebuff |
101 | | - ``` |
102 | | - |
103 | | -2. **Set up Infisical for secrets management**: |
| 26 | +```bash |
| 27 | +npm install -g codebuff |
| 28 | +cd your-project |
| 29 | +codebuff |
| 30 | +``` |
104 | 31 |
|
105 | | - ```bash |
106 | | - npm install -g @infisical/cli |
107 | | - infisical login |
108 | | - ``` |
| 32 | +Then just tell Codebuff what you want and it handles the rest: |
109 | 33 |
|
110 | | - When prompted, select the "US" region, then verify setup: |
| 34 | +- "Fix the SQL injection vulnerability in user registration" |
| 35 | +- "Add rate limiting to all API endpoints" |
| 36 | +- "Refactor the database connection code for better performance" |
111 | 37 |
|
112 | | - ```bash |
113 | | - infisical secrets |
114 | | - ``` |
| 38 | +Codebuff will find the right files, makes changes across your codebase, and runs tests to make sure nothing breaks. |
115 | 39 |
|
116 | | -3. **Configure direnv**: |
| 40 | +### Create custom agents |
117 | 41 |
|
118 | | - ```bash |
119 | | - direnv allow |
120 | | - ``` |
| 42 | +You can create specialized agents for your workflows using TypeScript generators for more programmatic control. |
121 | 43 |
|
122 | | - This automatically manages your PATH and environment variables. The `.envrc` file is already committed to the repository and sets up the correct PATH to use the project's bundled version of Bun. |
| 44 | +For example, here's a `git-committer` agent that creates git commits based on the current git state. Notice that it runs `git diff` and `git log` to analyze changes, but then hands control over to the LLM to craft a meaningful commit messagea and perform the actual commit. |
123 | 45 |
|
124 | | -4. **Install dependencies**: |
| 46 | +```typescript |
| 47 | +export default { |
| 48 | + id: 'git-committer', |
| 49 | + displayName: 'Git Committer', |
| 50 | + model: 'openai/gpt-5-nano', |
| 51 | + toolNames: ['read_files', 'run_terminal_command', 'end_turn'], |
125 | 52 |
|
126 | | - ```bash |
127 | | - bun install |
128 | | - ``` |
| 53 | + instructionsPrompt: |
| 54 | + 'You create meaningful git commits by analyzing changes, reading relevant files for context, and crafting clear commit messages that explain the "why" behind changes.', |
129 | 55 |
|
130 | | -5. **Start the development services**: |
| 56 | + async *handleSteps() { |
| 57 | + // Analyze what changed |
| 58 | + yield { tool: 'run_terminal_command', command: 'git diff' } |
| 59 | + yield { tool: 'run_terminal_command', command: 'git log --oneline -5' } |
131 | 60 |
|
132 | | - **Terminal 1 - Backend server**: |
| 61 | + // Stage files and create commit with good message |
| 62 | + yield 'STEP_ALL' |
| 63 | + }, |
| 64 | +} |
| 65 | +``` |
133 | 66 |
|
134 | | - ```bash |
135 | | - bun run start-server |
136 | | - ``` |
| 67 | +## SDK: Build custom AI coding tools |
| 68 | + |
| 69 | +```typescript |
| 70 | +import { CodebuffClient } from 'codebuff' |
| 71 | + |
| 72 | +// Initialize the client |
| 73 | +const client = new CodebuffClient({ |
| 74 | + apiKey: 'your-api-key', |
| 75 | + cwd: '/path/to/your/project', |
| 76 | + onError: (error) => console.error('Codebuff error:', error.message), |
| 77 | +}) |
| 78 | + |
| 79 | +// Run a task, like adding error handling to all API endpoints |
| 80 | +const result = await client.run({ |
| 81 | + prompt: 'Add comprehensive error handling to all API endpoints', |
| 82 | + agent: 'base', |
| 83 | + handleEvent: (event) => { |
| 84 | + console.log('Progress:', event) |
| 85 | + }, |
| 86 | +}) |
| 87 | +``` |
137 | 88 |
|
138 | | - **Terminal 2 - Web server** (requires Docker): |
| 89 | +Learn more about the SDK [here](https://www.npmjs.com/package/@codebuff/sdk). |
139 | 90 |
|
140 | | - ```bash |
141 | | - bun run start-web |
142 | | - ``` |
| 91 | +## Why choose Codebuff |
143 | 92 |
|
144 | | - **Terminal 3 - Client**: |
| 93 | +**Any model on OpenRouter**: Unlike Claude Code which locks you into Anthropic's models, Codebuff supports any model available on [OpenRouter](https://openrouter.ai/models) - from Claude and GPT to specialized models like Qwen, DeepSeek, and others. Switch models for different tasks or use the latest releases without waiting for platform updates. |
145 | 94 |
|
146 | | - ```bash |
147 | | - bun run start-client |
148 | | - ``` |
| 95 | +**Deep customizability**: Create sophisticated agent workflows with TypeScript generators that mix AI generation with programmatic control. Define custom agents that spawn subagents, implement conditional logic, and orchestrate complex multi-step processes that adapt to your specific use cases. |
149 | 96 |
|
150 | | -### Running Tests |
| 97 | +**Fully customizable SDK**: Build Codebuff's capabilities directly into your applications with a complete TypeScript SDK. Create custom tools, integrate with your CI/CD pipeline, build AI-powered development environments, or embed intelligent coding assistance into your products. |
151 | 98 |
|
152 | | -After direnv setup, you can run tests from any directory: |
| 99 | +## Get started |
153 | 100 |
|
154 | | -```bash |
155 | | -bun test # Runs with secrets automatically |
156 | | -bun test --watch # Watch mode |
157 | | -bun test specific.test.ts # Run specific test file |
158 | | -``` |
| 101 | +### Install |
159 | 102 |
|
160 | | -## Troubleshooting |
| 103 | +**CLI**: `npm install -g codebuff` |
161 | 104 |
|
162 | | -### direnv Issues |
| 105 | +**SDK**: `npm install @codebuff/sdk` |
163 | 106 |
|
164 | | -If direnv isn't working: |
| 107 | +### Resources |
165 | 108 |
|
166 | | -1. Ensure it's properly hooked into your shell (see Prerequisites step 3) |
167 | | -2. Run `direnv allow` in the project root |
168 | | -3. Check that `.envrc` exists and has the correct content |
169 | | -4. Restart your terminal if needed |
| 109 | +**Running Codebuff locally**: [local-development.md](./local-development.md) |
170 | 110 |
|
171 | | -## Licensing |
| 111 | +**Documentation**: [codebuff.com/docs](https://codebuff.com/docs) |
172 | 112 |
|
173 | | -1. NPM Package: The npm package contained in this project is licensed under the MIT License. See the LICENSE file in the npm package directory for details. |
| 113 | +**Community**: [Discord](https://codebuff.com/discord) |
174 | 114 |
|
175 | | -2. Other Project Components: All other parts of this project, including but not limited to server-side code and non-public client-side code, are proprietary and confidential. No license is granted for their use, modification, or distribution without explicit permission from the project owner. |
| 115 | +**Support**: [support@codebuff.com](mailto:support@codebuff.com) |
0 commit comments