You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(commands): wire before/after hook events into specify and plan templates (#1886)
* feat(commands): wire before/after hook events into specify and plan templates
Replicates the hook evaluation pattern from tasks.md and implement.md
(introduced in PR #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#1788
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Mark before_commit/after_commit as planned in extension docs
These hook events are defined in the API reference but not yet wired
into any core command template. Marking them as planned rather than
removing them, since the infrastructure supports them.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Fix hook enablement to default true when field is absent
Matches HookExecutor.get_hooks_for_event() semantics where
hooks without an explicit enabled field are treated as enabled.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(docs): mark commit hooks as planned in user guide config example
The yaml config comment listed before_commit/after_commit as
"Available events" but they are not yet wired into core templates.
Moved them to a separate "Planned" line, consistent with the
API reference.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(commands): align enabled-filtering semantics across all hook templates
tasks.md and implement.md previously said "Filter to only hooks where
enabled: true", which would skip hooks that omit the enabled field.
Updated to match specify.md/plan.md and HookExecutor's h.get('enabled', True)
behavior: filter out only hooks where enabled is explicitly false.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: templates/commands/plan.md
+63Lines changed: 63 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,40 @@ $ARGUMENTS
24
24
25
25
You **MUST** consider the user input before proceeding (if not empty).
26
26
27
+
## Pre-Execution Checks
28
+
29
+
**Check for extension hooks (before planning)**:
30
+
- Check if `.specify/extensions.yml` exists in the project root.
31
+
- If it exists, read it and look for entries under the `hooks.before_plan` key
32
+
- If the YAML cannot be parsed or is invalid, skip hook checking silently and continue normally
33
+
- Filter out hooks where `enabled` is explicitly `false`. Treat hooks without an `enabled` field as enabled by default.
34
+
- For each remaining hook, do **not** attempt to interpret or evaluate hook `condition` expressions:
35
+
- If the hook has no `condition` field, or it is null/empty, treat the hook as executable
36
+
- If the hook defines a non-empty `condition`, skip the hook and leave condition evaluation to the HookExecutor implementation
37
+
- For each executable hook, output the following based on its `optional` flag:
38
+
-**Optional hook** (`optional: true`):
39
+
```
40
+
## Extension Hooks
41
+
42
+
**Optional Pre-Hook**: {extension}
43
+
Command: `/{command}`
44
+
Description: {description}
45
+
46
+
Prompt: {prompt}
47
+
To execute: `/{command}`
48
+
```
49
+
- **Mandatory hook** (`optional: false`):
50
+
```
51
+
## Extension Hooks
52
+
53
+
**Automatic Pre-Hook**: {extension}
54
+
Executing: `/{command}`
55
+
EXECUTE_COMMAND: {command}
56
+
57
+
Wait for the result of the hook command before proceeding to the Outline.
58
+
```
59
+
- If no hooks are registered or `.specify/extensions.yml` does not exist, skip silently
60
+
27
61
## Outline
28
62
29
63
1. **Setup**: Run `{SCRIPT}` from repo root and parse JSON for FEATURE_SPEC, IMPL_PLAN, SPECS_DIR, BRANCH. For single quotes in args like "I'm Groot", use escape syntax: e.g 'I'\''m Groot' (or double-quote if possible: "I'm Groot").
@@ -41,6 +75,35 @@ You **MUST** consider the user input before proceeding (if not empty).
41
75
42
76
4. **Stop and report**: Command ends after Phase 2 planning. Report branch, IMPL_PLAN path, and generated artifacts.
43
77
78
+
5. **Check for extension hooks**: After reporting, check if `.specify/extensions.yml` exists in the project root.
79
+
- If it exists, read it and look for entries under the `hooks.after_plan` key
80
+
- If the YAML cannot be parsed or is invalid, skip hook checking silently and continue normally
81
+
- Filter out hooks where `enabled` is explicitly `false`. Treat hooks without an `enabled` field as enabled by default.
82
+
- For each remaining hook, do **not** attempt to interpret or evaluate hook `condition` expressions:
83
+
- If the hook has no `condition` field, or it is null/empty, treat the hook as executable
84
+
- If the hook defines a non-empty `condition`, skip the hook and leave condition evaluation to the HookExecutor implementation
85
+
- For each executable hook, output the following based on its `optional` flag:
86
+
- **Optional hook** (`optional: true`):
87
+
```
88
+
## Extension Hooks
89
+
90
+
**Optional Hook**: {extension}
91
+
Command: `/{command}`
92
+
Description: {description}
93
+
94
+
Prompt: {prompt}
95
+
To execute: `/{command}`
96
+
```
97
+
- **Mandatory hook** (`optional: false`):
98
+
```
99
+
## Extension Hooks
100
+
101
+
**Automatic Hook**: {extension}
102
+
Executing: `/{command}`
103
+
EXECUTE_COMMAND: {command}
104
+
```
105
+
- If no hooks are registered or `.specify/extensions.yml` does not exist, skip silently
Copy file name to clipboardExpand all lines: templates/commands/specify.md
+63Lines changed: 63 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,40 @@ $ARGUMENTS
21
21
22
22
You **MUST** consider the user input before proceeding (if not empty).
23
23
24
+
## Pre-Execution Checks
25
+
26
+
**Check for extension hooks (before specification)**:
27
+
- Check if `.specify/extensions.yml` exists in the project root.
28
+
- If it exists, read it and look for entries under the `hooks.before_specify` key
29
+
- If the YAML cannot be parsed or is invalid, skip hook checking silently and continue normally
30
+
- Filter out hooks where `enabled` is explicitly `false`. Treat hooks without an `enabled` field as enabled by default.
31
+
- For each remaining hook, do **not** attempt to interpret or evaluate hook `condition` expressions:
32
+
- If the hook has no `condition` field, or it is null/empty, treat the hook as executable
33
+
- If the hook defines a non-empty `condition`, skip the hook and leave condition evaluation to the HookExecutor implementation
34
+
- For each executable hook, output the following based on its `optional` flag:
35
+
-**Optional hook** (`optional: true`):
36
+
```
37
+
## Extension Hooks
38
+
39
+
**Optional Pre-Hook**: {extension}
40
+
Command: `/{command}`
41
+
Description: {description}
42
+
43
+
Prompt: {prompt}
44
+
To execute: `/{command}`
45
+
```
46
+
- **Mandatory hook** (`optional: false`):
47
+
```
48
+
## Extension Hooks
49
+
50
+
**Automatic Pre-Hook**: {extension}
51
+
Executing: `/{command}`
52
+
EXECUTE_COMMAND: {command}
53
+
54
+
Wait for the result of the hook command before proceeding to the Outline.
55
+
```
56
+
- If no hooks are registered or `.specify/extensions.yml` does not exist, skip silently
57
+
24
58
## Outline
25
59
26
60
The text the user typed after `/speckit.specify` in the triggering message **is** the feature description. Assume you always have it available in this conversation even if `{ARGS}` appears literally below. Do not ask the user to repeat it unless they provided an empty command.
@@ -176,6 +210,35 @@ Given that feature description, do this:
176
210
177
211
7. Report completion with branch name, spec file path, checklist results, and readiness for the next phase (`/speckit.clarify` or `/speckit.plan`).
178
212
213
+
8. **Check for extension hooks**: After reporting completion, check if `.specify/extensions.yml` exists in the project root.
214
+
- If it exists, read it and look for entries under the `hooks.after_specify` key
215
+
- If the YAML cannot be parsed or is invalid, skip hook checking silently and continue normally
216
+
- Filter out hooks where `enabled` is explicitly `false`. Treat hooks without an `enabled` field as enabled by default.
217
+
- For each remaining hook, do **not** attempt to interpret or evaluate hook `condition` expressions:
218
+
- If the hook has no `condition` field, or it is null/empty, treat the hook as executable
219
+
- If the hook defines a non-empty `condition`, skip the hook and leave condition evaluation to the HookExecutor implementation
220
+
- For each executable hook, output the following based on its `optional` flag:
221
+
- **Optional hook** (`optional: true`):
222
+
```
223
+
## Extension Hooks
224
+
225
+
**Optional Hook**: {extension}
226
+
Command: `/{command}`
227
+
Description: {description}
228
+
229
+
Prompt: {prompt}
230
+
To execute: `/{command}`
231
+
```
232
+
- **Mandatory hook** (`optional: false`):
233
+
```
234
+
## Extension Hooks
235
+
236
+
**Automatic Hook**: {extension}
237
+
Executing: `/{command}`
238
+
EXECUTE_COMMAND: {command}
239
+
```
240
+
- If no hooks are registered or `.specify/extensions.yml` does not exist, skip silently
241
+
179
242
**NOTE:** The script creates and checks out the new branch and initializes the spec file before writing.
0 commit comments