Configuring Models, Rules & Tools
This guide covers the essential configuration options for setting up AI models, defining rules, and integrating tools in ByteBuddy to customize your AI-assisted development experience.
Configuration File Structure
ByteBuddy uses YAML configuration files for maximum readability and ease of use:
# .bytebuddy/config.yaml
models:
# Model configurations
rules:
# Rule definitions
tools:
# Tool integrations
preferences:
# User preferencesAI Model Configuration
Provider Setup
Configure different AI providers with their specific requirements:
# .bytebuddy/config.yaml
models:
- name: "primary-chat"
provider: "openai"
model: "gpt-4-turbo"
apiKey: "${OPENAI_API_KEY}"
role: "chat"
- name: "fast-autocomplete"
provider: "anthropic"
model: "claude-3-haiku"
apiKey: "${ANTHROPIC_API_KEY}"
role: "autocomplete"
- name: "local-coding"
provider: "ollama"
model: "codellama:7b"
baseURL: "http://localhost:11434"
role: "chat"Model Roles
Different roles for specialized tasks:
- chat: General conversation and problem-solving
- autocomplete: Code completion and suggestions
- edit: Code editing and refactoring
- apply: Applying changes to files
- embeddings: Vector embeddings for similarity search
Advanced Model Settings
Fine-tune model behavior with additional parameters:
models:
- name: "custom-model"
provider: "openai"
model: "gpt-4-turbo"
apiKey: "${OPENAI_API_KEY}"
role: "chat"
temperature: 0.7
maxTokens: 2048
topP: 0.9
frequencyPenalty: 0.5
presencePenalty: 0.5
stopSequences:
- "\n\n"
- "```"Rules Configuration
Defining Custom Rules
Create rules to guide AI behavior and enforce coding standards:
rules:
- name: "security-first"
description: "Always prioritize security in code suggestions"
prompt: |
When generating code, always:
1. Use parameterized queries to prevent SQL injection
2. Validate and sanitize all user inputs
3. Follow the principle of least privilege
4. Include appropriate error handling without exposing sensitive information
- name: "performance-optimized"
description: "Generate performance-conscious code"
prompt: |
When writing code, consider:
1. Algorithmic efficiency and time complexity
2. Memory usage and garbage collection
3. Database query optimization
4. Caching strategies where appropriateRule Groups
Organize rules into groups for different contexts:
rules:
- name: "frontend-development"
group: "web-development"
description: "Frontend development best practices"
prompt: |
Follow these frontend development guidelines:
1. Use semantic HTML
2. Implement responsive design
3. Optimize for accessibility
4. Follow framework best practices
- name: "backend-development"
group: "web-development"
description: "Backend development best practices"
prompt: |
Follow these backend development guidelines:
1. Implement proper authentication and authorization
2. Use database transactions for consistency
3. Implement proper logging and monitoring
4. Design RESTful APIsTools Integration
Built-in Tools
Configure built-in tools for common tasks:
tools:
- name: "database-client"
tool: "databaseClient"
args:
databaseType: "postgresql"
serverName: "localhost"
database: "myapp"
username: "postgres"
password: "${DB_PASSWORD}"
- name: "ssh-client"
tool: "remote_command_execution"
args:
serverName: "production-server"
username: "admin"
keyPath: "~/.ssh/id_rsa"Custom Tools
Define custom tools for project-specific workflows:
tools:
- name: "run-tests"
tool: "shell_command"
args:
command: "npm test"
workingDirectory: "${PROJECT_ROOT}"
- name: "deploy-staging"
tool: "shell_command"
args:
command: "./scripts/deploy-staging.sh"
workingDirectory: "${PROJECT_ROOT}"Tool Parameters
Pass dynamic parameters to tools:
tools:
- name: "file-search"
tool: "grep_files"
args:
pattern: "{{query}}"
directory: "${PROJECT_ROOT}"
fileExtensions:
- ".js"
- ".ts"
- ".py"Preferences Configuration
User Interface Settings
Customize the ByteBuddy interface:
preferences:
language: "en-US"
theme: "dark"
fontSize: 14
fontFamily: "Fira Code"
autoScroll: true
showLineNumbers: trueBehavior Settings
Control how ByteBuddy behaves:
preferences:
autoSave: true
autoIndent: true
bracketPairColorization: true
suggestWhileTyping: true
inlineSuggestions: true
minAutoCompleteTriggerLength: 3Environment Variables
Secure Configuration
Use environment variables for sensitive information:
models:
- name: "openai-model"
provider: "openai"
model: "gpt-4-turbo"
apiKey: "${OPENAI_API_KEY}" # Loaded from environment
organization: "${OPENAI_ORG_ID}"
tools:
- name: "database"
tool: "databaseClient"
args:
password: "${DB_PASSWORD}" # Loaded from environment
connectionString: "${DATABASE_URL}"Setting Environment Variables
Different methods for different platforms:
Linux/macOS:
export OPENAI_API_KEY="your-api-key-here"
export DB_PASSWORD="your-db-password"Windows (Command Prompt):
set OPENAI_API_KEY=your-api-key-here
set DB_PASSWORD=your-db-passwordWindows (PowerShell):
$env:OPENAI_API_KEY="your-api-key-here"
$env:DB_PASSWORD="your-db-password"Configuration Validation
Syntax Checking
Validate your configuration files:
# Using the CLI
bytebuddy validate-config
# Or check specific file
bytebuddy validate-config --file .bytebuddy/config.yamlCommon Validation Errors
- Missing required fields: Ensure all required parameters are provided
- Invalid values: Check that values match expected types and formats
- Duplicate names: Ensure model, rule, and tool names are unique
Best Practices
Organization
- Modular Configuration: Split complex configurations into multiple files
- Clear Naming: Use descriptive names for models, rules, and tools
- Comments: Add comments to explain complex configurations
Security
- Environment Variables: Never hardcode sensitive information
- File Permissions: Restrict access to configuration files
- Regular Rotation: Rotate API keys and passwords regularly
Maintenance
- Version Control: Track configuration changes in version control
- Backup: Regularly backup configuration files
- Documentation: Document custom configurations and their purposes
Example Complete Configuration
Here's a comprehensive example configuration:
# .bytebuddy/config.yaml
models:
- name: "primary-chat"
provider: "openai"
model: "gpt-4-turbo"
apiKey: "${OPENAI_API_KEY}"
role: "chat"
temperature: 0.7
- name: "fast-autocomplete"
provider: "anthropic"
model: "claude-3-haiku"
apiKey: "${ANTHROPIC_API_KEY}"
role: "autocomplete"
rules:
- name: "security-guidelines"
description: "Security best practices"
prompt: |
Always follow security best practices:
1. Input validation and sanitization
2. Parameterized database queries
3. Proper authentication and authorization
4. Secure error handling
- name: "coding-standards"
description: "Project coding standards"
prompt: |
Follow our coding standards:
1. Use consistent naming conventions
2. Write clear, self-documenting code
3. Include appropriate comments
4. Follow SOLID principles
tools:
- name: "local-db"
tool: "databaseClient"
args:
databaseType: "postgresql"
connectionString: "${DATABASE_URL}"
- name: "production-server"
tool: "remote_command_execution"
args:
serverName: "prod-server"
username: "admin"
keyPath: "~/.ssh/prod_key"
preferences:
language: "en-US"
theme: "dark"
autoSave: true
suggestWhileTyping: trueTroubleshooting
Common Issues
Configuration Not Loading
- Check file syntax and indentation
- Verify file location (.bytebuddy/config.yaml)
- Ensure proper file permissions
Model Connection Failures
- Verify API keys are correct
- Check network connectivity
- Confirm model availability and quotas
Tool Execution Errors
- Verify tool parameters are correct
- Check tool dependencies are installed
- Ensure proper permissions for tool execution
Next Steps
After configuring your models, rules, and tools, explore these guides:
- Understanding Configs - Deep dive into all configuration options
- Continuous AI - Automate development workflows
- Custom Code RAG - Optimize code context understanding