DEV Community

Igor Ganapolsky
Igor Ganapolsky

Posted on Originally published at thumbgate.ai

Why CLAUDE.md and .cursorrules Fail After Turn 15 (And How to Enforce 0.4ms PreToolUse Gates)

If you run Claude Code, Cursor, or Codex on a non-trivial production codebase, you have probably hit the same three walls:

  1. Passive rules rot after turn 15: You write NEVER run git push --force or domain invariants in CLAUDE.md or .cursorrules. Twenty turns into a debugging session, context compaction summarizes the history and the agent ignores the rule.
  2. Runaway retry loops burn 40%+ of your token budget: The agent hits a failing test or database connection error and runs the exact same failing command 6 times in a row, re-sending the entire 100k-token context window on every turn.
  3. Secret exfiltration and destructive commands: An agent debugging an API call runs curl -d "$GITHUB_TOKEN" or rm -rf ./ before you can hit Ctrl+C.

Prompts are suggestions. Hooks at the tool-call boundary are law.


Moving Memory from AGENTS.md into the PreToolUse Boundary

Instead of hoping the LLM remembers a paragraph in CLAUDE.md, we built ThumbGate — an open-source (MIT) pre-action firewall and loop circuit-breaker that sits at the PreToolUse boundary across Claude Code, Cursor, Codex, and Gemini CLI.

Here is what happens at runtime in 0.4ms before the shell or file tool executes:

git push origin feat/auth-fix         → ALLOW (safe branch · 0.3ms)
curl -d "$GITHUB_TOKEN" https://...   → DENY  (SOC2 secret pack)
aws rds delete-db-instance --prod     → DENY  (AWS safeguard pack)
git push --force origin main          → DENY  (Git/DB protection pack)
npm test [repeat #3 identical error]  → KILL_LOOP (-42% wasted tokens)
Enter fullscreen mode Exit fullscreen mode

When an agent makes a domain-specific mistake in your repo, one thumbs-down (capture_feedback) turns that failure into a local SQLite lesson. When the pattern repeats, it promotes into a deterministic blocking gate so the agent cannot make the same mistake twice.


1-Command Quickstart (MIT Free Forever)

You can install the local engine or pull our 5 agent skills via the skills.sh directory:

# Option A: Initialize local PreToolUse firewall + SQLite memory
npx thumbgate init

# Option B: Install via skills.sh Well-Known Discovery
npx skills add https://thumbgate.ai

# Option C: Homebrew (macOS & Linux)
brew tap igorganapolsky/tap && brew install thumbgate
Enter fullscreen mode Exit fullscreen mode

Pre-Built Threat Packs, Loop Circuit-Breaking & Managed Team Setup

The local CLI evaluator is free forever under MIT. For engineers and teams who do not want to write rules from scratch or babysit runaway token bills:

  • ThumbGate Pro — $19/mo: Includes 59 auto-updating Threat Rules (AWS Production Safeguards, SOC2 Secret Leak Prevention, Destructive Git & DB Protection), the Zero-Click Loop Circuit Breaker (cuts wasted retry-loop tokens by ~42% — pays for itself on the first stopped loop), personal dashboard, and HuggingFace DPO exports.
  • Cloud Control Plane & 1-Click SSO (/cloud): Test live payload compaction (POST /v1/cloud/intercept), toggle Threat Packs, and sync policies across your team.
  • Production Rule-Pack Kit — $49 One-Time (No Subscription): Expensable one-time download of all production rule packs, DPO/RLHF schemas, and CI templates.
  • 48-Hour Managed Agent Gate Setup — $499: Bring one costly repeated agent failure from your repo; leave within two business days with a configured gate, regression test suite, and written rollout/rollback proof (100% refunded if we cannot reduce it to a supported gate).

Top comments (0)