AI Agent Guidelines
This document provides guidelines for AI agents (Claude Code, Cursor, Copilot, etc.) working on the caro codebase.
Code Style
Section titled “Code Style”Rust Conventions
Section titled “Rust Conventions”- Follow Rust 2021 edition idioms
- Use
rustfmtformatting - Pass all
clippylints - Prefer
Result<T>over panics - Use meaningful variable names
Documentation
Section titled “Documentation”- Add doc comments to all public APIs
- Use
///for function documentation - Include examples in doc comments
- Keep comments up-to-date with code
Safety Requirements
Section titled “Safety Requirements”Critical Rules
Section titled “Critical Rules”- Never bypass safety validation in production code
- Test dangerous patterns only in controlled test environments
- Document all security-relevant changes thoroughly
- Review generated commands before suggesting execution
Dangerous Patterns to Block
Section titled “Dangerous Patterns to Block”// These patterns MUST be detected and blocked:const DANGEROUS_PATTERNS: &[&str] = &[ "rm -rf /", "rm -rf ~", "mkfs", "dd if=/dev/zero", ":(){ :|:& };:", // Fork bomb "chmod 777 /", "> /dev/sda",];Testing Requirements
Section titled “Testing Requirements”Test Coverage
Section titled “Test Coverage”- All new features require tests
- Bug fixes must include regression tests
- Safety validation requires property tests
- Integration tests for CLI workflows
Test Quality
Section titled “Test Quality”- Tests should be deterministic
- Avoid flaky tests
- Mock external dependencies
- Use descriptive test names
Git Workflow
Section titled “Git Workflow”Commit Messages
Section titled “Commit Messages”feat: add new backend support for Ollamafix: resolve memory leak in MLX initializationdocs: update installation guide for Windowstest: add integration tests for safety modulerefactor: simplify backend trait implementationBranch Naming
Section titled “Branch Naming”feature/description- New featuresfix/description- Bug fixesdocs/description- Documentationrefactor/description- Code improvements
Performance Considerations
Section titled “Performance Considerations”Startup Time
Section titled “Startup Time”- Target: < 100ms cold start
- Lazy load dependencies
- Avoid blocking I/O on startup
Inference Time
Section titled “Inference Time”- Target: < 2s on Apple Silicon
- Cache model weights
- Use streaming where beneficial
Error Handling
Section titled “Error Handling”fn process_command(cmd: &str) -> Result<String, Error> { let validated = validate(cmd)?; execute(validated)}fn process_command(cmd: &str) -> String { let validated = validate(cmd).unwrap(); // NO! execute(validated).expect("should work") // NO!}Encoding Rules
Section titled “Encoding Rules”UTF-8 Compliance
Section titled “UTF-8 Compliance”- All source files must be UTF-8
- Use ASCII for identifiers
- Avoid smart quotes in strings
- Use standard ASCII punctuation
- Em-dashes (use
--instead) - Smart quotes (use
"and') - Non-breaking spaces
- Invisible Unicode characters