Wire a PostToolUse hook into kit/plugins/plan-agent so that whenever a .html file (excluding index.html ) is written to docs/plans/ , the plans gallery index regenerates automatically — keeping the library current without user intervention.
Read and implement all steps in the plan at docs/plans/add-hook-to-rebuild-plans-index.md — Add PostToolUse Hook to Auto-Rebuild the Plans Index. Verify against the plan's Tests, Verification, and Acceptance Criteria before reporting done. If everything passed, mark completion in docs/plans/add-hook-to-rebuild-plans-index.md — tick each step's [x] marker and each criterion's - [x], set status: completed — and re-render the HTML from the spec. If any check failed, leave status: in-progress and say which.
More ways to run this plan — goal & workflow prompts, file path
Achieve this goal: Add PostToolUse Hook to Auto-Rebuild the Plans Index. The plan at docs/plans/add-hook-to-rebuild-plans-index.md describes one approach — use it as reference, but optimize for the outcome. Verify against the plan's Tests, Verification, and Acceptance Criteria before reporting done. If everything passed, mark completion in docs/plans/add-hook-to-rebuild-plans-index.md — tick each step's [x] marker and each criterion's - [x], set status: completed — and re-render the HTML from the spec. If any check failed, leave status: in-progress and say which.
add-hook-to-rebuild-plans-index.html
docs/plans/add-hook-to-rebuild-plans-index.html
docs/plans/add-hook-to-rebuild-plans-index.md
Context
The story behind this plan — what prompted the work and why it matters now.
The plan-agent plugin's /plan-agent:planning skill writes HTML plan files to docs/plans/ . The gallery at docs/plans/index.html is only updated when a user explicitly runs /plan-agent:plans-library . This creates stale-index state: a newly written plan doesn't appear in the gallery until the user manually triggers a rebuild.
A PostToolUse hook that fires on every Write to docs/plans/*.html and calls bash docs/plans/build-index.sh eliminates the manual step. The hook is an observation hook (always exits 0) so index-rebuild failures never block plan writes.
Note on hook registration: The objective referenced plugin.json , but the existing validate-plan-filename hook for this plugin is registered in kit/plugins/plan-agent/hooks.json — a separate file that Claude Code reads alongside plugin.json . This plan follows the established pattern and adds to hooks.json .
Steps
The step-by-step work, in order — each step says what to do, why it matters, and how to check it worked.
Definition of done
The plan counts as done when every statement below is true — check each one off as you verify it.
Final check
One last pass to confirm the whole change works end to end.
Run the full sequence end-to-end:
bash docs/plans/build-index.sh from the project root — confirm index.html is rewritten with a fresh timestamp and valid gallery cards.
Pipe a matching plan path through rebuild-plans-index.py via stdin — confirm exit 0 and index.html updates.
Pipe docs/plans/index.html through rebuild-plans-index.py — confirm exit 0 with no build-index.sh invocation.
Write a test plan file in a live session — confirm the gallery refreshes automatically and the new card is visible in index.html .
Wrapping up
Three gates that must all pass before this plan is marked completed.
Completion Report
No items to report — all requirements met.