create-harness-vibe-coding 0.8.2 → 0.8.4
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/README-CN.md +2 -2
- package/README.md +2 -3
- package/package.json +1 -2
- package/src/generator.js +4 -5
- package/templates/common/.claude/agents/context-master.md +3 -2
- package/templates/common/.claude/agents/memory-master.md +3 -2
- package/templates/common/.claude/agents/tdd-guide.md +45 -19
- package/templates/common/.claude/agents/test-writer.md +52 -38
- package/templates/common/.claude/commands/wf-help.md +21 -0
- package/templates/common/.claude/rules/ecc/common.md +1 -1
- package/templates/common/.claude/settings.json +33 -90
- package/templates/common/.claude/skills/tdd/SKILL.md +18 -11
- package/templates/common/.claude/skills/wf-auto/SKILL.md +1 -1
- package/templates/common/.codex/config.toml +0 -2
- package/templates/common/.harness-version +55 -37
- package/templates/common/AGENTS.md +7 -6
- package/templates/common/CLAUDE.md +3 -4
- package/templates/common/Harness/ACCEPTANCE_PROTOCOL.md +170 -0
- package/templates/common/Harness/AGENT_ISOLATION.md +73 -0
- package/templates/common/Harness/DEBUG_PROTOCOL.md +64 -0
- package/templates/common/Harness/ECC-GUIDE.md +4 -4
- package/templates/common/Harness/HARNESS_BRIDGE.md +128 -0
- package/templates/common/Harness/MEMORY_PROTOCOL.md +114 -0
- package/templates/common/Harness/README.md +31 -16
- package/templates/common/Harness/TDD-GUIDE.md +138 -56
- package/templates/common/Harness/WF-AUTO.md +77 -16
- package/templates/common/Harness/WF-MAX.md +81 -22
- package/templates/common/Harness/WF.md +38 -18
- package/templates/common/Harness/agent-workflow.md +47 -22
- package/templates/common/Harness/context-loading.md +33 -32
- package/templates/common/Harness/dispatch.md +10 -4
- package/templates/common/Harness/extension.md +3 -3
- package/templates/common/Harness/lifecycle.md +19 -13
- package/templates/common/Harness/research/PRD.md +18 -9
- package/templates/common/Harness/subagents.md +41 -14
- package/templates/common/Harness/tasks/_template/NAMING.md +2 -2
- package/templates/common/Harness/tasks/_template/PLAN.md +53 -11
- package/templates/common/Harness/templates/ACCEPTANCE.template.md +20 -0
- package/templates/common/Harness/templates/API_CONTRACT.template.md +40 -0
- package/templates/common/Harness/templates/PLAYWRIGHT_SPEC.template.ts +21 -0
- package/templates/common/Harness/templates/PRD.template.md +45 -0
- package/templates/common/Harness/templates/TEST_PLAN.template.md +14 -0
- package/templates/common/Harness/templates/UI_CONTRACT.template.md +11 -0
- package/templates/common/Harness/templates/VALIDATION_REPORT.template.md +20 -0
- package/templates/common/MEMORY.md +14 -3
- package/templates/common/README.md +1 -1
- package/templates/common/SETUP.md +24 -20
- package/templates/common/scripts/validate-harness.mjs +134 -41
- package/templates/common/scripts/wf-remove.mjs +6 -2
- package/templates/optional/skills/browser-e2e/Harness/workflows/browser-e2e.md +11 -3
- package/templates/optional/skills/ts-react-frontend/Harness/workflows/ts-react-frontend.md +1 -1
- package/templates/common/.codex/hooks.json +0 -59
- package/templates/common/scripts/wf-mode-hook.mjs +0 -895
- package/templates/common/scripts/wf-statusline.ps1 +0 -62
- package/templates/common/scripts/wf-statusline.sh +0 -67
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# Harness Bridge
|
|
2
|
+
|
|
3
|
+
Purpose: define a test-only bridge for validating frontend, backend, state, and side effects without making test selectors part of production behavior.
|
|
4
|
+
|
|
5
|
+
Harness Bridge is not a business feature. It is enabled only in dev/test environments and must be absent or inert in production builds.
|
|
6
|
+
|
|
7
|
+
## Modules
|
|
8
|
+
|
|
9
|
+
| Module | Purpose | Output |
|
|
10
|
+
| --- | --- | --- |
|
|
11
|
+
| UI Test ID Contract | stable selectors for browser tests | `UI_CONTRACT.md` or task contract table |
|
|
12
|
+
| API Contract | endpoint, payload, response, and failure behavior | `API_CONTRACT.md` or OpenAPI/schema reference |
|
|
13
|
+
| Test Data Seeder | deterministic local data and mock external services | seed script or test fixture |
|
|
14
|
+
| Runtime State Probe | test-only access to route/store/toast state | `window.__HARNESS__` or equivalent |
|
|
15
|
+
| Network Trace Collector | CDP/Playwright capture of request/response behavior | trace file and assertion output |
|
|
16
|
+
|
|
17
|
+
## UI Test ID Contract
|
|
18
|
+
|
|
19
|
+
Every critical interactive element needs a stable selector before UI acceptance.
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
<button data-testid="login-submit-button">Log in</button>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Contract shape:
|
|
26
|
+
|
|
27
|
+
```markdown
|
|
28
|
+
# UI Contract
|
|
29
|
+
|
|
30
|
+
| Element | data-testid | Role | AC IDs |
|
|
31
|
+
| --- | --- | --- | --- |
|
|
32
|
+
| Phone input | `phone-input` | input phone number | AC-001, AC-002 |
|
|
33
|
+
| Submit button | `login-submit-button` | submit login | AC-004, AC-006 |
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
No `data-testid`, no UI acceptance, unless a stable accessible role/label is explicitly documented.
|
|
37
|
+
|
|
38
|
+
## API Contract
|
|
39
|
+
|
|
40
|
+
API-facing ACs need method, URL, payload, success response, failure response, and side effects.
|
|
41
|
+
|
|
42
|
+
````markdown
|
|
43
|
+
# API Contract
|
|
44
|
+
|
|
45
|
+
## POST /api/auth/send-code
|
|
46
|
+
|
|
47
|
+
Request:
|
|
48
|
+
```json
|
|
49
|
+
{ "phone": "13800138000" }
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Success:
|
|
53
|
+
```json
|
|
54
|
+
{ "ok": true }
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Failure:
|
|
58
|
+
```json
|
|
59
|
+
{ "ok": false, "message": "Invalid phone number" }
|
|
60
|
+
```
|
|
61
|
+
````
|
|
62
|
+
|
|
63
|
+
No API contract, no backend integration acceptance.
|
|
64
|
+
|
|
65
|
+
## Test Data Seeder
|
|
66
|
+
|
|
67
|
+
E2E tests must not depend on real SMS, payment providers, emails, or third-party side effects.
|
|
68
|
+
|
|
69
|
+
Example contract:
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
await bridge.seed({
|
|
73
|
+
user: {
|
|
74
|
+
phone: "13800138000",
|
|
75
|
+
code: "123456"
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Seeder requirements:
|
|
81
|
+
|
|
82
|
+
- deterministic
|
|
83
|
+
- resettable between tests
|
|
84
|
+
- scoped to dev/test
|
|
85
|
+
- records seeded IDs needed for assertions
|
|
86
|
+
|
|
87
|
+
## Runtime State Probe
|
|
88
|
+
|
|
89
|
+
Expose only safe test state in dev/test:
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
window.__HARNESS__ = {
|
|
93
|
+
getRoute: () => router.currentRoute.value,
|
|
94
|
+
getAuthState: () => authStore.state,
|
|
95
|
+
getLastToast: () => toastStore.lastMessage
|
|
96
|
+
};
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Playwright may assert:
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
const authState = await page.evaluate(() => window.__HARNESS__.getAuthState());
|
|
103
|
+
expect(authState.isLoggedIn).toBe(true);
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Production builds must not expose secrets, tokens, private user data, or privileged mutation APIs through `window.__HARNESS__`.
|
|
107
|
+
|
|
108
|
+
## Network Trace Collector
|
|
109
|
+
|
|
110
|
+
For frontend-backend ACs, collect network evidence:
|
|
111
|
+
|
|
112
|
+
```text
|
|
113
|
+
user action
|
|
114
|
+
-> CDP/Playwright records request
|
|
115
|
+
-> assert URL, method, payload, response, duplicate-request behavior
|
|
116
|
+
-> compare against API Contract
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Minimum checks:
|
|
120
|
+
|
|
121
|
+
- request sent or intentionally not sent
|
|
122
|
+
- method and URL
|
|
123
|
+
- payload shape and key values
|
|
124
|
+
- response handling
|
|
125
|
+
- disabled/loading behavior prevents duplicate submission
|
|
126
|
+
- error state for network failure
|
|
127
|
+
|
|
128
|
+
Trace evidence belongs under the task evidence folder or Playwright `test-results/`.
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# Memory Protocol
|
|
2
|
+
|
|
3
|
+
Purpose: record durable lessons from acceptance, validation, and debug work without storing noisy or sensitive context.
|
|
4
|
+
|
|
5
|
+
Memory is downstream of evidence. It records reusable patterns, not raw transcripts.
|
|
6
|
+
|
|
7
|
+
## When To Write Memory
|
|
8
|
+
|
|
9
|
+
Write memory when any condition applies:
|
|
10
|
+
|
|
11
|
+
- the same tool or command pattern fails 3+ times
|
|
12
|
+
- the user corrects the same assumption or preference 2+ times
|
|
13
|
+
- a review/debug loop reveals a reusable lesson
|
|
14
|
+
- WF closeout extracts durable acceptance, validation, or debug knowledge
|
|
15
|
+
|
|
16
|
+
## What To Record
|
|
17
|
+
|
|
18
|
+
Memory entries should be short, newest-first, and AC-aware when possible:
|
|
19
|
+
|
|
20
|
+
```markdown
|
|
21
|
+
## 2026-07-02 - Playwright login validation needs network trace
|
|
22
|
+
|
|
23
|
+
- Context: AC-003 passed visually but failed API payload validation.
|
|
24
|
+
- Lesson: For login flows, require CDP/Playwright request assertions in addition to DOM checks.
|
|
25
|
+
- Applies to: `ACCEPTANCE_PROTOCOL.md`, `HARNESS_BRIDGE.md`
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Good memory:
|
|
29
|
+
|
|
30
|
+
- failure mode
|
|
31
|
+
- root cause pattern
|
|
32
|
+
- better command or protocol
|
|
33
|
+
- affected AC IDs or workflow docs
|
|
34
|
+
- proof that the lesson is durable
|
|
35
|
+
|
|
36
|
+
Bad memory:
|
|
37
|
+
|
|
38
|
+
- secrets, tokens, credentials, private user data
|
|
39
|
+
- full logs when a summary is enough
|
|
40
|
+
- transient speculation
|
|
41
|
+
- implementation summaries with no reusable lesson
|
|
42
|
+
|
|
43
|
+
## Closeout Flow
|
|
44
|
+
|
|
45
|
+
For WF closeout:
|
|
46
|
+
|
|
47
|
+
```text
|
|
48
|
+
context-master
|
|
49
|
+
-> extract durable acceptance/debug/validation lessons
|
|
50
|
+
-> memory-master
|
|
51
|
+
-> deduplicate
|
|
52
|
+
-> write concise memory entry
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Memory Master writes to:
|
|
56
|
+
|
|
57
|
+
- `Harness/memory/tool-usage-reflections.md`
|
|
58
|
+
- `Harness/memory/user-corrections-preferences.md`
|
|
59
|
+
- `Harness/memory/agent-lessons-patterns.md`
|
|
60
|
+
- `Harness/MEMORY.md` only for routing/index updates
|
|
61
|
+
|
|
62
|
+
## Scenario Memory Hints
|
|
63
|
+
|
|
64
|
+
Controllers, context-master, or memory-master may load a compact memory hint
|
|
65
|
+
when the current task matches a known scenario. Hints must be scenario-specific
|
|
66
|
+
and must not dump full memory files into context.
|
|
67
|
+
|
|
68
|
+
Scenario hints are allowed when they help the current task avoid a known failure
|
|
69
|
+
mode:
|
|
70
|
+
|
|
71
|
+
| Scenario | Load Or Hint |
|
|
72
|
+
| --- | --- |
|
|
73
|
+
| new session / startup | `Harness/MEMORY.md` index only |
|
|
74
|
+
| same tool or command error repeats | matching entries from `memory/tool-usage-reflections.md` |
|
|
75
|
+
| user repeats a correction or preference | matching entries from `memory/user-corrections-preferences.md` |
|
|
76
|
+
| review/debug/validation failure | matching entries from `memory/agent-lessons-patterns.md` |
|
|
77
|
+
| acceptance/UI/API work | relevant AC/debug lessons plus `ACCEPTANCE_PROTOCOL.md` and `HARNESS_BRIDGE.md` |
|
|
78
|
+
| WF closeout | context-master extraction, then memory-master write/dedup |
|
|
79
|
+
| `/wf-auto` cycle start | auto PROGRESS/PLAN summary plus memory hints tied to the selected angle |
|
|
80
|
+
|
|
81
|
+
Hint rules:
|
|
82
|
+
|
|
83
|
+
- load or summarize 3-10 bullets, not whole memory files
|
|
84
|
+
- include file paths and trigger reasons
|
|
85
|
+
- include AC IDs or failure signatures when available
|
|
86
|
+
- load nothing when no relevant memory exists
|
|
87
|
+
- never inject secrets, credentials, tokens, private data, or raw transcripts
|
|
88
|
+
- memory-master owns writes; controller/context-master route context
|
|
89
|
+
|
|
90
|
+
## Memory Write Flow
|
|
91
|
+
|
|
92
|
+
Memory write triggers must never append raw logs directly to memory files.
|
|
93
|
+
|
|
94
|
+
Safe write flow:
|
|
95
|
+
|
|
96
|
+
```text
|
|
97
|
+
controller detects trigger
|
|
98
|
+
-> context-master extracts durable candidate
|
|
99
|
+
-> memory-master reads existing memory
|
|
100
|
+
-> memory-master deduplicates or merges
|
|
101
|
+
-> memory-master writes concise entry
|
|
102
|
+
-> controller records file path and reason
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Traceability
|
|
106
|
+
|
|
107
|
+
When a lesson comes from acceptance work, include:
|
|
108
|
+
|
|
109
|
+
- AC ID or contract name
|
|
110
|
+
- command or validation method
|
|
111
|
+
- failure layer
|
|
112
|
+
- final fix or operating rule
|
|
113
|
+
|
|
114
|
+
This keeps future agents from relearning the same acceptance gap.
|
|
@@ -7,7 +7,7 @@ Default load: `CLAUDE.md`, `Harness/MEMORY.md`, this file, and `Harness/PROGRESS
|
|
|
7
7
|
## 0-1 Flow
|
|
8
8
|
|
|
9
9
|
```text
|
|
10
|
-
Idea -> Research -> PRD ->
|
|
10
|
+
Idea -> Research -> Mini PRD -> Acceptance Criteria -> Contracts -> Tests -> Build -> Independent Validation -> Debug -> Memory
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
For the full phase contract, load [lifecycle.md](lifecycle.md).
|
|
@@ -24,7 +24,10 @@ For the full phase contract, load [lifecycle.md](lifecycle.md).
|
|
|
24
24
|
- Core rules live in `CLAUDE.md` and `.claude/rules/ecc/common.md`.
|
|
25
25
|
- WF mode rules live in [WF.md](WF.md).
|
|
26
26
|
- Phase rules live in [lifecycle.md](lifecycle.md).
|
|
27
|
-
- Build, review, test, and subagent rules live in [agent-workflow.md](agent-workflow.md).
|
|
27
|
+
- Build, review, test, and subagent rules live in [agent-workflow.md](agent-workflow.md); AC-linked TDD rules live in [TDD-GUIDE.md](TDD-GUIDE.md).
|
|
28
|
+
- Acceptance-driven gates live in [ACCEPTANCE_PROTOCOL.md](ACCEPTANCE_PROTOCOL.md). PRD-derived Acceptance Criteria are the source of truth for implementation, tests, review, validation, debug, and memory.
|
|
29
|
+
- Role/context isolation rules live in [AGENT_ISOLATION.md](AGENT_ISOLATION.md).
|
|
30
|
+
- Frontend-backend test harness and CDP/network evidence rules live in [HARNESS_BRIDGE.md](HARNESS_BRIDGE.md).
|
|
28
31
|
- Parallel dispatch rules live in [dispatch.md](dispatch.md).
|
|
29
32
|
- Subagent orchestration methodology lives in [subagents.md](subagents.md).
|
|
30
33
|
- Extension rules live in [extension.md](extension.md).
|
|
@@ -57,21 +60,22 @@ Routing priority: if a request explicitly says `/wf <task>`, `$wf`, `wf mode`, `
|
|
|
57
60
|
| --- | --- | --- | --- |
|
|
58
61
|
| Raw idea or vague product request | idea, vague, clarify, goal, non-goal, lifecycle | [lifecycle.md](lifecycle.md), [research/PRD.md](research/PRD.md) | clarified goal, non-goals, first questions |
|
|
59
62
|
| Need market/tech direction | research, market, competitor, stack, library, pricing, policy | [research/README.md](research/README.md), [research/research-results.md](research/research-results.md) | research protocol, adopted/rejected choices |
|
|
60
|
-
| Need MVP/spec | PRD, MVP, scope, requirement, acceptance, non-goal | [research/PRD.md](research/PRD.md) |
|
|
63
|
+
| Need MVP/spec | PRD, MVP, scope, requirement, acceptance, non-goal | [research/PRD.md](research/PRD.md), [ACCEPTANCE_PROTOCOL.md](ACCEPTANCE_PROTOCOL.md) | Mini PRD with AC IDs and verifiable acceptance criteria |
|
|
61
64
|
| Need architecture or boundaries | architecture, boundary, layer, port, adapter, dependency | [architecture.md](architecture.md) | layer map, ports, constraints |
|
|
65
|
+
| Need WF command help | /wf-help, wf help, command list, list wf commands | `.claude/commands/wf-help.md` | direct command table; no skill invocation |
|
|
62
66
|
| Need WF mode | wf, /wf, $wf, wf mode, workflow mode, wk mode, long task, difficult, stuck, repeated failure | [WF.md](WF.md), [PROGRESS.md](PROGRESS.md), the current task `tasks/<id>/PROGRESS.md` and `tasks/<id>/PLAN.md` | exploration plan, second plan, heartbeat, recovery loop; explicit WF/WK loads subagent docs immediately |
|
|
63
|
-
| Need perpetual auto-optimization | /wf-auto, $wf-auto, wf auto, auto mode, never stop, self-improve, continuous optimize | [WF-AUTO.md](WF-AUTO.md), [subagents.md](subagents.md), [dispatch.md](dispatch.md) | perpetual loop, 8-angle scan, spark search, intent checkpoint, evidence ledger; CEO never writes code |
|
|
67
|
+
| Need perpetual auto-optimization | /wf-auto, $wf-auto, wf auto, auto mode, never stop, self-improve, continuous optimize | [WF-AUTO.md](WF-AUTO.md), [subagents.md](subagents.md), [dispatch.md](dispatch.md) | perpetual loop, bounded ticks, optional wf-auto-only hook exception, 8-angle scan, spark search, intent checkpoint, evidence ledger; CEO never writes code |
|
|
64
68
|
| Need perpetual inspiration mode | /wf-auto-spark, $wf-auto-spark, wf auto spark, spark mode, external inspiration, discover mode, never stop | [WF-AUTO-SPARK.md](WF-AUTO-SPARK.md), [WF-AUTO.md](WF-AUTO.md), [subagents.md](subagents.md), [dispatch.md](dispatch.md) | roadmap-anchored: North Star + milestones; external spark search; ≤50% deviation guard; never auto-stops |
|
|
65
69
|
| Need WF-MAX mode | /wf-max, $wf-max, wf max, maximum parallelism, CEO, Manager, Worker, fan-out | [WF-MAX.md](WF-MAX.md), [subagents.md](subagents.md), [dispatch.md](dispatch.md) | CEO-only dispatch, W0 fan-out, D-GATE, wave evidence |
|
|
66
70
|
| Need peer review | /wf-review, $wf-review, peer review, second opinion, cross-check, stuck | `.claude/skills/wf-review/SKILL.md`, `.agents/skills/wf-review/SKILL.md`, `Harness/README.md` | cross-model multi-dimension review with severity classification |
|
|
67
71
|
| Adding harness to existing project | existing project, onboarding, migrate, bootstrap, preserve, conflict | [extension.md](extension.md), [PROGRESS.md](PROGRESS.md), root `README.md` and package/CI files | discovered project facts, preserved config, manual registration plan |
|
|
68
72
|
| README optimization | README, docs, quickstart, install docs, architecture diagram, command table, documentation polish | root `README.md`, `.claude/skills/wf-readme/SKILL.md`, [PROGRESS.md](PROGRESS.md), [architecture.md](architecture.md) as needed | approved README mode, preserved sections, proposed diff plan |
|
|
69
|
-
| Need implementation plan | plan, task, write set, verify, milestone, progress | [PROGRESS.md](PROGRESS.md), the current task `tasks/<id>/PROGRESS.md` and `tasks/<id>/PLAN.md`, [agent-workflow.md](agent-workflow.md) | tasks, write set, verification commands |
|
|
70
|
-
| Browser E2E testing or automation | /wf-browser, browser, e2e, web automation, form fill, screenshot verify, page test, browser test, Playwright AI, Browser Use | browser-e2e workflow, wf-browser skill, Browser Use skill | CLI commands, screenshots,
|
|
73
|
+
| Need implementation plan | plan, task, write set, verify, milestone, progress | [PROGRESS.md](PROGRESS.md), the current task `tasks/<id>/PROGRESS.md` and `tasks/<id>/PLAN.md`, [agent-workflow.md](agent-workflow.md), [ACCEPTANCE_PROTOCOL.md](ACCEPTANCE_PROTOCOL.md) | tasks, AC IDs, write set, verification commands |
|
|
74
|
+
| Browser E2E testing or automation | /wf-browser, browser, e2e, web automation, form fill, screenshot verify, page test, browser test, Playwright AI, Browser Use, CDP | browser-e2e workflow, [HARNESS_BRIDGE.md](HARNESS_BRIDGE.md), wf-browser skill, Browser Use skill | UI/API contract, CLI commands, screenshots, traces, validation matrix |
|
|
71
75
|
| Optional workflow installed | workflow, optional, ui-ux-review, github-pr-review, python-backend, ts-react-frontend | matching `workflows/*.md` (if installed), [extension.md](extension.md) | workflow-specific evidence, commands, fallback path |
|
|
72
|
-
| Need durable memory or reflection | memory, remember, preference, correction, tool failure, lesson, reflection | [MEMORY.md](MEMORY.md), `Harness/memory/tool-usage-reflections.md`, `Harness/memory/user-corrections-preferences.md`, `Harness/memory/agent-lessons-patterns.md` | concise newest-first memory entry or no-op rationale |
|
|
73
|
-
| Need subagents | subagent, role pack, context, inject, return format, orchestrator | [subagents.md](subagents.md), [context-loading.md](context-loading.md), [dispatch.md](dispatch.md) | controller plan, role-specific context pack, dispatch pack |
|
|
74
|
-
| Need feature work | feature, implementation, TDD, test, review, closeout | [tasks/_template/PLAN.md](tasks/_template/PLAN.md), [agent-workflow.md](agent-workflow.md) | task plan, tests, implementation loop |
|
|
76
|
+
| Need durable memory or reflection | memory, remember, preference, correction, tool failure, lesson, reflection, scenario memory | [MEMORY.md](MEMORY.md), [MEMORY_PROTOCOL.md](MEMORY_PROTOCOL.md), `Harness/memory/tool-usage-reflections.md`, `Harness/memory/user-corrections-preferences.md`, `Harness/memory/agent-lessons-patterns.md` | concise newest-first memory entry, scenario memory hint, or no-op rationale |
|
|
77
|
+
| Need subagents | subagent, role pack, context, inject, return format, orchestrator, isolation | [subagents.md](subagents.md), [context-loading.md](context-loading.md), [dispatch.md](dispatch.md), [AGENT_ISOLATION.md](AGENT_ISOLATION.md) | controller plan, role-specific context pack, isolation-aware dispatch pack |
|
|
78
|
+
| Need feature work | feature, implementation, TDD, test, review, closeout | [tasks/_template/PLAN.md](tasks/_template/PLAN.md), [agent-workflow.md](agent-workflow.md), [TDD-GUIDE.md](TDD-GUIDE.md), [ACCEPTANCE_PROTOCOL.md](ACCEPTANCE_PROTOCOL.md) | task plan, AC-linked RED tests, implementation loop |
|
|
75
79
|
| Review or release check | review, release, finding, risk, evidence, verification | [agent-workflow.md](agent-workflow.md), current feature doc | findings, verification evidence |
|
|
76
80
|
| Harness readiness check | validate, readiness, placeholder, missing file, release gate | `Harness/scripts/validate-harness.mjs`, `Harness/scripts/validate-harness.mjs --strict` | missing files and unresolved project placeholders |
|
|
77
81
|
| Need harness update | /wf-update, $wf-update, update, check for updates, harness version | `.claude/skills/wf-update/SKILL.md`, `.agents/skills/wf-update/SKILL.md`, `Harness/.harness-version`, `Harness/scripts/wf-update-check.mjs` | script-driven comparison, SAFE/CONFLICT/PRESERVE classification, user decides conflicts |
|
|
@@ -82,10 +86,13 @@ Routing priority: if a request explicitly says `/wf <task>`, `$wf`, `wf mode`, `
|
|
|
82
86
|
- Move phases in order unless the user asks for a fast lane.
|
|
83
87
|
- Use `/wf <task>` in Claude Code, `$wf` in Codex, `/wf-max [task]` or `$wf-max`, `wf mode`, `workflow mode`, or `wk mode` when a task is long, difficult, uncertain, multi-file, or repeatedly failing.
|
|
84
88
|
- Use `/wf-auto` for perpetual self-directed optimization that never stops until 8-angle exhaustion.
|
|
85
|
-
- **WF-MAX Role Contract**: Three-layer architecture — global mode (`wf-max`), agent role (`ceo|manager|worker|reviewer`), dispatch permission (`writeSet`, `forbidden`, `verification`). CEO never writes source code. Workers edit only dispatch.writeSet.
|
|
89
|
+
- **WF-MAX Role Contract**: Three-layer architecture — global mode (`wf-max`), agent role (`ceo|manager|worker|reviewer`), dispatch permission (`writeSet`, `forbidden`, `verification`). CEO never writes source code. Workers edit only dispatch.writeSet. Compliance is checked through dispatch packets, independent review, validation evidence, and task capsules. See `CLAUDE.md` §1a.
|
|
86
90
|
- **WF-REVIEW Anti-Self-Review**: Must invoke the OTHER CLI (Codex↔Claude). Same-model simulation is forbidden.
|
|
87
|
-
-
|
|
88
|
-
- Do not code before
|
|
91
|
+
- WF-MAX has no runtime hook state. The durable state is the task capsule, dispatch table, review findings, and validation evidence. The only runtime hook exception in Harness is the optional `/wf-auto` bounded tick hook described in `WF-AUTO.md`.
|
|
92
|
+
- Do not code before PRD-GATE, AC-GATE, CONTRACT-GATE, and TEST-GATE are satisfied or explicitly compressed into a documented fast lane.
|
|
93
|
+
- PRD-derived Acceptance Criteria are the source of truth. Code, tests, reviews, validation, debug, and memory must trace to AC IDs.
|
|
94
|
+
- No acceptance criteria, no tests. No acceptance criteria, no code.
|
|
95
|
+
- No `data-testid` or stable accessible selector, no UI acceptance. No API contract, no backend integration acceptance.
|
|
89
96
|
- Unsure whether to open a task? Read [agent-workflow.md](agent-workflow.md) Section 1.
|
|
90
97
|
- Do not spawn a subagent without a role, read boundary, write boundary, and return contract.
|
|
91
98
|
- Do not run writing agents in parallel unless write sets are disjoint.
|
|
@@ -97,7 +104,6 @@ Routing priority: if a request explicitly says `/wf <task>`, `$wf`, `wf mode`, `
|
|
|
97
104
|
- Do not close work without tests or recorded manual verification.
|
|
98
105
|
- Do not mark work `Verified` until evidence is recorded in the current task's `tasks/<id>/PROGRESS.md` and `tasks/<id>/PLAN.md` or the feature doc.
|
|
99
106
|
- Run `node Harness/scripts/validate-harness.mjs` for scaffold structure; run `node Harness/scripts/validate-harness.mjs --strict` after bootstrap and before release.
|
|
100
|
-
- Run `node tests/e2e-wf-hooks.test.mjs` to verify hook enforcement works before deploying WF-MAX.
|
|
101
107
|
- If a doc still has `{{...}}`, treat that section as a template, not project fact.
|
|
102
108
|
|
|
103
109
|
## Doc Map
|
|
@@ -107,13 +113,22 @@ Routing priority: if a request explicitly says `/wf <task>`, `$wf`, `wf mode`, `
|
|
|
107
113
|
| **Router + Index** | `README.md`, `MEMORY.md`, `PROGRESS.md` |
|
|
108
114
|
| **Task Capsule** | `tasks/<id>/PROGRESS.md`, `tasks/<id>/PLAN.md`, `tasks/_template/` |
|
|
109
115
|
| **Workflows** | `WF.md`, `WF-MAX.md`, `WF-AUTO.md`, `WF-AUTO-SPARK.md` |
|
|
116
|
+
| **Protocols** | `ACCEPTANCE_PROTOCOL.md`, `AGENT_ISOLATION.md`, `HARNESS_BRIDGE.md`, `DEBUG_PROTOCOL.md`, `MEMORY_PROTOCOL.md` |
|
|
110
117
|
| **Guides** | `ECC-GUIDE.md`, `TDD-GUIDE.md`, `lifecycle.md`, `architecture.md` |
|
|
111
118
|
| **Orchestration** | `subagents.md`, `context-loading.md`, `dispatch.md`, `agent-workflow.md`, `extension.md` |
|
|
112
119
|
| **Research** | `research/README.md`, `research/PRD.md`, `research/research-results.md` |
|
|
120
|
+
| **Acceptance Templates** | `templates/PRD.template.md`, `templates/ACCEPTANCE.template.md`, `templates/UI_CONTRACT.template.md`, `templates/API_CONTRACT.template.md`, `templates/TEST_PLAN.template.md`, `templates/PLAYWRIGHT_SPEC.template.ts`, `templates/VALIDATION_REPORT.template.md` |
|
|
113
121
|
| **Memory** | `memory/tool-usage-reflections.md`, `memory/user-corrections-preferences.md`, `memory/agent-lessons-patterns.md` |
|
|
114
|
-
| **Scripts** | `scripts/
|
|
115
|
-
| **Runtime** | `.
|
|
122
|
+
| **Scripts** | `scripts/validate-harness.mjs`, `scripts/wf-update-check.mjs`, `scripts/wf-remove.mjs` |
|
|
123
|
+
| **Runtime** | `.harness-version` |
|
|
116
124
|
| **Agents + Skills** | `.claude/agents/*`, `.claude/skills/*`, `.agents/skills/*` |
|
|
125
|
+
| **Direct Commands** | `.claude/commands/wf-help.md` |
|
|
126
|
+
|
|
127
|
+
## Direct Commands
|
|
128
|
+
|
|
129
|
+
| Command | Purpose |
|
|
130
|
+
|---|---|
|
|
131
|
+
| `/wf-help` | Directly returns a table of all Harness WF commands, usage, and purpose. It does not invoke a skill or start a workflow. |
|
|
117
132
|
|
|
118
133
|
## Skill Commands
|
|
119
134
|
|
|
@@ -126,6 +141,6 @@ Routing priority: if a request explicitly says `/wf <task>`, `$wf`, `wf mode`, `
|
|
|
126
141
|
| `/wf-review [focus]` | `$wf-review [focus]` | Cross-model peer review via Codex <-> Claude |
|
|
127
142
|
| `/wf-learn` | `$wf-learn` | Force learning cycle: context-master -> memory-master |
|
|
128
143
|
| `/wf-browser [task]` | `$wf-browser [task]` | AI-driven browser automation for E2E testing |
|
|
144
|
+
| `/wf-readme [task]` | `$wf-readme [task]` | README preservation, merge, and documentation improvement workflow |
|
|
129
145
|
| `/wf-update` | `$wf-update` | Script-driven harness update: fetch + compare + apply |
|
|
130
146
|
| `/wf-remove` | `$wf-remove` | Safe harness removal: auto-delete SAFE, confirm MODIFIED, preserve USER DATA |
|
|
131
|
-
```
|
|
@@ -1,83 +1,165 @@
|
|
|
1
|
-
# TDD Guide
|
|
1
|
+
# TDD Guide - Test-Driven Development in Harness
|
|
2
2
|
|
|
3
|
-
TDD is NOT optional in Harness. The
|
|
4
|
-
|
|
3
|
+
TDD is NOT optional in Harness. The workflow loop requires failing executable tests before implementation.
|
|
4
|
+
For behavior changes, tests must be derived from PRD acceptance criteria, not from the implementation.
|
|
5
5
|
|
|
6
|
-
##
|
|
6
|
+
## Source Of Truth
|
|
7
|
+
|
|
8
|
+
The source of truth for tests is the PRD-derived Acceptance Criteria in `ACCEPTANCE_PROTOCOL.md`.
|
|
9
|
+
|
|
10
|
+
Required trace:
|
|
11
|
+
|
|
12
|
+
```text
|
|
13
|
+
Mini PRD -> AC ID -> UI/API/state contract -> RED test -> implementation -> validation evidence
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Every behavior test must reference an AC ID in the test name, test comment, or validation matrix. A test that cannot be traced to an AC ID is not an acceptance test.
|
|
17
|
+
|
|
18
|
+
## When TDD Is Mandatory
|
|
7
19
|
|
|
8
20
|
| Trigger | Action |
|
|
9
|
-
|
|
10
|
-
| New feature | Write failing test first. Implementation MUST NOT start without it. |
|
|
11
|
-
| Bug fix | Write failing regression test that reproduces the bug
|
|
21
|
+
| --- | --- |
|
|
22
|
+
| New feature | Write failing AC-linked test first. Implementation MUST NOT start without it. |
|
|
23
|
+
| Bug fix | Write failing regression test that reproduces the bug and links to the affected AC or incident. |
|
|
12
24
|
| Refactor | Existing tests MUST be green before refactoring. Keep green throughout. |
|
|
13
|
-
| API endpoint | Integration test first
|
|
14
|
-
| UI component |
|
|
15
|
-
|
|
|
25
|
+
| API endpoint | Integration/API contract test first: request -> expected response -> error response. |
|
|
26
|
+
| UI component | Behavior test first: real user action -> DOM/state/API result. |
|
|
27
|
+
| Browser-visible flow | Playwright/CDP or documented real-browser test first; unit tests are supporting checks only. |
|
|
28
|
+
| Database change | Migration test first: apply -> verify schema/data -> rollback -> verify. |
|
|
29
|
+
|
|
30
|
+
## TDD Cycle
|
|
31
|
+
|
|
32
|
+
```text
|
|
33
|
+
RED:
|
|
34
|
+
Write the smallest AC-linked failing test.
|
|
35
|
+
Run it and confirm it fails for the expected product reason.
|
|
36
|
+
|
|
37
|
+
GREEN:
|
|
38
|
+
Write the smallest implementation needed to pass.
|
|
39
|
+
Run the target test and confirm it passes.
|
|
40
|
+
Run the declared broader test set.
|
|
41
|
+
|
|
42
|
+
IMPROVE:
|
|
43
|
+
Refactor while keeping tests green.
|
|
44
|
+
Re-run the declared verification commands.
|
|
45
|
+
Record coverage and acceptance evidence.
|
|
46
|
+
```
|
|
16
47
|
|
|
17
|
-
|
|
48
|
+
If the RED test passes immediately, the test is wrong, the fixture is wrong, or the behavior already exists. Stop and record which case is true before implementation.
|
|
18
49
|
|
|
50
|
+
## Browser/UI Acceptance TDD Gate
|
|
51
|
+
|
|
52
|
+
For user-visible or browser-visible behavior, syntax checks, type checks, shallow renders, import tests, and assertion-only unit tests are not acceptance tests.
|
|
53
|
+
|
|
54
|
+
The first acceptance test for a UI flow must exercise the real user path:
|
|
55
|
+
|
|
56
|
+
1. Open the real route/page in a browser-capable runner.
|
|
57
|
+
2. Interact through stable selectors such as `data-testid` or accessible roles.
|
|
58
|
+
3. Click, type, select, drag, submit, or navigate as a user would.
|
|
59
|
+
4. Assert the DOM result and the relevant URL, route, store, localStorage, or runtime state change.
|
|
60
|
+
5. For frontend-backend behavior, assert network/API behavior with Playwright request capture, CDP, or the Harness Bridge Network Trace Collector.
|
|
61
|
+
6. Capture evidence: screenshot, trace, video, console log, network log, or validation report path.
|
|
62
|
+
7. Record the AC-by-AC result matrix.
|
|
63
|
+
|
|
64
|
+
Default frontend verification, when tooling exists:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
npm run test
|
|
68
|
+
npm run typecheck
|
|
69
|
+
npm run lint
|
|
70
|
+
npx playwright test
|
|
19
71
|
```
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
IMPROVE: Refactor while keeping green
|
|
26
|
-
→ Run ALL tests → ALL GREEN
|
|
27
|
-
→ Coverage check (≥80%)
|
|
72
|
+
|
|
73
|
+
For frontend-backend flows or suspected flakes:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
npx playwright test --trace on
|
|
28
77
|
```
|
|
29
78
|
|
|
79
|
+
`npm test`, typecheck, lint, and component-unit tests are useful supporting checks. They cannot replace Playwright/CDP or documented real-browser validation for a browser-visible AC.
|
|
80
|
+
|
|
81
|
+
## Contract Requirements
|
|
82
|
+
|
|
83
|
+
Before writing browser or API acceptance tests, load the relevant contracts:
|
|
84
|
+
|
|
85
|
+
- UI selectors from `UI_CONTRACT.md` or the task PLAN contract table
|
|
86
|
+
- API requests/responses from `API_CONTRACT.md` or the task PLAN contract table
|
|
87
|
+
- Harness Bridge rules from `HARNESS_BRIDGE.md`
|
|
88
|
+
- Agent isolation rules from `AGENT_ISOLATION.md`
|
|
89
|
+
|
|
90
|
+
Missing selectors or contracts are blockers. Do not silently invent selectors in tests without updating the UI contract through the proper planning/acceptance role.
|
|
91
|
+
|
|
30
92
|
## ECC Testing Rules
|
|
31
93
|
|
|
32
|
-
Coverage thresholds, AAA structure, test naming, and per-stack setup live in ECC testing rules (`common/testing.md`
|
|
94
|
+
Coverage thresholds, AAA structure, test naming, and per-stack setup live in ECC testing rules (`common/testing.md` plus stack-specific files). This guide defines Harness sequencing and acceptance depth: failing test first, implementation second, real behavior validation last.
|
|
33
95
|
|
|
34
|
-
## Agent Dispatch
|
|
96
|
+
## Agent Dispatch - TDD Gate
|
|
35
97
|
|
|
36
|
-
Before dispatching an Implementer, the Planner MUST verify:
|
|
98
|
+
Before dispatching an Implementer, the Planner or Test Manager MUST verify:
|
|
37
99
|
|
|
38
|
-
1. [ ]
|
|
39
|
-
2. [ ]
|
|
40
|
-
3. [ ] Test
|
|
41
|
-
4. [ ]
|
|
42
|
-
5. [ ]
|
|
100
|
+
1. [ ] Each behavior change has a Mini PRD or task PLAN entry.
|
|
101
|
+
2. [ ] Each behavior change has AC IDs.
|
|
102
|
+
3. [ ] Test files or test specs reference the relevant AC IDs.
|
|
103
|
+
4. [ ] Tests are RED for new feature / bug fix work and fail for the expected reason.
|
|
104
|
+
5. [ ] Tests cover happy path, error path, empty/loading/disabled states where applicable.
|
|
105
|
+
6. [ ] Browser-visible ACs have real user interaction tests, not syntax-only or shallow render tests.
|
|
106
|
+
7. [ ] Frontend-backend ACs include network/API assertions against the contract.
|
|
107
|
+
8. [ ] Evidence capture is declared: screenshot, trace, video, log, or report path.
|
|
108
|
+
9. [ ] Coverage threshold and verification commands are declared in PLAN.md.
|
|
43
109
|
|
|
44
|
-
If any check fails
|
|
110
|
+
If any check fails, dispatch Test Writer or Acceptance Agent first, then Implementer.
|
|
45
111
|
|
|
46
|
-
##
|
|
112
|
+
## Forbidden Shortcuts
|
|
47
113
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
114
|
+
These are not valid acceptance tests for browser-visible behavior:
|
|
115
|
+
|
|
116
|
+
- A test that only imports a component and asserts it renders.
|
|
117
|
+
- A test that only checks TypeScript, lint, formatting, or build success.
|
|
118
|
+
- A snapshot with no user action and no AC-linked assertion.
|
|
119
|
+
- A mocked path where the browser, router, store, API boundary, and side effects are all replaced.
|
|
120
|
+
- An assertion against implementation internals instead of user-observable behavior.
|
|
121
|
+
- A test written from the implementer's code rather than from PRD/AC/contracts.
|
|
122
|
+
- Changing PRD, AC, UI contract, or API contract to make implementation tests pass.
|
|
55
123
|
|
|
56
|
-
## TDD
|
|
124
|
+
## TDD Anti-Patterns
|
|
57
125
|
|
|
58
|
-
|
|
126
|
+
| Anti-Pattern | Symptom | Fix |
|
|
127
|
+
| --- | --- | --- |
|
|
128
|
+
| Test-last | Writing implementation first, then tests "to verify" | Reverse order. Tests first. |
|
|
129
|
+
| Test-the-test | Test passes immediately and proves no product behavior | Rewrite around the AC and expected RED reason. |
|
|
130
|
+
| Syntax-only acceptance | UI flow "tested" by typecheck/build/import assertions | Add Playwright/CDP real user path coverage. |
|
|
131
|
+
| Mocked browser path | All browser, state, and network behavior mocked away | Keep only external services mocked; exercise real page behavior. |
|
|
132
|
+
| Network-blind UI test | UI assertion passes but request URL/method/payload is unchecked | Add Playwright/CDP/Harness Bridge network assertions. |
|
|
133
|
+
| No AC ID | Test name does not map to acceptance criteria | Add AC ID in name/comment and validation matrix. |
|
|
134
|
+
| Giant test | One test covering entire feature | Split into unit, API/integration, and E2E acceptance checks. |
|
|
135
|
+
| Mock everything | All dependencies mocked, no real behavior tested | Mock only external I/O when needed. Test real logic and boundaries. |
|
|
136
|
+
| Skip coverage | Coverage gate ignored | Record configured threshold and command evidence before closeout. |
|
|
137
|
+
|
|
138
|
+
## TDD In WF-MAX Mode
|
|
139
|
+
|
|
140
|
+
In `/wf-max`, acceptance/test planning and implementation are separate waves.
|
|
59
141
|
Test Writers MUST complete before Implementers start. No parallel overlap.
|
|
60
142
|
|
|
61
|
-
```
|
|
62
|
-
W2a
|
|
63
|
-
1.
|
|
64
|
-
2. Test Writer (
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
143
|
+
```text
|
|
144
|
+
W2a - ACCEPTANCE/TEST WAVE:
|
|
145
|
+
1. Acceptance Agent -> confirm AC IDs and contracts
|
|
146
|
+
2. Test Writer (FE) -> write RED Playwright/user-path tests for UI ACs
|
|
147
|
+
3. Test Writer (BE) -> write RED API/integration tests for API ACs
|
|
148
|
+
4. CDP/Network Agent -> define request/response assertions
|
|
149
|
+
-> BARRIER: all AC-linked tests written and confirmed RED
|
|
150
|
+
|
|
151
|
+
W2b - IMPLEMENTATION WAVE:
|
|
152
|
+
5. Implementer (FE) -> make FE acceptance tests pass
|
|
153
|
+
6. Implementer (BE) -> make API tests pass
|
|
154
|
+
-> BARRIER: target tests GREEN and broader checks run
|
|
155
|
+
|
|
156
|
+
W2R - REVIEW/VALIDATION WAVE:
|
|
157
|
+
7. Reviewer -> verify diff, AC coverage, and forbidden-file discipline
|
|
158
|
+
8. Validator -> run real browser/API validation and produce AC matrix
|
|
74
159
|
```
|
|
75
160
|
|
|
76
|
-
|
|
77
|
-
If Test Writers and Implementers share a wave, Implementers start before RED
|
|
78
|
-
tests exist — violating the TDD gate. Two waves with an explicit barrier
|
|
79
|
-
ensures tests exist before any implementation begins.
|
|
161
|
+
Workers in the same WF-MAX wave run in parallel. If Test Writers and Implementers share a wave, Implementers can start before RED tests exist, violating the TDD gate.
|
|
80
162
|
|
|
81
163
|
## Verification
|
|
82
164
|
|
|
83
|
-
Run the verification commands declared in the task PLAN or dispatch packet. Do not claim TDD completion until RED, GREEN,
|
|
165
|
+
Run the verification commands declared in the task PLAN or dispatch packet. Do not claim TDD completion until RED, GREEN, full-check evidence, and AC-by-AC validation evidence are recorded.
|