Dev.to
7/22/2026

Automated Weekly Self-Audit for Claude Code Environments: Measuring and Fixing Configuration Decay
Original: Your Claude Code Setup Gets Bloated If You Ignore It — Weekly Auto-Slimming by Watching Injected Bytes, Agent Count, and Frustration Words
Short summary
This article presents a self-audit script for Claude Code environments that measures five decay metrics weekly: injected bytes, loaded agents, audit-hook spam, frustration words in transcripts, and tool errors. When any metric exceeds its threshold, the script invokes claude -p to automatically remediate the issue, then re-measures to confirm improvement. The author shares a real incident where hidden dot-directories caused 99 agents to load despite apparent cleanup.
- •cc-self-audit.sh tracks 5 metrics: inject_bytes, agents_loaded, stopspam, frustration, toolerr
- •When thresholds are breached, claude -p automatically fixes the environment and re-measures
- •Real incident: dot-directories caused 99 agents to load despite manual cleanup
Generated with AI, which can make mistakes.
Is this a good recommendation for you?



