Skip to content

feat(commands): wire before/after hook events into specify and plan templates#1886

Open
mvanhorn wants to merge 1 commit intogithub:mainfrom
mvanhorn:osc/1788-wire-specify-plan-hook-events
Open

feat(commands): wire before/after hook events into specify and plan templates#1886
mvanhorn wants to merge 1 commit intogithub:mainfrom
mvanhorn:osc/1788-wire-specify-plan-hook-events

Conversation

@mvanhorn
Copy link

Summary

Completes the hook lifecycle across all SDD phases by adding before_specify/after_specify and before_plan/after_plan hook evaluation to the specify and plan command templates. This follows the pattern established in PR #1702 for tasks and implement templates.

Why this matters

Extensions can register hooks for after_tasks and after_implement (since PR #1702), but cannot hook into the specify or plan phases (#1788). This gap means extensions that need to run automation after specification or planning (e.g., creating tracking tickets, running validation, triggering notifications) have no supported hook point.

Per @dhilipkumars's feedback on #1788: both before_ and after_ hooks are included, and extension documentation is updated.

Changes

  • templates/commands/specify.md: Added before_specify (Pre-Execution Checks) and after_specify (step 8) hook evaluation blocks
  • templates/commands/plan.md: Added before_plan (Pre-Execution Checks) and after_plan (step 5) hook evaluation blocks
  • extensions/EXTENSION-API-REFERENCE.md: Added all new events to the documented hook events list and updated example references
  • extensions/EXTENSION-USER-GUIDE.md: Listed all available hook events in the configuration example

The hook blocks replicate the exact format from tasks.md and implement.md - same optional/mandatory handling, same condition-skipping logic, same output format.

Testing

  • All 382 existing tests pass (uv run pytest)
  • ruff check src/ passes
  • Hook blocks match the format in tasks.md lines 26-57 and 100-127

AI Disclosure

This PR was authored with AI assistance (Claude Code). The hook blocks were replicated from the existing tasks.md/implement.md pattern and verified for consistency.

Fixes #1788

…emplates

Replicates the hook evaluation pattern from tasks.md and implement.md
(introduced in PR github#1702) into the specify and plan command templates.
This completes the hook lifecycle across all SDD phases.

Changes:
- specify.md: Add before_specify/after_specify hook blocks
- plan.md: Add before_plan/after_plan hook blocks
- EXTENSION-API-REFERENCE.md: Document new hook events
- EXTENSION-USER-GUIDE.md: List all available hook events

Fixes github#1788

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR completes the hook lifecycle across the SDD workflow by adding before_*/after_* hook evaluation instructions to the specify and plan command templates, and updating extension documentation to include the newly-supported events.

Changes:

  • Add before_specify / after_specify hook evaluation blocks to templates/commands/specify.md.
  • Add before_plan / after_plan hook evaluation blocks to templates/commands/plan.md.
  • Update extension docs to list the expanded set of hook events.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
templates/commands/specify.md Adds pre/post hook-check instructions for the specification phase.
templates/commands/plan.md Adds pre/post hook-check instructions for the planning phase.
extensions/EXTENSION-API-REFERENCE.md Documents the new hook events in the API reference and examples.
extensions/EXTENSION-USER-GUIDE.md Updates the configuration example comments to list available hook events.
Comments suppressed due to low confidence (2)

templates/commands/specify.md:220

  • This block currently instructs skipping hooks with non-empty condition. The repository’s HookExecutor.check_hooks_for_event() is explicitly designed to return hooks “with condition evaluation applied”, so skipping conditional hooks here means after_specify hooks can never be conditionally enabled. Recommend aligning the template logic with HookExecutor: default enabled to true when missing and evaluate (or otherwise handle) condition instead of unconditionally skipping.
   - Filter to only hooks where `enabled: true`
   - For each remaining hook, do **not** attempt to interpret or evaluate hook `condition` expressions:
     - If the hook has no `condition` field, or it is null/empty, treat the hook as executable
     - If the hook defines a non-empty `condition`, skip the hook and leave condition evaluation to the HookExecutor implementation
   - For each executable hook, output the following based on its `optional` flag:

templates/commands/plan.md:85

  • This after_plan hook-check block instructs skipping hooks whenever condition is non-empty. Since HookExecutor.check_hooks_for_event() supports condition evaluation, this prevents using condition for after_plan hooks in practice. Recommend updating the template to evaluate supported condition expressions (or otherwise not exclude hooks purely because a condition is present), and to treat missing enabled as enabled by default.
   - Filter to only hooks where `enabled: true`
   - For each remaining hook, do **not** attempt to interpret or evaluate hook `condition` expressions:
     - If the hook has no `condition` field, or it is null/empty, treat the hook as executable
     - If the hook defines a non-empty `condition`, skip the hook and leave condition evaluation to the HookExecutor implementation
   - For each executable hook, output the following based on its `optional` flag:

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +30 to +33
- Filter to only hooks where `enabled: true`
- For each remaining hook, do **not** attempt to interpret or evaluate hook `condition` expressions:
- If the hook has no `condition` field, or it is null/empty, treat the hook as executable
- If the hook defines a non-empty `condition`, skip the hook and leave condition evaluation to the HookExecutor implementation
Comment on lines +33 to +36
- Filter to only hooks where `enabled: true`
- For each remaining hook, do **not** attempt to interpret or evaluate hook `condition` expressions:
- If the hook has no `condition` field, or it is null/empty, treat the hook as executable
- If the hook defines a non-empty `condition`, skip the hook and leave condition evaluation to the HookExecutor implementation
Comment on lines 562 to 563
- `before_commit` - Before git commit
- `after_commit` - After git commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Wire 'after_specify' and 'after_plan' hook events into command templates (following PR #1702)

2 participants