DEV Community

Argoness Vane
Argoness Vane

Posted on Edited on

Cutting Claude Code & Cursor Read-Context Burn by 40-70% with a <5ms Python PreToolUse Guard

Two silent failure modes hit heavy Claude Code and Cursor workflows on production repositories:

  1. Unbounded 800-line file reads busting prompt-cache budgets when the agent only needed a 35-line function.
  2. Untrusted third-party repositories smuggling instructions inside .claude/, CLAUDE.md, AGENTS.md, .cursorrules, active .git/hooks/*, or invisible Unicode Tag blocks (U+E0000–U+E007F).

To solve both without adding an LLM judge or confirmation popups on normal test runs, we built Iron Veil—a deterministic <5 ms pure Python 3.10+ stdlib guard.

1. AST Symbol Windowing Instead of Blind Full-File Dumps

When an agent issues an unwindowed read on a source file over 350 lines, returning a compact Python AST symbol map (Lstart-Lend) + 50-line header preview lets the model jump straight to the exact target symbol on the next call—cutting read-context bloat by 40–70% with zero accuracy loss.

2. Quarantining Priority-1 Repo Traps Before Opening Unfamiliar Code

Before opening an unfamiliar repository in a coding agent:

# Install via Claude Code Plugin Marketplace:
/plugin marketplace add argoness-prime/iron-veil

# Or run the 11-vector open-core sanitizer & repo quarantiner via pip:
pip install git+https://github.com/argoness-prime/iron-veil.git
iron-veil-core selftest
Enter fullscreen mode Exit fullscreen mode

Top comments (0)