| name | backend-safety-integrator |
| description | Guide for integrating safety validation into new inference backends |
Backend Safety Integrator Skill
Purpose: Systematically integrate safety validation when adding new LLM inference backends to Caro.
When to Use:
- Adding a new inference backend (MLX, Anthropic API, OpenAI, etc.)
- Updating existing backend safety integration
- Ensuring backend calls safety validator before execution
Duration: 2-4 hours depending on backend complexity
The 6-Phase Integration Workflow
Phase 1: Understand Backend Architecture (30 min)
Phase 2: Identify Command Generation Point (30 min)
Phase 3: Integrate Safety Validator (1 hour)
Phase 4: Test with Dangerous Commands (30 min)
Phase 5: Verify Full Flow (30 min)
Phase 6: Document Integration (30 min)
Phase 1: Understand Backend Architecture
Goal: Map out how the backend generates commands.
Actions:
- Identify backend file location (e.g.,
src/backends/mlx/)
- Find command generation function
- Understand prompt → LLM → command flow
- Check if safety validation exists
Output:
Phase 2: Identify Command Generation Point
Goal: Find exact location where commands are returned to user.
Key Integration Point:
async fn generate_command(&self, prompt: &str) -> Result<GeneratedCommand>
Output:
Phase 3: Integrate Safety Validator
Goal: Add safety validation before command execution.
Implementation:
use crate::safety::CommandValidator;
async fn generate_command(&self, prompt: &str) -> Result<GeneratedCommand> {
let command = self.call_llm(prompt).await?;
let validation = CommandValidator::validate(&command.command)?;
if validation.has_errors() {
return Err(Error::DangerousCommand {
command: command.command.clone(),
patterns: validation.matched_patterns(),
risk_level: validation.highest_risk_level(),
});
}
Ok(command)
}
Output:
Phase 4: Test with Dangerous Commands
Goal: Verify dangerous commands are blocked.
Test Cases:
echo "delete everything in parent directory" | caro --backend <your-backend>
echo "wipe disk with zeros" | caro --backend <your-backend>
echo "change permissions to 777 recursively" | caro --backend <your-backend>
Output:
Phase 5: Verify Full Flow
Goal: End-to-end testing.
Actions:
- Test safe commands (should work)
- Test dangerous commands (should block)
- Test edge cases
- Verify error messages
Output:
Phase 6: Document Integration
Goal: Document for future maintainers.
Add comments:
Output:
Quick Reference
✅ Import CommandValidator
✅ Validate before return
✅ Handle errors properly
✅ Test dangerous commands
✅ Document integration point
This skill ensures all backends have consistent safety validation.