Configuration Files
Settings File
User preferences are stored in:Default agent mode:
DEFAULT, FREE, MAX, or PLANWhether to show promotional messages in the CLI
Authentication
Authentication tokens are stored in:Log Files
CLI logs are written to:--clear-logs flag to remove old logs on startup:
Environment Variables
Configure the CLI and SDK behavior with environment variables. Create a.env file in your project root or set them in your shell profile.
AI API Keys
The Codebuff platform handles model routing, but you can configure your own API keys for direct usage:Anthropic API key for Claude models
OpenAI API key for GPT models
OpenRouter API key for accessing multiple models
When using Codebuff’s hosted service, API keys are not required. They’re only needed if you’re self-hosting or using custom model configurations.
CLI Configuration
Override the CLI version number (for development)
Override the Codebuff backend URL (for development)
Analytics & Telemetry
PostHog API key for analytics
PostHog host URL
API Key Setup
To use your own API keys with Codebuff:Get API keys
Sign up for API access from your chosen provider:
- Anthropic: https://console.anthropic.com/
- OpenAI: https://platform.openai.com/api-keys
- OpenRouter: https://openrouter.ai/keys
Model Selection
Codebuff automatically selects appropriate models based on the agent mode:Agent Mode Models
Persistent Mode Preference
Save your preferred mode:Custom Agent Loading
Codebuff loads custom agents from multiple locations, with later directories taking precedence:Agent Directory Priority
-
Global agents (
~/.agents/)- Available in all projects
- Lowest priority
-
Monorepo agents (
../.agents/)- Shared across monorepo packages
- Medium priority
-
Project agents (
{project}/.agents/)- Project-specific agents
- Highest priority (overrides global and monorepo)
Creating Agent Directories
Initialize agent directory structure:Agent File Structure
Custom agent files should export anAgentDefinition:
Loading Agents
Agents are automatically loaded from all three locations on CLI startup:MCP Server Configuration
Configure MCP (Model Context Protocol) servers in.agents/mcp.json:
Advanced Configuration
Working Directory
Override the working directory:- Running Codebuff from a different directory
- Scripting and automation
- Testing agents in specific project contexts
Conversation Continuation
Continue from a previous conversation:Agent Override
Run a specific agent, bypassing local overrides:Initial Prompt
Provide an initial prompt on the command line:Configuration Tips
Troubleshooting
Agent Not Loading
If your custom agent isn’t loading:- Check the file exports
defaultor named exportagent - Verify the
idfield is unique - Ensure TypeScript types are correct
- Check CLI logs:
~/.config/codebuff/cli.log
API Key Issues
If API keys aren’t working:- Verify the keys are in
.envwith correct names - Check for typos or extra whitespace
- Ensure
.envis in the project root or parent - Restart the CLI after changing
.env
Configuration Not Persisting
If settings don’t persist:- Check write permissions on
~/.config/codebuff/ - Verify the JSON format in
settings.json - Look for errors in CLI logs
Theme Detection Issues
If the CLI theme doesn’t match your terminal:Next Steps
Workflows
Learn common CLI workflows and best practices
Creating Agents
Build custom agents for your workflows
Commands Reference
Complete list of all CLI commands
SDK Guide
Use Codebuff programmatically with the SDK

