Urgent.News

What's breaking now, across thousands of outlets.

Tech

5 Verbal Corrections Didn't Stick, So a 46-Line Stop Hook Made the Mistake Physically Impossible

I corrected the same Claude Code mistake more than five times. It never stuck. Then I replaced the correction with a 46-line shell script, and the mistake has not come back once. Some background: I started freelancing in college at around ¥100,000 a month, stacked side gigs until I reached ¥600,000, got laid off and dropped to zero, and spent the next six months building an autonomous Claude Code…

Five attempts to correct Claude Code's mistake did not succeed. Then, a 46-line shell script was introduced, preventing the issue from recurring. Initially, I had corrected Claude Code's repeated misuse of the && operator in ! handoff commands. Despite pointing out the error multiple times, the mistake continued to appear. This issue stemmed from the nature of Claude Code sessions.

Each session is independent, and corrections are context-specific. They do not carry over to subsequent sessions. Moreover, the chaining of blocking commands using && caused the entire session to freeze, making debugging a time-consuming process. The Stop hook feature in Claude Code enabled the execution of a shell script before the response was returned to the user.

By crafting a 46-line script, the mistake could be rendered physically impossible. This script intercepted the transcript JSON, parsed it, and blocked the response if the last assistant message contained an ! command with &&. This architectural solution ensures that the mistake cannot occur again, regardless of how Claude Code labels the output.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Max Scherzer Net Worth

Max Scherzer has an estimated net worth of $180 million. The American professional baseball pitcher built his fortune through nearly two decades in Major League Baseball, earning more than $370…

More from Thursday 10 September →