deepwork 0.3.1__py3-none-any.whl → 0.5.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- deepwork/cli/hook.py +70 -0
- deepwork/cli/install.py +58 -14
- deepwork/cli/main.py +4 -0
- deepwork/cli/rules.py +32 -0
- deepwork/cli/sync.py +27 -1
- deepwork/core/adapters.py +213 -0
- deepwork/core/command_executor.py +26 -9
- deepwork/core/doc_spec_parser.py +205 -0
- deepwork/core/generator.py +79 -4
- deepwork/core/hooks_syncer.py +15 -2
- deepwork/core/parser.py +64 -2
- deepwork/hooks/__init__.py +9 -3
- deepwork/hooks/check_version.sh +230 -0
- deepwork/hooks/claude_hook.sh +13 -17
- deepwork/hooks/gemini_hook.sh +13 -17
- deepwork/hooks/rules_check.py +71 -12
- deepwork/hooks/wrapper.py +66 -16
- deepwork/schemas/doc_spec_schema.py +64 -0
- deepwork/schemas/job_schema.py +25 -3
- deepwork/standard_jobs/deepwork_jobs/doc_specs/job_spec.md +190 -0
- deepwork/standard_jobs/deepwork_jobs/job.yml +41 -8
- deepwork/standard_jobs/deepwork_jobs/steps/define.md +68 -2
- deepwork/standard_jobs/deepwork_jobs/steps/implement.md +3 -3
- deepwork/standard_jobs/deepwork_jobs/steps/learn.md +74 -5
- deepwork/standard_jobs/deepwork_jobs/steps/review_job_spec.md +208 -0
- deepwork/standard_jobs/deepwork_jobs/templates/doc_spec.md.example +86 -0
- deepwork/standard_jobs/deepwork_jobs/templates/doc_spec.md.template +26 -0
- deepwork/standard_jobs/deepwork_rules/hooks/capture_prompt_work_tree.sh +8 -0
- deepwork/standard_jobs/deepwork_rules/job.yml +5 -3
- deepwork/templates/claude/AGENTS.md +38 -0
- deepwork/templates/claude/skill-job-meta.md.jinja +7 -0
- deepwork/templates/claude/skill-job-step.md.jinja +107 -70
- deepwork/templates/gemini/skill-job-step.toml.jinja +18 -3
- deepwork/utils/fs.py +36 -0
- deepwork/utils/yaml_utils.py +24 -0
- {deepwork-0.3.1.dist-info → deepwork-0.5.1.dist-info}/METADATA +39 -2
- deepwork-0.5.1.dist-info/RECORD +72 -0
- deepwork-0.3.1.dist-info/RECORD +0 -62
- {deepwork-0.3.1.dist-info → deepwork-0.5.1.dist-info}/WHEEL +0 -0
- {deepwork-0.3.1.dist-info → deepwork-0.5.1.dist-info}/entry_points.txt +0 -0
- {deepwork-0.3.1.dist-info → deepwork-0.5.1.dist-info}/licenses/LICENSE.md +0 -0
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# Review Job Specification
|
|
2
|
+
|
|
3
|
+
## Objective
|
|
4
|
+
|
|
5
|
+
Review the `job.yml` created in the define step against the doc spec quality criteria using a sub-agent for unbiased evaluation, then iterate on fixes until all criteria pass.
|
|
6
|
+
|
|
7
|
+
## Why This Step Exists
|
|
8
|
+
|
|
9
|
+
The define step focuses on understanding user requirements and creating a job specification. This review step ensures the specification meets quality standards before implementation. Using a sub-agent provides an unbiased "fresh eyes" review that catches issues the main agent might miss after being deeply involved in the definition process.
|
|
10
|
+
|
|
11
|
+
## Task
|
|
12
|
+
|
|
13
|
+
Use a sub-agent to review the job.yml against all 9 doc spec quality criteria, then fix any failed criteria. Repeat until all criteria pass.
|
|
14
|
+
|
|
15
|
+
### Step 1: Read the Job Specification
|
|
16
|
+
|
|
17
|
+
Read the `job.yml` file created in the define step:
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
.deepwork/jobs/[job_name]/job.yml
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Also read the doc spec for reference:
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
.deepwork/doc_specs/job_spec.md
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Step 2: Spawn Review Sub-Agent
|
|
30
|
+
|
|
31
|
+
Use the Task tool to spawn a sub-agent that will provide an unbiased review:
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
Task tool parameters:
|
|
35
|
+
- subagent_type: "general-purpose"
|
|
36
|
+
- model: "haiku"
|
|
37
|
+
- description: "Review job.yml against doc spec"
|
|
38
|
+
- prompt: [see below]
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
**Sub-agent prompt template:**
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
Review this job.yml against the following 9 quality criteria from the doc spec.
|
|
45
|
+
|
|
46
|
+
For each criterion, respond with:
|
|
47
|
+
- PASS or FAIL
|
|
48
|
+
- If FAIL: specific issue and suggested fix
|
|
49
|
+
|
|
50
|
+
## job.yml Content
|
|
51
|
+
|
|
52
|
+
[paste the full job.yml content here]
|
|
53
|
+
|
|
54
|
+
## Quality Criteria
|
|
55
|
+
|
|
56
|
+
1. **Valid Identifier**: Job name must be lowercase with underscores, no spaces or special characters (e.g., `competitive_research`, `monthly_report`)
|
|
57
|
+
|
|
58
|
+
2. **Semantic Version**: Version must follow semantic versioning format X.Y.Z (e.g., `1.0.0`, `2.1.3`)
|
|
59
|
+
|
|
60
|
+
3. **Concise Summary**: Summary must be under 200 characters and clearly describe what the job accomplishes
|
|
61
|
+
|
|
62
|
+
4. **Rich Description**: Description must be multi-line and explain: the problem solved, the process, expected outcomes, and target users
|
|
63
|
+
|
|
64
|
+
5. **Changelog Present**: Must include a changelog array with at least the initial version entry
|
|
65
|
+
|
|
66
|
+
6. **Complete Steps**: Each step must have: id (lowercase_underscores), name, description, instructions_file, outputs (at least one), and dependencies array
|
|
67
|
+
|
|
68
|
+
7. **Valid Dependencies**: Dependencies must reference existing step IDs with no circular references
|
|
69
|
+
|
|
70
|
+
8. **Input Consistency**: File inputs with `from_step` must reference a step that is in the dependencies array
|
|
71
|
+
|
|
72
|
+
9. **Output Paths**: Outputs must be valid filenames or paths (e.g., `report.md` or `reports/analysis.md`)
|
|
73
|
+
|
|
74
|
+
## Response Format
|
|
75
|
+
|
|
76
|
+
Respond with a structured evaluation:
|
|
77
|
+
|
|
78
|
+
### Overall: [X/9 PASS]
|
|
79
|
+
|
|
80
|
+
### Criterion Results
|
|
81
|
+
|
|
82
|
+
1. Valid Identifier: [PASS/FAIL]
|
|
83
|
+
[If FAIL: Issue and fix]
|
|
84
|
+
|
|
85
|
+
2. Semantic Version: [PASS/FAIL]
|
|
86
|
+
[If FAIL: Issue and fix]
|
|
87
|
+
|
|
88
|
+
[... continue for all 9 criteria ...]
|
|
89
|
+
|
|
90
|
+
### Summary of Required Fixes
|
|
91
|
+
|
|
92
|
+
[List any fixes needed, or "No fixes required - all criteria pass"]
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Step 3: Review Sub-Agent Findings
|
|
96
|
+
|
|
97
|
+
Parse the sub-agent's response:
|
|
98
|
+
|
|
99
|
+
1. **Count passing criteria** - How many of the 9 criteria passed?
|
|
100
|
+
2. **Identify failures** - List specific criteria that failed
|
|
101
|
+
3. **Note suggested fixes** - What changes does the sub-agent recommend?
|
|
102
|
+
|
|
103
|
+
### Step 4: Fix Failed Criteria
|
|
104
|
+
|
|
105
|
+
For each failed criterion, edit the job.yml to address the issue:
|
|
106
|
+
|
|
107
|
+
**Common fixes by criterion:**
|
|
108
|
+
|
|
109
|
+
| Criterion | Common Issue | Fix |
|
|
110
|
+
|-----------|-------------|-----|
|
|
111
|
+
| Valid Identifier | Spaces or uppercase | Convert to lowercase_underscores |
|
|
112
|
+
| Semantic Version | Missing or invalid format | Set to `"1.0.0"` or fix format |
|
|
113
|
+
| Concise Summary | Too long or vague | Shorten to <200 chars, be specific |
|
|
114
|
+
| Rich Description | Single line or missing context | Add multi-line explanation with problem/process/outcome/users |
|
|
115
|
+
| Changelog Present | Missing changelog | Add `changelog:` with initial version entry |
|
|
116
|
+
| Complete Steps | Missing required fields | Add id, name, description, instructions_file, outputs, dependencies |
|
|
117
|
+
| Valid Dependencies | Non-existent step or circular | Fix step ID reference or reorder dependencies |
|
|
118
|
+
| Input Consistency | from_step not in dependencies | Add the referenced step to dependencies array |
|
|
119
|
+
| Output Paths | Invalid characters or format | Use valid filename/path format |
|
|
120
|
+
|
|
121
|
+
### Step 5: Re-Run Review (If Needed)
|
|
122
|
+
|
|
123
|
+
If any criteria failed:
|
|
124
|
+
|
|
125
|
+
1. **Spawn a new sub-agent** with the updated job.yml content
|
|
126
|
+
2. **Review the new findings**
|
|
127
|
+
3. **Fix any remaining issues**
|
|
128
|
+
4. **Repeat until all 9 criteria pass**
|
|
129
|
+
|
|
130
|
+
### Step 6: Confirm Completion
|
|
131
|
+
|
|
132
|
+
When all 9 criteria pass:
|
|
133
|
+
|
|
134
|
+
1. **Announce success**: "All 9 doc spec quality criteria pass."
|
|
135
|
+
2. **List what was validated**:
|
|
136
|
+
- Valid Identifier
|
|
137
|
+
- Semantic Version
|
|
138
|
+
- Concise Summary
|
|
139
|
+
- Rich Description
|
|
140
|
+
- Changelog Present
|
|
141
|
+
- Complete Steps
|
|
142
|
+
- Valid Dependencies
|
|
143
|
+
- Input Consistency
|
|
144
|
+
- Output Paths
|
|
145
|
+
3. **Include the promise**: `<promise>Quality Criteria Met</promise>`
|
|
146
|
+
4. **Guide to next step**: "Run `/deepwork_jobs.implement` to generate the step instruction files."
|
|
147
|
+
|
|
148
|
+
## Example Review Cycle
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
Claude: Let me review the job.yml against the doc spec quality criteria.
|
|
152
|
+
|
|
153
|
+
[Spawns sub-agent with haiku model]
|
|
154
|
+
|
|
155
|
+
Sub-agent response:
|
|
156
|
+
### Overall: 7/9 PASS
|
|
157
|
+
|
|
158
|
+
### Criterion Results
|
|
159
|
+
1. Valid Identifier: PASS
|
|
160
|
+
2. Semantic Version: PASS
|
|
161
|
+
3. Concise Summary: FAIL
|
|
162
|
+
Issue: Summary is 245 characters, exceeds 200 char limit
|
|
163
|
+
Fix: Shorten to "Competitive analysis workflow for product positioning"
|
|
164
|
+
4. Rich Description: PASS
|
|
165
|
+
5. Changelog Present: FAIL
|
|
166
|
+
Issue: No changelog array present
|
|
167
|
+
Fix: Add changelog with initial version entry
|
|
168
|
+
6. Complete Steps: PASS
|
|
169
|
+
7. Valid Dependencies: PASS
|
|
170
|
+
8. Input Consistency: PASS
|
|
171
|
+
9. Output Paths: PASS
|
|
172
|
+
|
|
173
|
+
### Summary of Required Fixes
|
|
174
|
+
1. Shorten summary to under 200 characters
|
|
175
|
+
2. Add changelog array with initial version
|
|
176
|
+
|
|
177
|
+
Claude: I found 2 issues. Let me fix them.
|
|
178
|
+
|
|
179
|
+
[Edits job.yml to shorten summary and add changelog]
|
|
180
|
+
|
|
181
|
+
Claude: Let me verify the fixes with another review.
|
|
182
|
+
|
|
183
|
+
[Spawns new sub-agent]
|
|
184
|
+
|
|
185
|
+
Sub-agent response:
|
|
186
|
+
### Overall: 9/9 PASS
|
|
187
|
+
|
|
188
|
+
### Summary of Required Fixes
|
|
189
|
+
No fixes required - all criteria pass
|
|
190
|
+
|
|
191
|
+
Claude: All 9 doc spec quality criteria pass.
|
|
192
|
+
|
|
193
|
+
<promise>Quality Criteria Met</promise>
|
|
194
|
+
|
|
195
|
+
**Next step:** Run `/deepwork_jobs.implement` to generate the step instruction files.
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Quality Criteria
|
|
199
|
+
|
|
200
|
+
- **Sub-Agent Used**: A sub-agent was spawned to provide unbiased review (not just self-review)
|
|
201
|
+
- **All doc spec Criteria Evaluated**: The sub-agent assessed all 9 quality criteria from the doc spec
|
|
202
|
+
- **Findings Addressed**: All failed criteria were fixed by the main agent
|
|
203
|
+
- **Validation Loop Complete**: The review-fix cycle continued until all criteria passed
|
|
204
|
+
- **Promise Included**: The response includes `<promise>Quality Criteria Met</promise>` when complete
|
|
205
|
+
|
|
206
|
+
## Output
|
|
207
|
+
|
|
208
|
+
The validated `job.yml` file at `.deepwork/jobs/[job_name]/job.yml` that passes all 9 doc spec quality criteria.
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "Monthly AWS Spending Report"
|
|
3
|
+
description: "A Markdown summary of AWS spend across accounts for finance and engineering leadership"
|
|
4
|
+
path_patterns:
|
|
5
|
+
- "finance/aws-reports/*.md"
|
|
6
|
+
- "reports/aws/*.md"
|
|
7
|
+
target_audience: "Finance team and Engineering leadership"
|
|
8
|
+
frequency: "Monthly, following AWS invoice arrival"
|
|
9
|
+
quality_criteria:
|
|
10
|
+
- name: Executive Summary
|
|
11
|
+
description: Must include a 2-3 sentence summary of total spend, month-over-month change percentage, and top cost driver
|
|
12
|
+
- name: Visualization
|
|
13
|
+
description: Must include at least one Mermaid.js chart showing spend breakdown by service (pie chart) or trend over time (line chart)
|
|
14
|
+
- name: Variance Analysis
|
|
15
|
+
description: Must compare current month against previous month with percentage changes for top 5 services
|
|
16
|
+
- name: Cost Attribution
|
|
17
|
+
description: Must break down costs by team/project using AWS tags where available
|
|
18
|
+
- name: Action Items
|
|
19
|
+
description: Must include 2-3 specific, actionable recommendations for cost optimization
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
# Monthly AWS Spending Report: [Month, Year]
|
|
23
|
+
|
|
24
|
+
## Executive Summary
|
|
25
|
+
|
|
26
|
+
[2-3 sentences summarizing:
|
|
27
|
+
- Total spend this month
|
|
28
|
+
- Percentage change from last month
|
|
29
|
+
- The primary cost driver]
|
|
30
|
+
|
|
31
|
+
## Spend Overview
|
|
32
|
+
|
|
33
|
+
### Total Spend by Service
|
|
34
|
+
|
|
35
|
+
```mermaid
|
|
36
|
+
pie title AWS Spend by Service
|
|
37
|
+
"EC2" : 45
|
|
38
|
+
"RDS" : 25
|
|
39
|
+
"S3" : 15
|
|
40
|
+
"Lambda" : 10
|
|
41
|
+
"Other" : 5
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Month-over-Month Trend
|
|
45
|
+
|
|
46
|
+
```mermaid
|
|
47
|
+
xychart-beta
|
|
48
|
+
title "Monthly AWS Spend Trend"
|
|
49
|
+
x-axis [Jan, Feb, Mar, Apr, May, Jun]
|
|
50
|
+
y-axis "Spend ($K)" 0 --> 100
|
|
51
|
+
line [45, 48, 52, 49, 55, 58]
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Variance Analysis
|
|
55
|
+
|
|
56
|
+
| Service | Last Month | This Month | Change | % Change |
|
|
57
|
+
|---------|-----------|------------|--------|----------|
|
|
58
|
+
| EC2 | $X,XXX | $X,XXX | +$XXX | +X.X% |
|
|
59
|
+
| RDS | $X,XXX | $X,XXX | -$XXX | -X.X% |
|
|
60
|
+
| S3 | $X,XXX | $X,XXX | +$XXX | +X.X% |
|
|
61
|
+
| Lambda | $X,XXX | $X,XXX | +$XXX | +X.X% |
|
|
62
|
+
| Other | $X,XXX | $X,XXX | +$XXX | +X.X% |
|
|
63
|
+
|
|
64
|
+
## Cost Attribution by Team
|
|
65
|
+
|
|
66
|
+
| Team/Project | Spend | % of Total |
|
|
67
|
+
|--------------|-------|------------|
|
|
68
|
+
| Platform | $X,XXX | XX% |
|
|
69
|
+
| Data | $X,XXX | XX% |
|
|
70
|
+
| Product | $X,XXX | XX% |
|
|
71
|
+
| Shared | $X,XXX | XX% |
|
|
72
|
+
|
|
73
|
+
## Recommendations
|
|
74
|
+
|
|
75
|
+
1. **[Action Item 1]**: [Specific recommendation with expected savings]
|
|
76
|
+
2. **[Action Item 2]**: [Specific recommendation with expected savings]
|
|
77
|
+
3. **[Action Item 3]**: [Specific recommendation with expected savings]
|
|
78
|
+
|
|
79
|
+
## Appendix
|
|
80
|
+
|
|
81
|
+
### Data Sources
|
|
82
|
+
- AWS Cost Explorer
|
|
83
|
+
- AWS Tags: team, project, environment
|
|
84
|
+
|
|
85
|
+
### Report Methodology
|
|
86
|
+
[Brief explanation of how costs are calculated and attributed]
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "[Document Name]"
|
|
3
|
+
description: "[Brief description of the document's purpose]"
|
|
4
|
+
path_patterns:
|
|
5
|
+
- "[path/to/documents/*.md]"
|
|
6
|
+
target_audience: "[Who reads this document]"
|
|
7
|
+
frequency: "[How often produced, e.g., Monthly, Per sprint, On demand]"
|
|
8
|
+
quality_criteria:
|
|
9
|
+
- name: "[Criterion Name]"
|
|
10
|
+
description: "[What this criterion requires - be specific]"
|
|
11
|
+
- name: "[Criterion Name]"
|
|
12
|
+
description: "[What this criterion requires - be specific]"
|
|
13
|
+
- name: "[Criterion Name]"
|
|
14
|
+
description: "[What this criterion requires - be specific]"
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# [Document Title]: [Variables like Month, Year, Sprint]
|
|
18
|
+
|
|
19
|
+
## Section 1
|
|
20
|
+
[Describe what goes in this section]
|
|
21
|
+
|
|
22
|
+
## Section 2
|
|
23
|
+
[Describe what goes in this section]
|
|
24
|
+
|
|
25
|
+
## Section 3
|
|
26
|
+
[Describe what goes in this section]
|
|
@@ -8,12 +8,20 @@
|
|
|
8
8
|
# The baseline contains ALL tracked files (not just changed files) so that
|
|
9
9
|
# the rules_check hook can determine which files are genuinely new vs which
|
|
10
10
|
# files existed before and were just modified.
|
|
11
|
+
#
|
|
12
|
+
# It also captures the HEAD commit ref so that committed changes can be detected
|
|
13
|
+
# by comparing HEAD at Stop time to the captured ref.
|
|
11
14
|
|
|
12
15
|
set -e
|
|
13
16
|
|
|
14
17
|
# Ensure .deepwork directory exists
|
|
15
18
|
mkdir -p .deepwork
|
|
16
19
|
|
|
20
|
+
# Save the current HEAD commit ref for detecting committed changes
|
|
21
|
+
# This is used by get_changed_files_prompt() to detect files changed since prompt,
|
|
22
|
+
# even if those changes were committed during the agent response.
|
|
23
|
+
git rev-parse HEAD > .deepwork/.last_head_ref 2>/dev/null || echo "" > .deepwork/.last_head_ref
|
|
24
|
+
|
|
17
25
|
# Save ALL tracked files (not just changed files)
|
|
18
26
|
# This is critical for created: mode rules to distinguish between:
|
|
19
27
|
# - Newly created files (not in baseline) -> should trigger created: rules
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
name: deepwork_rules
|
|
2
|
-
version: "0.
|
|
3
|
-
summary: "
|
|
2
|
+
version: "0.4.0"
|
|
3
|
+
summary: "Creates file-change rules that enforce guidelines during AI sessions. Use when automating documentation sync or code review triggers."
|
|
4
4
|
description: |
|
|
5
5
|
Manages rules that automatically trigger when certain files change during an AI agent session.
|
|
6
6
|
Rules help ensure that code changes follow team guidelines, documentation is updated,
|
|
@@ -33,11 +33,13 @@ changelog:
|
|
|
33
33
|
changes: "Standardized on 'ask structured questions' phrasing for user input"
|
|
34
34
|
- version: "0.3.0"
|
|
35
35
|
changes: "Migrated to v2 format - individual markdown files in .deepwork/rules/"
|
|
36
|
+
- version: "0.4.0"
|
|
37
|
+
changes: "Improved skill descriptions with third-person voice and 'Use when...' triggers for better discoverability"
|
|
36
38
|
|
|
37
39
|
steps:
|
|
38
40
|
- id: define
|
|
39
41
|
name: "Define Rule"
|
|
40
|
-
description: "
|
|
42
|
+
description: "Creates a rule file that triggers when specified files change. Use when setting up documentation sync, code review requirements, or automated commands."
|
|
41
43
|
instructions_file: steps/define.md
|
|
42
44
|
inputs:
|
|
43
45
|
- name: rule_purpose
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Claude Templates - Agent Notes
|
|
2
|
+
|
|
3
|
+
Notes for AI agents working on Claude Code jinja templates.
|
|
4
|
+
|
|
5
|
+
## Prompt-Based Stop Hooks - NOT WORKING
|
|
6
|
+
|
|
7
|
+
**IMPORTANT: Prompt-based stop hooks (`type: prompt` for Stop/SubagentStop events) do not currently work properly in Claude Code.**
|
|
8
|
+
|
|
9
|
+
Reference: https://github.com/anthropics/claude-code/issues/20221
|
|
10
|
+
|
|
11
|
+
### What This Means
|
|
12
|
+
|
|
13
|
+
- Do NOT use `type: prompt` hooks for Stop or SubagentStop events in templates
|
|
14
|
+
- The quality validation loop pattern that relies on prompt hooks will not function as expected
|
|
15
|
+
- Instead, instruct agents to use a sub-agent (e.g., Haiku) to review their work against quality criteria
|
|
16
|
+
|
|
17
|
+
### Workaround
|
|
18
|
+
|
|
19
|
+
Instead of prompt-based stop hooks, templates should include explicit instructions in the command content directing the agent to:
|
|
20
|
+
|
|
21
|
+
1. Have a sub-agent using Haiku review the work against the specified quality criteria
|
|
22
|
+
2. Fix any valid issues raised by the sub-agent
|
|
23
|
+
3. Have the sub-agent review again until all valid feedback is handled
|
|
24
|
+
|
|
25
|
+
### Future Reversal
|
|
26
|
+
|
|
27
|
+
If prompt-based stop hooks are fixed in Claude Code (check the issue above for updates), this guidance should be reversed and prompt hooks can be re-enabled in templates.
|
|
28
|
+
|
|
29
|
+
## Historical Context (Prompt Hooks - When They Work)
|
|
30
|
+
|
|
31
|
+
The following guidance applies IF prompt hooks start working again:
|
|
32
|
+
|
|
33
|
+
When writing prompt-based hooks (e.g., Stop hooks with `type: prompt`):
|
|
34
|
+
|
|
35
|
+
- **Do NOT include instructions on how to return responses** (e.g., "respond with JSON", "return `{"ok": true}`"). Claude Code's internal instructions already specify the expected response format for prompt hooks.
|
|
36
|
+
- Adding redundant response format instructions can cause conflicts or confusion with the built-in behavior. i.e. the hook will not block the agent from stopping.
|
|
37
|
+
|
|
38
|
+
Reference: https://github.com/anthropics/claude-code/issues/11786
|
|
@@ -65,6 +65,13 @@ If user intent is unclear, use AskUserQuestion to clarify:
|
|
|
65
65
|
- Present available steps as numbered options
|
|
66
66
|
- Let user select the starting point
|
|
67
67
|
|
|
68
|
+
## Guardrails
|
|
69
|
+
|
|
70
|
+
- Do NOT copy/paste step instructions directly; always use the Skill tool to invoke steps
|
|
71
|
+
- Do NOT skip steps in the workflow unless the user explicitly requests it
|
|
72
|
+
- Do NOT proceed to the next step if the current step's outputs are incomplete
|
|
73
|
+
- Do NOT make assumptions about user intent; ask for clarification when ambiguous
|
|
74
|
+
|
|
68
75
|
## Context Files
|
|
69
76
|
|
|
70
77
|
- Job definition: `.deepwork/jobs/{{ job_name }}/job.yml`
|
|
@@ -40,52 +40,51 @@ Template Variables:
|
|
|
40
40
|
---
|
|
41
41
|
name: {{ job_name }}.{{ step_id }}
|
|
42
42
|
description: "{{ step_description }}"
|
|
43
|
-
{
|
|
43
|
+
{%- if not exposed %}
|
|
44
44
|
user-invocable: false
|
|
45
|
-
{
|
|
46
|
-
{
|
|
45
|
+
{%- endif %}{#- if not exposed #}
|
|
46
|
+
{#-
|
|
47
|
+
NOTE: Prompt-based stop hooks do not currently work in Claude Code.
|
|
48
|
+
See: https://github.com/anthropics/claude-code/issues/20221
|
|
49
|
+
Only command/script hooks are generated here. Prompt hooks are filtered out.
|
|
50
|
+
Quality validation is handled via sub-agent review in the instructions section.
|
|
51
|
+
#}
|
|
52
|
+
{%- if hooks -%}
|
|
53
|
+
{%- set has_command_hooks = namespace(value=false) -%}
|
|
54
|
+
{%- for event_name, event_hooks in hooks.items() -%}
|
|
55
|
+
{%- for hook in event_hooks -%}
|
|
56
|
+
{%- if hook.type == "script" -%}
|
|
57
|
+
{%- set has_command_hooks.value = true -%}
|
|
58
|
+
{%- endif -%}{#- if hook.type == "script" #}
|
|
59
|
+
{%- endfor -%}{#- for hook in event_hooks #}
|
|
60
|
+
{%- endfor -%}{#- for event_name, event_hooks in hooks.items() #}
|
|
61
|
+
{%- if has_command_hooks.value %}
|
|
47
62
|
hooks:
|
|
48
|
-
{
|
|
49
|
-
|
|
63
|
+
{%- for event_name, event_hooks in hooks.items() %}
|
|
64
|
+
{%- set script_hooks = event_hooks | selectattr("type", "equalto", "script") | list %}
|
|
65
|
+
{%- if script_hooks -%}
|
|
66
|
+
{#- For Stop events, generate both Stop and SubagentStop blocks #}
|
|
67
|
+
{%- if event_name == "Stop" %}
|
|
68
|
+
{%- for stop_event in ["Stop", "SubagentStop"] %}
|
|
69
|
+
{{ stop_event }}:
|
|
50
70
|
- hooks:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
{% for criterion in quality_criteria %}
|
|
58
|
-
{{ loop.index }}. {{ criterion }}
|
|
59
|
-
{% endfor %}
|
|
60
|
-
|
|
61
|
-
## Instructions
|
|
62
|
-
|
|
63
|
-
Review the conversation and determine if ALL quality criteria above have been satisfied.
|
|
64
|
-
Look for evidence that each criterion has been addressed.
|
|
65
|
-
|
|
66
|
-
If the agent has included `<promise>✓ Quality Criteria Met</promise>` in their response AND
|
|
67
|
-
all criteria appear to be met, respond with: {"ok": true}
|
|
68
|
-
|
|
69
|
-
If criteria are NOT met OR the promise tag is missing, respond with:
|
|
70
|
-
{"ok": false, "reason": "**AGENT: TAKE ACTION** - [which criteria failed and why]"}
|
|
71
|
-
{% endif %}
|
|
72
|
-
{% for event_name, event_hooks in hooks.items() %}
|
|
73
|
-
{% if not (event_name == "Stop" and quality_criteria) %}
|
|
71
|
+
{%- for hook in script_hooks %}
|
|
72
|
+
- type: command
|
|
73
|
+
command: ".deepwork/jobs/{{ job_name }}/{{ hook.path }}"
|
|
74
|
+
{%- endfor %}{#- for hook in script_hooks #}
|
|
75
|
+
{%- endfor %}{#- for stop_event in ["Stop", "SubagentStop"] #}
|
|
76
|
+
{%- elif event_name != "SubagentStop" or "Stop" not in hooks %}
|
|
74
77
|
{{ event_name }}:
|
|
75
78
|
- hooks:
|
|
76
|
-
{
|
|
77
|
-
{% if hook.type == "script" %}
|
|
79
|
+
{%- for hook in script_hooks %}
|
|
78
80
|
- type: command
|
|
79
81
|
command: ".deepwork/jobs/{{ job_name }}/{{ hook.path }}"
|
|
80
|
-
{
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
{
|
|
85
|
-
{
|
|
86
|
-
{% endif %}
|
|
87
|
-
{% endfor %}
|
|
88
|
-
{% endif %}
|
|
82
|
+
{%- endfor %}{#- for hook in script_hooks #}
|
|
83
|
+
{%- endif %}{#- if event_name == "Stop" #}
|
|
84
|
+
{%- endif %}{#- if script_hooks #}
|
|
85
|
+
{%- endfor %}{#- for event_name, event_hooks in hooks.items() #}
|
|
86
|
+
{%- endif %}{#- if has_command_hooks.value #}
|
|
87
|
+
{%- endif %}{#- if hooks #}
|
|
89
88
|
---
|
|
90
89
|
|
|
91
90
|
# {{ job_name }}.{{ step_id }}
|
|
@@ -94,7 +93,7 @@ hooks:
|
|
|
94
93
|
**Standalone skill** - can be run anytime
|
|
95
94
|
{% else %}
|
|
96
95
|
**Step {{ step_number }}/{{ total_steps }}** in **{{ job_name }}** workflow
|
|
97
|
-
{% endif %}
|
|
96
|
+
{% endif %}{#- if is_standalone #}
|
|
98
97
|
|
|
99
98
|
> {{ job_summary }}
|
|
100
99
|
|
|
@@ -104,8 +103,8 @@ hooks:
|
|
|
104
103
|
Before proceeding, confirm these steps are complete:
|
|
105
104
|
{% for dep in dependencies %}
|
|
106
105
|
- `/{{ job_name }}.{{ dep }}`
|
|
107
|
-
{% endfor %}
|
|
108
|
-
{% endif %}
|
|
106
|
+
{% endfor %}{#- for dep in dependencies #}
|
|
107
|
+
{% endif %}{#- if dependencies #}
|
|
109
108
|
|
|
110
109
|
## Instructions
|
|
111
110
|
|
|
@@ -117,7 +116,7 @@ Before proceeding, confirm these steps are complete:
|
|
|
117
116
|
### Job Context
|
|
118
117
|
|
|
119
118
|
{{ job_description }}
|
|
120
|
-
{% endif %}
|
|
119
|
+
{% endif %}{#- if job_description #}
|
|
121
120
|
|
|
122
121
|
{% if user_inputs or file_inputs %}
|
|
123
122
|
## Required Inputs
|
|
@@ -126,16 +125,16 @@ Before proceeding, confirm these steps are complete:
|
|
|
126
125
|
**User Parameters** - Gather from user before starting:
|
|
127
126
|
{% for input in user_inputs %}
|
|
128
127
|
- **{{ input.name }}**: {{ input.description }}
|
|
129
|
-
{% endfor %}
|
|
130
|
-
{% endif %}
|
|
128
|
+
{% endfor %}{#- for input in user_inputs #}
|
|
129
|
+
{% endif %}{#- if user_inputs #}
|
|
131
130
|
|
|
132
131
|
{% if file_inputs %}
|
|
133
132
|
**Files from Previous Steps** - Read these first:
|
|
134
133
|
{% for input in file_inputs %}
|
|
135
134
|
- `{{ input.file }}` (from `{{ input.from_step }}`)
|
|
136
|
-
{% endfor %}
|
|
137
|
-
{% endif %}
|
|
138
|
-
{% endif %}
|
|
135
|
+
{% endfor %}{#- for input in file_inputs #}
|
|
136
|
+
{% endif %}{#- if file_inputs #}
|
|
137
|
+
{% endif %}{#- if user_inputs or file_inputs #}
|
|
139
138
|
|
|
140
139
|
## Work Branch
|
|
141
140
|
|
|
@@ -149,49 +148,87 @@ Use branch format: `deepwork/{{ job_name }}-[instance]-YYYYMMDD`
|
|
|
149
148
|
{% if outputs %}
|
|
150
149
|
**Required outputs**:
|
|
151
150
|
{% for output in outputs %}
|
|
152
|
-
- `{{ output }}`{% if output.endswith('/') %} (directory){% endif %}
|
|
153
|
-
|
|
151
|
+
- `{{ output.file }}`{% if output.file.endswith('/') %} (directory){% endif %}
|
|
152
|
+
|
|
153
|
+
{% if output.has_doc_spec and output.doc_spec %}
|
|
154
|
+
**Doc Spec**: {{ output.doc_spec.name }}
|
|
155
|
+
> {{ output.doc_spec.description }}
|
|
156
|
+
**Definition**: `{{ output.doc_spec.path }}`
|
|
157
|
+
{% if output.doc_spec.target_audience %}
|
|
158
|
+
**Target Audience**: {{ output.doc_spec.target_audience }}
|
|
159
|
+
{% endif %}{#- if output.doc_spec.target_audience #}
|
|
160
|
+
{% if output.doc_spec.quality_criteria %}
|
|
161
|
+
**Quality Criteria**:
|
|
162
|
+
{% for criterion in output.doc_spec.quality_criteria %}
|
|
163
|
+
{{ loop.index }}. **{{ criterion.name }}**: {{ criterion.description }}
|
|
164
|
+
{% endfor %}{#- for criterion in output.doc_spec.quality_criteria #}
|
|
165
|
+
{% endif %}{#- if output.doc_spec.quality_criteria #}
|
|
166
|
+
{% if output.doc_spec.example_document %}
|
|
167
|
+
|
|
168
|
+
<details>
|
|
169
|
+
<summary>Example Document Structure</summary>
|
|
170
|
+
|
|
171
|
+
```markdown
|
|
172
|
+
{{ output.doc_spec.example_document | indent(2) }}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
</details>
|
|
176
|
+
{% endif %}{#- if output.doc_spec.example_document #}
|
|
177
|
+
{% endif %}{#- if output.has_doc_spec and output.doc_spec #}
|
|
178
|
+
{% endfor %}{#- for output in outputs #}
|
|
154
179
|
{% else %}
|
|
155
180
|
No specific file outputs required.
|
|
156
|
-
{% endif %}
|
|
181
|
+
{% endif %}{#- if outputs #}
|
|
157
182
|
|
|
158
|
-
|
|
159
|
-
## Quality Validation
|
|
183
|
+
## Guardrails
|
|
160
184
|
|
|
161
|
-
|
|
185
|
+
- Do NOT skip prerequisite verification if this step has dependencies
|
|
186
|
+
- Do NOT produce partial outputs; complete all required outputs before finishing
|
|
187
|
+
- Do NOT proceed without required inputs; ask the user if any are missing
|
|
188
|
+
- Do NOT modify files outside the scope of this step's defined outputs
|
|
162
189
|
|
|
163
190
|
{% if quality_criteria %}
|
|
164
|
-
|
|
165
|
-
{% for criterion in quality_criteria %}
|
|
166
|
-
{{ loop.index }}. {{ criterion }}
|
|
167
|
-
{% endfor %}
|
|
168
|
-
{% endif %}
|
|
191
|
+
## Quality Validation
|
|
169
192
|
|
|
170
|
-
|
|
171
|
-
{% if hook.type == "script" %}
|
|
172
|
-
**Validation script**: `.deepwork/jobs/{{ job_name }}/{{ hook.path }}` (runs automatically)
|
|
173
|
-
{% endif %}
|
|
174
|
-
{% endfor %}
|
|
193
|
+
**Before completing this step, you MUST have your work reviewed against the quality criteria below.**
|
|
175
194
|
|
|
176
|
-
|
|
195
|
+
Use a sub-agent (Haiku model) to review your work against these criteria:
|
|
177
196
|
|
|
178
|
-
|
|
197
|
+
**Criteria (all must be satisfied)**:
|
|
198
|
+
{% for criterion in quality_criteria -%}
|
|
199
|
+
{{ loop.index }}. {{ criterion }}
|
|
200
|
+
{% endfor %}{#- for criterion in quality_criteria #}
|
|
201
|
+
**Review Process**:
|
|
202
|
+
1. Once you believe your work is complete, spawn a sub-agent using Haiku to review your work against the quality criteria above
|
|
203
|
+
2. The sub-agent should examine your outputs and verify each criterion is met
|
|
204
|
+
3. If the sub-agent identifies valid issues, fix them
|
|
205
|
+
4. Have the sub-agent review again until all valid feedback has been addressed
|
|
206
|
+
5. Only mark the step complete when the sub-agent confirms all criteria are satisfied
|
|
207
|
+
|
|
208
|
+
{% endif %}{#- if quality_criteria #}
|
|
209
|
+
{% if stop_hooks -%}
|
|
210
|
+
{% for hook in stop_hooks -%}
|
|
211
|
+
{% if hook.type == "script" -%}
|
|
212
|
+
**Validation script**: `.deepwork/jobs/{{ job_name }}/{{ hook.path }}` (runs automatically)
|
|
213
|
+
{% endif -%}{#- if hook.type == "script" #}
|
|
214
|
+
{% endfor %}{#- for hook in stop_hooks #}
|
|
215
|
+
{% endif %}{#- if stop_hooks #}
|
|
179
216
|
## On Completion
|
|
180
217
|
|
|
181
218
|
{% if is_standalone %}
|
|
182
219
|
1. Verify outputs are created
|
|
183
|
-
2. Inform user: "{{ step_id }} complete{% if outputs %}, outputs: {{ outputs | join(', ') }}{% endif %}"
|
|
220
|
+
2. Inform user: "{{ step_id }} complete{% if outputs %}, outputs: {{ outputs | map(attribute='file') | join(', ') }}{% endif %}"
|
|
184
221
|
|
|
185
222
|
This standalone skill can be re-run anytime.
|
|
186
223
|
{% else %}
|
|
187
224
|
1. Verify outputs are created
|
|
188
|
-
2. Inform user: "Step {{ step_number }}/{{ total_steps }} complete{% if outputs %}, outputs: {{ outputs | join(', ') }}{% endif %}"
|
|
225
|
+
2. Inform user: "Step {{ step_number }}/{{ total_steps }} complete{% if outputs %}, outputs: {{ outputs | map(attribute='file') | join(', ') }}{% endif %}"
|
|
189
226
|
{% if next_step %}
|
|
190
227
|
3. **Continue workflow**: Use Skill tool to invoke `/{{ job_name }}.{{ next_step }}`
|
|
191
228
|
{% else %}
|
|
192
229
|
3. **Workflow complete**: All steps finished. Consider creating a PR to merge the work branch.
|
|
193
|
-
{% endif %}
|
|
194
|
-
{% endif %}
|
|
230
|
+
{% endif %}{#- if next_step #}
|
|
231
|
+
{% endif %}{#- if is_standalone #}
|
|
195
232
|
|
|
196
233
|
---
|
|
197
234
|
|