Block your coding agent from editing tests while it fixes a bug
Asked to fix a failing test, Claude Code changed toBe(42) to toBe(41): green build, bug intact. He added a PreToolUse hook that blocks edits to *.test.ts files during bug fixes, because the test is the spec.
Source
@rthiago on X · 2026-10-19
Written in our own words. Credit to the original author. Link checked 2026-10-19.
What they did
Asked to fix a failing test, Claude Code changed toBe(42) to toBe(41): green build, bug intact. He added a PreToolUse hook that blocks edits to *.test.ts files during bug fixes, because the test is the spec.
Result (as claimed)
The agent can no longer "fix" bugs by changing the test.
Tools they used
Cost: Claude Code: from $17/mo.
Set it up
Pick a contained repo or task
Start on a branch or side project where mistakes are cheap.
Install and configure
Set up Claude Code. Read what it can run on your machine and limit permissions where possible.
Run it on a real task
Give it a well-scoped issue and let it work. Review the diff like any pull request.
Add guardrails
Keep tests and CI in the loop, and never let an agent push to main or touch production secrets unattended.
Copy the full setup prompt
Paste into your agent and it will walk you through the setup, asking before anything that sends, posts or spends.
You are helping me set up this AI use case end to end in Claude Code. Goal: Block your coding agent from editing tests while it fixes a bug What the original author did: Asked to fix a failing test, Claude Code changed toBe(42) to toBe(41): green build, bug intact. He added a PreToolUse hook that blocks edits to *.test.ts files during bug fixes, because the test is the spec. Reported result (as claimed by the author): The agent can no longer "fix" bugs by changing the test. Source: https://x.com/rthiago/status/2112160015683666414 Tools they used: Claude Code Category: Dev & ops Please: 1. Ask me 3 short questions about my situation (accounts I have, budget, what I want the output to look like). 2. Propose a step-by-step plan using these tools or cheaper alternatives, with the time and cost of each step. Use official pricing pages; say "check pricing" if unsure. 3. Then do the setup with me one step at a time, waiting for my OK before anything that sends messages, posts publicly, spends money or deletes data. 4. Finish with a checklist to run it again next time.
You are helping me set up this AI use case end to end in Codex. Goal: Block your coding agent from editing tests while it fixes a bug What the original author did: Asked to fix a failing test, Claude Code changed toBe(42) to toBe(41): green build, bug intact. He added a PreToolUse hook that blocks edits to *.test.ts files during bug fixes, because the test is the spec. Reported result (as claimed by the author): The agent can no longer "fix" bugs by changing the test. Source: https://x.com/rthiago/status/2112160015683666414 Tools they used: Claude Code Category: Dev & ops Please: 1. Ask me 3 short questions about my situation (accounts I have, budget, what I want the output to look like). 2. Propose a step-by-step plan using these tools or cheaper alternatives, with the time and cost of each step. Use official pricing pages; say "check pricing" if unsure. 3. Then do the setup with me one step at a time, waiting for my OK before anything that sends messages, posts publicly, spends money or deletes data. 4. Finish with a checklist to run it again next time.
You are helping me set up this AI use case end to end in Grok Bot. Goal: Block your coding agent from editing tests while it fixes a bug What the original author did: Asked to fix a failing test, Claude Code changed toBe(42) to toBe(41): green build, bug intact. He added a PreToolUse hook that blocks edits to *.test.ts files during bug fixes, because the test is the spec. Reported result (as claimed by the author): The agent can no longer "fix" bugs by changing the test. Source: https://x.com/rthiago/status/2112160015683666414 Tools they used: Claude Code Category: Dev & ops Please: 1. Ask me 3 short questions about my situation (accounts I have, budget, what I want the output to look like). 2. Propose a step-by-step plan using these tools or cheaper alternatives, with the time and cost of each step. Use official pricing pages; say "check pricing" if unsure. 3. Then do the setup with me one step at a time, waiting for my OK before anything that sends messages, posts publicly, spends money or deletes data. 4. Finish with a checklist to run it again next time.
The Daily 5
Get five new use cases tomorrow morning
Free. Real sources. Unsubscribe any time.
Guides for this use case
Related use cases
Hand a coding agent a spec and come back to tested, committed work
Tired of an agent asking him to approve every section of a design and reviewing one task at a time, a developer made Superlite, a lighter alternative to the Superpowers workflow. You hand over a spec once and several agents build the independent pieces in parallel, test them and commit, without stopping every few minutes for a yes.
Let your next coding agent search what the last one already tried
Switching from Claude Code to Codex or Cursor meant explaining the same work again, so a developer built Agent Recall: a local, redacted index of past agent transcripts that the next agent can search.
Let your coding agent sessions message each other without you relaying
A developer open-sourced agentsocks so his coding agents can talk to each other. A Claude Code or Codex session can message another session, ask it a question or hand it a tracked task, and the answer comes back into the session that asked.
Get one inbox for every coding agent that needs you
Agentrix is one inbox for AI coding tasks that need your attention, like Claude Code waiting for approval or Codex finishing, so you keep your CLIs and stop hopping between tabs.