Skip to content

Commit 99b3999

Browse files
nhortonclaude
andcommitted
Add job.yml DTD for define step output validation
- Create job_spec.md DTD with 9 quality criteria for job.yml files - Update install.py to copy DTDs from standard jobs to .deepwork/dtds/ - Reference DTD in deepwork_jobs define step output with document_type - Bump deepwork_jobs version to 0.7.0 - Temporarily disable new-standard-job-warning rule (bug causes infinite loop) The DTD ensures consistent quality for all job.yml files created via /deepwork_jobs.define by validating: identifier format, semantic version, summary length, description richness, changelog presence, step completeness, dependency validity, input consistency, and output paths. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent bcdb262 commit 99b3999

26 files changed

Lines changed: 1380 additions & 44 deletions

File tree

.claude/skills/add_platform.add_capabilities/SKILL.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,9 @@ Use branch format: `deepwork/add_platform-[instance]-YYYYMMDD`
208208
## Outputs
209209

210210
**Required outputs**:
211-
- `job_schema.py`- `adapters.py`
211+
- `job_schema.py`
212+
- `adapters.py`
213+
212214
## Quality Validation
213215

214216
Stop hooks will automatically validate your work. The loop continues until all criteria pass.

.claude/skills/add_platform.implement/SKILL.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,10 @@ Use branch format: `deepwork/add_platform-[instance]-YYYYMMDD`
306306
## Outputs
307307
308308
**Required outputs**:
309-
- `templates/` (directory)- `tests/` (directory)- `README.md`
309+
- `templates/` (directory)
310+
- `tests/` (directory)
311+
- `README.md`
312+
310313
## Quality Validation
311314
312315
Stop hooks will automatically validate your work. The loop continues until all criteria pass.

.claude/skills/add_platform.research/SKILL.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,9 @@ Use branch format: `deepwork/add_platform-[instance]-YYYYMMDD`
258258
## Outputs
259259

260260
**Required outputs**:
261-
- `cli_configuration.md`- `hooks_system.md`
261+
- `cli_configuration.md`
262+
- `hooks_system.md`
263+
262264
## Quality Validation
263265

264266
Stop hooks will automatically validate your work. The loop continues until all criteria pass.

.claude/skills/deepwork_jobs.define/SKILL.md

Lines changed: 267 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@ hooks:
1313
1414
1. **User Understanding**: Did the agent fully understand the user's workflow by asking structured questions?
1515
2. **Structured Questions Used**: Did the agent ask structured questions (using the AskUserQuestion tool) to gather user input?
16-
3. **Clear Inputs/Outputs**: Does every step have clearly defined inputs and outputs?
17-
4. **Logical Dependencies**: Do step dependencies make sense and avoid circular references?
18-
5. **Concise Summary**: Is the summary under 200 characters and descriptive?
19-
6. **Rich Description**: Does the description provide enough context for future refinement?
20-
7. **Valid Schema**: Does the job.yml follow the required schema (name, version, summary, steps)?
21-
8. **File Created**: Has the job.yml file been created in `.deepwork/jobs/[job_name]/job.yml`?
16+
3. **Document Detection**: For document-oriented workflows, did the agent detect patterns and offer DTD creation?
17+
4. **DTD Created (if applicable)**: If a DTD was needed, was it created in `.deepwork/dtds/[dtd_name].md` with proper quality criteria?
18+
5. **DTD References**: Are document outputs properly linked to their DTDs using `{file, document_type}` format?
19+
6. **Valid Against DTD**: Does the job.yml conform to the job.yml DTD quality criteria (valid identifier, semantic version, concise summary, rich description, complete steps, valid dependencies)?
20+
7. **Clear Inputs/Outputs**: Does every step have clearly defined inputs and outputs?
21+
8. **Logical Dependencies**: Do step dependencies make sense and avoid circular references?
22+
9. **Concise Summary**: Is the summary under 200 characters and descriptive?
23+
10. **Rich Description**: Does the description provide enough context for future refinement?
24+
11. **Valid Schema**: Does the job.yml follow the required schema (name, version, summary, steps)?
25+
12. **File Created**: Has the job.yml file been created in `.deepwork/jobs/[job_name]/job.yml`?
2226
2327
## Instructions
2428
@@ -76,6 +80,55 @@ Start by asking structured questions to understand what the user wants to accomp
7680
- What are the distinct stages from start to finish?
7781
- Are there any dependencies between phases?
7882

83+
### Step 1.5: Detect Document-Oriented Workflows
84+
85+
**Check for document-focused patterns** in the user's description:
86+
- Keywords: "report", "summary", "document", "create", "monthly", "quarterly", "for stakeholders", "for leadership"
87+
- Final deliverable is a specific document type (e.g., "AWS spending report", "competitive analysis", "sprint summary")
88+
- Recurring documents with consistent structure
89+
90+
**If a document-oriented workflow is detected:**
91+
92+
1. Inform the user: "This workflow produces a specific document type. I recommend defining a Document Type Definition (DTD) first to ensure consistent quality."
93+
94+
2. Ask structured questions to understand if they want to:
95+
- Create a DTD for the document type
96+
- Use an existing DTD (if any exist in `.deepwork/dtds/`)
97+
- Skip DTD and proceed with simple outputs
98+
99+
### Step 1.6: Define the Document Type Definition (if needed)
100+
101+
When creating a DTD, gather the following information:
102+
103+
1. **Document Identity**
104+
- What is the document called? (e.g., "Monthly AWS Spending Report")
105+
- Brief description of its purpose
106+
- Where should these documents be stored? (path patterns like `finance/aws-reports/*.md`)
107+
108+
2. **Audience and Context**
109+
- Who reads this document? (target audience)
110+
- How often is it produced? (frequency)
111+
112+
3. **Quality Criteria** (3-5 criteria, each with name and description)
113+
Examples for a spending report:
114+
- **Visualization**: Must include charts showing spend breakdown by service
115+
- **Variance Analysis**: Must compare current month against previous with percentages
116+
- **Action Items**: Must include recommended cost optimization actions
117+
118+
4. **Document Structure**
119+
- What sections should it have?
120+
- Any required elements (tables, charts, summaries)?
121+
122+
### Step 1.7: Create the DTD File (if needed)
123+
124+
Create the DTD file at `.deepwork/dtds/[dtd_name].md`:
125+
126+
**Template reference**: See `.deepwork/jobs/deepwork_jobs/templates/dtd.md.template` for the standard structure.
127+
128+
**Complete example**: See `.deepwork/jobs/deepwork_jobs/templates/dtd.md.example` for a fully worked example.
129+
130+
After creating the DTD, proceed to Step 2 with the DTD reference for the final step's output.
131+
79132
### Step 2: Define Each Step
80133

81134
For each major phase they mentioned, ask structured questions to gather details:
@@ -97,6 +150,7 @@ For each major phase they mentioned, ask structured questions to gather details:
97150
- Where should each output be saved? (filename/path)
98151
- Should outputs be organized in subdirectories? (e.g., `reports/`, `data/`, `drafts/`)
99152
- Will other steps need this output?
153+
- **Does this output have a DTD?** If a DTD was created in Step 1.6/1.7, reference it for the appropriate output
100154

101155
4. **Step Dependencies**
102156
- Which previous steps must complete before this one?
@@ -109,6 +163,18 @@ For each major phase they mentioned, ask structured questions to gather details:
109163

110164
**Note**: You're gathering this information to understand what instructions will be needed, but you won't create the instruction files yet - that happens in the `implement` step.
111165

166+
#### DTD-Aware Output Format
167+
168+
When a step produces a document with a DTD reference, use this format in job.yml:
169+
170+
```yaml
171+
outputs:
172+
- file: reports/monthly_spending.md
173+
dtd: monthly_aws_report # References .deepwork/dtds/monthly_aws_report.md
174+
```
175+
176+
The DTD's quality criteria will automatically be included in the generated skill, ensuring consistent document quality.
177+
112178
### Capability Considerations
113179
114180
When defining steps, identify any that require specialized tools:
@@ -203,6 +269,8 @@ This creates:
203269

204270
(Where `[job_name]` is the name of the NEW job you're creating, e.g., `competitive_research`)
205271

272+
**Document Type Definition**: See `.deepwork/dtds/job_spec.md` for the complete specification with quality criteria.
273+
206274
**Template reference**: See `.deepwork/jobs/deepwork_jobs/templates/job.yml.template` for the standard structure.
207275

208276
**Complete example**: See `.deepwork/jobs/deepwork_jobs/templates/job.yml.example` for a fully worked example.
@@ -407,19 +475,206 @@ Use branch format: `deepwork/deepwork_jobs-[instance]-YYYYMMDD`
407475
408476
**Required outputs**:
409477
- `job.yml`
478+
**Document Type**: DeepWork Job Specification
479+
> YAML specification file that defines a multi-step workflow job for AI agents
480+
**Definition**: `.deepwork/dtds/job_spec.md`
481+
**Target Audience**: AI agents executing jobs and developers defining workflows
482+
**Quality Criteria**:
483+
1. **Valid Identifier**: Job name must be lowercase with underscores, no spaces or special characters (e.g., `competitive_research`, `monthly_report`)
484+
2. **Semantic Version**: Version must follow semantic versioning format X.Y.Z (e.g., `1.0.0`, `2.1.3`)
485+
3. **Concise Summary**: Summary must be under 200 characters and clearly describe what the job accomplishes
486+
4. **Rich Description**: Description must be multi-line and explain: the problem solved, the process, expected outcomes, and target users
487+
5. **Changelog Present**: Must include a changelog array with at least the initial version entry
488+
6. **Complete Steps**: Each step must have: id (lowercase_underscores), name, description, instructions_file, outputs (at least one), and dependencies array
489+
7. **Valid Dependencies**: Dependencies must reference existing step IDs with no circular references
490+
8. **Input Consistency**: File inputs with `from_step` must reference a step that is in the dependencies array
491+
9. **Output Paths**: Outputs must be valid filenames or paths (e.g., `report.md` or `reports/analysis.md`)
492+
493+
<details>
494+
<summary>Example Document Structure</summary>
495+
496+
```markdown
497+
# DeepWork Job Specification: [job_name]
498+
499+
A `job.yml` file defines a complete multi-step workflow that AI agents can execute. Each job breaks down a complex task into reviewable steps with clear inputs and outputs.
500+
501+
## Required Fields
502+
503+
### Top-Level Metadata
504+
505+
```yaml
506+
name: job_name # lowercase, underscores only
507+
version: "1.0.0" # semantic versioning
508+
summary: "Brief description" # max 200 characters
509+
description: | # detailed multi-line explanation
510+
[Explain what this workflow does, why it exists,
511+
what outputs it produces, and who should use it]
512+
```
513+
514+
### Changelog
515+
516+
```yaml
517+
changelog:
518+
- version: "1.0.0"
519+
changes: "Initial job creation"
520+
- version: "1.1.0"
521+
changes: "Added quality validation hooks"
522+
```
523+
524+
### Steps Array
525+
526+
```yaml
527+
steps:
528+
- id: step_id # unique, lowercase_underscores
529+
name: "Human Readable Name"
530+
description: "What this step accomplishes"
531+
instructions_file: steps/step_id.md
532+
inputs:
533+
# User-provided inputs:
534+
- name: param_name
535+
description: "What the user provides"
536+
# File inputs from previous steps:
537+
- file: output.md
538+
from_step: previous_step_id
539+
outputs:
540+
- filename.md # simple filename
541+
- reports/analysis.md # path with directory
542+
# With document type reference:
543+
- file: report.md
544+
document_type: .deepwork/dtds/report_type.md
545+
dependencies:
546+
- previous_step_id # steps that must complete first
547+
```
548+
549+
## Optional Fields
550+
551+
### Exposed Steps
552+
553+
```yaml
554+
steps:
555+
- id: learn
556+
exposed: true # Makes step available without running dependencies
557+
```
558+
559+
### Quality Hooks
560+
561+
```yaml
562+
steps:
563+
- id: step_id
564+
hooks:
565+
after_agent:
566+
# Inline prompt for quality validation:
567+
- prompt: |
568+
Verify the output meets criteria:
569+
1. [Criterion 1]
570+
2. [Criterion 2]
571+
If ALL criteria are met, include `<promise>...</promise>`.
572+
# External prompt file:
573+
- prompt_file: hooks/quality_check.md
574+
# Script for programmatic validation:
575+
- script: hooks/run_tests.sh
576+
```
577+
578+
### Stop Hooks (Legacy)
579+
580+
```yaml
581+
steps:
582+
- id: step_id
583+
stop_hooks:
584+
- prompt: "Validation prompt..."
585+
- prompt_file: hooks/check.md
586+
- script: hooks/validate.sh
587+
```
588+
589+
## Validation Rules
590+
591+
1. **No circular dependencies**: Step A cannot depend on Step B if Step B depends on Step A
592+
2. **File inputs require dependencies**: If a step uses `from_step: X`, then X must be in its dependencies
593+
3. **Unique step IDs**: No two steps can have the same id
594+
4. **Valid file paths**: Output paths must not contain invalid characters
595+
5. **Instructions files exist**: Each `instructions_file` path should have a corresponding file created
596+
597+
## Example: Complete Job Specification
598+
599+
```yaml
600+
name: competitive_research
601+
version: "1.0.0"
602+
summary: "Systematic competitive analysis workflow"
603+
description: |
604+
A comprehensive workflow for analyzing competitors in your market segment.
605+
Helps product teams understand the competitive landscape through systematic
606+
identification, research, comparison, and positioning recommendations.
607+
608+
Produces:
609+
- Vetted competitor list
610+
- Research notes per competitor
611+
- Comparison matrix
612+
- Strategic positioning report
613+
614+
changelog:
615+
- version: "1.0.0"
616+
changes: "Initial job creation"
617+
618+
steps:
619+
- id: identify_competitors
620+
name: "Identify Competitors"
621+
description: "Identify 5-7 key competitors in the target market"
622+
instructions_file: steps/identify_competitors.md
623+
inputs:
624+
- name: market_segment
625+
description: "The market segment to analyze"
626+
- name: product_category
627+
description: "The product category"
628+
outputs:
629+
- competitors_list.md
630+
dependencies: []
631+
632+
- id: research_competitors
633+
name: "Research Competitors"
634+
description: "Deep dive research on each identified competitor"
635+
instructions_file: steps/research_competitors.md
636+
inputs:
637+
- file: competitors_list.md
638+
from_step: identify_competitors
639+
outputs:
640+
- research_notes.md
641+
dependencies:
642+
- identify_competitors
643+
644+
- id: positioning_report
645+
name: "Positioning Report"
646+
description: "Strategic positioning recommendations"
647+
instructions_file: steps/positioning_report.md
648+
inputs:
649+
- file: research_notes.md
650+
from_step: research_competitors
651+
outputs:
652+
- file: positioning_report.md
653+
document_type: .deepwork/dtds/positioning_report.md
654+
dependencies:
655+
- research_competitors
656+
```
657+
```
658+
659+
</details>
660+
410661
## Quality Validation
411662

412663
Stop hooks will automatically validate your work. The loop continues until all criteria pass.
413664

414665
**Criteria (all must be satisfied)**:
415666
1. **User Understanding**: Did the agent fully understand the user's workflow by asking structured questions?
416667
2. **Structured Questions Used**: Did the agent ask structured questions (using the AskUserQuestion tool) to gather user input?
417-
3. **Clear Inputs/Outputs**: Does every step have clearly defined inputs and outputs?
418-
4. **Logical Dependencies**: Do step dependencies make sense and avoid circular references?
419-
5. **Concise Summary**: Is the summary under 200 characters and descriptive?
420-
6. **Rich Description**: Does the description provide enough context for future refinement?
421-
7. **Valid Schema**: Does the job.yml follow the required schema (name, version, summary, steps)?
422-
8. **File Created**: Has the job.yml file been created in `.deepwork/jobs/[job_name]/job.yml`?
668+
3. **Document Detection**: For document-oriented workflows, did the agent detect patterns and offer DTD creation?
669+
4. **DTD Created (if applicable)**: If a DTD was needed, was it created in `.deepwork/dtds/[dtd_name].md` with proper quality criteria?
670+
5. **DTD References**: Are document outputs properly linked to their DTDs using `{file, document_type}` format?
671+
6. **Valid Against DTD**: Does the job.yml conform to the job.yml DTD quality criteria (valid identifier, semantic version, concise summary, rich description, complete steps, valid dependencies)?
672+
7. **Clear Inputs/Outputs**: Does every step have clearly defined inputs and outputs?
673+
8. **Logical Dependencies**: Do step dependencies make sense and avoid circular references?
674+
9. **Concise Summary**: Is the summary under 200 characters and descriptive?
675+
10. **Rich Description**: Does the description provide enough context for future refinement?
676+
11. **Valid Schema**: Does the job.yml follow the required schema (name, version, summary, steps)?
677+
12. **File Created**: Has the job.yml file been created in `.deepwork/jobs/[job_name]/job.yml`?
423678

424679

425680
**To complete**: Include `<promise>✓ Quality Criteria Met</promise>` in your final response only after verifying ALL criteria are satisfied.

.claude/skills/deepwork_jobs.implement/SKILL.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ Use branch format: `deepwork/deepwork_jobs-[instance]-YYYYMMDD`
319319
320320
**Required outputs**:
321321
- `steps/` (directory)
322+
322323
## Quality Validation
323324
324325
Stop hooks will automatically validate your work. The loop continues until all criteria pass.

0 commit comments

Comments
 (0)