feat(hooks-plugin): add bash-antipatterns-teach PostToolUse hook (opt-in)#1308
Conversation
…-in) Teach soft-pattern alternatives (cat, find -name, grep, head/tail, ls *.glob) via output augmentation rather than PreToolUse blocking. W20 friction analysis showed 21% same-session repeat-block rate on grep/rg - letting the command run and prepending the corrective hint to the result should land the lesson concretely. Phase 1: opt-in only. Enable with CLAUDE_HOOKS_ENABLE_BASH_ANTIPATTERNS_TEACH=1. Existing bash-antipatterns.sh blocking is unchanged. W21 friction pass evaluates whether to promote to default in phase 2. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Plugin Compliance Review
Recommendations
|
|
Let's address the recommendations in the comments. Evaluate which pieces of criticism and recommendations are substantive and valid. Act accordingly and refute invalid points. |
|
Claude finished @laurigates's task in 7m 28s —— View job Evaluating CI RecommendationsAssessment All three size warnings are valid — every flagged skill was in the 251–500 WARN zone per
All three are now at or below the 200-line ideal. The extracted templates and specs live in Tasks:
|
…three skills hooks-permission-request-hook: 442 → 193 lines (script template + test spec extracted) hooks-session-start-hook: 291 → 179 lines (script template extracted) hooks-configuration: 312 → 240 lines (prompt/agent hooks + debugging sections extracted) All three were in the 251-500 WARN zone per skill-quality.md. Now all are below 200 (permission-request) or near it (session-start, configuration). Co-authored-by: Lauri Gates <[email protected]>
🤖 I have created a release *beep* *boop* --- <details><summary>hooks-plugin: 2.2.0</summary> ## [2.2.0](hooks-plugin-v2.1.1...hooks-plugin-v2.2.0) (2026-05-12) ### Features * **hooks-plugin:** add bash-antipatterns-teach PostToolUse hook (opt-in) ([#1308](#1308)) ([edf32fd](edf32fd)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --------- Co-authored-by: laurigates-release-please[bot] <272124289+laurigates-release-please[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Summary
bash-antipatterns-teach.sh: a PostToolUse Bash hook that augments tool output viahookSpecificOutput.updatedToolOutput(Claude Code 2.1.121+) with concrete tool-replacement hints for soft-teach antipatterns (cat/head/tail,find -name,grep/rg,ls *.glob)hooks-plugin/.claude-plugin/plugin.jsonas aPostToolUseBashmatcher withtimeout: 5000CLAUDE_HOOKS_ENABLE_BASH_ANTIPATTERNS_TEACH=1(default disabled; matchesevent-logger.shopt-in convention)bash-antipatterns.shis unchangedMotivation
W20 friction analysis (
~/.claude/rules/friction/2026-W20-frictions.md) measured a 21% same-session repeat-block rate ongrep/rgPreToolUse blocks — about 2× the rate forgit &&(8%) orfind -name(12%). The hook teaches less effectively because the agent only sees the corrective message, never the would-have-been-result. Letting the command run and prepending the hint to the tool result gives the agent both the data and the lesson in one response.Hypothesis: same-session repeat-block rate on
grep/rg/find -name/cat/head/tail/ls *.globdrops from ~21% to the established ~10% floor. W21 friction pass (2026-05-18) measures.Test plan
bash -nsyntax-check on both scriptsjq emptyvalidatesplugin.jsontest-bash-antipatterns-teach.sh: 17 passed, 0 failed (covers all match patterns, exemptions, and the env-var guard)test-bash-antipatterns.sh: 25 passed, 0 failed (no regression)event-logger.sh-style opt-in conventionFollow-ups (not in this PR)
bash-antipatterns.shhooks-plugin/hooks/test-*.shfrom CISee
hooks-plugin/docs/teach-mode-experiment.mdfor full hypothesis, rollout plan, and success criterion.🤖 Generated with Claude Code