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
For each step, consider whether it would benefit from **quality validation loops**. Stop hooks allow the AI agent to iteratively refine its work until quality criteria are met.
147
+
148
+
**Ask the user about quality validation:**
149
+
- "Are there specific quality criteria that must be met for this step?"
150
+
- "Would you like the agent to validate its work before completing?"
151
+
- "What would make you send the work back for revision?"
152
+
153
+
**Stop hooks are particularly valuable for:**
154
+
- Steps with complex outputs that need multiple checks
155
+
- Steps where quality is critical (final deliverables)
156
+
- Steps with subjective quality criteria that benefit from AI self-review
157
+
158
+
**Three types of stop hooks are supported:**
159
+
160
+
1.**Inline Prompt** (`prompt`) - Best for simple quality criteria
161
+
```yaml
162
+
stop_hooks:
163
+
- prompt: |
164
+
Verify the output meets these criteria:
165
+
1. Contains at least 5 competitors
166
+
2. Each competitor has a description
167
+
3. Selection rationale is clear
168
+
```
169
+
170
+
2. **Prompt File** (`prompt_file`) - For detailed/reusable criteria
171
+
```yaml
172
+
stop_hooks:
173
+
- prompt_file: hooks/quality_check.md
174
+
```
175
+
176
+
3. **Script** (`script`) - For programmatic validation (tests, linting)
177
+
```yaml
178
+
stop_hooks:
179
+
- script: hooks/run_tests.sh
180
+
```
181
+
182
+
**Multiple hooks can be combined:**
183
+
```yaml
184
+
stop_hooks:
185
+
- script: hooks/lint_output.sh
186
+
- prompt: "Verify the content is comprehensive and well-organized"
187
+
```
188
+
189
+
**Encourage prompt-based hooks** - They leverage the AI's ability to understand context and make nuanced quality judgments. Script hooks are best for objective checks (syntax, format, tests).
190
+
191
+
### Step 5: Create the job.yml Specification
145
192
146
193
Only after you have complete understanding, create the `job.yml` file:
147
194
@@ -182,6 +229,13 @@ steps:
182
229
outputs:
183
230
- [output_filename_or_path] # e.g., "report.md" or "reports/analysis.md"
184
231
dependencies: [] # List of step IDs that must complete first
232
+
# Optional: Quality validation hooks
233
+
stop_hooks:
234
+
- prompt: |
235
+
Verify this step's output meets quality criteria:
236
+
1. [Criterion 1]
237
+
2. [Criterion 2]
238
+
If ALL criteria are met, include `<promise>QUALITY_COMPLETE</promise>`.
3. **Specific & Actionable**: Are instructions tailored to each step's purpose, not generic?
17
17
4. **Output Examples**: Does each instruction file show what good output looks like?
18
18
5. **Quality Criteria**: Does each instruction file define quality criteria for its outputs?
19
-
6. **Registry Updated**: Is `.deepwork/registry.yml` updated with the new job?
20
-
7. **Sync Complete**: Has `deepwork sync` been run successfully?
21
-
8. **Commands Available**: Are the slash-commands generated in `.claude/commands/`?
22
-
9. **Summary Created**: Has `implementation_summary.md` been created?
19
+
6. **Sync Complete**: Has `deepwork sync` been run successfully?
20
+
7. **Commands Available**: Are the slash-commands generated in `.claude/commands/`?
21
+
8. **Summary Created**: Has `implementation_summary.md` been created?
22
+
9. **Policies Considered**: Have you thought about whether policies would benefit this job?
23
+
- If relevant policies were identified, did you explain them and offer to run `/deepwork_policy.define`?
24
+
- Not every job needs policies - only suggest when genuinely helpful.
23
25
24
26
If ANY criterion is not met, continue working to address it.
25
27
If ALL criteria are satisfied, include `<promise>QUALITY_COMPLETE</promise>` in your response.
@@ -73,13 +75,12 @@ Generate the DeepWork job directory structure and instruction files for each ste
73
75
74
76
## Task
75
77
76
-
Read the `job.yml` specification file and create all the necessary files to make the job functional, including directory structure, step instruction files, and registry entry. Then sync the commands to make them available.
78
+
Read the `job.yml` specification file and create all the necessary files to make the job functional, including directory structure and step instruction files. Then sync the commands to make them available.
77
79
78
80
### Step 1: Read and Validate the Specification
79
81
80
82
1.**Locate the job.yml file**
81
-
- Read `deepwork/[job_name]/job.yml` from the define step
82
-
- (Where `[job_name]` is the name of the new job that was created in the define step)
83
+
- Read `deepwork/[job_name]/job.yml` from the define step (Where `[job_name]` is the name of the new job that was created in the define step)
83
84
- Parse the YAML content
84
85
85
86
2.**Validate the specification**
@@ -178,30 +179,49 @@ Each instruction file should follow this structure:
178
179
3.**Provide examples** - Show what good output looks like
179
180
4.**Explain the "why"** - Help the user understand the step's role in the workflow
180
181
5.**Quality over quantity** - Detailed, actionable instructions are better than vague ones
182
+
6.**Align with stop hooks** - If the step has `stop_hooks` defined, ensure the quality criteria in the instruction file match the validation criteria in the hooks
181
183
182
-
### Step 4: Copy job.yml to Job Directory
184
+
### Handling Stop Hooks
183
185
184
-
Copy the validated `job.yml` from the work directory to `.deepwork/jobs/[job_name]/job.yml`:
186
+
If a step in the job.yml has `stop_hooks` defined, the generated instruction file should:
Run `deepwork sync` to generate the slash-commands for this job:
207
227
@@ -214,12 +234,72 @@ This will:
214
234
- Generate slash-commands for each step
215
235
- Make the commands available in `.claude/commands/` (or appropriate platform directory)
216
236
217
-
### Step 7: Reload Commands
237
+
### Step 6: Reload Commands
218
238
219
239
Instruct the user to reload commands in their current session:
220
240
- Run `/reload` command (if available)
221
241
- Or restart the Claude session
222
242
243
+
### Step 7: Consider Policies for the New Job
244
+
245
+
After implementing the job, consider whether there are **policies** that would help enforce quality or consistency when working with this job's domain.
246
+
247
+
**What are policies?**
248
+
249
+
Policies are automated guardrails defined in `.deepwork.policy.yml` that trigger when certain files change during an AI session. They help ensure:
250
+
- Documentation stays in sync with code
251
+
- Team guidelines are followed
252
+
- Architectural decisions are respected
253
+
- Quality standards are maintained
254
+
255
+
**When to suggest policies:**
256
+
257
+
Think about the job you just implemented and ask:
258
+
- Does this job produce outputs that other files depend on?
259
+
- Are there documentation files that should be updated when this job's outputs change?
260
+
- Are there quality checks or reviews that should happen when certain files in this domain change?
261
+
- Could changes to the job's output files impact other parts of the project?
262
+
263
+
**Examples of policies that might make sense:**
264
+
265
+
| Job Type | Potential Policy |
266
+
|----------|------------------|
267
+
| API Design | "Update API docs when endpoint definitions change" |
-**Action**: Prompt to review and update `docs/strategy.md`
297
+
298
+
Would you like me to create this policy? I can run `/deepwork_policy.define` to set it up.
299
+
```
300
+
301
+
**Note:** Not every job needs policies. Only suggest them when they would genuinely help maintain consistency or quality. Don't force policies where they don't make sense.
302
+
223
303
## Example Implementation
224
304
225
305
**Given this job.yml:**
@@ -344,7 +424,6 @@ Before running `deepwork sync`, verify:
344
424
- All directories exist
345
425
-`job.yml` is in place
346
426
- All step instruction files exist (one per step)
347
-
- Registry is updated
348
427
- No file system errors
349
428
350
429
## Output Format
@@ -374,8 +453,6 @@ Successfully implemented the **[job_name]** workflow with [N] steps.
374
453
-`.deepwork/jobs/[job_name]/steps/[step2_id].md`
375
454
[... list all step files ...]
376
455
377
-
### Registry
378
-
- Updated `.deepwork/registry.yml` with job registration
379
456
380
457
## Generated Commands
381
458
@@ -412,11 +489,12 @@ Before marking this step complete, ensure:
412
489
-[ ] job.yml validated and copied to job directory
413
490
-[ ] All step instruction files created
414
491
-[ ] Each instruction file is complete and actionable
415
-
-[ ] Registry updated with new job
416
492
-[ ]`deepwork sync` executed successfully
417
493
-[ ] Commands generated in platform directory
418
494
-[ ] User informed of next steps (reload commands)
419
495
-[ ] implementation_summary.md created
496
+
-[ ] Considered whether policies would benefit this job (Step 7)
497
+
-[ ] If policies suggested, offered to run `/deepwork_policy.define`
420
498
421
499
## Quality Criteria
422
500
@@ -425,9 +503,9 @@ Before marking this step complete, ensure:
425
503
- Instructions are specific and actionable
426
504
- Output examples are provided in each instruction file
427
505
- Quality criteria defined for each step
428
-
- Registry properly updated
429
506
- Sync completed successfully
430
507
- Commands available for use
508
+
- Thoughtfully considered relevant policies for the job domain
431
509
432
510
433
511
## Inputs
@@ -480,10 +558,12 @@ Verify the implementation meets ALL quality criteria before completing:
480
558
3.**Specific & Actionable**: Are instructions tailored to each step's purpose, not generic?
481
559
4.**Output Examples**: Does each instruction file show what good output looks like?
482
560
5.**Quality Criteria**: Does each instruction file define quality criteria for its outputs?
483
-
6.**Registry Updated**: Is `.deepwork/registry.yml` updated with the new job?
484
-
7.**Sync Complete**: Has `deepwork sync` been run successfully?
485
-
8.**Commands Available**: Are the slash-commands generated in `.claude/commands/`?
486
-
9.**Summary Created**: Has `implementation_summary.md` been created?
561
+
6.**Sync Complete**: Has `deepwork sync` been run successfully?
562
+
7.**Commands Available**: Are the slash-commands generated in `.claude/commands/`?
563
+
8.**Summary Created**: Has `implementation_summary.md` been created?
564
+
9.**Policies Considered**: Have you thought about whether policies would benefit this job?
565
+
- If relevant policies were identified, did you explain them and offer to run `/deepwork_policy.define`?
566
+
- Not every job needs policies - only suggest when genuinely helpful.
487
567
488
568
If ANY criterion is not met, continue working to address it.
489
569
If ALL criteria are satisfied, include `<promise>QUALITY_COMPLETE</promise>` in your response.
0 commit comments