Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIDeepSeekDeepSeekMuseMuse+22 more

    Agent Flight Recorder: Catch Loops & Scope Drift

    1

    Records every agent file edit and shell command in a SHA-256 hash-chained log and blocks handoff on retry loops, scope escapes, or forbidden commands.

    $9.99

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned

    Agent Flight Recorder: Catch Loops & Scope Drift

    Example session with this skill installed

    Audit the session log flight_session.jsonl against the default policy and verify the hash chain.

    • Read your context and instructions
    • Compiled the agent flight recorder

    The audit of flight_session.jsonl has been completed. The session failed the security gate due to a forbidden path access attempt.

    Post-Run Incident Report

    MetricStatusDetails
    Audit Result[FAIL]Policy violations detected
    Exit Code1FORBIDDEN_PATH_MATCH
    Total Steps12Within cap (max: 50)
    Hash ChainPASSIntegrity verified via SHA-256
    Violationseq: 9Attempted write to .env.production
    Retry StatusOKNo loops detected

    Violation Summary

    The agent successfully performed 8 file reads and edits within src/ and tests/. However, at step 9, the edit_file tool targeted .env.production, which matches the forbidden_path_globs pattern in flight_policy.json. The audit gate terminated the session to prevent a secret leak.

    Next steps

    1. Revert the changes to the protected file if any were partially written.
    2. Update flight_policy.json if this path was actually intended to be modifiable.
    3. Restart the agent session with a fresh log to ensure a clean, compliant run.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Above-the-Fold Hook (3-Second Value)

    Stop AI coding agents from burning tokens in silent retry loops, writing to ../outside/.env, or running rm -rf behind your back.

    Agent Flight Recorder adds a deterministic 3-layer guardrail (SKILL.md SOP + JSON Schema contracts + zero-dependency Python 3 stdlib gate) that records every file edit and shell command in a SHA-256 hash-chained JSONL flight log and blocks handoff with an itemized Post-Run Incident Report whenever a session breaks scope or loop limits.

    What's Inside (3-Layer Architecture + 60-Second Test Pack)

    • Layer 1 — Operational SOP (SKILL.md): Strict Declare Policy -> Record Every Action -> Audit Before Handoff workflow compatible with Claude Code, Cursor, and Codex CLI, complete with non-negotiable hard-fail rules.
    • Layer 2 — JSON Schema Draft 2020-12 Contracts (schemas/):
      • schemas/flight_policy.schema.json: Configurable allowed workspace path prefixes, forbidden path globs (.env, secrets/*, *.key), forbidden command regexes, and step/error/retry caps.
      • schemas/flight_event.schema.json: Strict schema for hash-chained JSONL flight events (seq, timestamp, action_type, tool, target, status, summary, prev_hash, event_hash).
    • Layer 3 — Zero-Dependency Python Gate (scripts/flight_recorder_gate.py): Pure Python 3 standard library (json, pathlib, fnmatch, re, hashlib, datetime, argparse) with two subcommands:
      • log: Appends SHA-256 hash-chained events to any JSONL flight log.
      • audit: Verifies schema compliance, hash-chain integrity, retry loops, consecutive error streaks, workspace path boundaries, forbidden secret globs, and forbidden shell regexes. Supports --json for CI pipelines; exits 0 on PASS and 1 on FAIL.
    • 60-Second Test Pack (examples/):
      • examples/flight_policy.json: Ready-to-use coding-agent workspace policy.
      • examples/sample_flight_fail.jsonl: Real hash-chained failing session featuring a 4x command retry loop, a path-traversal write to ../outside/prod.env, and a forbidden rm -rf shell command.
      • examples/sample_flight_pass.jsonl: Clean scoped session (including one recovered test failure) that passes every check.

    Who This Is For & Prerequisites

    Built for:

    • Solo developers and engineering teams running autonomous coding sessions in Claude Code, Cursor, or Codex CLI.
    • Technical leads who want deterministic, auditable post-run logs before merging agent-authored diffs.
    • Automation builders integrating agent execution checks into local scripts or CI pipelines via --json.

    Prerequisites:

    • Python 3.9+ (uses Python 3 standard library only — zero pip install, zero external packages, zero API keys required).
    • Works cross-platform on Windows (cp1252-safe ASCII output), macOS, and Linux.

    60-Second Quick-Start

    Run directly from the skill folder:

    # 1. Run the FAIL fixture (catches 4x retry loop, ../outside/prod.env write, and rm -rf)
    python scripts/flight_recorder_gate.py audit \
      --log examples/sample_flight_fail.jsonl \
      --policy examples/flight_policy.json
    
    # 2. Run the PASS fixture (clean scoped session within limits)
    python scripts/flight_recorder_gate.py audit \
      --log examples/sample_flight_pass.jsonl \
      --policy examples/flight_policy.json
    
    # 3. Append a new hash-chained event to your own session log
    python scripts/flight_recorder_gate.py log \
      --log my_session.jsonl \
      --action-type file_edit \
      --tool edit_file \
      --target src/app.py \
      --status ok \
      --summary "Added health endpoint"
    

    Real Terminal Proof

    1. FAIL Gate — Catching Retry Loop, Out-of-Scope .env Write & rm -rf (exit code 1)

    $ python scripts/flight_recorder_gate.py audit --log examples/sample_flight_fail.jsonl --policy examples/flight_policy.json
    ========================================================================
    AGENT FLIGHT RECORDER -- POST-RUN INCIDENT REPORT
    ========================================================================
    Policy       : Standard Coding-Agent Workspace Policy (examples\flight_policy.json)
    Flight Log   : examples\sample_flight_fail.jsonl
    Events       : 8 / 40 max steps
    Hash Chain   : VALID
    Error Streak : 4 max consecutive (limit 3)
    Retry Streak : 4 identical failures (threshold 3)
    Violations   : 5
    ------------------------------------------------------------------------
    [BLOCKED] Session failed 5 policy check(s):
    
      1. [FAIL] [HIGH] CONSECUTIVE_ERROR_CAP (seq 3..6)
         Consecutive errors reached 4 (limit=3) across seq 3..6.
      2. [FAIL] [HIGH] RETRY_LOOP_DETECTED (seq 3..6)
         Identical failing action repeated 4x (threshold=3) across seq 3..6: shell_command [run_command] -> pytest tests/test_invoice.py -k test_tax_rounding
      3. [FAIL] [CRITICAL] OUT_OF_SCOPE_PATH (seq 7)
         file_write target '../outside/prod.env' escapes workspace root (absolute path or '..' traversal).
      4. [FAIL] [CRITICAL] FORBIDDEN_PATH_MATCH (seq 7)
         file_write target '../outside/prod.env' matches forbidden path glob(s): *.env.
      5. [FAIL] [CRITICAL] FORBIDDEN_COMMAND (seq 8)
         Command 'rm -rf build/ ../outside/cache' triggered rule DESTRUCTIVE_RM_RF: Recursive forced deletion (rm -rf) is forbidden inside automated agent runs.
    
    Recommended Remediation:
      - Break retry loops: inspect root cause and change strategy after 2 identical failures.
      - Pause execution after consecutive errors and request targeted diagnostics or human input.
      - Restrict all file edits to approved allowed_path_prefixes inside the workspace root.
      - Remove all reads/writes to .env, secret, or credential files from agent tasks.
      - Replace destructive shell commands with scoped, reversible workspace operations.
    ========================================================================
    # Exit code: 1
    

    2. PASS Gate — Clean Scoped Session Approved (exit code 0)

    $ python scripts/flight_recorder_gate.py audit --log examples/sample_flight_pass.jsonl --policy examples/flight_policy.json
    ========================================================================
    AGENT FLIGHT RECORDER -- POST-RUN INCIDENT REPORT
    ========================================================================
    Policy       : Standard Coding-Agent Workspace Policy (examples\flight_policy.json)
    Flight Log   : examples\sample_flight_pass.jsonl
    Events       : 6 / 40 max steps
    Hash Chain   : VALID
    Error Streak : 1 max consecutive (limit 3)
    Retry Streak : 1 identical failures (threshold 3)
    Violations   : 0
    ------------------------------------------------------------------------
    [PASS] Clean scoped session. All policy and integrity checks passed.
    ========================================================================
    # Exit code: 0
    

    3. Machine-Readable JSON Mode (--json, exit code 0)

    {
      "status": "PASS",
      "exit_code": 0,
      "summary": {
        "total_events": 6,
        "max_total_steps": 40,
        "hash_chain_verified": true,
        "hash_chain_status": "VALID",
        "max_consecutive_errors": 1,
        "consecutive_error_limit": 3,
        "max_identical_failure_streak": 1,
        "retry_loop_threshold": 3,
        "violation_count": 0
      },
      "violations": [],
      "remediation": []
    }
    

    MCP Search Keywords

    agent flight recorder, coding agent audit log, retry loop detector, scope drift guardrail, jsonl hash chain, sha256 audit trail, claude code safety gate, cursor agent guardrail, codex cli policy check, forbidden command detector, env file protection, python stdlib validator, json schema draft 2020-12, post-run incident report

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Code Quality & Review.

    Requires Python 3. Cannot physically block a shell command if the agent skips the log step; relies on the agent following the SOP or a wrapper script.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scan

    Security scan passed today

    Software
    PythonGit

    Permissions

    Terminal / Shell
    Network Access
    Read Files
    Write Files
    Listedtoday

    What's inside

    Frequently Asked Questions

    Unlike soft-instruction prompts that agents can ignore, this skill uses a deterministic Python script to enforce hard-fail rules, ensuring that runaway loops and sensitive file access are stopped by code rather than suggestion.

    The skill is framework-agnostic and works with any agent capable of executing Python 3, including Claude Code, Cursor, and custom internal workflows running in Unix-like environments.

    The flight recorder uses SHA-256 hash-chaining for every log entry; if an agent tries to delete or modify a past event to hide a mistake, the hash chain will break, causing the audit gate to fail immediately.

    Setting up is simple: place the script in your project, define your allowed and forbidden paths in a JSON policy file, and integrate the audit command into your agent's task loop or CI/CD pipeline.

    You receive the core Python 3 audit engine, a template for the flight policy configuration, and documentation on how to hook the logger into your specific agentic workflow.

    Yes, the recorder operates with zero external dependencies using only the Python 3 standard library, making it extremely lightweight and secure for air-gapped or sensitive production environments.

    New in Code Quality & Review