~/resources/patterns/outbound-api-integrations
// pattern

Outbound API Integrations — Required Safeguards

The full safeguard checklist for any project hitting an external API. Rate ceilings, cost accounting, circuit breaker, dry-run mode, payload bounds, secrets handling, observability — the list you wire up before the first real call.

Origin: COMSAT Haiku supervisor build Domain: engineering · agents · safety Status: canonical

Every time COMSAT (or any other Tier 0/1 project) starts hitting a remote service — Anthropic, Slack, Stripe, Notion, an MCP server, anything — these safeguards must be wired before the first real call. They are not optional.

This came from the COMSAT Haiku supervisor build: one outbound destination, one classifier, one polling loop. Easy to imagine that loop firing 1,000× because of a bug, a stuck workspace, or an mtime that doesn't change. So we encode this once and reuse it.

When to apply

Apply when any of the following becomes true in a project:

The pattern applies even for "just a quick test" — once the call lands in the codebase, the loop is one mistake away from production.

The hard checklist

Tier promotion (the meta-safeguard)

Every project has a CLAUDE.md that states its safety tier (0–3). When you add an outbound dependency:

If the tier doesn't move with the code, you'll silently slip from sandbox → production-adjacent without a corresponding safety review.

Idempotency / change detection

Rate ceilings

Cost accounting

Circuit breaker

Per-call timeouts

Backoff on errors

Dry-run mode

Privacy and payload bounds

Secrets handling

Activity log

Opt-in / off-by-default for new projects

Heuristic / offline fallback

Observability

Don't auto-retry side-effecting calls

Concurrency

Working example: COMSAT Haiku supervisor

The reference implementation in COMSAT hits all of the above:

Use it as the template the next time you add an outbound integration. Copy the structure, swap the model and the classification logic, keep the safeguards.

How to use this file

When starting any task that adds an outbound dependency:

  1. Read this file end to end.
  2. Walk every checkbox. If you can't honor one, decide explicitly whether to skip or add it later — and document the decision.
  3. Apply the same structure as the COMSAT supervisor (rate buckets, circuit breaker, cost accounting).
  4. Update the destination project's CLAUDE.md with the tier change.
  5. Reference this file in the project's commit message or PR description.

If a future Claude session adds an outbound call without going through this list, that's a regression — push back and route through this file.