Decisions

  • Pending: Which hook has the highest value to implement first?
  • Pending: Should protect-files block or just warn?
  • Pending: Should verify-tests be agent-based (can inspect code) or command-based (just runs test suite)?

User Tasks


FR-011: Hook Scripts

Summary

Implement hook scripts that automate checks and actions around Claude Code tool usage.

Problem / Motivation

Several repetitive safeguards and automations (file protection, format validation, session context) could be handled automatically via hooks instead of relying on manual discipline. CLAUDE.md defines rules like “show recent changes at session start” and “always test before presenting as done” — hooks can enforce these.

Proposed Solution

Implement hooks registered in .claude/settings.json that trigger on tool events.

Planned Hooks

PreToolUse:

  • protect-files — Block edits to sensitive files (.env, secrets, CLAUDE.md, settings.json)
  • validate-feature-format — Ensure feature request files follow the template

PostToolUse:

  • auto-format — Run formatter after file edits
  • sync-overview — Update feature-dashboard.md after feature file changes

SessionStart:

  • session-recap (matcher: startup|resume) — Auto-inject recent git commits + modified vault files into context
  • rehydrate-context (matcher: compact) — After context compaction, re-inject key project state

UserPromptSubmit:

  • inject-date — Inject the current date into context so Claude always knows today’s date

Stop:

  • auto-changelog — Append session summary to daily changelog
  • verify-tests (agent-based) — Check if tests pass before Claude presents code work as done

SessionEnd:

  • suggest-next-step — Auto-write a next-step note to vault/90_inbox/ before session ends

Open Questions

  • Which hook has the highest value to implement first?
  • Should protect-files block or just warn?
  • Should verify-tests be agent-based (can inspect code) or command-based (just runs test suite)?

Phase Overview

PhaseDescriptionStatus
Phase 1High-value quick wins (session-recap, inject-date, protect-files)
Phase 2Enforcement hooks (verify-tests, validate-feature-format)
Phase 3Automation hooks (sync-overview, auto-changelog, suggest-next-step)

Phase 1: Quick Wins —

Goal: Implement the highest-value hooks that improve daily workflow immediately.

File / FeatureDetailsOwnerStatus
session-recapInject recent git log + vault changes at session startopus
inject-dateInject current date via UserPromptSubmitopus
protect-filesBlock edits to protected pathsopus
rehydrate-contextRe-inject state after compactionopus

Phase 2: Enforcement —

Goal: Add hooks that enforce project rules automatically.

File / FeatureDetailsOwnerStatus
verify-testsAgent-based test check before presenting work as doneopus
validate-feature-formatCheck FR files against template on editopus

Phase 3: Automation —

Goal: Automate routine tasks that currently require manual effort.

File / FeatureDetailsOwnerStatus
sync-overviewAuto-update feature-dashboard after FR changesopus
auto-changelogWrite changelog entry at session endopus
suggest-next-stepWrite next-step note at session endopus
auto-formatRun formatter after file editsopus
decision-log-reminderAt session end, check if significant decisions were made but not logged in decision-log.md. Prompt user to log them.opus
design-doc-checkWhen FR moves to done, check if it contains complex architecture worth extracting to 00_system/designs/. Prompt user.opus

Acceptance Criteria:

  • At least one hook is working and registered
  • Hook README documents only existing (implemented) hooks
  • Session-recap automates the manual “show recent changes” convention

Notes:

  • Sound-alert is already handled by global user settings — not a project hook.
  • Moved from .claude/hooks/README.md which previously contained plans inline.
  • See Claude Code docs for all hook types: SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, Notification, Stop, SessionEnd, PreCompact, and more.

Prerequisites / Gap Analysis

Requirements

RequirementDescription
REQ-1.claude/settings.json must support hook registration
REQ-2Hook scripts must be executable bash/python

Current State

ComponentStatusDetails
.claude/settings.jsondoneExists with hook support
.claude/hooks/ directorydoneExists, README present
Implemented hooksNone implemented yet

Gap (What’s missing?)

GapEffortBlocker?
All hook scriptsMedNo

Test

Manual tests

TestExpectedOwnerActualLast
session-recap fires on startupRecent changes shownmvpending-
inject-date injects correct dateToday’s date in contextmvpending-
protect-files blocks protected editEdit rejected with messagemvpending-

AI-verified tests

ScenarioExpected behaviorVerification method

E2E tests

ScenarioAssertion

Integration tests

ComponentCoverage

Unit tests

ComponentTestsCoverage

History

DateEventDetails
2026-02-27CreatedExtracted from hooks README
2026-02-27ExpandedAdded SessionStart, SessionEnd, UserPromptSubmit, verify-tests hooks; reorganized phases
2026-02-27RenumberedFrom FR-024 to FR-011
2026-02-28ReformattedAligned to feature-request template

References

  • FR-003 (Protected Files System) — protect-files hook
  • FR-010 (Testing Infrastructure) — verify-tests hook
  • FR-027 (Feature Overview Sync Check) — sync-overview hook