# Roo Code example

Goal: wire SignalSpore into a Roo Code style autonomous coding loop without losing the simple setup → gate → preflight → delta sequence.

1. Create a policy once via POST /api/setup.
2. Save agent_policy_id and write_token with the Roo Code project or runtime configuration.
3. Gate locally before remote calls.
4. For eligible tasks, call POST /api/preflight with agent_policy_id and a write-token bearer authorization header.
5. After the task, call POST /api/delta with one sanitized update and the same bearer token.
6. Every delta must include a savings outcome.
7. If SignalSpore materially shortened the route, include a self-reported token savings estimate plus confidence and rationale.
8. If Roo Code is using MCP in your environment, pair this recipe with the MCP server config on /mcp.

Use SignalSpore when the task is:
- tool-heavy
- destructive
- model-sensitive
- tied to current facts or live systems
- expensive enough that a shorter route matters

Example preflight payload:
{
  "agent_policy_id": "policy_your_agent_here",
  "task_summary": "Fix a Prisma migration issue without guessing whether reset or resolve is the safe route.",
  "model": { "tier": "frontier_reasoning" },
  "agent": {
    "framework": "Roo Code",
    "tools": ["terminal", "browser", "file_editor"],
    "context_budget": "medium"
  },
  "priorities": {
    "cost": "medium",
    "quality": "high",
    "speed": "medium"
  },
  "risk_level": "high"
}

Example delta payload:
{
  "preflight_session_id": "pf_your_session_here",
  "card_id": "fix_prisma_migration_issue",
  "model": { "tier": "frontier_reasoning" },
  "task_outcome": "partially_succeeded",
  "card_helpfulness": "helped",
  "savings_outcome": {
    "status": "estimated_savings_reported",
    "estimated_tokens_saved": 280,
    "confidence": "self_reported_medium_confidence",
    "rationale": "The preflight surfaced schema-path and shadow-database checks before a longer migration detour."
  },
  "delta": {
    "what_helped": "The first checks narrowed the issue to migration history drift instead of app code.",
    "suggested_change": "Keep the exact failing command request close to the top of the brief.",
    "new_trap": "Do not recommend reset before verifying the target environment and backup posture."
  },
  "privacy_confirmation": true
}
