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
Copy file name to clipboardExpand all lines: templates/commands/implement.md
+34Lines changed: 34 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,40 @@ $ARGUMENTS
13
13
14
14
You **MUST** consider the user input before proceeding (if not empty).
15
15
16
+
## Pre-Execution Checks
17
+
18
+
**Check for extension hooks (before implementation)**:
19
+
- Check if `.specify/extensions.yml` exists in the project root.
20
+
- If it exists, read it and look for entries under the `hooks.before_implement` key
21
+
- If the YAML cannot be parsed or is invalid, skip hook checking silently and continue normally
22
+
- Filter to only hooks where `enabled: true`
23
+
- For each remaining hook, do **not** attempt to interpret or evaluate hook `condition` expressions:
24
+
- If the hook has no `condition` field, or it is null/empty, treat the hook as executable
25
+
- If the hook defines a non-empty `condition`, skip the hook and leave condition evaluation to the HookExecutor implementation
26
+
- For each executable hook, output the following based on its `optional` flag:
27
+
-**Optional hook** (`optional: true`):
28
+
```
29
+
## Extension Hooks
30
+
31
+
**Optional Pre-Hook**: {extension}
32
+
Command: `/{command}`
33
+
Description: {description}
34
+
35
+
Prompt: {prompt}
36
+
To execute: `/{command}`
37
+
```
38
+
- **Mandatory hook** (`optional: false`):
39
+
```
40
+
## Extension Hooks
41
+
42
+
**Automatic Pre-Hook**: {extension}
43
+
Executing: `/{command}`
44
+
EXECUTE_COMMAND: {command}
45
+
46
+
Wait for the result of the hook command before proceeding to the Outline.
47
+
```
48
+
- If no hooks are registered or `.specify/extensions.yml` does not exist, skip silently
49
+
16
50
## Outline
17
51
18
52
1. Run `{SCRIPT}` from repo root and parse FEATURE_DIR and AVAILABLE_DOCS list. All paths must be absolute. 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").
Copy file name to clipboardExpand all lines: templates/commands/tasks.md
+34Lines changed: 34 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,6 +22,40 @@ $ARGUMENTS
22
22
23
23
You **MUST** consider the user input before proceeding (if not empty).
24
24
25
+
## Pre-Execution Checks
26
+
27
+
**Check for extension hooks (before tasks generation)**:
28
+
- Check if `.specify/extensions.yml` exists in the project root.
29
+
- If it exists, read it and look for entries under the `hooks.before_tasks` key
30
+
- If the YAML cannot be parsed or is invalid, skip hook checking silently and continue normally
31
+
- Filter to only hooks where `enabled: true`
32
+
- For each remaining hook, do **not** attempt to interpret or evaluate hook `condition` expressions:
33
+
- If the hook has no `condition` field, or it is null/empty, treat the hook as executable
34
+
- If the hook defines a non-empty `condition`, skip the hook and leave condition evaluation to the HookExecutor implementation
35
+
- For each executable hook, output the following based on its `optional` flag:
36
+
-**Optional hook** (`optional: true`):
37
+
```
38
+
## Extension Hooks
39
+
40
+
**Optional Pre-Hook**: {extension}
41
+
Command: `/{command}`
42
+
Description: {description}
43
+
44
+
Prompt: {prompt}
45
+
To execute: `/{command}`
46
+
```
47
+
- **Mandatory hook** (`optional: false`):
48
+
```
49
+
## Extension Hooks
50
+
51
+
**Automatic Pre-Hook**: {extension}
52
+
Executing: `/{command}`
53
+
EXECUTE_COMMAND: {command}
54
+
55
+
Wait for the result of the hook command before proceeding to the Outline.
56
+
```
57
+
- If no hooks are registered or `.specify/extensions.yml` does not exist, skip silently
58
+
25
59
## Outline
26
60
27
61
1. **Setup**: Run `{SCRIPT}` from repo root and parse FEATURE_DIR and AVAILABLE_DOCS list. All paths must be absolute. 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").
This directory contains a mock project to verify that LLM agents correctly identify and execute hook commands defined in `.specify/extensions.yml`.
4
+
5
+
## Test 1: Testing `before_tasks` and `after_tasks`
6
+
7
+
1. Open a chat with an LLM (like GitHub Copilot) in this project.
8
+
2. Ask it to generate tasks for the current directory:
9
+
> "Please follow `/speckit.tasks` for the `./tests/hooks` directory."
10
+
3.**Expected Behavior**:
11
+
- Before doing any generation, the LLM should notice the `AUTOMATIC Pre-Hook` in `.specify/extensions.yml` under `before_tasks`.
12
+
- It should state it is executing `EXECUTE_COMMAND: pre_tasks_test`.
13
+
- It should then proceed to read the `.md` docs and produce a `tasks.md`.
14
+
- After generation, it should output the optional `after_tasks` hook (`post_tasks_test`) block, asking if you want to run it.
15
+
16
+
## Test 2: Testing `before_implement` and `after_implement`
17
+
18
+
*(Requires `tasks.md` from Test 1 to exist)*
19
+
20
+
1. In the same (or new) chat, ask the LLM to implement the tasks:
21
+
> "Please follow `/speckit.implement` for the `./tests/hooks` directory."
22
+
2.**Expected Behavior**:
23
+
- The LLM should first check for `before_implement` hooks.
24
+
- It should state it is executing `EXECUTE_COMMAND: pre_implement_test` BEFORE doing any actual task execution.
25
+
- It should evaluate the checklists and execute the code writing tasks.
26
+
- Upon completion, it should output the optional `after_implement` hook (`post_implement_test`) block.
27
+
28
+
## How it works
29
+
30
+
The templates for these commands in `templates/commands/tasks.md` and `templates/commands/implement.md` contains strict ordered lists. The new `before_*` hooks are explicitly formulated in a **Pre-Execution Checks** section prior to the outline to ensure they're evaluated first without breaking template step numbers.
0 commit comments