buildwright 0.0.9 → 0.0.11

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.md CHANGED
@@ -1,81 +1,438 @@
1
- # buildwright
1
+ # Buildwright
2
2
 
3
- Agent-first autonomous development workflow. Ship code you don't read.
3
+ **Ship code you don't read. Let automated systems be your reviewer.**
4
4
 
5
- ## Install
5
+ An agent-first autonomous development workflow where humans approve specifications and agents handle everything else — implementation, testing, security review, code review, and shipping.
6
+
7
+ ---
8
+
9
+ ## The Flow
10
+
11
+ ```mermaid
12
+ flowchart TD
13
+ A["/bw-new-feature"] --> B{Greenfield?}
14
+ B -- Yes --> C[Ask product vision<br>Derive tech stack from vision]
15
+ C --> D
16
+ B -- No --> D["1. RESEARCH<br>Deep-read codebase"]
17
+ D --> E["1.5. RESOLVE AMBIGUITIES<br>Auto-decide or ask user<br>(BUILDWRIGHT_AUTO_APPROVE)"]
18
+ E --> F["2. PLAN<br>Generate spec"]
19
+ F --> G["3. VALIDATE<br>Staff Engineer review (auto)"]
20
+ G --> H["4. APPROVE<br>Human or auto<br>(BUILDWRIGHT_AUTO_APPROVE)"]
21
+ H --> I["5. BUILD<br>TDD per milestone<br>→ verify after each"]
22
+ I --> J["6.5 UPDATE DOCS<br>README · CHANGELOG · docs/"]
23
+ J --> K["7. SHIP"]
24
+ K --> L[Verify]
25
+ L --> M[Security]
26
+ M --> N[Review]
27
+ N --> O["PR Ready ✓"]
28
+
29
+ P["/bw-quick"] --> Q[Quick research]
30
+ Q --> R[Implement TDD]
31
+ R --> S[Verify]
32
+ S --> U[Security]
33
+ U --> V[Code Review]
34
+ V --> W[Update Docs]
35
+ W --> T["Commit Ready ✓"]
36
+ ```
37
+
38
+ > If anything fails → commit completed work, push, PR with failure report, exit(1). No orphaned branches.
39
+
40
+ ---
41
+
42
+ ## Greenfield Projects
43
+
44
+ Starting a new project? Buildwright handles it:
45
+
46
+ ```
47
+ /bw-new-feature "Add product catalog with search"
48
+
49
+ > "This looks like a new project. What is the product vision, and do you have
50
+ > any tech constraints (team expertise, deployment environment, integrations,
51
+ > compliance)?"
52
+ E-commerce platform for handmade crafts. Team knows Python. Deploying to AWS Lambda.
53
+
54
+ > [AI generates steering docs + spec]
55
+ > [Derives and presents tech stack for approval]
56
+
57
+ PROPOSED TECH STACK
58
+ ───────────────────
59
+ [Stack derived from your product vision and constraints]
60
+ Chosen because: [2-3 sentences linking requirements to stack]
61
+ Alternatives considered: [brief list]
62
+
63
+ Reply "approved" to proceed with this stack.
64
+ Or adjust: "approved, but use PostgreSQL instead of DynamoDB"
65
+ ```
66
+
67
+ One question. One approval. Tech stack + spec reviewed together.
68
+
69
+ ---
70
+
71
+ ## Autonomous Mode
72
+
73
+ Want fully autonomous operation? Skip human approval entirely:
6
74
 
7
75
  ```bash
8
- npm install -g buildwright
76
+ # Set environment variable
77
+ export BUILDWRIGHT_AUTO_APPROVE=true
78
+
79
+ # Then run as usual
80
+ /bw-new-feature "Add user authentication"
9
81
  ```
10
82
 
11
- Requires Node.js 18+.
83
+ **What happens:**
84
+ - Research, plan, validate still run (quality preserved)
85
+ - Spec documents committed to git BEFORE implementation
86
+ - No approval wait — proceeds directly to build
87
+ - Full audit trail in version control
88
+
89
+ ```
90
+ docs(spec): add specification for user-auth
91
+
92
+ - research.md: codebase analysis
93
+ - spec.md: implementation plan
94
+ - Validated by Staff Engineer agent
95
+
96
+ Auto-approved: BUILDWRIGHT_AUTO_APPROVE=true
97
+ ```
98
+
99
+ **Use autonomous mode when:**
100
+ - You trust the workflow for routine features
101
+ - Running in CI/CD pipelines
102
+ - Batch processing multiple features
103
+ - You want to review specs via git history instead of real-time
104
+
105
+ ---
12
106
 
13
107
  ## Quick Start
14
108
 
109
+ ### npm (Recommended)
110
+
15
111
  ```bash
16
- # Navigate to your project
17
- cd my-project
18
- git init # if not already a git repo
112
+ npm install -g buildwright
113
+ cd my-project && buildwright init
114
+ ```
115
+
116
+ Requires Node.js 18+. All templates are bundled — works offline after install. Run `buildwright update` to pull the latest commands/agents/claws from GitHub.
117
+
118
+ ### For Claude Code
19
119
 
20
- # Set up Buildwright
21
- buildwright init
120
+ ```bash
121
+ # Add to any project
122
+ curl -sL https://raw.githubusercontent.com/raunakkathuria/buildwright/main/setup.sh | bash
22
123
 
23
- # Customize for your project
24
- nano .buildwright/steering/product.md # add product context
25
- nano .buildwright/steering/tech.md # add tech stack + commands
124
+ # Customize steering docs
125
+ nano .buildwright/steering/product.md # Your product context
126
+ nano .buildwright/steering/tech.md # Your tech stack
26
127
 
27
128
  # Start building
28
129
  claude
29
- > /bw-new-feature "Add user authentication"
130
+ > /bw-new-feature "Add user authentication with OAuth2"
30
131
  ```
31
132
 
32
- ## Commands
133
+ ### For an existing clone
33
134
 
34
- | Command | Description |
35
- |---------|-------------|
36
- | `buildwright init` | Set up Buildwright in the current project |
37
- | `buildwright update` | Update commands/agents/claws from GitHub (preserves your steering docs) |
38
- | `buildwright sync` | Re-sync `.buildwright/` to `.claude/`, `.opencode/`, `.cursor/rules/` |
135
+ ```bash
136
+ # After cloning the repo, generate tool-specific configs
137
+ make sync
39
138
 
40
- ## What `init` Does
139
+ # This creates:
140
+ # .claude/ (commands, agents, claws, steering — from .buildwright/)
141
+ # .opencode/ (commands, agents, claws, steering — from .buildwright/)
142
+ # .cursor/rules/ (commands, agents, claws, steering — from .buildwright/)
143
+ # AGENTS.md (from CLAUDE.md — for OpenCode compatibility)
41
144
 
42
- 1. Copies all Buildwright templates to your project:
43
- - `.buildwright/` — canonical config (agents, claws, commands, steering)
44
- - `scripts/` — sync and hook scripts
45
- - `Makefile`, `CLAUDE.md`, `BUILDWRIGHT.md`
46
- 2. Makes scripts executable
47
- 3. Runs `make sync` to generate `.claude/`, `.opencode/`, `.cursor/rules/`
48
- 4. Installs git hooks for auto-sync on `.buildwright/` changes
145
+ # Install git hooks to auto-sync on .buildwright/ changes
146
+ make install-hooks
147
+ ```
49
148
 
50
- ## What `update` Does
149
+ ### For OpenClaw
51
150
 
52
- Downloads the latest release from GitHub and updates:
53
- - `.buildwright/commands/` — slash command definitions
54
- - `.buildwright/agents/` — agent personas
55
- - `.buildwright/claws/` domain specialist prompts
56
- - `CLAUDE.md` — agent instructions
151
+ The recommended approach is to run the setup script, which installs the full workflow (commands, agents, claws, steering docs) into your project:
152
+
153
+ ```bash
154
+ curl -sL https://raw.githubusercontent.com/raunakkathuria/buildwright/main/setup.sh | bash
155
+ make sync
156
+ ```
157
+
158
+ Alternatively, install just the skill globally for reference across all projects:
159
+
160
+ ```bash
161
+ mkdir -p ~/.openclaw/skills/buildwright
162
+ curl -s https://raw.githubusercontent.com/raunakkathuria/buildwright/main/SKILL.md > ~/.openclaw/skills/buildwright/SKILL.md
163
+ ```
57
164
 
58
- **Preserves** your customizations in `.buildwright/steering/` (product.md, tech.md, etc.).
165
+ > **Note:** The global skill install provides buildwright's workflow guidance via SKILL.md. The slash commands (`/bw-new-feature`, `/bw-claw`, etc.) require the full project setup above.
59
166
 
60
- ## Slash Commands (inside AI editors)
167
+ ### For OpenCode
168
+
169
+ Same as above — run the setup script for the full workflow:
170
+
171
+ ```bash
172
+ curl -sL https://raw.githubusercontent.com/raunakkathuria/buildwright/main/setup.sh | bash
173
+ make sync
174
+ ```
175
+
176
+ Or install the skill globally:
177
+
178
+ ```bash
179
+ mkdir -p ~/.config/opencode/skills/buildwright
180
+ curl -s https://raw.githubusercontent.com/raunakkathuria/buildwright/main/SKILL.md > ~/.config/opencode/skills/buildwright/SKILL.md
181
+ ```
182
+
183
+ > **Note:** The global skill install provides buildwright's workflow guidance via SKILL.md. The slash commands require the full project setup.
184
+
185
+ ### For Cursor
186
+
187
+ Same setup — run the setup script for the full workflow:
188
+
189
+ ```bash
190
+ curl -sL https://raw.githubusercontent.com/raunakkathuria/buildwright/main/setup.sh | bash
191
+ ```
192
+
193
+ Cursor rules are generated automatically in `.cursor/rules/` by the sync step. Open the project in Cursor — steering rules apply always, commands/agents/claws apply intelligently.
194
+
195
+ ### For Codex CLI
196
+
197
+ Buildwright skills are discovered by Codex via `~/.agents/skills/`. After cloning:
198
+
199
+ ```bash
200
+ cd ~/.codex/buildwright && make codex
201
+ # Creates: ~/.agents/skills/buildwright → skills/
202
+ ```
203
+
204
+ Or follow the detailed guide in [`.codex/INSTALL.md`](.codex/INSTALL.md).
205
+
206
+ Each `bw-*` command is available as a Codex skill. `AGENTS.md` (generated by `make sync`) is also read automatically by Codex at the project level.
207
+
208
+ ---
209
+
210
+ ## When to Use What
211
+
212
+ | Scenario | Approach | Why |
213
+ |----------|----------|-----|
214
+ | New feature, unclear scope | `/bw-new-feature` | Research prevents building the wrong thing |
215
+ | New feature, clear scope | `/bw-new-feature` | Spec creates audit trail + validation |
216
+ | Bug fix | `/bw-quick` | Fast path with full quality gates |
217
+ | Small task (< 2 hrs) | `/bw-quick` | Lightweight planning, full quality gates |
218
+ | Config change | `/bw-quick` | Quick path with security scan + code review |
219
+ | Refactor, clear scope | `/bw-quick` | You already know what to change |
220
+ | Refactor, unclear scope | `/bw-new-feature` | Research phase prevents breaking things |
221
+ | Unfamiliar / brownfield codebase | `/bw-analyse` | Generates stack, architecture, conventions, and concerns docs so every session starts with real context |
222
+ | Greenfield project | `/bw-new-feature` | Auto-generates steering docs + tech stack |
223
+ | Prototype / spike | Just code it | Ceremony kills exploration speed |
224
+ | One-off script | Just code it | No need for spec, review, or CI |
225
+ | Learning / experimenting | Just code it | Pipeline adds friction to discovery |
226
+
227
+ ---
228
+
229
+ ## Commands
61
230
 
62
231
  | Command | Purpose |
63
232
  |---------|---------|
233
+ | `/bw-analyse` | Analyse codebase: writes stack, architecture, conventions, concerns to `.buildwright/codebase/`, updates `tech.md` |
64
234
  | `/bw-new-feature` | Full pipeline: research → spec → approve → build → ship |
235
+ | `/bw-claw` | Multi-agent: architect decomposes → claws execute per domain |
65
236
  | `/bw-quick` | Fast path for bug fixes, small tasks |
66
- | `/bw-claw` | Cross-domain features (DB + API + UI) |
67
- | `/bw-ship` | Quality gates + push + PR |
68
- | `/bw-verify` | Quick typecheck/lint/test/build |
69
- | `/bw-analyse` | Analyse brownfield codebase |
70
- | `/bw-help` | Show all commands |
237
+ | `/bw-plan` | Research a question, produce a written deliverable — no implementation, no commits |
238
+ | `/bw-ship` | Quality gates + release: verify → security → review → push PR |
239
+ | `/bw-verify` | Quick checks: typecheck, lint, test, build |
240
+ | `/bw-help` | Show available commands |
241
+
242
+ ---
243
+
244
+ ## Agent Personas
245
+
246
+ Modular, extensible agent personas in `.buildwright/agents/`:
247
+
248
+ | Agent | File | Used By | Purpose |
249
+ |-------|------|---------|---------|
250
+ | Staff Engineer | `staff-engineer.md` | `/bw-new-feature`, `/bw-ship` | Spec & code review |
251
+ | Security Engineer | `bw-security-engineer.md` | `/bw-ship` | OWASP, SAST, security review |
252
+
253
+ ### Adding New Agents
254
+
255
+ ```bash
256
+ # Create new agent persona
257
+ cat > .buildwright/agents/qa-engineer.md << 'EOF'
258
+ # QA Engineer Agent
259
+
260
+ You are a QA Engineer specialized in test coverage...
261
+
262
+ ## What You Look For
263
+ ...
264
+
265
+ ## Output Format
266
+ ...
267
+ EOF
268
+ ```
269
+
270
+ Then reference in commands:
271
+ ```markdown
272
+ ## Adopt Persona
273
+ Read and adopt persona from `.buildwright/agents/qa-engineer.md`
274
+ ```
275
+
276
+ ---
277
+
278
+ ## Security Review
279
+
280
+ The security phase in `/bw-ship` covers:
281
+
282
+ | Category | Checks |
283
+ |----------|--------|
284
+ | **OWASP Top 10** | All 10 categories (A01-A10:2021) |
285
+ | **SAST** | Static analysis via Semgrep |
286
+ | **Secrets** | API keys, passwords, tokens, private keys |
287
+ | **Dependencies** | npm audit, cargo audit, pip-audit |
288
+ | **Financial** | No float for currency, transaction integrity, audit logging |
289
+
290
+ ### Severity Triage
291
+
292
+ Findings are classified by severity to avoid blocking on low-risk items:
293
+
294
+ | Severity | Action | Example |
295
+ |----------|--------|---------|
296
+ | **Critical / High** | Block — must fix before merge | SQL injection, exposed secrets, auth bypass |
297
+ | **Medium** | Fix in this PR if feasible, otherwise track | Missing rate limiting, verbose error messages |
298
+ | **Low / Info** | Advisory — log and move on | Minor header hardening, informational findings |
299
+
300
+ ---
301
+
302
+ ## Project Structure
303
+
304
+ ```
305
+ your-project/
306
+ ├── CLAUDE.md # Agent instructions (committed)
307
+ ├── BUILDWRIGHT.md # Human documentation (committed)
308
+ ├── SKILL.md # Agent Skills standard (committed)
309
+ ├── .buildwright/ # Canonical config (committed)
310
+ │ ├── agents/ # Reusable personas
311
+ │ │ ├── architect.md
312
+ │ │ ├── staff-engineer.md
313
+ │ │ └── security-engineer.md
314
+ │ ├── claws/ # Domain specialists
315
+ │ │ ├── frontend.md
316
+ │ │ ├── backend.md
317
+ │ │ ├── database.md
318
+ │ │ └── TEMPLATE.md
319
+ │ ├── codebase/ # Analysis docs (generated by /bw-analyse)
320
+ │ │ ├── STACK.md
321
+ │ │ ├── ARCHITECTURE.md
322
+ │ │ ├── CONVENTIONS.md
323
+ │ │ └── CONCERNS.md
324
+ │ ├── commands/ # Slash commands
325
+ │ │ ├── bw-analyse.md
326
+ │ │ ├── bw-claw.md
327
+ │ │ ├── bw-new-feature.md
328
+ │ │ ├── bw-plan.md
329
+ │ │ ├── bw-quick.md
330
+ │ │ ├── bw-ship.md
331
+ │ │ ├── bw-verify.md
332
+ │ │ └── bw-help.md
333
+ │ ├── steering/ # Project context
334
+ │ │ ├── product.md
335
+ │ │ ├── tech.md
336
+ │ │ ├── quality-gates.md
337
+ │ │ └── naming-conventions.md
338
+ │ └── tasks/
339
+ ├── .claude/ # Generated by `make sync` (gitignored)
340
+ │ ├── settings.json # Claude Code permissions (committed)
341
+ │ └── agents/, claws/, commands/, steering/ (generated)
342
+ ├── .opencode/ # Generated by `make sync` (gitignored)
343
+ ├── .cursor/rules/ # Generated by `make sync` (gitignored)
344
+ ├── AGENTS.md # Generated by `make sync` (gitignored)
345
+ ├── scripts/
346
+ │ ├── sync-agents.sh # Sync .buildwright/ → .claude/ + .opencode/ + .cursor/rules/
347
+ │ ├── install-hooks.sh # Install git hooks (run via: make install-hooks)
348
+ │ ├── validate-skill.sh # Validate SKILL.md against agentskills.io
349
+ │ └── hooks/ # Git hooks source (committed, installed to .git/hooks/)
350
+ │ ├── pre-commit # Auto-sync when .buildwright/ files are staged
351
+ │ ├── post-merge # Auto-sync after git pull/merge
352
+ │ └── post-checkout # Auto-sync on branch switches
353
+ ├── docs/
354
+ │ ├── requirements/
355
+ │ └── specs/
356
+ └── .github/
357
+ └── workflows/
358
+ └── quality-gates.yml
359
+ ```
360
+
361
+ > **Note:** After cloning, run `make sync && make install-hooks` to generate tool-specific configs and install git hooks that auto-sync on `.buildwright/` changes.
362
+
363
+ ---
364
+
365
+ ## Design Principles (Built-In)
366
+
367
+ Every spec and implementation follows:
368
+
369
+ | Principle | Meaning |
370
+ |-----------|---------|
371
+ | **KISS** | Keep It Simple — prefer simple over clever |
372
+ | **YAGNI** | You Aren't Gonna Need It — build only what's needed now, no speculative abstractions |
373
+ | **DRY** | Don't Repeat Yourself — reuse existing code, extract common logic |
374
+ | **No Premature Optimization** | Make it work first, optimize with data |
375
+ | **Boring Technology** | Proven tools over shiny new ones |
376
+ | **Fail Fast** | Validate early, error loudly |
377
+
378
+ ---
379
+
380
+ ## Extending the Workflow
381
+
382
+ ### Add New Agent
383
+
384
+ 1. Create `.buildwright/agents/[role].md`
385
+ 2. Define mindset, checklist, output format
386
+ 3. Reference in commands with `Adopt persona from...`
387
+
388
+ ### Add New Command
389
+
390
+ 1. Create `.buildwright/commands/[name].md`
391
+ 2. Define arguments, phases, output format
392
+ 3. Reference agents as needed
393
+
394
+ ### Planned Agents (Future)
395
+
396
+ | Agent | Purpose |
397
+ |-------|---------|
398
+ | QA Engineer | Test coverage, edge cases |
399
+ | Performance Engineer | Bottleneck identification |
400
+ | DevOps Engineer | Infrastructure review |
401
+ | Database Engineer | Schema review, query optimization |
402
+ | UX Engineer | API design review |
403
+
404
+ ---
405
+
406
+ ## Customization
407
+
408
+ | File | Purpose | Edit Frequency |
409
+ |------|---------|----------------|
410
+ | `.buildwright/steering/product.md` | Product context | Per project |
411
+ | `.buildwright/steering/tech.md` | Tech stack & commands | Per project |
412
+ | `.buildwright/agents/*.md` | Agent personas | Rarely |
413
+ | `.buildwright/commands/*.md` | Slash commands | Rarely |
414
+ | `CLAUDE.md` | Learned patterns | As discovered |
415
+
416
+ ---
417
+
418
+ ## FAQ
419
+
420
+ ### Do I need to review code?
421
+ No. `/bw-ship` handles security review and code review automatically using Staff Engineer and Security Engineer personas.
71
422
 
72
- ## Offline Support
423
+ ### What if a step fails?
424
+ - **Verify fails**: Retries up to 2x automatically.
425
+ - **Security/Review fails**: No retry — requires judgment.
426
+ - **Autonomous mode** (`BUILDWRIGHT_AUTO_APPROVE=true`): Commits completed work, pushes, creates PR with failure details, exits with error code.
427
+ - **Interactive mode** (`BUILDWRIGHT_AUTO_APPROVE=false`): STOP immediately — human fixes in-session.
73
428
 
74
- All templates are bundled in the npm package — `buildwright init` works without internet access after installation. Use `buildwright update` to pull the latest templates from GitHub.
429
+ ### Can I skip security review?
430
+ No. Both `/bw-ship` and `/bw-quick` include mandatory security and code review steps. Use `/bw-verify` for quick checks during active development, before committing.
75
431
 
76
- ## More Information
432
+ ### How do I add project-specific rules?
433
+ Add to `CLAUDE.md` under "Learned Patterns" or create a new agent.
77
434
 
78
- See the [full documentation](https://github.com/raunakkathuria/buildwright) on GitHub.
435
+ ---
79
436
 
80
437
  ## License
81
438
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "buildwright",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "description": "Agent-first autonomous development workflow. Ship code you don't read.",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -35,6 +35,8 @@ You are a **Staff Engineer** with 15+ years of experience building production sy
35
35
  - Security vulnerabilities
36
36
  - Performance foot-guns
37
37
  - Unnecessary complexity
38
+ - Duplicated logic that should reuse existing functions or be extracted into shared utilities
39
+ - Unnecessary new types or abstractions when existing ones suffice
38
40
  - Missing validation
39
41
  - Poor abstractions
40
42
  - Technical debt being introduced
@@ -107,6 +109,8 @@ Only flag issues where:
107
109
  - Security vulnerabilities with a concrete exploit path (defer to security phase in /bw-ship)
108
110
  - Data loss or corruption risk with a traceable scenario
109
111
  - Missing validation at system boundaries where untrusted input enters
112
+ - Reimplemented logic that already exists elsewhere in the codebase (DRY violation with concrete duplicate identified)
113
+ - New types, wrappers, or abstractions not required by current requirements (YAGNI violation)
110
114
 
111
115
  Do NOT flag:
112
116
  - Potential issues that depend on specific inputs or runtime state
@@ -148,6 +148,7 @@ find . -type f -name "*.ts" | xargs grep -l "[relevant terms]"
148
148
  - How does similar functionality work today?
149
149
  - What patterns are used for this type of feature?
150
150
  - What services/utilities already exist that I should use?
151
+ - What types/structs already exist that I can reuse instead of creating new ones?
151
152
  - What would break if I change this?
152
153
 
153
154
  ### 2.3 Read Existing Tests
@@ -208,6 +209,13 @@ Create `docs/specs/[feature-name]/research.md`:
208
209
  - [Service]: [what it does, how to use]
209
210
  - [Utility]: [what it does, how to use]
210
211
 
212
+ ### Reusable Types & Functions
213
+ - [Function/Type]: [location] — [what it does, how to reuse]
214
+ - [Function/Type]: [location] — [what it does, how to reuse]
215
+
216
+ Flag any near-duplicates found during research. If two utilities do similar things,
217
+ recommend which one to use and whether to consolidate.
218
+
211
219
  ### Integration Points
212
220
  - [System A]: Will need to integrate via [method]
213
221
  - [System B]: [description]
@@ -433,9 +441,11 @@ For each milestone:
433
441
 
434
442
  2. **Implement**
435
443
  - Follow patterns identified in research.md
436
- - Use existing services/utilities discovered
444
+ - Use existing services/utilities discovered — do NOT reimplement
445
+ - Reuse existing types and structures — create new ones only when no existing type fits
446
+ - If you find yourself writing logic that resembles something in the codebase, stop and reuse or extract
437
447
  - Write minimal code to pass tests
438
- - Remember: KISS, YAGNI
448
+ - Remember: KISS, YAGNI, DRY
439
449
 
440
450
  3. **Verify (with retry)**
441
451
  ```bash
@@ -453,6 +463,8 @@ For each milestone:
453
463
 
454
464
  After each milestone passes verification, briefly self-review for:
455
465
  - **Simplicity**: Is this the simplest solution? Any unnecessary complexity?
466
+ - **Duplication**: Does this duplicate existing functions, types, or logic? Can anything be reused or extracted?
467
+ - **Necessity**: Is every new type, abstraction, and code path required by the current requirements? Remove anything speculative.
456
468
  - **Correctness**: Any logic errors or missed edge cases in the new code?
457
469
  - **Conventions**: Does the new code follow established project patterns?
458
470
 
@@ -522,6 +534,6 @@ PIPELINE STATUS
522
534
  ✅ Code Reviewed (Staff Engineer)
523
535
  ✅ Shipped
524
536
 
525
- Quality gates running in CI. Will auto-merge on pass.
537
+ Quality gates running in CI. PR ready for team review.
526
538
  ═══════════════════════════════════════════════════════════════
527
539
  ```
@@ -96,6 +96,7 @@ find . -name "*.test.*" -o -name "*.spec.*" | xargs grep -l "[relevant terms]"
96
96
  Understand:
97
97
  - Current implementation
98
98
  - Patterns used in these files
99
+ - Existing functions, types, and utilities that can be reused instead of reimplemented
99
100
  - Related tests
100
101
 
101
102
  **Do NOT write a research document. Keep it in context.**
@@ -122,8 +123,9 @@ Commit: `test: add test for [task]`
122
123
 
123
124
  - Fix the bug / add the feature
124
125
  - Follow existing patterns in the file
126
+ - Reuse existing functions and types — do NOT reimplement what already exists
125
127
  - Minimal changes only
126
- - KISS, YAGNI
128
+ - KISS, YAGNI, DRY
127
129
 
128
130
  ### 3.3 Update Documentation
129
131
 
@@ -153,7 +153,7 @@ git diff HEAD
153
153
 
154
154
  **Phase A — Repository Context:** Understand existing patterns, conventions, error handling, and testing approaches.
155
155
 
156
- **Phase B — Comparative Analysis:** Does new code follow established patterns? Does it bypass or weaken existing controls?
156
+ **Phase B — Comparative Analysis:** Does new code follow established patterns? Does it reuse existing utilities and types instead of reimplementing? Does it bypass or weaken existing controls?
157
157
 
158
158
  **Phase C — Issue Assessment:** Review changes for real issues. For each: verify it's real, confirm it was INTRODUCED by these changes, assign confidence (only report ≥ 80).
159
159
 
@@ -236,7 +236,7 @@ If `gh` is not available, provide the PR creation URL.
236
236
  ╠═══════════════════════════════════════════════════════════════╣
237
237
  ║ ║
238
238
  ║ Quality gates will run in CI. ║
239
- ║ PR will auto-merge when all gates pass.
239
+ ║ PR ready for team review when all gates pass.
240
240
  ║ ║
241
241
  ╚═══════════════════════════════════════════════════════════════╝
242
242
  ```
@@ -31,5 +31,5 @@ These automated gates replace human code review. ALL must pass for merge.
31
31
  - [ ] Rate limiting on sensitive endpoints
32
32
  - [ ] Audit logging for transactions
33
33
 
34
- ## Auto-Merge Criteria
35
- When ALL gates pass → PR auto-merges Deploy triggers
34
+ ## Merge Policy
35
+ When ALL gates pass → PR is ready for merge (team follows their own merge process)
@@ -133,18 +133,3 @@ jobs:
133
133
  go) govulncheck ./... || echo "govulncheck not installed" ;;
134
134
  python) pip-audit || safety check || echo "No Python audit tool" ;;
135
135
  esac
136
-
137
- auto-merge:
138
- needs: quality
139
- runs-on: ubuntu-latest
140
- if: github.event_name == 'pull_request'
141
- permissions:
142
- contents: write
143
- pull-requests: write
144
- steps:
145
- - name: Auto-merge on quality pass
146
- uses: pascalgn/automerge-action@v0.15.6
147
- env:
148
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
149
- MERGE_METHOD: squash
150
- MERGE_LABELS: ""
@@ -119,6 +119,8 @@ When a feature touches multiple domains (e.g., DB + API + UI):
119
119
  - Build only what's required NOW
120
120
  - No speculative features "for later"
121
121
  - Avoid abstractions until they're proven needed
122
+ - No wrapper types, adapter layers, or extension points "just in case"
123
+ - If the requirements don't ask for it, don't build it
122
124
 
123
125
  3. **No Premature Optimization**
124
126
  - Make it work first, then make it fast (if needed)
@@ -135,6 +137,12 @@ When a feature touches multiple domains (e.g., DB + API + UI):
135
137
  - Throw errors early with clear messages
136
138
  - No silent failures
137
139
 
140
+ 6. **DRY (Don't Repeat Yourself)**
141
+ - Before writing new code, search for existing functions, types, and utilities that already do the job
142
+ - Reuse existing structures — if `User` exists, don't create `UserDTO` or `UserEntity` unless the codebase already separates those concerns
143
+ - If two pieces of code do similar things, extract the common part rather than duplicating
144
+ - Prefer importing over reimplementing
145
+
138
146
  ## Code Standards
139
147
  - Follow existing patterns in the codebase exactly
140
148
  - Keep files under 500 lines; split proactively
@@ -60,7 +60,11 @@ sync_dir() {
60
60
  tmpdir=$(mktemp -d)
61
61
  cp -R "$src/"* "$tmpdir/" 2>/dev/null || true
62
62
  if [ -n "$rewrite_from" ] && [ -n "$rewrite_to" ]; then
63
- find "$tmpdir" -name "*.md" -exec sed -i "s|$rewrite_from|$rewrite_to|g" {} + 2>/dev/null || true
63
+ # Only rewrite @@.buildwright/ (read instructions) → tool-specific path
64
+ # Bare .buildwright/ (write/canonical instructions) stays untouched
65
+ find "$tmpdir" -name "*.md" -exec sed -i '' \
66
+ -e "s|@@${rewrite_from}|${rewrite_to}|g" \
67
+ {} + 2>/dev/null || true
64
68
  fi
65
69
  if ! diff -rq "$tmpdir" "$dst" > /dev/null 2>&1; then
66
70
  echo "OUT OF SYNC: $dst differs from $src"
@@ -71,8 +75,12 @@ sync_dir() {
71
75
  mkdir -p "$dst"
72
76
  rsync -a --delete "$src/" "$dst/" 2>/dev/null || (rm -rf "$dst"/* && cp -R "$src/"* "$dst/")
73
77
  # Rewrite path references for tool-specific copies
78
+ # @@.buildwright/ = "resolve to tool-specific dir" → gets rewritten
79
+ # Bare .buildwright/ = "canonical path" → stays untouched
74
80
  if [ -n "$rewrite_from" ] && [ -n "$rewrite_to" ]; then
75
- find "$dst" -name "*.md" -exec sed -i "s|$rewrite_from|$rewrite_to|g" {} + 2>/dev/null || true
81
+ find "$dst" -name "*.md" -exec sed -i '' \
82
+ -e "s|@@${rewrite_from}|${rewrite_to}|g" \
83
+ {} + 2>/dev/null || true
76
84
  fi
77
85
  echo " synced $src → $dst"
78
86
  fi
@@ -284,6 +292,15 @@ if [ "$CHECK_ONLY" = false ] && [ -f "SKILL.md" ]; then
284
292
  echo " packaged dist/buildwright/SKILL.md for ClawHub"
285
293
  fi
286
294
 
295
+ # ============================================================================
296
+ # 7. README.md → cli/README.md (single source of truth for npm package page)
297
+ # ============================================================================
298
+
299
+ if [ "$CHECK_ONLY" = false ] && [ -f "README.md" ]; then
300
+ cp README.md cli/README.md
301
+ echo " README.md → cli/README.md"
302
+ fi
303
+
287
304
  # ============================================================================
288
305
  # Result
289
306
  # ============================================================================
@@ -306,6 +323,7 @@ else
306
323
  echo " CLAUDE.md → AGENTS.md"
307
324
  echo " SKILL.md → dist/buildwright/SKILL.md"
308
325
  echo " .buildwright/commands/ → skills/ (Codex CLI skill discovery)"
326
+ echo " README.md → cli/README.md (npm package page)"
309
327
 
310
328
  # Validate all commands are documented in SKILL.md and README.md
311
329
  if [ -f "scripts/validate-docs.sh" ]; then