The complete guide to pre-action checks, feedback capture, history-aware lesson distillation, and automatic prevention rules.
Your AI coding agent force-pushes to main. You correct it. Next session, it force-pushes again. You add a rule to CLAUDE.md. It ignores it. You lose an afternoon reverting.
This happens because prompt rules are suggestions. The agent can read them, forget them, or override them. There is no enforcement at the tool-call level.
ThumbGate adds an enforcement layer between your agent and its tools. When the agent tries to execute a tool call, a PreToolUse hook fires before the action runs. The hook checks the call against known failure patterns. If it matches a check, the action is flagged and logged — and hard-blocked by default for catastrophic commands (force-push, git reset --hard, rm -rf on home or root, DROP TABLE, cloud wipes), secret exfiltration and guardrail-tampering. Everything else, supply-chain risks included, warns by default and hard-blocks when strict enforcement (THUMBGATE_STRICT_ENFORCEMENT=1) is on.
Agent: git push --force origin main
Result: Force-pushed. You lose 3 commits. Again.
Agent: git push --force origin main
[check] Warn: no-force-push (confidence: 0.94) — hard-blocked under strict mode
Agent: git push origin feature-branch
[check] Passed
# Auto-detect your agent and configure hooks
npx thumbgate init
# Or specify your agent directly
npx thumbgate init --agent claude-code
npx thumbgate init --agent codex
npx thumbgate init --agent cursor
npx thumbgate init --agent gemini
First run: a thumbs-down typed right after the agent ran a command makes a learned rule that denies that command the next time the agent tries it, with your reason (since 1.64.0). By default ThumbGate also denies catastrophic commands, secret leaks and attempts to switch it off; other built-in checks warn. A thumbs-down that is only a sentence, with no command attached, is saved as a lesson. To gate one command without a thumbs-down, run thumbgate force-gate "<command>". That gate denies only when strict enforcement is on (THUMBGATE_STRICT_ENFORCEMENT=1); in default mode it warns. Measured 24 Nov 2026 on a throwaway directory: warn in default mode, deny in strict mode, including bash -c "<command>".
| Scope | Command | Claude Code hooks | Lessons and dashboard data |
|---|---|---|---|
| Machine-wide (default) | npx thumbgate init |
~/.claude/settings.json, so they run in every repo on this machine |
<repo>/.thumbgate/ |
| Per-project | npx thumbgate init --project (run inside the repo) |
<repo>/.claude/settings.json, so they run only in this repo |
<repo>/.thumbgate/ |
Both scopes also write the MCP entry to <repo>/.mcp.json. Lessons stay per repo either way: a thumbs-down in repo-A does not flag anything in repo-B. Keep .thumbgate/ gitignored. For an MCP-only install, npx thumbgate install-mcp adds the server to ~/.claude/settings.json, and npx thumbgate install-mcp --project adds it to <repo>/.claude/settings.json. Neither writes hooks.
If none of these fit, you may not need it yet. ThumbGate checks tool calls before they run; it is not a sandbox.
npx thumbgate init
npx thumbgate doctor # look for: Overall: READY
Pick one command your agent has run when it should not have.
Right after the agent runs that command, type thumbs down: and the reason. Ask it to run the command again: it is denied, with your reason, because the thumbs-down made a learned rule for that command (since 1.64.0). The command is also held until you say "go ahead", but the learned rule keeps refusing it after that (thumbgate unblock <gate> turns it into a timed, logged warning). To have holds refuse the command instead of warning, set THUMBGATE_HARD_BLOCK_GATES=thumbs-down-hold, or THUMBGATE_STRICT_ENFORCEMENT=1 to make every warning a deny.
npx thumbgate gate-stats # Actions blocked, Actions warned, Top blocked gate
npx thumbgate gate-audit # replays learned gates on past allowed actions: false-fire rate
The counts include the test you ran on day 2. ThumbGate cannot know that a block was wrong, so when one stops something you wanted, write it down. With few past actions, gate-audit has no rate to show yet.
.thumbgate/auto-promoted-gates.json in the project, using the id gate-stats or the block message shows. Another thumbs-down on the same command can bring it back. A hold clears with npx thumbgate holds release.When your agent makes a mistake, tell it. ThumbGate captures the feedback as structured data with context, tags, and domain. In the current Claude auto-capture path, if the thumbs-down is vague, it can reuse up to 8 prior recorded entries and the failed tool call to propose a better lesson instead of discarding the feedback.
# Your agent force-pushed. You say:
"thumbs down — force-pushed to main, lost commits"
# ThumbGate captures:
{
signal: "negative",
context: "force-pushed to main, lost commits",
tags: ["git", "force-push", "destructive"],
domain: "version-control"
}
After repeated failures with the same pattern, ThumbGate generates a prevention rule automatically. No manual rule writing needed.
Prevention rules are enforced as pre-action checks. The check fires at the PreToolUse hook level — inside the agent's runtime, before the tool call executes.
Checks that block too aggressively (high false-positive rate) get their confidence reduced automatically. Checks that catch real mistakes get reinforced. This is Bayesian multi-armed bandit optimization, not static rules.
ThumbGate stores feedback in a local SQLite database with FTS5 full-text indexing. Lookups are sub-millisecond even at tens of thousands of entries. Old entries that contradict newer evidence are auto-pruned via Bayesian belief decay.
recall — injects relevant context at session startsearch_lessons — finds promoted lessons with corrective actionsretrieve_lessons — surfaces lessons for the tool or action you are about to runsession_handoff — preserves continuity across sessionsThumbGate supports linked feedback sessions for the messy reality of AI debugging. In the current Claude flow, accepted feedback opens a 60-second follow-up session. You can append more context, reset the timer, and finalize once the lesson is clear.
open_feedback_session starts a linked correction thread.append_feedback_context adds later notes, failed tool output, or user corrections to the same thread.finalize_feedback_session promotes the combined evidence into one reusable lesson.reflect_on_feedback proposes a reusable rule from the same transcript when the failure pattern is obvious.| Feature | Prompt Rules | Pre-Action Checks |
|---|---|---|
| Where they live | CLAUDE.md, .cursorrules | PreToolUse hooks |
| Enforcement | Suggestion (can be ignored) | Flags + logs; hard-blocks critical / strict mode |
| When they fire | At prompt load | Before a tool runs |
| Auto-generated | No — hand-written | Yes — from feedback |
| Adaptive | No | Yes — Thompson Sampling |
| Persist across sessions | Only if in a file | SQLite + JSONL |
| Feature | ThumbGate | SpecLock | Mem0 |
|---|---|---|---|
| Flags mistakes before execution | Yes — PreToolUse checks (built-in rules deny a short list; other matches warn) | Yes — Patch Firewall | No |
| Turns feedback into rules | Yes — thumbs up/down | Not stated in its README; it reads existing rule files | Yes — auto-capture |
| Auto-generates rules | Auto-promotes a warning rule from repeated thumbs-downs | Not compared | No |
| Agent support | Claude Code, Codex, Gemini, Amp, Cursor, OpenCode | Claude Code, Cursor, Windsurf, Cline | Claude, Cursor |
| Install | npx thumbgate init | npx speclock setup | Cloud signup |
| Cost | Free local CLI; Pro $19/month | Free | Free tier + paid |
Give a thumbs-down: "deleted production config file." ThumbGate saves your reason and shows it back as a warning when a similar command comes up. It does not block on a thumbs-down alone.
Give a thumbs-down: "committed code with failing tests." ThumbGate learns the pattern and checks future commits when test results show failures.
Give a thumbs-down: "called staging API in production code." The check flags and logs tool calls that reference staging URLs in production contexts (and hard-blocks them under strict mode).
ThumbGate uses four words for what happens to a command. They mean the same thing on every ThumbGate page.
| Situation | Default install | Strict mode |
|---|---|---|
git push --force, git reset --hard, git clean -fdx, rm -rf on home or root, find / -delete, DROP TABLE | Denied | Denied |
terraform destroy, kubectl delete, aws s3 rm and other cloud or cluster wipes | Denied | Denied |
Sending a secret out, for example curl -d @.env | Denied | Denied |
Switching ThumbGate off, for example pkill -f thumbgate or uninstalling it from inside the agent | Denied | Denied |
git push origin main (a push to the default branch) | Denied (lift it for an hour with npx thumbgate unblock protected-branch-push --reason "why you need it") | Denied |
| A command you gave a thumbs-down, right after and each time it runs again (a rule that would have blocked your past safe calls stays a Warning) | Denied | Denied |
| A learned check that passed its 30-day replay (under 2% of 50+ matching calls were ones you let through) | Denied | Denied |
Other flagged actions, for example npm publish or git commit --no-verify | Warning | Denied |
| Claude Code says "deployed" or "live" with no production output in the reply (Stop hook) | Reply sent back once to add proof. It checks that proof is present, not that it is true. | Same as default |
The same action, reworded (for example python3 -c "shutil.rmtree(...)" after a thumbs-down on rm -rf) | Not caught. A learned rule matches the command, not its purpose. | Not caught |
| Damage from a command ThumbGate allows | Not contained. ThumbGate is not a sandbox. | Not contained |
The CLI sends anonymous usage events: a random install id, the ThumbGate, Node and OS versions, the event name, and which built-in check fired (any rule learned from your thumbs-downs is sent only as "learned", never its words). Releases before 1.62.0 could send words from a learned rule's command; update to stop that. THUMBGATE_NO_TELEMETRY=1 or DO_NOT_TRACK=1 turns it off. Lessons and rules stay in .thumbgate/ in your repo.
Stuck? Do this.
1. Say "go ahead" to your agent, or give a thumbs-up.
2. Or run npx thumbgate unblock to see what refused the call and how to clear it (details).
3. To stop holds for good, run npx thumbgate holds off. Your other gates stay on.
A hold is a pause. When you type a thumbs-down right after the agent ran something, ThumbGate warns the agent, with your reason, before that same action (the same tool; for a shell command, the same first three words) until you say to go on. In strict mode, or with THUMBGATE_HARD_BLOCK_GATES=thumbs-down-hold, the hold refuses it instead. A hold on inline code (python3 -c, a heredoc, a pipe into Python) covers that script in any form, not every later python3 run. It stops the agent from repeating what you just marked wrong. A hold lasts up to 24 hours, and several thumbs-downs on the same action count as one hold.
Three ways out: start your message with "go ahead" (or "continue", "proceed", "resume", "unblock"), or give a thumbs-up; run npx thumbgate holds release in the project folder to clear it now; or run npx thumbgate holds off to turn the hold off, even in a session that is already running (npx thumbgate holds on brings it back).
Run npx thumbgate unblock to see which gate or hold refused a call and the exact command that clears it. npx thumbgate unblock holds releases thumbs-down holds. npx thumbgate unblock <gate> --reason "why" --ttl 1h grants a time-boxed, audited override for that one gate (24 hours at most; --revoke ends it early). The override turns that gate into a warning even in strict mode or under THUMBGATE_HARD_BLOCK_GATES. Catastrophic commands, secrets and attempts to switch off ThumbGate are never unblocked: change the command instead. From 1.61.0 the money and outbound-send gates (financial-control, outbound-email-send) can't be unblocked either, if you've turned them into blocks. From 1.61.0 the local dashboard (npx thumbgate dashboard --open) has an Unblock panel that does the same with buttons.
Turning the hold off keeps every other gate on, including the commands denied by default and the chat send rules. THUMBGATE_SEND_GATE=0 turns off the whole chat send gate, holds included. npx thumbgate break-glass does not lift a hold. A reworded command is not held, and ThumbGate is not a sandbox.
Stay on the free plan while three learned rules cover the mistakes you correct. Pro starts to pay off when you correct your agent often enough to want every rule kept active, and to search what you taught it last month.
npx thumbgate init to prove one workflow on one machine.The repo sales plan is proof-led, not hype-led. Commercial claims stay anchored to the current truth file, and engineering claims stay anchored to verification evidence and machine-readable proof reports.
git push --force, git reset --hard, git clean -fdx, rm -rf on home or root, find / -delete, DROP TABLE; terraform destroy, kubectl delete, aws s3 rm and other cloud or cluster wipes; Sending a secret out, for example curl -d @.env; Switching ThumbGate off, for example pkill -f thumbgate or uninstalling it from inside the agent; git push origin main (a push to the default branch); A command you gave a thumbs-down, right after and each time it runs again (a rule that would have blocked your past safe calls stays a Warning); A learned check that passed its 30-day replay (under 2% of 50+ matching calls were ones you let through). These are denied before they run, in every plan.
A command you gave a thumbs-down, right after and each time it runs again (a rule that would have blocked your past safe calls stays a Warning): Denied. A learned check that passed its 30-day replay (under 2% of 50+ matching calls were ones you let through): Denied. The same action, reworded (for example python3 -c "shutil.rmtree(...)" after a thumbs-down on rm -rf): Not caught. A learned rule matches the command, not its purpose.
Other flagged actions, for example npm publish or git commit --no-verify: a Warning by default. The agent sees the check and your reason. The command can still run. Strict mode denies these instead.
THUMBGATE_STRICT_ENFORCEMENT=1. Checks that only warn by default deny instead, except a rule learned from a single thumbs-down. Built-in checks that warn by default, such as npm publish, are Denied.
Claude Code: Denied and Warning, tested end to end. Cursor: Shell commands: Denied and Warning, tested end to end. Other tools: Advisory. Codex, Gemini CLI: Wired, not yet tested end to end with each agent's own payload. Pydantic AI Pax: Denied and Warning. Cline, OpenCode, Amp and other MCP-only clients: Advisory only.
Free keeps 3 active learned rules and records 2 thumbs a day after a 7-day full Pro trial. Pro is $19/month for one developer. Pro adds unlimited active learned rules (free keeps 3), unlimited thumbs-up and thumbs-down captures, recall and lesson search across everything you have taught it, DPO and training-data exports. Not shipped in any plan: team-shared rules, rules shared between teammates' machines, audit history for managers.
The CLI sends anonymous usage events: a random install id, the ThumbGate, Node and OS versions, the event name, and which built-in check fired (any rule learned from your thumbs-downs is sent only as "learned", never its words). Releases before 1.62.0 could send words from a learned rule's command; update to stop that. THUMBGATE_NO_TELEMETRY=1 or DO_NOT_TRACK=1 turns it off. Lessons and rules stay in .thumbgate/ in your repo.
Not yet. Not shipped in any plan: team-shared rules, rules shared between teammates' machines, audit history for managers. Teams can ask for a 30-day pilot at https://thumbgate.ai/pilot. It is request only, with no self-serve team checkout.
npx thumbgate init
One command. Works with Claude Code, Cursor, Codex, Gemini, Amp, and OpenCode. Claude Code can also call Codex for review, adversarial review, and second-pass handoffs through the repo-local bridge plugin.
Request a team pilot Send workflow firstFree: 2 captures/day, 3 active prevention rules, hook blocking. Pro: recall, lesson search, unlimited captures and rules, DPO export. The local dashboard is free. Enterprise service work is qualified and signed after intake; hosted team sync and a hosted org dashboard are not generally available.