feat: add context-efficient backpressure hooks#16
Merged
Conversation
Keep Claude in the "smart zone" by deterministically controlling tool output. Three-layer system: run_silent.sh wrapper suppresses verbose success output (with test count extraction for vitest/pytest), command-interceptor PreToolUse hook wraps test/lint/build commands and injects fail-fast flags, auto-lint PostToolUse hook runs biome/ruff after every Write/Edit with self-healing error loop. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
scripts/run_silent.sh— wraps test/lint/build commands; prints✓ cmd (12 tests, 3s)on success, filtered output on failure.VERBOSE=1bypasses..claude/hooks/command-interceptor.sh(PreToolUse) — intercepts Bash commands matching test/lint/build patterns, rewrites them through run_silent, injects fail-fast flags (--bail 1for vitest,-xfor pytest), auto-approves. Rejects shell metacharacters ($(, backticks, pipes, redirects)..claude/hooks/auto-lint.sh(PostToolUse on Write|Edit) — auto-runs biome (TS) or ruff (Python) after file edits. Blocks Claude on lint errors, creating a self-healing fix loop.Test plan
run_silent.shpasses withecho hello→✓ echo hello (0s)run_silent.shfails withfalse→✗ false (exit 1, 0s)run_silent.shwraps realpnpm typecheck→ single line outputpnpm test→ JSON with run_silent pathgit status→ empty output (passthrough)pnpm test && pnpm lint→ passthroughpnpm test | head→ passthrough$(...)substitution → passthrough--bail 1forvitest run-xforpytest🤖 Generated with Claude Code