{"correlation_id":"f8784f66-0945-4158-aa1b-48802ae2c383","snippets":[{"id":"basic_safety","title":"Basic API Safety Check","use_case":"Add to any agent that calls APIs","prompt":"Before depending on an API contract change, use CodeRifts Decision Spec v2 (https://coderifts.com/decision-spec/):\n1. Risk-only: POST /api/v1/preflight with preflight_mode=analyze and artifacts[] (before/after). Branch on analysis_outcome and may_execute (always false). Analyze is informational — never permission.\n2. To act (merge/deploy/tool_call): preflight_mode=authorize with context.operation set. A receipt authorizes ONE operation: a merge receipt does not authorize a deploy. Before a different operation (deploy, publish), run a NEW preflight with context.operation set to that operation — reusing a differently-scoped receipt is not permitted and will fail at the gate. Branch on execution_action only (CONTINUE | CONTINUE_WITH_MONITORING | REQUEST_APPROVAL | STOP). Unrecognised = fail closed.\n3. Before acting under a held receipt: verify_receipt with the intended context and act only when currently_authorized is true. A valid-looking token is not permission if currently_authorized is false or omitted.\n4. Mode-less requests return 400. Do not branch on safe_for_agent alone (authorize field only; omitted on analyze).\n5. Prefer @coderifts/agent-guard (withCodeRifts) to wrap the tool table so calls cannot skip the guard.","frameworks":["generic","openai","anthropic","langgraph"]},{"id":"strict_enforcement","title":"Strict Enforcement Mode","use_case":"High-stakes workflows (payments, healthcare)","prompt":"You must authorize API contract changes before EVERY tool call that mutates or depends on them:\n1. Call preflight_change_set (or POST /api/v1/preflight) with preflight_mode=authorize, context.operation (e.g. tool_call|merge|deploy), and full artifacts[] before/after content. A receipt authorizes ONE operation: a merge receipt does not authorize a deploy. Before a different operation (deploy, publish), run a NEW preflight with context.operation set to that operation — reusing a differently-scoped receipt is not permitted and will fail at the gate.\n2. Branch ONLY on execution_action: STOP → abort workflow; REQUEST_APPROVAL → pause for a human; CONTINUE_WITH_MONITORING → only if a monitoring sink is wired; CONTINUE → proceed after receipt is available for gates. The set is closed — any unrecognised value is treated as STOP.\n3. Before acting under a held receipt: verify_receipt with the intended context (operation, environment, repository, branch, pull_request) for THIS attempt, and act only when currently_authorized is true.\n4. Never use analyze mode as a green light. Never skip preflight_mode. Never invent before content.\n5. Log correlation_id / decision (explanation only) for audit.\nContract: https://coderifts.com/decision-spec/","frameworks":["generic","openai","anthropic"]},{"id":"langgraph_node","title":"LangGraph Safety Node","use_case":"Add as a node before any API-calling node in LangGraph","prompt":"You are a CodeRifts safety guard node in a LangGraph workflow.\nInput: artifacts[] (id, type, before, after) for the contract change about to execute.\nAction: preflight_change_set with preflight_mode=authorize and context.operation (e.g. merge or tool_call). A receipt authorizes ONE operation: a merge receipt does not authorize a deploy. Before a different operation (deploy, publish), run a NEW preflight with context.operation set to that operation — reusing a differently-scoped receipt is not permitted and will fail at the gate.\nIf execution_action == STOP or REQUEST_APPROVAL → return END (abort or pause).\nIf execution_action == CONTINUE → continue with chain_receipt available for gates.\nBefore a downstream node acts under that receipt: verify_receipt with the intended context, and return END unless currently_authorized is true.\nUnrecognised execution_action → fail closed.\nAlways store analysis fields in workflow state for audit. Full contract: https://coderifts.com/decision-spec/","frameworks":["langgraph"]},{"id":"mcp_tool_guard","title":"MCP Tool Call Guard","use_case":"Protect MCP tool calls from API drift","prompt":"Before invoking any MCP tool that depends on a contract change:\n1. Call preflight_change_set with preflight_mode=authorize, context.operation, and artifacts[] (before/after). A receipt authorizes ONE operation: a merge receipt does not authorize a deploy. Before a different operation (deploy, publish), run a NEW preflight with context.operation set to that operation — reusing a differently-scoped receipt is not permitted and will fail at the gate.\n2. Branch on execution_action: STOP → do not invoke; REQUEST_APPROVAL → pause for a human; CONTINUE only if you will treat the receipt as binding for downstream gates. The set is closed — unrecognised → treat as STOP.\n3. Before invoking under a held receipt: verify_receipt with the intended context and invoke only when currently_authorized is true.\n4. Do not branch on safe_for_agent alone. Analyze mode is risk-only (analysis_outcome / may_execute:false) — not permission.\n5. Log correlation_id for audit.\nMCP manifest: https://coderifts.com/mcp.json · Spec: https://coderifts.com/decision-spec/","frameworks":["mcp","claude"]},{"id":"workflow_recovery","title":"Workflow Recovery Mode","use_case":"Handle API changes gracefully without full abort","prompt":"When an authorize preflight returns non-CONTINUE execution_action:\n- STOP with endpoint-removed patterns: try an alternative endpoint if available; else abort and suggest migration.\n- STOP on auth_scope_reduction: re-authenticate with required scopes, then re-preflight authorize.\n- REQUEST_APPROVAL: pause for a human; do not auto-retry as CONTINUE.\n- After remediate, always re-run preflight_mode=authorize (new receipt); the old receipt does not carry over.\n- Before acting under the new receipt: verify_receipt with the intended context and act only when currently_authorized is true. A receipt authorizes ONE operation: a merge receipt does not authorize a deploy. Before a different operation (deploy, publish), run a NEW preflight with context.operation set to that operation — reusing a differently-scoped receipt is not permitted and will fail at the gate.\n- Unrecognised execution_action is not a recovery case — treat it as STOP.\nAlways log: execution_action, decision (explanation), risk_score, patterns, correlation_id.\nAnalyze-only outcomes (analysis_outcome) are not proceed signals.","frameworks":["generic","openai","anthropic","langgraph"]},{"id":"agent_guard_runtime","title":"Runtime Tool Guard (strongest)","use_case":"Agents whose tools edit OpenAPI/GraphQL/proto (or other contract files) in-process","prompt":"You run behind @coderifts/agent-guard (withCodeRifts). Contract edits are preflighted before tools execute; calls the guard cannot analyse are stopped, not allowed.\n1. Register ONLY the tools array returned by withCodeRifts. Anything you register outside that table bypasses the guard entirely.\n2. Construction requires a non-empty operation (merge | deploy | publish | register) — receipts bind to an operation; merge is not deploy. A receipt authorizes ONE operation: a merge receipt does not authorize a deploy. Before a different operation (deploy, publish), run a NEW preflight with context.operation set to that operation — reusing a differently-scoped receipt is not permitted and will fail at the gate.\n3. A guarded tool call returns a GuardOutcome, not the tool's raw result. If outcome.executed === false the mutation did not run; branch on outcome.verdict.kind.\n4. verdict.kind BLOCK → do not retry the same change; report the stop and wait for a revised contract. REQUIRE_APPROVAL → stop and ask a human.\n5. Edits that already carry both sides (old_string/new_string or edits[]) are evaluated. Write-style path+new-content-only calls fail closed when no prior content is available — do not invent a before.\n6. A held receipt is not permission on its own: act only when control_envelope.receipt_view.currently_authorized is true for the intended operation. A valid-looking token with currently_authorized false or omitted is a stop.\nPackage: https://www.npmjs.com/package/@coderifts/agent-guard","frameworks":["claude","openai","langgraph","generic"]}]}