Overview

Make your agent API-safe in 3 steps

1
Add the preflight guard

Install the runtime guard: @coderifts/agent-guard (withCodeRifts / the guarded registry). It runs an authorize preflight (operation-bound) for contract changes. On authorize responses, execution_action is a closed set of four: CONTINUE, CONTINUE_WITH_MONITORING, REQUEST_APPROVAL, STOP — anything unrecognised fails closed. Fail-closed also on an unverifiable receipt or a degraded server. Analyze-mode responses omit execution vocabulary entirely — see Decision Spec v2.

The runtime sees only calls through the returned tool table. Construction requires a non-empty operation (merge | deploy | publish | register) — receipts bind to an operation; merge is not deploy. PR comments and MCP tools alone do not prevent a call — see What Each Path Does.

npm install @coderifts/agent-guard @coderifts/sdk

The canonical call — supply the change as artifacts[] with before/after content; the factory runs only if the verdict permits:

import { guardToolCall } from '@coderifts/agent-guard';
import { CodeRifts } from '@coderifts/sdk';
 
const client = new CodeRifts({ apiKey: process.env.CODERIFTS_API_KEY });
 
const outcome = await guardToolCall(
  {
    toolName: 'Edit',
    arguments: { path: 'openapi.yaml' },
    artifacts: [{ id: 'public-api', type: 'openapi', before: baseSpec, after: proposedSpec }],
  },
  async (envelope, redactedCall) => applyEdit(redactedCall),
  { client, operation: 'merge', environment: 'production' },
);
 
if (!outcome.executed) {
  // Fail-closed: the tool never ran.
  console.error('CodeRifts blocked the call:', outcome.verdict);
}

If the guard detects a contract change but artifacts[] was not supplied with content, it fails closed locally with outcome.verdict.cause === 'MISSING_ARTIFACT_CONTENT' — an actionable error, never a silent bypass. resolveArtifacts can fill before/after in from git automatically.

Prefer a framework drop-in? CodeRifts ships ready-made snippets (LangGraph, AutoGen, and more) — each has a keyless quick check plus an enforcement block that posts a change set and needs an API key — and a keyless /api/v1/public/preflight endpoint for trying it out without a key:

curl https://app.coderifts.com/api/v1/snippets/langgraph
# full framework list: https://app.coderifts.com/api/v1/snippets
2
Adopt the recommended policy

CodeRifts publishes a default agent policy: when a contract artifact changes, call preflight_change_set with preflight_mode: "authorize" and context.operation, then branch on execution_action — not on ad-hoc on_block / on_warn strings, and not on analyze bodies.

curl https://app.coderifts.com/api/v1/policy/default

Fetch the policy and enforce it as-is, or customize it.

3
Read the verdict

Branch strictly on execution_action for control flow. Treat safe_for_agent as a dashboard/legacy signal, never the sole gate. A valid signature is not authorization by itself — currently_authorized lives on the verify_receipt response, checked conjunctively with operation, fingerprint, and execution_action. See the full contract on Decision Spec v2 and the tool list on MCP Integration.

Get a free API key · MCP tools reference

Updated

Was this page helpful?