> ## Content Index
> Fetch the complete content index at: https://www.stirup.si/llms.txt
> Use this file to discover other available public pages before exploring further.

# Implementation of Code Guards Based on Past Mistakes
- URL: https://www.stirup.si/implementation-of-code-guards-based-on-past-mistakes-9aa08f9f/
- Published: 2026-10-30T14:43:46.000Z
- Updated: 2026-10-30T14:43:46.000Z
- Description: From June to October 2026, Claude Code was run daily on real work including apps, games, store listings, servers, and a shared git repo touched by several sessions at once.
- Author: Satish Das
- Tags: Community, News, Stirup Research

## Implementation of Code Guards Based on Past Mistakes

Implementation of Code Guards Based on Past Mistakes

From June to October 2026, Claude Code was run daily on real work including apps, games, store listings, servers, and a shared git repo touched by several sessions at once. This repo contains three Claude Code hooks and four pre-ship scripts, each with a test that proves it really blocks.

The guards are as follows:

- **File:** hooks/guard\_bash.py**Runs on:** PreToolUse · Bash**What it blocks:** pkill -f and pgrep -f wait loops that match their own shell**The mistake it came from:** pkill -f server.js killed Claude's own Bash shell (exit 144); a while pgrep -f wait never ended.
- **File:** hooks/guard\_short\_save.py**Runs on:** PreToolUse · your MCP save tool**What it blocks:** A save under 300 characters to a tool that overwrites the whole record**The mistake it came from:** To learn a version value, the agent sent a placeholder body to the save tool, twice in one day. Only a wrong guess stopped the record from being replaced by one line.
- **File:** hooks/stop\_check.py**Runs on:** Stop**What it blocks:** A reply that judges account eligibility from web search, or reads traffic as demand, without the fact that must come with it**The mistake it came from:** Web search beat our own measured record three times ("you need a business registration": our own payout profile said otherwise).

## Examples of Specific Guards and Their Functions

Examples of Specific Guards and Their Functions include tools like `add_unique.py`, which prevents duplicate records by checking for similar titles, though it only warns rather than blocks in some cases. Despite a written rule and on-screen warnings, five identical records were added in four days. Another example is `baseline_check.py`, which ensures sprites are placed on walkable ground during scene renders. It caught issues like floating sprites, bridges in ponds, and reeds hanging off banks. These guards are drawn from real-world use cases, including a marketplace listing, a fact table, and a sprite on a map. However, it is important to note that each guard only checks what reaches it, and some, like `guard_bash.py`, may miss hidden paths in variables or within ssh commands. Installation instructions are provided for users looking to implement these guards in their projects.

## Guard Behavior and Limitations

The guard behavior in Claude Code is derived from specific mistakes that occurred during its operation, with each rule directly tied to a real-world error. These rules are documented in a Korean e-book containing over 300 entries, each detailing the incident, its cause, the corrective action taken, and a concise rule to be added to the `CLAUDE.md` file. The records were authored by Claude Code itself as it learned from its errors. The English version of this documentation, along with the fact-checking process, was also handled by AI, using raw session logs, git history, and official documentation for verification. Public tools such as Claude Code, git, Playwright, and ffmpeg retain their names in the project. The code is provided as-is, with users advised to test it in their own environments before relying on it for critical tasks.

## Performance and Resource Usage of Background Agent Summaries

Every \~30 seconds, Claude Code re-sends each background agent's full transcript to the model to update the agent's status line in the agents panel. This process, while seemingly minor, consumes a significant portion of computational resources. According to data from the source, this activity accounts for approximately 16.4% of all Claude Code spend, with 19.7% of all API requests attributed to this task. Notably, 96% of this spend involves the Opus model, and the input-to-output token ratio is roughly 9,000:1\. The `no-agent-summary.js` script, a Bun --preload tool, can be used to stop this timer without modifying the Claude Code binary, reducing unnecessary computational overhead. This approach offers a workaround for users seeking to optimize performance and resource usage.

## Installation and Compatibility of the No-Agent-Summary Fix

The No-Agent-Summary Fix is specifically designed for use within the Claude Code environment, ensuring compatibility with the required installation structures. According to [gist.github.com](https://gist.github.com/flamerix-ai/c3905705cc4205e5de3011fa2e74efce?ref=stirup.si), the hook installs only inside Claude Code, requiring that `Bun.main` be set to `/$bunfs/root/cli` and `process.execPath` must point to a valid Claude Code installation. [gist.github.com](https://gist.github.com/flamerix-ai/c3905705cc4205e5de3011fa2e74efce?ref=stirup.si) outlines several supported installation channels, including Linux, where the `process.execPath` varies depending on the method used, such as `nix`, `npm`, or a `native installer`. For macOS and Windows, the hook installs only if the same structures are produced, as noted in [gist.github.com](https://gist.github.com/flamerix-ai/c3905705cc4205e5de3011fa2e74efce?ref=stirup.si). A known pass-through scenario is described in [gist.github.com](https://gist.github.com/flamerix-ai/c3905705cc4205e5de3011fa2e74efce?ref=stirup.si), where a foreign binary built with `bun build --compile --outfile cli` and renamed `claude` may allow the hook to function under specific conditions.

## Sources and reporting notes

- [Hacker News Show](https://github.com/hadiux0295/claude-code-mistake-guards?ref=stirup.si)
- [gist.github.com](https://gist.github.com/flamerix-ai/c3905705cc4205e5de3011fa2e74efce?ref=stirup.si)

Based on published source material. No independent hands-on testing is claimed.