Skip to content

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:

yaml
# .bytebuddy/config.yaml
models:
  # Model configurations
rules:
  # Rule definitions
tools:
  # Tool integrations
preferences:
  # User preferences

AI Model Configuration

Provider Setup

Configure different AI providers with their specific requirements:

yaml
# .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:

yaml
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:

yaml
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 appropriate

Rule Groups

Organize rules into groups for different contexts:

yaml
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 APIs

Tools Integration

Built-in Tools

Configure built-in tools for common tasks:

yaml
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:

yaml
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:

yaml
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:

yaml
preferences:
  language: "en-US"
  theme: "dark"
  fontSize: 14
  fontFamily: "Fira Code"
  autoScroll: true
  showLineNumbers: true

Behavior Settings

Control how ByteBuddy behaves:

yaml
preferences:
  autoSave: true
  autoIndent: true
  bracketPairColorization: true
  suggestWhileTyping: true
  inlineSuggestions: true
  minAutoCompleteTriggerLength: 3

Environment Variables

Secure Configuration

Use environment variables for sensitive information:

yaml
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:

bash
export OPENAI_API_KEY="your-api-key-here"
export DB_PASSWORD="your-db-password"

Windows (Command Prompt):

cmd
set OPENAI_API_KEY=your-api-key-here
set DB_PASSWORD=your-db-password

Windows (PowerShell):

powershell
$env:OPENAI_API_KEY="your-api-key-here"
$env:DB_PASSWORD="your-db-password"

Configuration Validation

Syntax Checking

Validate your configuration files:

bash
# Using the CLI
bytebuddy validate-config

# Or check specific file
bytebuddy validate-config --file .bytebuddy/config.yaml

Common Validation Errors

  1. Missing required fields: Ensure all required parameters are provided
  2. Invalid values: Check that values match expected types and formats
  3. Duplicate names: Ensure model, rule, and tool names are unique

Best Practices

Organization

  1. Modular Configuration: Split complex configurations into multiple files
  2. Clear Naming: Use descriptive names for models, rules, and tools
  3. Comments: Add comments to explain complex configurations

Security

  1. Environment Variables: Never hardcode sensitive information
  2. File Permissions: Restrict access to configuration files
  3. Regular Rotation: Rotate API keys and passwords regularly

Maintenance

  1. Version Control: Track configuration changes in version control
  2. Backup: Regularly backup configuration files
  3. Documentation: Document custom configurations and their purposes

Example Complete Configuration

Here's a comprehensive example configuration:

yaml
# .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: true

Troubleshooting

Common Issues

Configuration Not Loading

  1. Check file syntax and indentation
  2. Verify file location (.bytebuddy/config.yaml)
  3. Ensure proper file permissions

Model Connection Failures

  1. Verify API keys are correct
  2. Check network connectivity
  3. Confirm model availability and quotas

Tool Execution Errors

  1. Verify tool parameters are correct
  2. Check tool dependencies are installed
  3. Ensure proper permissions for tool execution

Next Steps

After configuring your models, rules, and tools, explore these guides: