Skip to content

docs: ADR-001 — Claude Code conditional hooks (if field)#52

Merged
SZoloth merged 1 commit into
mainfrom
feat/sam-218-conditional-hooks
Apr 6, 2026
Merged

docs: ADR-001 — Claude Code conditional hooks (if field)#52
SZoloth merged 1 commit into
mainfrom
feat/sam-218-conditional-hooks

Conversation

@SZoloth
Copy link
Copy Markdown
Owner

@SZoloth SZoloth commented Mar 30, 2026

Summary

  • Applies the new Claude Code if field (v2.1.85+) to 4 Bash hook handlers in ~/.claude/settings.json, so hook processes only spawn when their command pattern matches
  • Removes now-redundant early-exit guards from conventional_commits.py, tsc_precommit.py, and pnpm_enforcer.py
  • Documents findings and exclusions in DECISIONS.md as ADR-001

Changes

~/.claude/settings.json (global config):

  • conventional_commits.pyif: "Bash(git commit *)"
  • tsc_precommit.pyif: "Bash(git commit *)"
  • git_safety.pyif: "Bash(git *)"
  • pnpm_enforcer.py → two handlers: if: "Bash(npm *)" + if: "Bash(yarn *)"

Hook scripts simplified: removed internal early-exit guards from conventional_commits.py, tsc_precommit.py, pnpm_enforcer.py

Excluded from if field: writing_guard.py (auto-generated by Margin CLI), voice_loader.py (Write|Edit matcher restructuring required), trauma_guard.py (dynamic JSONL patterns)

Test plan

  • python3 -m json.tool ~/.claude/settings.json — valid JSON
  • conventional_commits.py: exits silently on non-commit input; blocks bad commit message; passes conventional format
  • git_safety.py: exits silently on non-git Bash; blocks destructive git commands
  • pnpm_enforcer.py: blocks npm/yarn in pnpm project; exits silently on other commands
  • All three modified scripts pass python3 -m py_compile

🤖 Generated with Claude Code

Applied `if` field filtering to ~/.claude/settings.json for 4 Bash
hooks (conventional_commits, tsc_precommit, git_safety, pnpm_enforcer).
Hook processes now only spawn when their specific command pattern matches.
Removed redundant early-exit guards from the three scripts that did
internal command matching. Documents the writing hook exclusion rationale
(auto-generated script + Write|Edit matcher restructuring complexity).

Closes SAM-218

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@SZoloth SZoloth added the concerto Concerto agent-managed label Mar 30, 2026
@SZoloth SZoloth merged commit de73e83 into main Apr 6, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

concerto Concerto agent-managed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant