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: teach learn workflow to create deepschemas and deepreview rules (#327)
* feat: inject sorted git diff into broad review rule prompts
Rules with strategy all_changed_files or matches_together and a **/*
matcher now get git diff main..HEAD pre-fetched and injected into the
review instruction file. The diff is sorted by filepath to group files
by directory, reducing reviewer turn count. Diff is scoped to the
rule's source_dir so subdirectory .deepreview files get narrower diffs.
Also streamlines the /review skill to skip the get_configured_reviews
call and go straight to get_review_instructions.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat: teach learn workflow to create deepschemas and deepreview rules
The learn workflow now evaluates whether deepschemas or deepreview rules
could prevent issues encountered during a session, covering both process
mistakes and the substance of the work. Adds a "Preventable" classification,
a new Step 7 with actionable instructions for creating anonymous/named
deepschemas and deepreview rules, and a process requirement ensuring
prevention opportunities are always evaluated.
Also adds a filesystem-verifiable requirement to the deepschema meta-schema,
ensuring all deepschema requirements can be checked from filesystem assets.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat: add claude_settings deepschema and enforce JSON-schema-first requirements
- Add .deepwork/schemas/claude_settings/ with deepschema.yml (semantic
requirements) and vendored SchemaStore JSON Schema for structural validation
- Add no-structural-requirements rule to deepschema standard schema: requirements
must not restate what json_schema_path already enforces
- Update /deepschema skill with JSON Schema First guidance: maximize structural
validation, check SchemaStore for existing schemas, vendor local copies
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* docs: update architecture.md to reflect learn workflow's preventive automation
The learn workflow now evaluates prevention opportunities and creates
DeepSchemas and DeepReview rules. Updated three sections in architecture.md
to document this capability.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor: move knowledge-based deepschema requirements to instructions
Requirements about author understanding (sandbox path semantics, automode
defaults replacement, attribution deprecation, sandbox write paths) are not
filesystem-verifiable. Moved them to the instructions section and kept only
requirements that can be checked by examining file contents.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* style: fix ruff formatting in review/instructions.py
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
description: "Community-maintained JSON Schema on SchemaStore — the most comprehensive structural schema available. Consider syncing our local schema with this periodically."
- Cleans up and migrates DeepWork configurations from prior versions
485
485
- **`learn`** workflow: `learn`
486
-
- Analyzes conversation history to improve job instructions and capture learnings
486
+
- Analyzes conversation history to improve job instructions, capture learnings, and create preventive automation (DeepSchemas and DeepReview rules)
487
487
488
488
These are auto-discovered at runtime by the MCP server from the Python package.
489
489
@@ -532,7 +532,7 @@ User: /deepwork new_job
532
532
533
533
### The `learn` Workflow
534
534
535
-
Analyzes conversation history to improve job instructions and capture learnings:
535
+
Analyzes conversation history to improve job instructions, capture learnings, and create preventive automation:
536
536
537
537
```
538
538
User: /deepwork_jobs.learn
@@ -551,10 +551,14 @@ Claude: I'll analyze this conversation for DeepWork job executions...
551
551
Bespoke learnings captured:
552
552
✓ Created AGENTS.md with project-specific notes about this competitive research instance
553
553
554
+
Prevention opportunities evaluated:
555
+
✓ Created DeepSchema for competitor_profiles/ output format
556
+
✓ Added DeepReview rule to enforce source prioritization in research steps
557
+
554
558
Job instructions updated in place. Changes take effect on next workflow run.
555
559
```
556
560
557
-
This standalone skill can be run anytime after executing a job to capture learnings and improve instructions.
561
+
This standalone skill can be run anytime after executing a job to capture learnings, improve instructions, and create preventive automation (DeepSchemas and DeepReview rules).
558
562
559
563
### Step Instructions at Runtime
560
564
@@ -742,6 +746,7 @@ The `/deepwork_jobs.define` command:
**The `json_schema_path` file is the primary enforcement mechanism.** Every constraint that _can_ be expressed structurally MUST go in the JSON Schema, not in requirements. Requirements exist only for semantic rules that JSON Schema cannot express.
85
+
86
+
Put in the JSON Schema (not requirements):
87
+
- File format validity (valid JSON, valid YAML)
88
+
- Field types (string, number, boolean, array, object)
- Array item types and constraints (`minItems`, `uniqueItems`)
93
+
- Numeric ranges (`minimum`, `maximum`)
94
+
- String patterns (`pattern`, `format`)
95
+
- Conditional field presence (`if`/`then` — e.g., "when type is 'http', url is required")
96
+
- Nested object shapes and their constraints
97
+
98
+
Put in requirements (not the JSON Schema):
99
+
- Semantic rules about _meaning_ ("secrets MUST NOT appear in shared settings")
100
+
- Cross-file concerns ("this field MUST reference an existing named schema")
101
+
- Behavioral gotchas ("sandbox paths use different prefix semantics than permission paths")
102
+
- Design guidance ("deny rules SHOULD be used for hard security boundaries, not soft preferences")
103
+
- Anything requiring judgment or context a machine validator cannot assess
104
+
105
+
**Build the JSON Schema to be as strict and comprehensive as possible.** Use `additionalProperties: false` to catch typos. Use enums for closed sets. Use `if/then` for conditional requirements. Use `pattern` for string formats. Use `$defs` and `$ref` for reusable types. Use `anyOf` for discriminated unions. Use `uniqueItems`, `minLength`, `minItems` where appropriate. A good JSON Schema catches errors at write time before a reviewer ever sees the file. Requirements that duplicate what the schema already enforces are noise — they dilute the reviewer's attention and risk contradicting the schema.
106
+
107
+
### Check SchemaStore for Existing Schemas
108
+
109
+
Before writing a JSON Schema from scratch, check whether a published schema already exists at [SchemaStore](https://www.schemastore.org/) (`https://json.schemastore.org/<name>.json`). SchemaStore hosts community-maintained schemas for hundreds of config file formats.
110
+
111
+
If a good schema exists:
112
+
1. **Vendor a local copy** into your schema directory (e.g., `claude_settings.schema.json`)
113
+
2. **Add a `_source` field** at the top of the file with the original URL and sync date:
114
+
```json
115
+
{
116
+
"_source": "Vendored from https://json.schemastore.org/example.json. To update: fetch the latest version from that URL and replace this file. Last synced: 2026-04-01."
117
+
}
118
+
```
119
+
3. **Point `json_schema_path`** at the local copy — this avoids network dependencies during validation
120
+
4. **Periodically re-fetch** the upstream schema to pick up improvements — the `_source` field tells future maintainers where to look
Copy file name to clipboardExpand all lines: specs/deepwork/review/REVIEW-REQ-004-rule-matching-and-strategies.md
+10-1Lines changed: 10 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ After discovering review rules (REVIEW-REQ-002) and changed files (REVIEW-REQ-00
19
19
### REVIEW-REQ-004.2: Review Task Data Model
20
20
21
21
1. Each review task MUST be represented as a `ReviewTask` dataclass.
22
-
2. The `ReviewTask` MUST contain: `rule_name` (str), `files_to_review` (list[str] — paths relative to repo root), `instructions` (str), `agent_name` (str | None), `source_location` (str — formatted as `"path:line"`), `additional_files` (list[str] — unchanged matching files, relative to repo root), `all_changed_filenames` (list[str] | None).
22
+
2. The `ReviewTask` MUST contain: `rule_name` (str), `files_to_review` (list[str] — paths relative to repo root), `instructions` (str), `agent_name` (str | None), `source_location` (str — formatted as `"path:line"`), `additional_files` (list[str] — unchanged matching files, relative to repo root), `all_changed_filenames` (list[str] | None), `git_diff_output` (str | None — pre-fetched diff for broad rules, see REVIEW-REQ-004.11).
23
23
3.`files_to_review` MUST always contain at least one file path.
24
24
4.`source_location` MUST be formatted as `"{relative_path}:{line_number}"` where the path is relative to the project root (e.g., `"src/.deepreview:5"`).
25
25
@@ -71,3 +71,12 @@ After discovering review rules (REVIEW-REQ-002) and changed files (REVIEW-REQ-00
71
71
1. Rules with the same name defined in different `.deepreview` files MUST produce independent `ReviewTask` objects. The system MUST NOT merge or combine matched files across rules from different source directories.
72
72
2. When two `.deepreview` files in different directories define a rule with the same name and the same strategy, and changed files match both rules, the system MUST create separate `ReviewTask` objects — one per directory — each containing only the files that matched within its own `source_dir`.
73
73
3. This isolation is a consequence of REVIEW-REQ-004.1.2 (files outside `source_dir` do not match) but is stated explicitly because `.deepreview` files can be templated or symlinked across directories, making same-name rules a common scenario.
74
+
75
+
### REVIEW-REQ-004.11: Git Diff Injection for Broad Rules
76
+
77
+
1. When a rule has strategy `"all_changed_files"` or `"matches_together"` AND its `include` patterns contain `**/*`, the system MUST run `git diff <merge-base>..HEAD` and attach the output to the resulting `ReviewTask` as `git_diff_output`.
78
+
2. The git diff MUST be computed at most once per unique `source_dir` per `match_files_to_rules` invocation, even if multiple rules with the same `source_dir` qualify for injection.
79
+
3. If the git diff command fails or produces empty output, `git_diff_output` MUST be `None`.
80
+
4. Rules with strategy `"individual"` MUST NOT receive `git_diff_output`, regardless of their include patterns.
81
+
5. The `ReviewTask` dataclass MUST include a `git_diff_output: str | None` field defaulting to `None`.
82
+
6. When a rule's `source_dir` is a subdirectory of the project root, the git diff MUST be scoped to that subdirectory (via `-- <relpath>` pathspec). When `source_dir` equals the project root, the diff MUST cover the entire repository.
Copy file name to clipboardExpand all lines: specs/deepwork/review/REVIEW-REQ-005-instruction-generation.md
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,13 @@ For each `ReviewTask`, the system generates a self-contained markdown instructio
16
16
6. When the task has `additional_files` (unchanged matching files), the file MUST contain an "Unchanged Matching Files" section listing those file paths.
17
17
7. When the task has `all_changed_filenames`, the file MUST contain an "All Changed Files" section listing every changed filename for context.
18
18
19
+
### REVIEW-REQ-005.7: Git Diff Section
20
+
21
+
1. When a `ReviewTask` has a non-null `git_diff_output`, the instruction file MUST contain a section headed `## Output from \`git diff main..HEAD\` for you to review (sorted by filepath)`.
22
+
2. The diff output MUST be rendered inside a fenced code block with the `diff` language tag.
23
+
3. This section MUST appear after the "Files to Review" section and before the "All Changed Files" section.
24
+
4. When `git_diff_output` is `None`, this section MUST be omitted.
25
+
19
26
### REVIEW-REQ-005.2: File Path Formatting
20
27
21
28
1. File paths in the "Files to Review" section MUST be prefixed with `@` to trigger Claude Code's file-reading behavior (e.g., `@src/app.py`).
0 commit comments