@brunosps00/dev-workflow 2.1.0 → 2.3.0
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.
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +118 -0
- package/README.md +17 -6
- package/lib/constants.js +24 -20
- package/lib/init.js +34 -0
- package/lib/instruction-health.js +38 -0
- package/lib/post-update.js +2 -1
- package/lib/validate.js +3 -1
- package/package.json +1 -1
- package/scaffold/config/routing.json +61 -23
- package/scaffold/en/agent-instructions.md +31 -135
- package/scaffold/en/commands/dw-analyze-project.md +2 -0
- package/scaffold/en/commands/dw-autopilot.md +22 -243
- package/scaffold/en/commands/dw-bugfix.md +9 -35
- package/scaffold/en/commands/dw-claude-run.md +29 -45
- package/scaffold/en/commands/dw-codex-run.md +30 -45
- package/scaffold/en/commands/dw-context-budget.md +6 -14
- package/scaffold/en/commands/dw-copilot-run.md +29 -41
- package/scaffold/en/commands/dw-generate-pr.md +2 -2
- package/scaffold/en/commands/dw-goal.md +11 -5
- package/scaffold/en/commands/dw-harness-audit.md +2 -0
- package/scaffold/en/commands/dw-help.md +8 -4
- package/scaffold/en/commands/dw-pause.md +1 -0
- package/scaffold/en/commands/dw-plan.md +14 -7
- package/scaffold/en/commands/dw-qa.md +2 -0
- package/scaffold/en/commands/dw-report.md +169 -0
- package/scaffold/en/commands/dw-resume.md +5 -11
- package/scaffold/en/commands/dw-review.md +4 -3
- package/scaffold/en/commands/dw-run.md +19 -165
- package/scaffold/en/commands/dw-skill-health.md +7 -0
- package/scaffold/en/commands/dw-update.md +18 -4
- package/scaffold/en/commands/dw-worktree.md +100 -0
- package/scaffold/en/references/command-routing.md +53 -0
- package/scaffold/en/references/execution-contract.md +55 -0
- package/scaffold/en/templates/frontend-quality-template.md +43 -0
- package/scaffold/en/templates/task-template.md +20 -40
- package/scaffold/en/templates/tasks-template.md +9 -6
- package/scaffold/en/templates/techspec-template.md +4 -0
- package/scaffold/pt-br/agent-instructions.md +31 -135
- package/scaffold/pt-br/commands/dw-analyze-project.md +2 -0
- package/scaffold/pt-br/commands/dw-autopilot.md +22 -243
- package/scaffold/pt-br/commands/dw-bugfix.md +9 -35
- package/scaffold/pt-br/commands/dw-claude-run.md +29 -46
- package/scaffold/pt-br/commands/dw-codex-run.md +30 -45
- package/scaffold/pt-br/commands/dw-context-budget.md +6 -14
- package/scaffold/pt-br/commands/dw-copilot-run.md +29 -43
- package/scaffold/pt-br/commands/dw-generate-pr.md +2 -2
- package/scaffold/pt-br/commands/dw-goal.md +11 -5
- package/scaffold/pt-br/commands/dw-harness-audit.md +2 -0
- package/scaffold/pt-br/commands/dw-help.md +8 -4
- package/scaffold/pt-br/commands/dw-pause.md +1 -0
- package/scaffold/pt-br/commands/dw-plan.md +14 -7
- package/scaffold/pt-br/commands/dw-qa.md +2 -0
- package/scaffold/pt-br/commands/dw-report.md +169 -0
- package/scaffold/pt-br/commands/dw-resume.md +7 -11
- package/scaffold/pt-br/commands/dw-review.md +4 -3
- package/scaffold/pt-br/commands/dw-run.md +19 -165
- package/scaffold/pt-br/commands/dw-skill-health.md +7 -0
- package/scaffold/pt-br/commands/dw-update.md +18 -4
- package/scaffold/pt-br/commands/dw-worktree.md +100 -0
- package/scaffold/pt-br/references/command-routing.md +53 -0
- package/scaffold/pt-br/references/execution-contract.md +55 -0
- package/scaffold/pt-br/templates/frontend-quality-template.md +43 -0
- package/scaffold/pt-br/templates/task-template.md +20 -40
- package/scaffold/pt-br/templates/tasks-template.md +9 -6
- package/scaffold/pt-br/templates/techspec-template.md +4 -0
- package/scaffold/scripts/hooks/git-guardrails.mjs +1 -0
- package/scaffold/scripts/lib/workflow-contract.mjs +101 -0
- package/scaffold/scripts/lib/worktree-gc.mjs +460 -0
- package/scaffold/skill-registry.json +23 -23
- package/scaffold/skills/dw-cli-run/SKILL.md +33 -208
- package/scaffold/skills/dw-cli-run/references/dispatch-tuning.md +14 -72
- package/scaffold/skills/dw-codebase-intel/SKILL.md +5 -39
- package/scaffold/skills/dw-codebase-intel/agents/intel-updater.md +1 -1
- package/scaffold/skills/dw-codebase-intel/references/agents-detail.md +7 -0
- package/scaffold/skills/dw-codebase-intel/references/files-in-dw-intel-detail.md +16 -0
- package/scaffold/skills/dw-codebase-intel/references/how-dw-intel-reads-this-detail.md +12 -0
- package/scaffold/skills/dw-codebase-intel/references/how-to-compose-the-typical-flow-detail.md +11 -0
- package/scaffold/skills/dw-council/SKILL.md +2 -17
- package/scaffold/skills/dw-council/references/integration-with-other-dw-commands-detail.md +7 -0
- package/scaffold/skills/dw-council/references/phase-2-tensions-and-rebuttals-detail.md +15 -0
- package/scaffold/skills/dw-domain-modeling/SKILL.md +1 -1
- package/scaffold/skills/dw-execute-phase/SKILL.md +12 -32
- package/scaffold/skills/dw-execute-phase/agents/executor.md +15 -252
- package/scaffold/skills/dw-execute-phase/agents/plan-checker.md +4 -207
- package/scaffold/skills/dw-execute-phase/references/atomic-commits.md +8 -18
- package/scaffold/skills/dw-execute-phase/references/de-sloppify-pass-optional-cleanup-task-detail.md +12 -0
- package/scaffold/skills/dw-execute-phase/references/deviation-rules-during-execution-detail.md +8 -0
- package/scaffold/skills/dw-execute-phase/references/how-the-two-agents-compose-detail.md +7 -0
- package/scaffold/skills/dw-execute-phase/references/plan-verification.md +9 -155
- package/scaffold/skills/dw-execute-phase/references/wave-coordination.md +6 -97
- package/scaffold/skills/dw-git-discipline/SKILL.md +2 -2
- package/scaffold/skills/dw-grilling/SKILL.md +1 -1
- package/scaffold/skills/dw-incident-response/SKILL.md +1 -64
- package/scaffold/skills/dw-incident-response/references/the-five-phases-detail.md +66 -0
- package/scaffold/skills/dw-llm-eval/SKILL.md +5 -53
- package/scaffold/skills/dw-llm-eval/references/agent-tool-use-evaluation-detail.md +23 -0
- package/scaffold/skills/dw-llm-eval/references/anti-patterns-will-block-in-dw-review-code-only-detail.md +9 -0
- package/scaffold/skills/dw-llm-eval/references/consistency-run-to-run-stability-detail.md +10 -0
- package/scaffold/skills/dw-llm-eval/references/integration-with-dev-workflow-commands-detail.md +6 -0
- package/scaffold/skills/dw-llm-eval/references/the-oracle-ladder-detail.md +15 -0
- package/scaffold/skills/dw-memory/SKILL.md +4 -50
- package/scaffold/skills/dw-memory/references/context-budget.md +8 -56
- package/scaffold/skills/dw-memory/references/promotion-decision-test-detail.md +30 -0
- package/scaffold/skills/dw-minimalism/SKILL.md +4 -5
- package/scaffold/skills/dw-review-rigor/SKILL.md +1 -54
- package/scaffold/skills/dw-review-rigor/references/the-five-rules-detail.md +56 -0
- package/scaffold/skills/dw-simplification/SKILL.md +2 -55
- package/scaffold/skills/dw-simplification/references/pattern-recognition-detail.md +11 -0
- package/scaffold/skills/dw-simplification/references/the-five-rules-detail.md +48 -0
- package/scaffold/skills/dw-source-grounding/SKILL.md +1 -56
- package/scaffold/skills/dw-source-grounding/references/the-protocol-detect-fetch-implement-cite-detail.md +58 -0
- package/scaffold/skills/dw-testing-discipline/SKILL.md +25 -177
- package/scaffold/skills/dw-testing-discipline/references/agent-guardrails.md +9 -167
- package/scaffold/skills/dw-testing-discipline/references/core-rules.md +3 -3
- package/scaffold/skills/dw-testing-discipline/references/mutation-testing.md +19 -0
- package/scaffold/skills/dw-testing-discipline/references/patterns.md +3 -12
- package/scaffold/skills/dw-ui-discipline/SKILL.md +2 -59
- package/scaffold/skills/dw-ui-discipline/references/frontend-engineering.md +46 -0
- package/scaffold/skills/dw-ui-discipline/references/the-four-grounding-questions-detail.md +61 -0
- package/scaffold/skills/dw-verify/SKILL.md +26 -148
- package/scaffold/skills/dw-verify/references/verification-discovery-and-attribution.md +2 -2
- package/scaffold/skills/humanizer/SKILL.md +2 -1
- package/scaffold/skills/security-review/SKILL.md +3 -183
- package/scaffold/skills/security-review/references/do-not-flag-detail.md +49 -0
- package/scaffold/skills/security-review/references/quick-patterns-reference-detail.md +56 -0
- package/scaffold/skills/security-review/references/review-process-detail.md +84 -0
- package/scaffold/skills/vercel-react-best-practices/SKILL.md +1 -90
- package/scaffold/skills/vercel-react-best-practices/references/quick-reference-detail.md +92 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
## Agent / tool-use evaluation
|
|
2
|
+
|
|
3
|
+
Two questions distinguish good agent eval from bad:
|
|
4
|
+
|
|
5
|
+
### Question 1: outcome or trajectory?
|
|
6
|
+
|
|
7
|
+
| Approach | What it checks | Failure mode |
|
|
8
|
+
|----------|---------------|--------------|
|
|
9
|
+
| **Outcome-only** | Did the agent achieve the goal? Was the final state correct? | Misses "ghost actions" — agent did the right thing for the wrong reasons |
|
|
10
|
+
| **Trajectory** | Did the agent take the expected sequence of steps / tool calls? | Punishes legitimate creativity — agent solved it via a different valid path |
|
|
11
|
+
|
|
12
|
+
**Recommendation:** outcome-only with side-effect assertion as default. Trajectory match for cases where the path matters (e.g., "must call `get-user` before `update-user`").
|
|
13
|
+
|
|
14
|
+
### Question 2: which trajectory match mode?
|
|
15
|
+
|
|
16
|
+
When trajectory matching IS the right call, four modes are available:
|
|
17
|
+
|
|
18
|
+
- **Strict** — same tool calls, same order, same arguments. Use when both sequence and parameters are part of the contract.
|
|
19
|
+
- **Unordered** — same tool calls, any order. Use when concurrent calls are valid.
|
|
20
|
+
- **Subset** — actual trajectory contains a subset of reference calls. Use to enforce "don't exceed expected tool use" (frugality / cost).
|
|
21
|
+
- **Superset** — actual contains all reference calls plus possibly more. Use when specific tools are mandatory but extras are acceptable.
|
|
22
|
+
|
|
23
|
+
See `agent-eval.md` for examples and the decision tree.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
## Anti-patterns (will block in `/dw-review --code-only`)
|
|
2
|
+
|
|
3
|
+
- **LLM-as-judge without calibration evidence.** PR adds LLM-as-judge but the calibration Spearman score is missing or < 0.80. REJECTED.
|
|
4
|
+
- **Same-model judge.** Judge model is the same as the system under test. REJECTED unless explicitly documented (and even then, results are suspect).
|
|
5
|
+
- **Single-rung eval.** Feature ships with only LLM-as-judge; no rung 1-3 grounding. REJECTED — the cheap rungs catch the loud failures.
|
|
6
|
+
- **Synthetic-only dataset.** No traceable production-failure source for any case. REJECTED — confirm at least 20% of cases come from real user inputs.
|
|
7
|
+
- **"Looks good to me" QA.** No reference dataset, no metric, no rubric — just sampling output and calling it good. REJECTED.
|
|
8
|
+
- **Coverage as metric.** Quoting "we tested 50 prompts" without saying what was measured. The number is meaningless without the metric.
|
|
9
|
+
- **Single-run eval on a non-deterministic feature.** Each case run once at production temperature; a lucky pass reported as a pass. REJECTED — report `pass_rate` over N runs (see Consistency).
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
## Consistency (run-to-run stability)
|
|
2
|
+
|
|
3
|
+
The oracle ladder measures whether an output is *correct*; it does not measure whether the feature is *stable*. Because LLMs are non-deterministic, a case that passes once may fail the next run. Measure it:
|
|
4
|
+
|
|
5
|
+
- Re-run each case **N times** (default 3) against the same code + model + prompt.
|
|
6
|
+
- Record `pass_rate` (e.g. `2/3`) and `consistency` (fraction agreeing with the majority verdict) per case in `runs/<YYYY-MM-DD>.jsonl`.
|
|
7
|
+
- A case with pass_rate strictly between `1/N` and `(N-1)/N` is **flaky** — a signal, not a pass. A 2/3 pass hides a one-in-three production failure; investigate before shipping.
|
|
8
|
+
- Sample at the **temperature the feature uses in production** — consistency measured at temp 0 lies about a temp-0.7 feature.
|
|
9
|
+
|
|
10
|
+
Deterministic rungs (1–3) are usually stable; consistency matters most for rung 4 (LLM-as-judge) and agent trajectories. Record the run count `N` in the run log so later comparisons are apples-to-apples.
|
package/scaffold/skills/dw-llm-eval/references/integration-with-dev-workflow-commands-detail.md
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
## Integration with dev-workflow commands
|
|
2
|
+
|
|
3
|
+
- `/dw-plan tasks`: when the PRD has an AI feature requirement, an eval-plan subtask is mandatory. The task references this skill's oracle ladder.
|
|
4
|
+
- `/dw-review --code-only`: AI feature PRs require a reference dataset + ≥2 oracle rungs (lower rungs FIRST). The constitution gate also applies — if the project has principles about AI feature reliability, they're enforced here.
|
|
5
|
+
- `/dw-qa --ai`: new mode (when this skill is bundled) — runs the reference dataset against the current implementation, logs to `QA/logs/ai/<feature>-<date>.jsonl`, computes precision@k / faithfulness / outcome accuracy per the feature type.
|
|
6
|
+
- `/dw-bugfix` when the bug is an AI failure mode (hallucination, tool misuse, classification error): adds the failing case to the reference dataset BEFORE fixing — the case is now a regression test forever.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
## The oracle ladder
|
|
2
|
+
|
|
3
|
+
Five rungs, climb from CHEAPEST/STRICTEST to MOST EXPENSIVE/SUBJECTIVE. Always start at the bottom; only climb when the lower rung can't cover the case.
|
|
4
|
+
|
|
5
|
+
| Rung | What it checks | Cost | When to use |
|
|
6
|
+
|------|----------------|------|-------------|
|
|
7
|
+
| 1. **Exact match** | `output === expected` | ~free | Structured outputs (function calls, JSON with stable shape, classifications) |
|
|
8
|
+
| 2. **Schema validation** | Output matches JSON schema / type contract | ~free | Output shape matters; specific values vary |
|
|
9
|
+
| 3. **Outcome state** | Side effect produced the expected change (DB row, file written, tool called) | cheap | Agents, tool-use, RAG with concrete answers |
|
|
10
|
+
| 4. **LLM-as-judge** | A different model grades the output against a rubric | medium ($$$) | Subjective quality (helpfulness, tone, faithfulness) where no rule can decide |
|
|
11
|
+
| 5. **Human review** | Domain expert scores | expensive | Calibration of rung 4; high-stakes outputs; edge cases |
|
|
12
|
+
|
|
13
|
+
**Rule:** never reach for rung 4 before checking if rungs 1-3 can cover the case. Every rung up costs an order of magnitude more (latency, money, calibration effort) — and adds entropy.
|
|
14
|
+
|
|
15
|
+
See `oracle-ladder.md` for examples per rung and the climbing decision tree.
|
|
@@ -87,7 +87,7 @@ Create `MEMORY.md` and `<N>_memory.md` on first use with the template below. Nev
|
|
|
87
87
|
|
|
88
88
|
## Workflow
|
|
89
89
|
|
|
90
|
-
### 1. Load
|
|
90
|
+
### 1. Load relevant task memory on start or resume
|
|
91
91
|
- Read `MEMORY.md` and the current task's `<N>_memory.md` **before** any code change.
|
|
92
92
|
- Treat these as mandatory context for the run, not optional notes.
|
|
93
93
|
- If the caller marks either file for compaction, apply the Compaction Rules (below) before continuing.
|
|
@@ -116,34 +116,7 @@ Create `MEMORY.md` and `<N>_memory.md` on first use with the template below. Nev
|
|
|
116
116
|
|
|
117
117
|
## Promotion Decision Test
|
|
118
118
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
1. Will another task need this to avoid a mistake or rediscovery?
|
|
122
|
-
2. Is this fact durable across multiple runs, not just the current execution?
|
|
123
|
-
3. Is this information NOT already obvious from the PRD, TechSpec, task files, or the repository itself?
|
|
124
|
-
|
|
125
|
-
All three must be "yes" to promote. If any is "no", the item stays in task memory.
|
|
126
|
-
|
|
127
|
-
### Confidence signal
|
|
128
|
-
|
|
129
|
-
Tag each durable decision with a confidence in `[0.3–0.9]` plus the tasks that confirmed it — `… — [confidence: 0.7; seen in tasks 1,3,5]`:
|
|
130
|
-
|
|
131
|
-
- Confirmed in **≥2 of the last 3 tasks** with no contradiction → **≥0.7** (trust it; safe to act on without re-deriving).
|
|
132
|
-
- Confirmed once, or inferred but not yet reused → **0.3–0.5** (tentative; gather more signal before relying).
|
|
133
|
-
- Contradicted by a later task or the repo → lower it or drop the decision (see Error Handling).
|
|
134
|
-
|
|
135
|
-
Confidence makes cross-task learning explicit and is the signal `/dw-learn` reads to promote high-confidence decisions into durable instincts, constitution principles, or rules.
|
|
136
|
-
|
|
137
|
-
### Belongs in shared memory
|
|
138
|
-
- A discovered constraint affecting multiple tasks ("the Stripe API rate-limits to 100 req/s — batch operations must respect this")
|
|
139
|
-
- A cross-cutting architectural decision made during implementation ("chose React Server Components for data fetching across the whole feature")
|
|
140
|
-
- An open risk future tasks must account for ("migration depends on schema v3 which is not yet deployed to staging")
|
|
141
|
-
|
|
142
|
-
### Stays in task memory
|
|
143
|
-
- Files touched during this task's implementation
|
|
144
|
-
- Debugging steps taken to resolve a task-specific error
|
|
145
|
-
- The current task's objective and acceptance criteria snapshot
|
|
146
|
-
- A workaround applied only to the current task's scope
|
|
119
|
+
For promotion decision test, read `references/promotion-decision-test-detail.md`. Load only when this part of the task applies.
|
|
147
120
|
|
|
148
121
|
## Compaction Rules
|
|
149
122
|
|
|
@@ -157,26 +130,7 @@ When flagged for compaction, apply inline:
|
|
|
157
130
|
|
|
158
131
|
## Context Budget
|
|
159
132
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
**Targets:**
|
|
163
|
-
|
|
164
|
-
- **Total active context:** under **40k tokens** (rough working budget across PRD + TechSpec + tasks + MEMORY.md + per-task memory + open files).
|
|
165
|
-
- **Reserve:** at least **120k tokens** of headroom for actual reasoning, tool output, and the model's response stream.
|
|
166
|
-
- **Hard ceiling per memory file:** `MEMORY.md` ≤ 6KB; `<N>_memory.md` ≤ 3KB. Past those, compact instead of growing.
|
|
167
|
-
|
|
168
|
-
**Anti-co-load rules** (apply on every load):
|
|
169
|
-
|
|
170
|
-
1. Never load two PRD specs in the same context. If switching PRDs, drop the previous PRD's spec/techspec/tasks references from the active set.
|
|
171
|
-
2. Never load multiple archived `.dw/bugfixes/` SUMMARY.md files together — load only what's needed for the active fix or query.
|
|
172
|
-
3. Never load `.dw/intel/files.json` and `.dw/intel/deps.json` simultaneously when answering a single question — pick the primary per query shape (see `dw-codebase-intel/references/query-patterns.md`).
|
|
173
|
-
4. Never load a design proposal AND the prior design's full text — if comparing, summarize the prior into 5-10 lines.
|
|
174
|
-
|
|
175
|
-
**Monitoring signal:**
|
|
176
|
-
|
|
177
|
-
If the agent finds itself reading large files repeatedly or summarizing the same fact across multiple turns, that's a budget signal. Compact memory and explicitly drop unrelated loaded context before proceeding. Note this in `MEMORY.md` under Handoff Notes so the next task starts lean.
|
|
178
|
-
|
|
179
|
-
This budget is doctrine, not a hard gate. No command currently rejects work for exceeding 40k. The discipline lives here because future sessions read this skill first.
|
|
133
|
+
For context budget, read `references/context-budget.md`. Load only when this part of the task applies.
|
|
180
134
|
|
|
181
135
|
## Error Handling
|
|
182
136
|
|
|
@@ -199,7 +153,7 @@ Ported from Compozy's `cy-workflow-memory` skill (`/tmp/compozy/.agents/skills/c
|
|
|
199
153
|
|
|
200
154
|
- Paths are `.dw/spec/<prd-slug>/` instead of `.compozy/tasks/<name>/`.
|
|
201
155
|
- Task-local file is `<N>_memory.md` next to `<N>_task.md` (mirrors the existing dev-workflow task layout).
|
|
202
|
-
- Inline Compaction Rules (Compozy keeps them in
|
|
156
|
+
- Inline Compaction Rules (Compozy keeps them in its upstream memory-guidelines reference); the budget discipline was extracted to `references/context-budget.md` because it's about model behavior, not file management.
|
|
203
157
|
|
|
204
158
|
Credit: Compozy project (https://github.com/compozy/compozy).
|
|
205
159
|
|
|
@@ -1,63 +1,15 @@
|
|
|
1
|
-
# Context
|
|
1
|
+
# Context and memory budget
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Read when memory grows or repeated exploration obscures the active task. Context capacity and compaction behavior vary by host/model; do not assume a universal 40k active limit or 120k reserve. A model may expose telemetry; label estimates and unknown usage accurately.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Keep relevant requirements, constraints, decisions, pending work and evidence available. Read sections or query indexes when that answers the question. Comparing PRDs/designs or tracing source plus dependencies can require multiple sources; do not prohibit necessary co-loading. Avoid bulk-loading unrelated archived summaries or task memories.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- **Reasoning reserve:** **120k+ tokens** of headroom for tool output, model thinking, and response generation.
|
|
9
|
-
- **Soft alert:** when active load crosses **30k tokens**, plan to compact before the next major task.
|
|
10
|
-
- **Compaction threshold for `MEMORY.md`:** ≤ 6KB on disk.
|
|
11
|
-
- **Compaction threshold for `<N>_memory.md`:** ≤ 3KB on disk.
|
|
7
|
+
Use concise durable memory: target MEMORY.md at most 6KB and per-task memory at most 3KB, moving detailed logs to linked artifacts. These are project maintenance targets, not model capacity claims or task-completion gates. Preserve unresolved decisions, acceptance criteria, session identity and evidence when compacting.
|
|
12
8
|
|
|
13
|
-
|
|
9
|
+
Repeated reads, growing summaries and confused task boundaries are reasons to inspect context use, not proof of exceeding a hidden token threshold. Update the checkpoint if context limits threaten continuity; otherwise continue authorized work. Do not promise to evict individual messages from a host's context.
|
|
14
10
|
|
|
15
|
-
|
|
11
|
+
Use `../../dw-codebase-intel/references/query-patterns.md` for indexed queries when useful. Verification failures still require diagnosing actual code/environment; do not attribute them to context size without evidence.
|
|
16
12
|
|
|
17
|
-
|
|
13
|
+
## Attribution
|
|
18
14
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
2. **Multiple archived bugfix SUMMARY.md files.** Bugfix history queries should go through `.dw/intel/bugfixes.json` (compact, indexed), not by reading 20 SUMMARY.md files. Read individual SUMMARY.md only when the user is acting on that specific fix.
|
|
22
|
-
|
|
23
|
-
3. **Files.json + deps.json simultaneously.** They overlap. Each query has a primary file per `dw-codebase-intel/references/query-patterns.md`. Pick the primary; consult the secondary only if the primary returns nothing.
|
|
24
|
-
|
|
25
|
-
4. **A design proposal AND its predecessor's full text.** When comparing two designs, summarize the older one to 5–10 lines (the deltas the new one addresses) and reference it that way. Don't carry both in full.
|
|
26
|
-
|
|
27
|
-
5. **Per-task memories from non-adjacent tasks.** Only the current task's `<N>_memory.md` and the immediately-previous one (for handoff) belong in active context. Older `<N>_memory.md` files are durable storage — read them when explicitly handing back to an old task, not as part of routine loading.
|
|
28
|
-
|
|
29
|
-
## The monitoring signal
|
|
30
|
-
|
|
31
|
-
You will not see a token counter. You can't measure your own budget directly. But these are observable proxies that mean **you are over budget**:
|
|
32
|
-
|
|
33
|
-
- You are reading the same file twice in the same session without it having changed.
|
|
34
|
-
- You are summarizing the same fact across multiple turns to keep it in scope.
|
|
35
|
-
- You are answering questions by re-deriving from the repo what a memory file would tell you in one line.
|
|
36
|
-
- You are confusing details between two PRDs, tasks, or designs.
|
|
37
|
-
- Your turn outputs are getting longer to compensate for context that is silently slipping out of the model's attention.
|
|
38
|
-
|
|
39
|
-
When you notice any of these, stop:
|
|
40
|
-
|
|
41
|
-
1. Compact `MEMORY.md` and the active `<N>_memory.md` per the Compaction Rules in `SKILL.md`.
|
|
42
|
-
2. Explicitly state in chat what you are dropping from active context.
|
|
43
|
-
3. Note the budget event in `MEMORY.md` under Handoff Notes ("compacted at task N — see this section for what was dropped").
|
|
44
|
-
4. Resume the turn.
|
|
45
|
-
|
|
46
|
-
## What is NOT a budget problem
|
|
47
|
-
|
|
48
|
-
These look like budget problems but aren't — don't compact for them:
|
|
49
|
-
|
|
50
|
-
- **A genuinely complex task.** Some features legitimately need many files. Read what you need; the alternative (working from partial context) is worse.
|
|
51
|
-
- **A long verification report.** Verify output can be long. Don't summarize it before logging it to disk; truncate the chat surface, not the artifact.
|
|
52
|
-
- **A long user message.** The user wrote what they wrote. Don't compact to shave their words.
|
|
53
|
-
- **The first PRD load of a new feature.** First-load is fine; second-load of the same PRD in the same turn is the signal.
|
|
54
|
-
|
|
55
|
-
## Integration with other skills
|
|
56
|
-
|
|
57
|
-
- **`dw-memory` (this skill)**: compaction is the lever for memory files; this file describes when and why.
|
|
58
|
-
- **`dw-codebase-intel`**: `query-patterns.md` defines the primary-vs-secondary rule that anti-co-load rule #3 references.
|
|
59
|
-
- **`dw-verify`**: a budget-related degradation may show up as a verify regression. If verify keeps failing on facts the PRD already states, suspect budget before suspecting code.
|
|
60
|
-
|
|
61
|
-
## Source
|
|
62
|
-
|
|
63
|
-
Adapted from [`tech-leads-club/agent-skills/tlc-spec-driven`](https://github.com/tech-leads-club/agent-skills/tree/main/packages/skills-catalog/skills/(development)/tlc-spec-driven) (CC-BY-4.0, Felipe Rodrigues). The 40k target, the anti-co-load principle, and the monitoring-signal framing come from there. The specific anti-co-load pairings, file-size ceilings, and the integration with `dw-memory`/`dw-codebase-intel` are dev-workflow-specific.
|
|
15
|
+
The earlier context-budget guidance adapted tech-leads-club's [tlc-spec-driven](https://github.com/tech-leads-club/agent-skills/tree/main/packages/skills-catalog/skills/(development)/tlc-spec-driven) (CC-BY-4.0, Felipe Rodrigues). This revision retains scoped retrieval and durable handoffs; rejects universal token thresholds and unconditional anti-co-loading rules. See docs/skills-ecosystem-comparison.md in the package source for the modernization decision.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
## Promotion Decision Test
|
|
2
|
+
|
|
3
|
+
Before promoting an item from `<N>_memory.md` to `MEMORY.md`, ask:
|
|
4
|
+
|
|
5
|
+
1. Will another task need this to avoid a mistake or rediscovery?
|
|
6
|
+
2. Is this fact durable across multiple runs, not just the current execution?
|
|
7
|
+
3. Is this information NOT already obvious from the PRD, TechSpec, task files, or the repository itself?
|
|
8
|
+
|
|
9
|
+
All three must be "yes" to promote. If any is "no", the item stays in task memory.
|
|
10
|
+
|
|
11
|
+
### Confidence signal
|
|
12
|
+
|
|
13
|
+
Tag each durable decision with a confidence in `[0.3–0.9]` plus the tasks that confirmed it — `… — [confidence: 0.7; seen in tasks 1,3,5]`:
|
|
14
|
+
|
|
15
|
+
- Confirmed in **≥2 of the last 3 tasks** with no contradiction → **≥0.7** (trust it; safe to act on without re-deriving).
|
|
16
|
+
- Confirmed once, or inferred but not yet reused → **0.3–0.5** (tentative; gather more signal before relying).
|
|
17
|
+
- Contradicted by a later task or the repo → lower it or drop the decision (see Error Handling).
|
|
18
|
+
|
|
19
|
+
Confidence makes cross-task learning explicit and is the signal `/dw-learn` reads to promote high-confidence decisions into durable instincts, constitution principles, or rules.
|
|
20
|
+
|
|
21
|
+
### Belongs in shared memory
|
|
22
|
+
- A discovered constraint affecting multiple tasks ("the Stripe API rate-limits to 100 req/s — batch operations must respect this")
|
|
23
|
+
- A cross-cutting architectural decision made during implementation ("chose React Server Components for data fetching across the whole feature")
|
|
24
|
+
- An open risk future tasks must account for ("migration depends on schema v3 which is not yet deployed to staging")
|
|
25
|
+
|
|
26
|
+
### Stays in task memory
|
|
27
|
+
- Files touched during this task's implementation
|
|
28
|
+
- Debugging steps taken to resolve a task-specific error
|
|
29
|
+
- The current task's objective and acceptance criteria snapshot
|
|
30
|
+
- A workaround applied only to the current task's scope
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: dw-minimalism
|
|
3
|
-
description:
|
|
3
|
+
description: Evaluate a proposed abstraction, module or dependency for unnecessary complexity during planning or a focused over-engineering review.
|
|
4
4
|
allowed-tools:
|
|
5
5
|
- Read
|
|
6
6
|
- Grep
|
|
@@ -11,8 +11,7 @@ allowed-tools:
|
|
|
11
11
|
# dw-minimalism — Write the Least Code That Solves the Problem
|
|
12
12
|
|
|
13
13
|
The cheapest code to maintain is the code you never wrote. This skill runs a
|
|
14
|
-
**pre-generation gate**:
|
|
15
|
-
abstraction, justify it against a decision ladder. It is the missing rung
|
|
14
|
+
**pre-generation gate**: when evaluating a proposed abstraction or module, assess its necessity against the task requirements. It is the missing rung
|
|
16
15
|
between `dw-search-first` (which evaluates *external dependencies*) and
|
|
17
16
|
`dw-simplification` (which cleans up code *after* it exists).
|
|
18
17
|
|
|
@@ -21,9 +20,9 @@ between `dw-search-first` (which evaluates *external dependencies*) and
|
|
|
21
20
|
Read this skill when:
|
|
22
21
|
|
|
23
22
|
- `/dw-plan` is about to specify new modules/services — pressure-test scope before tasks are written.
|
|
24
|
-
-
|
|
23
|
+
- A task proposes an abstraction or module whose necessity is unclear.
|
|
25
24
|
- `/dw-review` flags over-engineering (speculative generality, premature abstraction, unused options).
|
|
26
|
-
- The user
|
|
25
|
+
- The user asks to assess whether a helper, wrapper, abstraction or dependency is necessary.
|
|
27
26
|
|
|
28
27
|
Do NOT use to:
|
|
29
28
|
|
|
@@ -34,60 +34,7 @@ Report only findings you are **>80% confident** are real. A style preference no
|
|
|
34
34
|
|
|
35
35
|
## The Five Rules
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
If the same pattern (e.g., missing null check, unhandled error, magic constant) appears in multiple files, **create one finding** for the most representative instance and list the other affected files inside its body. Do not create N identical findings for N files sharing one root cause.
|
|
40
|
-
|
|
41
|
-
Example — wrong:
|
|
42
|
-
```
|
|
43
|
-
- [HIGH] src/a.ts:14 — missing null check on user
|
|
44
|
-
- [HIGH] src/b.ts:22 — missing null check on user
|
|
45
|
-
- [HIGH] src/c.ts:31 — missing null check on user
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
Example — right:
|
|
49
|
-
```
|
|
50
|
-
- [HIGH] Missing null check on `user` in 3 places.
|
|
51
|
-
Representative: src/a.ts:14
|
|
52
|
-
Also affects: src/b.ts:22, src/c.ts:31
|
|
53
|
-
Fix: add `if (!user) return` at function entry.
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
### 2. Severity-order the output
|
|
57
|
-
|
|
58
|
-
Always present findings in this order: **critical → high → medium → low**. Inside each severity, order by impact or blast radius, not by file path.
|
|
59
|
-
|
|
60
|
-
Severity definitions:
|
|
61
|
-
- **critical** — correctness bug, security hole, data loss, unavailability.
|
|
62
|
-
- **high** — material deviation from PRD/TechSpec, concurrency hazard, significant perf regression, missing error handling on a user path.
|
|
63
|
-
- **medium** — maintainability cost that will hurt the next change, missing edge-case handling, inconsistent with project rules.
|
|
64
|
-
- **low** — stylistic, naming, minor readability. Often omit unless pattern-level.
|
|
65
|
-
|
|
66
|
-
### 3. Verify intent before flagging
|
|
67
|
-
|
|
68
|
-
Before creating a finding, check whether the pattern is intentional:
|
|
69
|
-
- adjacent comment explaining the choice?
|
|
70
|
-
- ADR in `.dw/spec/*/adrs/` that justifies it?
|
|
71
|
-
- test coverage that asserts the behavior?
|
|
72
|
-
- rule in `.dw/rules/` that permits it?
|
|
73
|
-
|
|
74
|
-
If the code looks suspicious but has a clear justification (e.g., `// intentionally ignoring close error on read-only handle`), do NOT create a finding. Only flag patterns that are genuinely problematic, not merely unconventional.
|
|
75
|
-
|
|
76
|
-
### 4. Skip what linters already catch
|
|
77
|
-
|
|
78
|
-
Before writing findings, ensure the project's linter/formatter has run. Anything the configured linter would flag is NOT a finding in this review — it is a linter task. Save human attention for issues linters cannot find (logic, architecture, security, requirements).
|
|
79
|
-
|
|
80
|
-
If the linter cannot run (missing tooling, build errors), note that in the summary and proceed with the review.
|
|
81
|
-
|
|
82
|
-
### 5. Signal over volume
|
|
83
|
-
|
|
84
|
-
Aim for fewer, higher-quality findings.
|
|
85
|
-
|
|
86
|
-
- Keep ALL `critical` and `high`.
|
|
87
|
-
- If total findings exceed 20, prune `medium` and `low` to the most impactful ones.
|
|
88
|
-
- A review with 8 precise findings is more useful than one with 30 that includes marginal concerns.
|
|
89
|
-
|
|
90
|
-
**Also note well-implemented aspects.** They inform the summary and calibrate tone — but they do not produce findings.
|
|
37
|
+
For the five rules, read `references/the-five-rules-detail.md`. Load only when this part of the task applies.
|
|
91
38
|
|
|
92
39
|
## Prior-Round Awareness
|
|
93
40
|
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
## The Five Rules
|
|
2
|
+
|
|
3
|
+
### 1. De-duplicate before writing
|
|
4
|
+
|
|
5
|
+
If the same pattern (e.g., missing null check, unhandled error, magic constant) appears in multiple files, **create one finding** for the most representative instance and list the other affected files inside its body. Do not create N identical findings for N files sharing one root cause.
|
|
6
|
+
|
|
7
|
+
Example — wrong:
|
|
8
|
+
```
|
|
9
|
+
- [HIGH] src/a.ts:14 — missing null check on user
|
|
10
|
+
- [HIGH] src/b.ts:22 — missing null check on user
|
|
11
|
+
- [HIGH] src/c.ts:31 — missing null check on user
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Example — right:
|
|
15
|
+
```
|
|
16
|
+
- [HIGH] Missing null check on `user` in 3 places.
|
|
17
|
+
Representative: src/a.ts:14
|
|
18
|
+
Also affects: src/b.ts:22, src/c.ts:31
|
|
19
|
+
Fix: add `if (!user) return` at function entry.
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### 2. Severity-order the output
|
|
23
|
+
|
|
24
|
+
Always present findings in this order: **critical → high → medium → low**. Inside each severity, order by impact or blast radius, not by file path.
|
|
25
|
+
|
|
26
|
+
Severity definitions:
|
|
27
|
+
- **critical** — correctness bug, security hole, data loss, unavailability.
|
|
28
|
+
- **high** — material deviation from PRD/TechSpec, concurrency hazard, significant perf regression, missing error handling on a user path.
|
|
29
|
+
- **medium** — maintainability cost that will hurt the next change, missing edge-case handling, inconsistent with project rules.
|
|
30
|
+
- **low** — stylistic, naming, minor readability. Often omit unless pattern-level.
|
|
31
|
+
|
|
32
|
+
### 3. Verify intent before flagging
|
|
33
|
+
|
|
34
|
+
Before creating a finding, check whether the pattern is intentional:
|
|
35
|
+
- adjacent comment explaining the choice?
|
|
36
|
+
- ADR in `.dw/spec/*/adrs/` that justifies it?
|
|
37
|
+
- test coverage that asserts the behavior?
|
|
38
|
+
- rule in `.dw/rules/` that permits it?
|
|
39
|
+
|
|
40
|
+
If the code looks suspicious but has a clear justification (e.g., `// intentionally ignoring close error on read-only handle`), do NOT create a finding. Only flag patterns that are genuinely problematic, not merely unconventional.
|
|
41
|
+
|
|
42
|
+
### 4. Skip what linters already catch
|
|
43
|
+
|
|
44
|
+
Before writing findings, ensure the project's linter/formatter has run. Anything the configured linter would flag is NOT a finding in this review — it is a linter task. Save human attention for issues linters cannot find (logic, architecture, security, requirements).
|
|
45
|
+
|
|
46
|
+
If the linter cannot run (missing tooling, build errors), note that in the summary and proceed with the review.
|
|
47
|
+
|
|
48
|
+
### 5. Signal over volume
|
|
49
|
+
|
|
50
|
+
Aim for fewer, higher-quality findings.
|
|
51
|
+
|
|
52
|
+
- Keep ALL `critical` and `high`.
|
|
53
|
+
- If total findings exceed 20, prune `medium` and `low` to the most impactful ones.
|
|
54
|
+
- A review with 8 precise findings is more useful than one with 30 that includes marginal concerns.
|
|
55
|
+
|
|
56
|
+
**Also note well-implemented aspects.** They inform the summary and calibrate tone — but they do not produce findings.
|
|
@@ -30,64 +30,11 @@ Do NOT use when:
|
|
|
30
30
|
|
|
31
31
|
## The Five Rules
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
Before removing or rewriting any code, answer three questions:
|
|
36
|
-
|
|
37
|
-
1. **What does it actually do?** Run/trace it; don't guess from the name.
|
|
38
|
-
2. **Why was it added?** Check `git log --follow <file> --oneline` and look at the introducing commit's message + PR. Often there's a reason.
|
|
39
|
-
3. **What breaks if it's gone?** Search for callers. Run the test suite to find what changes.
|
|
40
|
-
|
|
41
|
-
If you can't answer all three, you're not ready to simplify. Get answers first.
|
|
42
|
-
|
|
43
|
-
Concrete cases where Chesterton's Fence saves you:
|
|
44
|
-
- A "redundant" early return that handles a race condition.
|
|
45
|
-
- A "useless" type cast that fixes a compiler bug on a specific platform.
|
|
46
|
-
- A "duplicated" check that exists for clarity at the API boundary.
|
|
47
|
-
- A "dead" branch that runs only with a feature flag enabled in production.
|
|
48
|
-
|
|
49
|
-
### 2. Preserve behavior exactly
|
|
50
|
-
|
|
51
|
-
The test for "did I simplify or did I change?" is: do the existing tests still pass without modification? If yes, behavior is preserved. If you needed to update tests, you changed behavior — that's a refactor, not a simplification.
|
|
52
|
-
|
|
53
|
-
When tests are inadequate to confirm behavior preservation, write tests FIRST that document current behavior, then simplify against them. This is the test characterization technique.
|
|
54
|
-
|
|
55
|
-
### 3. Follow project conventions
|
|
56
|
-
|
|
57
|
-
Match what the project already does. If files use 2-space indent and arrow functions, your simplified version uses 2-space indent and arrow functions — even if you'd prefer 4-space and `function`. Conventions matter more than personal preference; consistency is itself a form of clarity.
|
|
58
|
-
|
|
59
|
-
Project conventions live in `.dw/rules/<module>.md` (from `/dw-analyze-project`). Read first.
|
|
60
|
-
|
|
61
|
-
### 4. Prefer clarity over cleverness
|
|
62
|
-
|
|
63
|
-
Rules of thumb:
|
|
64
|
-
|
|
65
|
-
- A line of code that takes 30 seconds to understand is worse than three lines that take 5 seconds each.
|
|
66
|
-
- A "neat trick" with comments is uglier than the boring obvious code without comments.
|
|
67
|
-
- Optimization that costs readability needs measurement (`dw-performance` skill territory) — without numbers, prefer the readable version.
|
|
68
|
-
- "Magic" that requires knowing a language feature most teammates haven't used is anti-clarity. Use it only when the alternative is genuinely worse.
|
|
69
|
-
|
|
70
|
-
### 5. Scope to recent changes
|
|
71
|
-
|
|
72
|
-
Don't go simplifying old code while you're "in there". The risk-to-benefit ratio of changing 5-year-old battle-tested code is bad. Limit simplification to:
|
|
73
|
-
|
|
74
|
-
- Code you just wrote in this session.
|
|
75
|
-
- Code your current task touches.
|
|
76
|
-
- Code with explicit recent breakage (e.g., a bug just fixed that revealed bad structure).
|
|
77
|
-
|
|
78
|
-
Out of scope: any other code, no matter how ugly. Open a task / ADR for those instead of fixing in-flight.
|
|
33
|
+
For the five rules, read `references/the-five-rules-detail.md`. Load only when this part of the task applies.
|
|
79
34
|
|
|
80
35
|
## Pattern recognition
|
|
81
36
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
| Smell | Healthy refactor | When NOT to refactor |
|
|
85
|
-
|-------|------------------|----------------------|
|
|
86
|
-
| Deep nesting (4+ levels) | Early returns / guard clauses | When the nesting maps to a real domain hierarchy (e.g., visitor pattern) |
|
|
87
|
-
| Long function (>50 lines) | Extract method | When the "natural" extraction would produce 3-4 single-call helpers — you're trading complexity for indirection |
|
|
88
|
-
| Generic name (`data`, `info`, `helper`) | Rename to specific | When the function genuinely processes generic input (e.g., a serializer middleware) |
|
|
89
|
-
| Duplication (same 5 lines twice) | Extract to function/constant | When the duplication is by design (e.g., independent business rules that may diverge) |
|
|
90
|
-
| `if/elif/else` chain (5+ branches) | Strategy pattern / lookup table | When the branches are naturally exclusive states with branch-specific logic |
|
|
37
|
+
For pattern recognition, read `references/pattern-recognition-detail.md`. Load only when this part of the task applies.
|
|
91
38
|
|
|
92
39
|
## Rule of 500 — automate large refactors
|
|
93
40
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
## Pattern recognition
|
|
2
|
+
|
|
3
|
+
Frequent simplification targets — but apply Rules 1-5 before acting:
|
|
4
|
+
|
|
5
|
+
| Smell | Healthy refactor | When NOT to refactor |
|
|
6
|
+
|-------|------------------|----------------------|
|
|
7
|
+
| Deep nesting (4+ levels) | Early returns / guard clauses | When the nesting maps to a real domain hierarchy (e.g., visitor pattern) |
|
|
8
|
+
| Long function (>50 lines) | Extract method | When the "natural" extraction would produce 3-4 single-call helpers — you're trading complexity for indirection |
|
|
9
|
+
| Generic name (`data`, `info`, `helper`) | Rename to specific | When the function genuinely processes generic input (e.g., a serializer middleware) |
|
|
10
|
+
| Duplication (same 5 lines twice) | Extract to function/constant | When the duplication is by design (e.g., independent business rules that may diverge) |
|
|
11
|
+
| `if/elif/else` chain (5+ branches) | Strategy pattern / lookup table | When the branches are naturally exclusive states with branch-specific logic |
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
## The Five Rules
|
|
2
|
+
|
|
3
|
+
### 1. Chesterton's Fence — understand BEFORE changing
|
|
4
|
+
|
|
5
|
+
Before removing or rewriting any code, answer three questions:
|
|
6
|
+
|
|
7
|
+
1. **What does it actually do?** Run/trace it; don't guess from the name.
|
|
8
|
+
2. **Why was it added?** Check `git log --follow <file> --oneline` and look at the introducing commit's message + PR. Often there's a reason.
|
|
9
|
+
3. **What breaks if it's gone?** Search for callers. Run the test suite to find what changes.
|
|
10
|
+
|
|
11
|
+
If you can't answer all three, you're not ready to simplify. Get answers first.
|
|
12
|
+
|
|
13
|
+
Concrete cases where Chesterton's Fence saves you:
|
|
14
|
+
- A "redundant" early return that handles a race condition.
|
|
15
|
+
- A "useless" type cast that fixes a compiler bug on a specific platform.
|
|
16
|
+
- A "duplicated" check that exists for clarity at the API boundary.
|
|
17
|
+
- A "dead" branch that runs only with a feature flag enabled in production.
|
|
18
|
+
|
|
19
|
+
### 2. Preserve behavior exactly
|
|
20
|
+
|
|
21
|
+
The test for "did I simplify or did I change?" is: do the existing tests still pass without modification? If yes, behavior is preserved. If you needed to update tests, you changed behavior — that's a refactor, not a simplification.
|
|
22
|
+
|
|
23
|
+
When tests are inadequate to confirm behavior preservation, write tests FIRST that document current behavior, then simplify against them. This is the test characterization technique.
|
|
24
|
+
|
|
25
|
+
### 3. Follow project conventions
|
|
26
|
+
|
|
27
|
+
Match what the project already does. If files use 2-space indent and arrow functions, your simplified version uses 2-space indent and arrow functions — even if you'd prefer 4-space and `function`. Conventions matter more than personal preference; consistency is itself a form of clarity.
|
|
28
|
+
|
|
29
|
+
Project conventions live in `.dw/rules/<module>.md` (from `/dw-analyze-project`). Read first.
|
|
30
|
+
|
|
31
|
+
### 4. Prefer clarity over cleverness
|
|
32
|
+
|
|
33
|
+
Rules of thumb:
|
|
34
|
+
|
|
35
|
+
- A line of code that takes 30 seconds to understand is worse than three lines that take 5 seconds each.
|
|
36
|
+
- A "neat trick" with comments is uglier than the boring obvious code without comments.
|
|
37
|
+
- Optimization that costs readability needs measurement (`dw-performance` skill territory) — without numbers, prefer the readable version.
|
|
38
|
+
- "Magic" that requires knowing a language feature most teammates haven't used is anti-clarity. Use it only when the alternative is genuinely worse.
|
|
39
|
+
|
|
40
|
+
### 5. Scope to recent changes
|
|
41
|
+
|
|
42
|
+
Don't go simplifying old code while you're "in there". The risk-to-benefit ratio of changing 5-year-old battle-tested code is bad. Limit simplification to:
|
|
43
|
+
|
|
44
|
+
- Code you just wrote in this session.
|
|
45
|
+
- Code your current task touches.
|
|
46
|
+
- Code with explicit recent breakage (e.g., a bug just fixed that revealed bad structure).
|
|
47
|
+
|
|
48
|
+
Out of scope: any other code, no matter how ugly. Open a task / ADR for those instead of fixing in-flight.
|
|
@@ -34,62 +34,7 @@ Do NOT use when:
|
|
|
34
34
|
|
|
35
35
|
## The Protocol — Detect → Fetch → Implement → Cite
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
Before researching anything, read the project's manifest and identify the EXACT version of the library/framework that matters:
|
|
40
|
-
|
|
41
|
-
| Stack | File | Field |
|
|
42
|
-
|-------|------|-------|
|
|
43
|
-
| Node/TS | `package.json` | `dependencies`, `devDependencies` |
|
|
44
|
-
| Python | `pyproject.toml`, `requirements*.txt`, `Pipfile.lock` | each dep with version |
|
|
45
|
-
| .NET | `*.csproj`, `packages.lock.json` | `PackageReference Version="..."` |
|
|
46
|
-
| Rust | `Cargo.toml`, `Cargo.lock` | `[dependencies]` |
|
|
47
|
-
|
|
48
|
-
Record the version. If a range (`^4.18.0`), note the lockfile-resolved version.
|
|
49
|
-
|
|
50
|
-
If no manifest exists OR the dep is not yet in the manifest (e.g., choosing what to install), record "no version yet — choosing fresh".
|
|
51
|
-
|
|
52
|
-
### 2. Fetch — pull the matching version's official docs
|
|
53
|
-
|
|
54
|
-
Authority hierarchy:
|
|
55
|
-
|
|
56
|
-
1. **Official docs** for the EXACT version (or nearest stable). E.g., `react.dev/reference/react?version=18` not `react.dev` default.
|
|
57
|
-
2. **Official changelog / migration guide** when transitioning across versions.
|
|
58
|
-
3. **Web standards** (MDN, RFCs, W3C) for cross-implementation behavior.
|
|
59
|
-
4. **Compatibility tables** (caniuse, Compat data) for API support across runtimes.
|
|
60
|
-
|
|
61
|
-
Forbidden as primary source:
|
|
62
|
-
|
|
63
|
-
- Stack Overflow answers (use only as discovery, then verify via official).
|
|
64
|
-
- Tutorial blogs (frequently outdated; never authoritative).
|
|
65
|
-
- AI training data (your training is months/years stale).
|
|
66
|
-
- README screenshots from random GitHub repos.
|
|
67
|
-
|
|
68
|
-
Fetch via `WebFetch` or `mcp__context7__*` if available. If both fail, surface to the user that you're falling back to training-data knowledge AND mark the citation `[source: training-data, unverified]`.
|
|
69
|
-
|
|
70
|
-
### 3. Implement — apply the documented pattern
|
|
71
|
-
|
|
72
|
-
Use exactly the API the documented version provides. Don't mix patterns from multiple versions ("this useEffect example is from React 16; you're on 18.3"). When the doc shows multiple acceptable patterns, pick the simplest that matches the project's style.
|
|
73
|
-
|
|
74
|
-
If the doc presents migration warnings (e.g., "deprecated in v5, use X instead"), follow the new path unless the project explicitly pins to the old version for a documented reason.
|
|
75
|
-
|
|
76
|
-
### 4. Cite — record the source verifiably
|
|
77
|
-
|
|
78
|
-
Every decision that depended on an external source ends with a citation block:
|
|
79
|
-
|
|
80
|
-
```
|
|
81
|
-
[source: <url>, version: <X.Y>, retrieved: <YYYY-MM-DD>]
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
Examples:
|
|
85
|
-
|
|
86
|
-
```
|
|
87
|
-
[source: https://react.dev/reference/react/useEffect, version: 18.3, retrieved: 2026-05-07]
|
|
88
|
-
[source: https://docs.python.org/3.12/library/asyncio-task.html, version: 3.12, retrieved: 2026-05-07]
|
|
89
|
-
[source: https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/welcome.html, version: SDK v3, retrieved: 2026-05-07]
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
When citing in PRDs, techspecs, decision logs, or deps-audit reports, the citation is mandatory adjacent to each claim. A future engineer reading the doc can click and verify.
|
|
37
|
+
For the protocol — detect → fetch → implement → cite, read `references/the-protocol-detect-fetch-implement-cite-detail.md`. Load only when this part of the task applies.
|
|
93
38
|
|
|
94
39
|
## How `dw-create-techspec` uses this
|
|
95
40
|
|