feat(claude): add 6 lifecycle hooks reinforcing template hard rules
Project-level Claude Code hooks committed to .claude/settings.json with scripts under .claude/hooks/. Three tiers: Tier 1 — hard guards (exit 2 to block the tool call): - bash-guard.sh: blocks bypass flags (verify-skip, sign-skip), forceful push variants, destructive resets, force clean, working-tree-wipe checkouts/restores, force branch delete, amend, and rm -rf against root or home. Reinforces CLAUDE.md Git Safety Protocol. - generator-first-nudge.sh: blocks creating a new top-level packages/<name> or apps/<name> directory by hand. Allows working inside an existing package. Reinforces the non-negotiable generator-first rule. Tier 2 — context injection (stdout becomes additional context): - session-start.sh: prints glossary, AGENTS.md, workflow CLI, and conformance pointers on session boot. - prompt-context.sh: keyword-matches the user prompt against eight concept groups (events, realtime, audit, instrumentation, manifest, workflow, DI, boundaries) and injects the relevant ADR + rule pointers for the turn. Tier 3 — side-effect automation: - post-manifest-edit.sh: when Edit/Write touches feature.manifest.ts, prints the manifest-first ordering reminder plus the per-feature verify commands. - stop-check-manifest-tests.sh: at agent Stop time, if the working tree has manifest changes but no sibling test changes, exits 2 to force continuation. Loop-guarded via stop_hook_active. All hooks are bash + jq, use CLAUDE_PROJECT_DIR for safety, and were smoke-tested end-to-end (block + allow paths both verified). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
15
.claude/hooks/session-start.sh
Executable file
15
.claude/hooks/session-start.sh
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
# Tier 2 — surfaces a fresh session's "where to look first" pointers.
|
||||
# Output on stdout is injected as additional context.
|
||||
|
||||
cat <<'EOF'
|
||||
=== template-vertical session pointers ===
|
||||
Canonical vocabulary: docs/glossary.md (resolve "what does X mean here?" first)
|
||||
Architecture: AGENTS.md, docs/architecture/overview.md, docs/architecture/agent-first-workflow-and-conformance.md
|
||||
Workflow: pnpm work status | pnpm work next | pnpm work dispatch (ADR-019)
|
||||
Generator-first: pnpm turbo gen <kind> beats hand-rolled scaffolding (non-negotiable)
|
||||
Conformance: pnpm conformance + pnpm fallow (5-gate drift detection)
|
||||
Skills: to-prd, grill-with-docs, grill-me, handoff (.claude/skills/)
|
||||
EOF
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user