ThumbGateThumbGate Verification evidence
guide | stop ai coding agents from repeating mistakes

How to stop an AI coding agent from repeating a mistake

You corrected the agent, and the next session it ran the same command again. Memory and CLAUDE.md are notes the model reads; it can still run the command. A check in the PreToolUse hook runs before the command and can deny it. ThumbGate makes that check from your thumbs-down.

👍 Thumbs up saves what worked as a lesson
👎 Thumbs down catches repeated mistakes

In short

  • A correction in the chat or in memory is guidance. The model can read it and still run the command.
  • A check that runs before the tool call can stop the command. In Claude Code that is a PreToolUse hook.
  • ThumbGate turns a thumbs-down on a command into that check: the next time the agent tries the command it is Denied, with your reason (if that rule would also have blocked commands you allowed before, it warns instead).

Why the same mistake comes back

A new session starts with a fresh context. Your correction survives only if it is in CLAUDE.md or memory, and even then it is text the model weighs against everything else in the prompt. Long sessions and compaction make that weaker.

So the fix that holds is not more notes. It is a check outside the model that sees the command before it runs.

Three ways to stop it, from simplest

  • One or two commands you never want run: add a deny rule to your Claude Code permissions.
  • A short, stable list: write a PreToolUse hook that denies them.
  • A list that keeps growing from real sessions: give the command a thumbs-down and let ThumbGate write the rule.

What happens after a thumbs-down in ThumbGate

  • ThumbGate saves your reason and the command as a lesson in .thumbgate/ in your repo.
  • It makes a learned rule that matches that command.
  • The next time the agent tries it, the PreToolUse hook denies it and shows your reason. npx thumbgate rules lists the rule, and npx thumbgate unblock <gate-id> --reason "why you need it" lifts it for an hour.
  • If the rule would also have blocked commands you let through before, it stays a Warning instead, so one thumbs-down cannot lock you out of normal work.

What it does not catch

A learned rule matches the command, not its purpose. If the agent rewrites the same action another way, for example deleting a folder from Python after you gave rm -rf a thumbs-down, the rule does not catch it. Give the new form a thumbs-down too. ThumbGate is not a sandbox.

FAQ

Is memory alone enough to stop repeated mistakes?

Often it helps, but it cannot stop a command. Memory and CLAUDE.md are guidance the model reads. A PreToolUse check runs before the command and can deny it.

Which agents does this work in?

Claude Code is tested end to end, and so are shell commands in Cursor. Codex and Gemini CLI are wired but not yet tested end to end. In MCP-only clients such as Cline and OpenCode it is Advisory: the agent has to call the check.

What does a thumbs-up do?

It saves what worked as a lesson, so the record shows good runs too. It does not loosen or remove any check.