specweave 1.0.78 → 1.0.80

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.md CHANGED
@@ -1,10 +1,10 @@
1
- <!-- SW:META template="claude" version="1.0.60" sections="header,start,autodetect,metarule,rules,workflow,context,lsp,structure,taskformat,secrets,syncing,mapping,testing,api,limits,troubleshooting,principles,linking,mcp,autoexecute,auto,docs" -->
1
+ <!-- SW:META template="claude" version="1.0.79" sections="header,start,autodetect,metarule,rules,workflow,context,lsp,structure,taskformat,secrets,syncing,mapping,testing,api,limits,troubleshooting,principles,linking,mcp,autoexecute,auto,docs" -->
2
2
 
3
- <!-- SW:SECTION:header version="1.0.60" -->
3
+ <!-- SW:SECTION:header version="1.0.79" -->
4
4
  **Framework**: SpecWeave | **Truth**: `spec.md` + `tasks.md`
5
5
  <!-- SW:END:header -->
6
6
 
7
- <!-- SW:SECTION:start version="1.0.60" -->
7
+ <!-- SW:SECTION:start version="1.0.79" -->
8
8
  ## Getting Started
9
9
 
10
10
  **Initial increment**: `0001-project-setup` (auto-created by `specweave init`)
@@ -14,7 +14,7 @@
14
14
  2. **Customize**: Edit spec.md and use for setup tasks
15
15
  <!-- SW:END:start -->
16
16
 
17
- <!-- SW:SECTION:autodetect version="1.0.60" -->
17
+ <!-- SW:SECTION:autodetect version="1.0.79" -->
18
18
  ## Auto-Detection
19
19
 
20
20
  SpecWeave auto-detects product descriptions and routes to `/sw:increment`:
@@ -24,7 +24,7 @@ SpecWeave auto-detects product descriptions and routes to `/sw:increment`:
24
24
  **Opt-out phrases**: "Just brainstorm first" | "Don't plan yet" | "Quick discussion" | "Let's explore ideas"
25
25
  <!-- SW:END:autodetect -->
26
26
 
27
- <!-- SW:SECTION:metarule version="1.0.60" -->
27
+ <!-- SW:SECTION:metarule version="1.0.79" -->
28
28
  ## Meta-Rule: Think-Before-Act
29
29
 
30
30
  **Satisfy dependencies BEFORE dependent operations.**
@@ -35,7 +35,7 @@ SpecWeave auto-detects product descriptions and routes to `/sw:increment`:
35
35
  ```
36
36
  <!-- SW:END:metarule -->
37
37
 
38
- <!-- SW:SECTION:rules version="1.0.60" -->
38
+ <!-- SW:SECTION:rules version="1.0.79" -->
39
39
  ## Rules
40
40
 
41
41
  1. **Files** → `.specweave/increments/####-name/` (spec.md, plan.md, tasks.md at root; reports/, scripts/, logs/ subfolders)
@@ -45,7 +45,7 @@ SpecWeave auto-detects product descriptions and routes to `/sw:increment`:
45
45
  5. **Root clean**: NEVER create .md/reports/scripts in project root → use increment folders
46
46
  <!-- SW:END:rules -->
47
47
 
48
- <!-- SW:SECTION:workflow version="1.0.60" -->
48
+ <!-- SW:SECTION:workflow version="1.0.79" -->
49
49
  ## Workflow
50
50
 
51
51
  `/sw:increment "X"` → `/sw:do` → `/sw:progress` → `/sw:done 0001`
@@ -65,7 +65,7 @@ SpecWeave auto-detects product descriptions and routes to `/sw:increment`:
65
65
  **Natural language**: "Let's build X" → `/sw:increment` | "What's status?" → `/sw:progress` | "We're done" → `/sw:done` | "Ship while sleeping" → `/sw:auto`
66
66
  <!-- SW:END:workflow -->
67
67
 
68
- <!-- SW:SECTION:context version="1.0.60" -->
68
+ <!-- SW:SECTION:context version="1.0.79" -->
69
69
  ## Living Docs Context
70
70
 
71
71
  **Before implementing features**: Check existing docs for patterns and decisions.
@@ -85,176 +85,51 @@ grep -ril "keyword" .specweave/docs/internal/
85
85
  **Use `/sw:context <topic>`** to load relevant living docs into conversation.
86
86
  <!-- SW:END:context -->
87
87
 
88
- <!-- SW:SECTION:lsp version="1.0.61" -->
89
- ## LSP-Enhanced Exploration (ACTIVE - Claude Code 2.0.74+)
88
+ <!-- SW:SECTION:lsp version="1.0.79" -->
89
+ ## LSP-Enhanced Exploration
90
90
 
91
- **LSP is POWERFUL - USE IT ACTIVELY** for semantic code understanding. 100x faster and more accurate than grep.
91
+ **USE LSP ACTIVELY** for semantic code understanding (100x faster than grep).
92
92
 
93
- **WHEN to use LSP (PROACTIVE):**
93
+ **Key operations**: `findReferences` (before refactoring) | `goToDefinition` (navigate) | `documentSymbol` (structure) | `hover` (types) | `getDiagnostics` (errors)
94
94
 
95
- | Scenario | LSP Operation | Why Use It |
96
- |----------|---------------|------------|
97
- | Before refactoring | `findReferences` | Know ALL usages before changing |
98
- | Navigate to source | `goToDefinition` | Jump directly to implementation |
99
- | Understand module | `documentSymbol` | See complete structure/hierarchy |
100
- | Check types | `hover` | Get accurate signatures, JSDoc |
101
- | Code quality | `getDiagnostics` | Errors, warnings before commit |
102
-
103
- **ACTIVE Usage Examples:**
95
+ **Install**:
104
96
  ```bash
105
- # Before renaming a function - find ALL references
106
- "Use LSP findReferences to find all usages of calculateTax"
107
-
108
- # Navigate to implementation instead of grep
109
- "Use goToDefinition to find where PaymentService is defined"
110
-
111
- # Get accurate type signature
112
- "Use hover to check the type of processOrder function"
113
-
114
- # Check for errors before suggesting changes
115
- "Use getDiagnostics on this file to check for issues"
116
-
117
- # Understand module structure
118
- "Use documentSymbol to map the API surface of auth.ts"
97
+ npm install -g typescript-language-server typescript # TS/JS
98
+ pip install python-lsp-server # Python
99
+ go install golang.org/x/tools/gopls@latest # Go
119
100
  ```
120
101
 
121
- **Smart Integration (ADR-0222):**
122
- - LSP is EXEMPT from "Code First, Tools Second" rule (ADR-0140)
123
- - LSP responses are small (~100-5000 bytes), no context bloat
124
- - Use LSP for precision, code execution for bulk processing
125
-
126
- **Install Language Servers** (required):
127
- ```bash
128
- # TypeScript/JavaScript
129
- npm install -g typescript-language-server typescript
130
-
131
- # Python
132
- pip install python-lsp-server
133
-
134
- # Go
135
- go install golang.org/x/tools/gopls@latest
136
-
137
- # C#
138
- brew install omnisharp # or: dotnet tool install -g omnisharp
139
- ```
140
-
141
- **Configuration** (optional, `.lsp.json` in project root):
142
- ```json
143
- {
144
- "vtsls": {
145
- "command": "typescript-language-server",
146
- "args": ["--stdio"],
147
- "extensionToLanguage": { ".ts": "typescript", ".tsx": "typescriptreact", ".js": "javascript" }
148
- }
149
- }
150
- ```
151
-
152
- **Best Practices**:
153
- - **ALWAYS use findReferences** before any refactoring
154
- - **ALWAYS use goToDefinition** instead of grep for navigation
155
- - **Use documentSymbol** to understand module organization
156
- - **Use hover** to verify type signatures before changes
157
- - Combine with Explore agent for comprehensive understanding
102
+ **Best Practices**: ALWAYS use `findReferences` before refactoring | Use `goToDefinition` instead of grep | Combine with Explore agent
158
103
  <!-- SW:END:lsp -->
159
104
 
160
- <!-- SW:SECTION:structure version="1.0.61" -->
105
+ <!-- SW:SECTION:structure version="1.0.79" -->
161
106
  ## Structure
162
107
 
163
108
  ```
164
109
  .specweave/
165
110
  ├── increments/####-name/ # metadata.json, spec.md, tasks.md
166
- ├── docs/internal/
167
- ├── specs/{project}/ # Living docs (check before implementing!)
168
- │ ├── architecture/adr/ # ADRs (check before design decisions!)
169
- │ └── operations/ # Runbooks
111
+ ├── docs/internal/specs/ # Living docs (check before implementing!)
112
+ └── architecture/adr/ # ADRs (check before design decisions!)
170
113
  └── config.json
171
114
  ```
172
115
 
173
- ### ⚠️ CRITICAL: Increment Folder Organization (MANDATORY)
174
-
175
- **ONLY these files allowed at increment ROOT:**
176
- ```
177
- .specweave/increments/####-name/
178
- ├── metadata.json # Increment state
179
- ├── spec.md # Specification
180
- ├── plan.md # Implementation plan
181
- └── tasks.md # Task list
182
- ```
183
-
184
- **ALL other files MUST go in subfolders:**
185
- ```
186
- .specweave/increments/####-name/
187
- ├── reports/ # Validation reports, QA reports, completion summaries
188
- │ └── *.md # PM-VALIDATION-REPORT.md, qa-post-closure.md, etc.
189
- ├── logs/ # Debug logs, execution traces, session logs
190
- │ └── {YYYY-MM-DD}/ # Daily logs with assets/
191
- ├── scripts/ # Helper scripts, automation tools
192
- ├── docs/ # Additional documentation, domain knowledge
193
- │ └── domain/ # Domain models for brownfield analysis
194
- └── backups/ # Backup files
195
- ```
196
-
197
- **File Routing Rules:**
198
- | File Type | Folder | Examples |
199
- |-----------|--------|----------|
200
- | Validation reports | `reports/` | `PM-VALIDATION-REPORT.md`, `validation-report.md` |
201
- | QA assessments | `reports/` | `qa-post-closure.md`, `COMPLETION-SUMMARY.md` |
202
- | Session logs | `logs/{date}/` | `session.md`, `assets/` |
203
- | Domain analysis | `docs/domain/` | `appointments/domain-model.md` |
204
- | Helper scripts | `scripts/` | `migrate.sh`, `validate.js` |
116
+ **Increment folders - ONLY at root**: metadata.json, spec.md, plan.md, tasks.md
117
+ **Everything else → subfolders**: reports/ (validation, QA) | logs/{YYYY-MM-DD}/ | scripts/ | docs/domain/ | backups/
205
118
 
206
- **FORBIDDEN - Files that pollute increment root:**
119
+ **Multi-repo projects**: Create in `repositories/` folder (NEVER project root!)
207
120
  ```
208
- ❌ .specweave/increments/0001/PM-VALIDATION-REPORT.md # → reports/
209
- ❌ .specweave/increments/0001/completion-report.md # → reports/
210
- ❌ .specweave/increments/0001/domain-model.md # → docs/domain/
211
- ❌ .specweave/increments/0001/helper.sh # → scripts/
212
- ```
213
-
214
- ### ⚠️ CRITICAL: Multi-Repo Project Paths (MANDATORY)
215
-
216
- **ALL multi-project repositories MUST be created in `repositories/` folder - NEVER in project root!**
217
-
218
- ```
219
- ❌ FORBIDDEN (pollutes root):
220
- my-project/
221
- ├── frontend/ ← WRONG!
222
- ├── backend/ ← WRONG!
223
- ├── shared/ ← WRONG!
224
- └── .specweave/
225
-
226
- ✅ REQUIRED (clean structure):
227
121
  my-project/
228
- ├── repositories/
229
- │ ├── frontend/ ← CORRECT!
230
- │ ├── backend/ ← CORRECT!
231
- │ └── shared/ ← CORRECT!
122
+ ├── repositories/ # All repos here: frontend/, backend/, shared/
232
123
  └── .specweave/
233
124
  ```
234
125
 
235
- **This applies to ALL cases:**
236
- - GitHub multi-repo → `repositories/`
237
- - Azure DevOps multi-repo → `repositories/`
238
- - Bitbucket multi-repo → `repositories/`
239
- - **Local git multi-repo → `repositories/`** ← Same rule!
240
- - Monorepo with multiple packages → `repositories/` or `packages/`
241
-
242
- **When spec.md has `projects:` array:**
243
- ```yaml
244
- projects:
245
- - id: my-api
246
- scope: "Backend API"
247
- ```
248
- The implementation path is ALWAYS: `repositories/my-api/` (NOT `my-api/` in root!)
249
-
250
- **Multi-repo permissions**: In `.claude/settings.json`:
126
+ **Permissions** (`.claude/settings.json`):
251
127
  ```json
252
- {"permissions":{"allow":["Write(//**)","Edit(//**)"],"additionalDirectories":["repositories"],"defaultMode":"bypassPermissions"}}
128
+ {"permissions":{"allow":["Write(//**)","Edit(//**)"],"additionalDirectories":["repositories"]}}
253
129
  ```
254
- **Path syntax**: `//path` = absolute | `/path` = relative to settings file | `**` = recursive | `additionalDirectories` = explicit working dirs
255
130
  <!-- SW:END:structure -->
256
131
 
257
- <!-- SW:SECTION:taskformat version="1.0.60" -->
132
+ <!-- SW:SECTION:taskformat version="1.0.79" -->
258
133
  ## Task Format
259
134
 
260
135
  ```markdown
@@ -264,7 +139,7 @@ The implementation path is ALWAYS: `repositories/my-api/` (NOT `my-api/` in root
264
139
  ```
265
140
  <!-- SW:END:taskformat -->
266
141
 
267
- <!-- SW:SECTION:secrets version="1.0.60" -->
142
+ <!-- SW:SECTION:secrets version="1.0.79" -->
268
143
  ## Secrets Check
269
144
 
270
145
  **BEFORE CLI tools**: Check existing config first!
@@ -275,7 +150,7 @@ gh auth status
275
150
  ```
276
151
  <!-- SW:END:secrets -->
277
152
 
278
- <!-- SW:SECTION:syncing version="1.0.60" -->
153
+ <!-- SW:SECTION:syncing version="1.0.79" -->
279
154
  ## External Sync (GitHub/JIRA/ADO)
280
155
 
281
156
  **After increment creation**: Run `/sw-github:sync {id}` to create issues!
@@ -303,7 +178,7 @@ Living docs sync ≠ External sync. They are separate:
303
178
  **Verify tokens**: `grep GITHUB_TOKEN .env` | `gh auth status`
304
179
  <!-- SW:END:syncing -->
305
180
 
306
- <!-- SW:SECTION:mapping version="1.0.60" -->
181
+ <!-- SW:SECTION:mapping version="1.0.79" -->
307
182
  ## GitHub Mapping
308
183
 
309
184
  | SpecWeave | GitHub |
@@ -313,7 +188,7 @@ Living docs sync ≠ External sync. They are separate:
313
188
  | Task T-XXX | Checkbox |
314
189
  <!-- SW:END:mapping -->
315
190
 
316
- <!-- SW:SECTION:testing version="1.0.60" -->
191
+ <!-- SW:SECTION:testing version="1.0.79" -->
317
192
  ## Testing
318
193
 
319
194
  BDD in tasks.md | Unit >80% | `.test.ts` (Vitest)
@@ -325,106 +200,32 @@ vi.mock('fs', () => ({ readFile: vi.fn() }));
325
200
  ```
326
201
  <!-- SW:END:testing -->
327
202
 
328
- <!-- SW:SECTION:api version="1.0.60" -->
203
+ <!-- SW:SECTION:api version="1.0.79" -->
329
204
  ## API Development (OpenAPI-First)
330
205
 
331
- **For API projects only.** Skip this section if your project has no REST/GraphQL endpoints.
332
-
333
- **Use OpenAPI as the source of truth for API documentation.** Postman collections and environments are derived from OpenAPI and .env.
334
-
335
- ### Configuration (`.specweave/config.json`)
206
+ **For API projects only.** OpenAPI = source of truth Postman derived from it.
336
207
 
208
+ **Config** (`.specweave/config.json`):
337
209
  ```json
338
- {
339
- "apiDocs": {
340
- "enabled": true,
341
- "openApiPath": "openapi.yaml",
342
- "generatePostman": true,
343
- "postmanPath": "postman-collection.json",
344
- "postmanEnvPath": "postman-environment.json",
345
- "generateOn": "on-increment-done",
346
- "baseUrl": "http://localhost:3000"
347
- }
348
- }
349
- ```
350
-
351
- ### Generated Artifacts
352
-
353
- | File | Purpose | Source |
354
- |------|---------|--------|
355
- | `openapi.yaml` | API specification (source of truth) | Framework decorators/annotations |
356
- | `postman-collection.json` | API requests for testing | Derived from OpenAPI |
357
- | `postman-environment.json` | Variables (baseUrl, tokens, etc.) | Derived from .env |
358
-
359
- ### OpenAPI Generation by Framework
360
-
361
- | Framework | Auto-Generation | Setup |
362
- |-----------|-----------------|-------|
363
- | **NestJS** | `@nestjs/swagger` | Decorators auto-generate OpenAPI |
364
- | **FastAPI** | Built-in | Auto-generates at `/openapi.json` |
365
- | **Express** | `swagger-jsdoc` | JSDoc comments → OpenAPI |
366
- | **Spring Boot** | `springdoc-openapi` | Annotations auto-generate |
367
- | **Go/Gin** | `swag` | Comments → OpenAPI |
368
-
369
- ### Workflow
370
-
371
- ```
372
- ┌─────────────────────────────────────────────────────────────┐
373
- │ Code (decorators/annotations) │
374
- │ ↓ (auto-generated or manual) │
375
- │ openapi.yaml (SOURCE OF TRUTH - version controlled) │
376
- │ ↓ (derived on /sw:done or /sw:api-docs) │
377
- │ ├── postman-collection.json (requests with {{baseUrl}}) │
378
- │ └── postman-environment.json (variables from .env) │
379
- └─────────────────────────────────────────────────────────────┘
210
+ {"apiDocs":{"enabled":true,"openApiPath":"openapi.yaml","generatePostman":true,"generateOn":"on-increment-done"}}
380
211
  ```
381
212
 
382
- ### Commands
213
+ **Frameworks**: NestJS (`@nestjs/swagger`) | FastAPI (built-in) | Express (`swagger-jsdoc`) | Spring Boot (`springdoc-openapi`)
383
214
 
384
- ```bash
385
- # Generate all API docs (OpenAPI + Postman collection + environment)
386
- /sw:api-docs --all
215
+ **Commands**: `/sw:api-docs --all` (OpenAPI + Postman) | `--openapi` | `--postman` | `--env` | `--validate`
387
216
 
388
- # Generate only OpenAPI
389
- /sw:api-docs --openapi
390
-
391
- # Generate only Postman collection from existing OpenAPI
392
- /sw:api-docs --postman
393
-
394
- # Generate only environment file from .env
395
- /sw:api-docs --env
396
-
397
- # Validate existing OpenAPI spec
398
- /sw:api-docs --validate
399
-
400
- # Generate on increment close (automatic if enabled)
401
- /sw:done 0001 # → triggers API doc generation
402
- ```
217
+ **Flow**: Code decorators → `openapi.yaml` → `/sw:done` or `/sw:api-docs` → Postman collection + env
403
218
 
404
- ### Postman Import
405
-
406
- After generation:
407
- 1. Postman → Import → `postman-collection.json`
408
- 2. Postman → Environments → Import → `postman-environment.json`
409
- 3. Fill in secret values (marked as secret type, values empty)
410
- 4. Select environment from dropdown
411
-
412
- ### When Docs Update
413
-
414
- | `generateOn` Setting | When API Docs Regenerate |
415
- |---------------------|--------------------------|
416
- | `on-increment-done` | When closing increment (recommended) |
417
- | `on-api-change` | When API files change (hook-based) |
418
- | `manual` | Only via `/sw:api-docs` command |
219
+ **Import**: Postman Import collection + env → Fill secrets → Select env
419
220
  <!-- SW:END:api -->
420
221
 
421
- <!-- SW:SECTION:limits version="1.0.60" -->
222
+ <!-- SW:SECTION:limits version="1.0.79" -->
422
223
  ## Limits
423
224
 
424
225
  **Max 1500 lines/file** — extract before adding
425
226
  <!-- SW:END:limits -->
426
227
 
427
- <!-- SW:SECTION:troubleshooting version="1.0.60" -->
228
+ <!-- SW:SECTION:troubleshooting version="1.0.79" -->
428
229
  ## Troubleshooting
429
230
 
430
231
  | Issue | Fix |
@@ -441,10 +242,9 @@ After generation:
441
242
  | No GITHUB_TOKEN | Check `.env` file or run `gh auth login` |
442
243
  | Edits blocked in repositories/ | Add `"additionalDirectories":["repositories"]` + `Write(//**)`, `Edit(//**)` to `.claude/settings.json` |
443
244
  | Path patterns not working | `//path` = absolute, `/path` = relative to settings file, `additionalDirectories` for explicit working dirs |
444
- | **specweave/claude not found after Node upgrade** | **nvm users**: Global packages are lost when switching Node versions! Fix: `nvm reinstall-packages <old-version>` OR `npm install -g specweave @anthropic-ai/claude-code`. See [Node Version Management](/.specweave/docs/internal/operations/runbook-node-version-management.md) |
445
245
  <!-- SW:END:troubleshooting -->
446
246
 
447
- <!-- SW:SECTION:principles version="1.0.60" -->
247
+ <!-- SW:SECTION:principles version="1.0.79" -->
448
248
  ## Principles
449
249
 
450
250
  1. **Spec-first**: `/sw:increment` before coding
@@ -454,7 +254,7 @@ After generation:
454
254
  5. **Clean**: All files in increment folders
455
255
  <!-- SW:END:principles -->
456
256
 
457
- <!-- SW:SECTION:linking version="1.0.60" -->
257
+ <!-- SW:SECTION:linking version="1.0.79" -->
458
258
  ## Bidirectional Linking
459
259
 
460
260
  Tasks ↔ User Stories auto-linked via AC-IDs: `AC-US1-01` → `US-001`
@@ -462,534 +262,118 @@ Tasks ↔ User Stories auto-linked via AC-IDs: `AC-US1-01` → `US-001`
462
262
  Task format: `**AC**: AC-US1-01, AC-US1-02` (CRITICAL for linking)
463
263
  <!-- SW:END:linking -->
464
264
 
465
- <!-- SW:SECTION:mcp version="1.0.60" -->
466
- ## External Service Connection (MCP + Smart Fallbacks)
467
-
468
- **Core principle: Never fight connection issues. Use the path of least resistance.**
469
-
470
- ### Connection Priority (ALWAYS follow this order)
471
-
472
- ```
473
- MCP Server → REST API → SDK/Client → CLI → Direct Connection
474
- ↑ ↓
475
- BEST WORST
476
- ```
477
-
478
- ### Service Connection Matrix
479
-
480
- | Service | BEST Method | Fallback | AVOID |
481
- |---------|-------------|----------|-------|
482
- | **Supabase** | MCP Server | REST API / JS Client | Direct `psql` (IPv6 issues) |
483
- | **Cloudflare** | `wrangler` + OAuth | REST API | Manual curl |
484
- | **PostgreSQL** | MCP / Pooler (6543) | `psql` with pooler | Direct port 5432 |
485
- | **MongoDB** | Atlas Data API | MCP / Driver | Direct connection |
486
- | **Redis** | Upstash REST | MCP | `redis-cli` (TCP issues) |
487
- | **AWS** | CLI with SSO | SDK | Hardcoded keys |
488
- | **Vercel** | CLI with OAuth | REST API | Manual deploys |
265
+ <!-- SW:SECTION:mcp version="1.0.79" -->
266
+ ## External Service Connection
489
267
 
490
- ### Quick Setup Commands
268
+ **Priority**: MCP Server → REST API → CLI → Direct Connection
491
269
 
270
+ **Setup**:
492
271
  ```bash
493
- # MCP Servers (one-time, restart Claude Code after)
272
+ # MCP (restart Claude Code after)
494
273
  npx @anthropic-ai/claude-code-mcp add supabase
495
- npx @anthropic-ai/claude-code-mcp add postgres
496
274
 
497
- # CLI Auth (persistent OAuth sessions)
498
- wrangler login # Cloudflare
499
- vercel login # Vercel
500
- aws configure sso # AWS
501
- supabase login # Supabase CLI
502
-
503
- # Verify auth status
504
- wrangler whoami && vercel whoami && aws sts get-caller-identity
505
- ```
506
-
507
- ### Supabase (Most Common Issues)
508
-
509
- ```bash
510
- # ❌ DON'T: Direct psql or supabase db push (IPv6 fails)
511
- supabase db push # Often fails with connection errors
512
-
513
- # ✅ DO: Use REST API or MCP
514
- # REST API works everywhere - no network issues
515
- curl "${SUPABASE_URL}/rest/v1/table" \
516
- -H "apikey: ${SUPABASE_ANON_KEY}"
517
-
518
- # For migrations: Use Supabase Dashboard SQL Editor
519
- # OR use connection pooler (port 6543, NOT 5432)
520
- DATABASE_URL="postgresql://postgres.[ref]:[pass]@aws-0-region.pooler.supabase.com:6543/postgres"
521
- ```
522
-
523
- ### Cloudflare Workers
524
-
525
- ```bash
526
- # One-time login (saves OAuth session)
527
- wrangler login
528
-
529
- # All operations then work:
530
- wrangler deploy # Deploy worker
531
- echo "value" | wrangler secret put KEY # Set secret
532
- wrangler kv:key put --binding=KV k v # KV operations
533
- wrangler d1 execute DB --command "SQL" # D1 database
275
+ # CLI Auth
276
+ wrangler login && vercel login && supabase login
534
277
  ```
535
278
 
536
- ### Auto-Detection (Run Before External Ops)
279
+ **Supabase**: Use REST API or pooler (port 6543), AVOID direct `psql`
280
+ **Cloudflare**: `wrangler login` once, then `wrangler deploy/secret put/kv:key put`
537
281
 
282
+ **Check credentials before ops**:
538
283
  ```bash
539
- # Check configured services
540
- grep -E "SUPABASE_|DATABASE_URL|MONGODB|UPSTASH|CF_API" .env 2>/dev/null
284
+ grep -E "SUPABASE_|DATABASE_URL|CF_API" .env 2>/dev/null
541
285
  wrangler whoami 2>/dev/null
542
- aws sts get-caller-identity 2>/dev/null
543
286
  ```
544
-
545
- **Full reference**: See `/sw:service-connect` skill for complete patterns.
546
287
  <!-- SW:END:mcp -->
547
288
 
548
- <!-- SW:SECTION:autoexecute version="1.0.60" -->
549
- ## Auto-Execute Rule (CRITICAL)
550
-
551
- **NEVER output "Manual Step Required" or "Next Steps" when credentials are available.**
552
-
553
- ### The Golden Rule
554
-
555
- ```
556
- ❌ FORBIDDEN: "Manual Step Required: Open Supabase SQL Editor..."
557
- ❌ FORBIDDEN: "Next Steps: 1. Run wrangler deploy..."
558
- ❌ FORBIDDEN: "Execute this SQL in your database console..."
559
-
560
- ✅ REQUIRED: Execute commands directly using available credentials
561
- ```
562
-
563
- ### Decision Tree
289
+ <!-- SW:SECTION:autoexecute version="1.0.79" -->
290
+ ## Auto-Execute Rule
564
291
 
565
- ```
566
- Credentials in .env? ──YES──→ EXECUTE IMMEDIATELY
567
-
568
- NO
569
-
570
-
571
- ASK for credentials (don't show manual steps!)
572
-
573
-
574
- Save to .env → EXECUTE IMMEDIATELY → Continue
575
- ```
292
+ **NEVER** output "Manual Step Required" when credentials exist. **EXECUTE DIRECTLY.**
576
293
 
577
- ### Credential Lookup (MANDATORY before any external operation)
294
+ **Flow**: Check `.env` If exists, EXECUTE | If missing, ASK for credentials → Save → EXECUTE
578
295
 
296
+ **Check before ops**:
579
297
  ```bash
580
- # 1. Check .env
581
298
  grep -E "(SUPABASE_|DATABASE_URL|CF_API_|GITHUB_TOKEN)" .env 2>/dev/null
582
-
583
- # 2. Check CLI auth
584
- supabase status 2>/dev/null # Supabase
585
- wrangler whoami 2>/dev/null # Cloudflare
586
- gh auth status 2>/dev/null # GitHub
587
- aws sts get-caller-identity 2>/dev/null # AWS
588
-
589
- # 3. Use MCP server if available
590
- # MCP servers provide direct API access
591
- ```
592
-
593
- ### Auto-Execute Examples
594
-
595
- ```bash
596
- # Supabase SQL execution
597
- if [ -n "$DATABASE_URL" ]; then
598
- psql "$DATABASE_URL" -f schema.sql # ✅ Execute directly
599
- fi
600
-
601
- # Wrangler secrets
602
- if wrangler whoami 2>/dev/null; then
603
- echo "$SECRET" | wrangler secret put MY_SECRET # ✅ Execute directly
604
- wrangler deploy # ✅ Deploy directly
605
- fi
606
- ```
607
-
608
- ### If Credentials Missing → ASK, Don't Show Manual Steps
609
-
610
- ```markdown
611
- 🔐 **Credential Required**
612
-
613
- I need your DATABASE_URL to execute the migration.
614
-
615
- **Paste your connection string:**
616
- [I will save to .env and execute automatically]
299
+ wrangler whoami 2>/dev/null && gh auth status 2>/dev/null
617
300
  ```
618
301
  <!-- SW:END:autoexecute -->
619
302
 
620
- <!-- SW:SECTION:auto version="1.0.60" -->
303
+ <!-- SW:SECTION:auto version="1.0.79" -->
621
304
  ## Auto Mode (Autonomous Execution)
622
305
 
623
- **Auto mode enables continuous autonomous execution** until all tasks are complete.
624
-
625
- ### 🆕 Intelligent Increment Creation (NEW!)
626
-
627
- **Auto mode now auto-creates increments when none exist!**
628
-
629
- **Default behavior**: `/sw:auto` with no arguments will:
630
- 1. Check for active/in-progress increments → use if found
631
- 2. If none found → **intelligently create increments** based on user context
632
- 3. Match existing planned/backlog increments OR create new ones
633
- 4. Ask user if ambiguous
634
-
635
- **Strict mode**: Use `--no-increment` or `--no-inc` flag to require existing increments (no auto-creation)
636
-
637
- **Examples:**
638
- ```bash
639
- # User says: "Let's build the dashboard feature"
640
- /sw:auto
641
- # → Finds 0004-dashboard in backlog OR creates it
642
-
643
- # User says: "Work on auth and notifications"
644
- /sw:auto
645
- # → Creates queue: [0001-auth, 0002-notifications]
646
-
647
- # Strict mode (no auto-creation) - both forms work
648
- /sw:auto --no-increment
649
- /sw:auto --no-inc
650
- # → ERROR if no active increment
651
- ```
652
-
653
- **Intelligence patterns:**
654
- - **Match**: "continue auth" → finds `0002-authentication`
655
- - **Extend**: "add password reset" → adds tasks to active auth increment
656
- - **Create**: "build payment system" → creates `0003-payment-integration`
657
- - **Queue**: "finish all pending" → processes all backlog items
658
- - **Ask**: If ambiguous → present options to user
659
-
660
- ### 🚨 CRITICAL: Zero Manual Steps in Auto Mode
661
-
662
- **Auto mode MUST be fully autonomous. NEVER ask user to:**
663
- - Open a web dashboard (Supabase, AWS Console, etc.)
664
- - Copy/paste SQL into an editor
665
- - Run commands manually
666
- - Click buttons in UIs
667
-
668
- **If you need external access:**
669
- 1. Check for credentials in `.env`
670
- 2. Use CLI tools (`supabase`, `wrangler`, `gh`, `aws`)
671
- 3. Use MCP servers for direct API access
672
- 4. If credentials missing → ASK for them, save to `.env`, then EXECUTE
673
-
674
- ### 🧪 Test Execution Loop (MANDATORY)
675
-
676
- **After EVERY implementation task, run tests in a self-healing loop:**
677
-
678
- ```bash
679
- # 1. Run unit/integration tests
680
- npm test # or: npx vitest run
681
-
682
- # 2. If UI exists, run E2E tests
683
- npx playwright test
684
-
685
- # 3. If tests fail → FIX → RE-RUN (max 3 attempts)
686
- ```
687
-
688
- **Test Loop Pattern (Ralph Loop):**
689
- ```
690
- ┌─────────────────────────────────────────────────────────────┐
691
- │ IMPLEMENT → TEST → FAIL? → FIX → TEST → PASS → NEXT TASK │
692
- │ ↑________________↓ │
693
- │ (max 3 iterations) │
694
- └─────────────────────────────────────────────────────────────┘
695
- ```
696
-
697
- **E2E Test Execution (when UI exists):**
698
- ```bash
699
- # Install Playwright browsers if needed
700
- npx playwright install --with-deps chromium
701
-
702
- # Run E2E tests with proper reporting
703
- npx playwright test --reporter=list
704
-
705
- # On failure, capture screenshot/trace
706
- npx playwright test --trace on
707
- ```
708
-
709
- **Focus on MVP Critical Paths:**
710
- 1. **Authentication flows** (login, logout, register)
711
- 2. **Core business transactions** (create, update, delete)
712
- 3. **Payment/checkout flows** (if applicable)
713
- 4. **Data integrity scenarios**
714
-
715
- ### ⚠️ Pragmatic Completion (NOT 100% Blindly!)
716
-
717
- **Don't blindly follow 100% completion rules!** Reality:
718
- - Specs have bugs, ambiguities, conflicts
719
- - Requirements change mid-implementation
720
- - Some planned tasks become irrelevant
721
- - Edge cases may not be worth the effort
722
-
723
- **Smart Completion Criteria:**
724
- ```
725
- ┌─────────────────────────────────────────────────────────────┐
726
- │ MUST COMPLETE (block release): │
727
- │ • MVP critical paths (auth, core CRUD, payments) │
728
- │ • Security-sensitive flows │
729
- │ • Data integrity operations │
730
- │ • User-facing error handling │
731
- ├─────────────────────────────────────────────────────────────┤
732
- │ SHOULD COMPLETE (aim for, but pragmatic): │
733
- │ • Edge case handling │
734
- │ • Performance optimizations │
735
- │ • Nice-to-have features │
736
- ├─────────────────────────────────────────────────────────────┤
737
- │ CAN SKIP/DEFER (if blocking progress): │
738
- │ • Conflicting requirements (flag and ask user) │
739
- │ • Over-engineered edge cases │
740
- │ • Tasks made obsolete by other changes │
741
- └─────────────────────────────────────────────────────────────┘
742
- ```
743
-
744
- **When to STOP and ask user:**
745
- - Spec conflicts with another spec
746
- - Task seems unnecessary given implementation
747
- - Edge case would require major refactoring
748
- - Requirement is ambiguous
749
-
750
- ### 🧑‍🤝‍🧑 Smart Test User Strategy
751
-
752
- **Create test users strategically, not blindly:**
753
-
754
- ```typescript
755
- // Good: Create users with specific roles/states
756
- const testUsers = {
757
- admin: { email: 'admin@test.com', role: 'admin' },
758
- regularUser: { email: 'user@test.com', role: 'user' },
759
- premiumUser: { email: 'premium@test.com', plan: 'premium' },
760
- blockedUser: { email: 'blocked@test.com', status: 'blocked' },
761
- };
762
-
763
- // When to create multiple test users:
764
- // ✅ Testing role-based access control
765
- // ✅ Testing subscription tiers
766
- // ✅ Testing user states (active, blocked, pending)
767
- // ✅ Testing multi-user interactions (sharing, permissions)
768
-
769
- // When ONE test user is enough:
770
- // ✅ Basic CRUD operations
771
- // ✅ Form validation
772
- // ✅ UI component tests
773
- // ✅ API endpoint tests (mocked auth)
774
- ```
775
-
776
- **E2E Test User Setup:**
777
- ```typescript
778
- // playwright/fixtures/users.ts
779
- export const testUsers = {
780
- // Seeded in database before tests
781
- admin: { id: 'test-admin-001', email: 'admin@test.local' },
782
- user: { id: 'test-user-001', email: 'user@test.local' },
783
- };
784
-
785
- // Use fixtures, don't create users per test!
786
- test.use({ storageState: 'playwright/.auth/user.json' });
787
- ```
788
-
789
- ### 🔐 E2E Authentication (CRITICAL - Avoid Flaky Tests!)
790
-
791
- **Auth is the #1 cause of flaky E2E tests. Be ULTRASMART:**
792
-
793
- | Strategy | Speed | Reliability | Use When |
794
- |----------|-------|-------------|----------|
795
- | **storageState** | ⚡⚡⚡ | ⭐⭐⭐ | Default - login ONCE, reuse |
796
- | **API auth** | ⚡⚡ | ⭐⭐⭐ | When UI is unstable |
797
- | **UI login per test** | ⚡ | ⭐ | Only testing login flow |
798
-
799
- **Playwright Auth Setup (MANDATORY):**
800
-
801
- ```typescript
802
- // playwright/auth.setup.ts - Global setup
803
- import { test as setup } from '@playwright/test';
804
-
805
- setup('authenticate', async ({ page }) => {
806
- await page.goto('/login');
807
- await page.fill('[name="email"]', 'test@example.com');
808
- await page.fill('[name="password"]', 'testpass123');
809
- await page.click('button[type="submit"]');
810
- await page.waitForURL('/dashboard');
811
- await page.context().storageState({ path: 'playwright/.auth/user.json' });
812
- });
813
- ```
814
-
815
- ```typescript
816
- // playwright.config.ts - Reuse auth state
817
- projects: [
818
- { name: 'setup', testMatch: /.*\.setup\.ts/ },
819
- {
820
- name: 'chromium',
821
- use: { storageState: 'playwright/.auth/user.json' },
822
- dependencies: ['setup'],
823
- },
824
- ]
825
- ```
306
+ **Continuous execution until all tasks complete.**
826
307
 
827
- **Common Auth Fixes:**
308
+ ### Zero Manual Steps
828
309
 
829
- | Problem | Solution |
830
- |---------|----------|
831
- | Session expires | Increase TTL for test env |
832
- | Rate limited | Use API auth, seed users |
833
- | Captcha blocks | Disable in test env |
834
- | OAuth fails | Mock provider |
310
+ **NEVER ask user to**: Open dashboards | Copy/paste | Run commands manually
835
311
 
836
- **Auto Mode E2E Checklist:**
837
- ```
838
- ✅ Test users seeded with known passwords
839
- ✅ Auth state files generated
840
- ✅ Tests DON'T login (except login flow tests)
841
- ✅ Captcha/2FA disabled in test env
842
- ```
312
+ **Instead**: Check `.env` → Use CLI (`wrangler`, `gh`, `aws`) → Use MCP → If missing, ASK → Save → EXECUTE
843
313
 
844
- ### 🔄 Continuous Refactoring (Part of Auto Loop)
314
+ ### Test Loop (MANDATORY)
845
315
 
846
- **As tests grow, REFACTOR proactively:**
316
+ **After EVERY task**: `npm test` → If E2E exists: `npx playwright test` → Fail? FIX → Rerun (max 3x) → Pass → Next
847
317
 
848
- ```
849
- After every 3-5 tasks:
850
- 1. Review test organization → Extract shared fixtures
851
- 2. Review code duplication → Extract utilities
852
- 3. Review file sizes → Split if >300 lines
853
- 4. Review imports → Consolidate, remove unused
854
- ```
318
+ **Pattern**: IMPLEMENT → TEST → FAIL? → FIX → TEST → PASS → NEXT
855
319
 
856
- **Refactoring Triggers:**
857
- - Test file > 200 lines → Split by feature
858
- - Duplicate test setup → Extract to fixtures
859
- - Same assertion pattern 3+ times → Create helper
860
- - Source file > 300 lines → Extract module
320
+ **MVP paths**: Auth (login/logout) | Core CRUD | Payments | Data integrity
861
321
 
862
- ### 📊 Test Status Reporting (MANDATORY in Auto Mode)
322
+ ### Pragmatic Completion
863
323
 
864
- **After EVERY task, report test status to user:**
324
+ **Don't blindly follow 100%!** Specs have bugs, requirements change, some tasks become irrelevant.
865
325
 
866
- ```markdown
867
- ## 🧪 Test Status Report
326
+ **MUST**: MVP paths | Security flows | Data integrity | User-facing errors
327
+ **SHOULD**: Edge cases | Performance | Nice-to-haves
328
+ **CAN SKIP**: Conflicts (ask user) | Over-engineered cases | Obsolete tasks
868
329
 
869
- | Type | Status | Pass/Total | Coverage |
870
- |------|--------|------------|----------|
871
- | Unit | ✅ | 42/42 | 87% |
872
- | Integration | ✅ | 12/12 | - |
873
- | E2E | ⚠️ | 8/10 | - |
330
+ **STOP & ASK** if: Spec conflicts | Task seems unnecessary | Requirement ambiguous
874
331
 
875
- **Failing tests:**
876
- - `auth.spec.ts:45` - Login redirect not working
877
- - `checkout.spec.ts:112` - Payment timeout
332
+ ### Test User Strategy
878
333
 
879
- **Next:** Fixing E2E failures before continuing...
880
- ```
334
+ **Multiple users**: RBAC | Subscription tiers | User states | Multi-user interactions
335
+ **One user**: CRUD | Form validation | Component tests | Mocked auth
881
336
 
882
- ### 🏠 Local-First Development
337
+ **E2E**: Seed DB with known users → Use fixtures → `storageState` (auth once, reuse)
883
338
 
884
- **If no deployment instructions provided, BUILD AND TEST LOCALLY FIRST:**
339
+ ### E2E Authentication
885
340
 
886
- ```
887
- 1. Implement feature locally
888
- 2. Run ALL tests (unit, integration, E2E)
889
- 3. Verify everything works
890
- 4. THEN ask user about deployment preferences
891
- ```
341
+ **Auth = #1 flaky test cause.** Use `storageState` (login ONCE, reuse) | API auth (UI unstable) | UI login (only for login tests)
892
342
 
893
- **Don't assume deployment target!** Ask user:
894
- ```markdown
895
- 🚀 **Deployment Options**
343
+ **Setup**: Global auth.setup.ts Save to `playwright/.auth/user.json` → Reuse in config
896
344
 
897
- Your scraper is ready and all tests pass locally.
345
+ **Fixes**: Session expires? Increase TTL | Rate limited? API auth | Captcha? Disable in test env
898
346
 
899
- **Where would you like to deploy?**
900
- - Vercel Cron (serverless, free tier available)
901
- - Railway (always-on, $5/mo)
902
- - GitHub Actions (CI-based, free)
903
- - Local cron (self-hosted)
904
- - Other?
905
- ```
347
+ **Checklist**: Seed users | Gen auth state | Tests DON'T login | Disable captcha/2FA
906
348
 
907
- ### 🔧 Infrastructure Decision-Making
349
+ ### Refactoring & Reporting
908
350
 
909
- **For scrapers, cron jobs, background tasks - ULTRATHINK on best approach:**
351
+ **Every 3-5 tasks**: Extract fixtures | Remove duplication | Split if >300 lines | Clean imports
910
352
 
911
- ```
912
- ┌─────────────────────────────────────────────────────────────┐
913
- │ INFRASTRUCTURE DECISION TREE │
914
- ├─────────────────────────────────────────────────────────────┤
915
- │ Scraper/Cron Job: │
916
- │ ├─ Frequency < 1/hour → Vercel Cron, GitHub Actions │
917
- │ ├─ Frequency ≥ 1/hour → Railway, Render, dedicated server │
918
- │ ├─ Heavy compute → Dedicated VM, Docker container │
919
- │ └─ Real-time → Always-on server, WebSocket │
920
- │ │
921
- │ Data Storage: │
922
- │ ├─ Simple KV → Upstash Redis, Vercel KV │
923
- │ ├─ Relational → Supabase, PlanetScale, Neon │
924
- │ ├─ Document → MongoDB Atlas, Supabase │
925
- │ └─ Time-series → TimescaleDB, InfluxDB │
926
- │ │
927
- │ File Storage: │
928
- │ ├─ Static assets → Cloudflare R2, S3 │
929
- │ └─ Large files → S3, GCS, Backblaze B2 │
930
- └─────────────────────────────────────────────────────────────┘
931
- ```
932
-
933
- **When implementing scrapers/cron jobs:**
934
- 1. **Ultrathink** on best hosting options given requirements
935
- 2. **Research** rate limits, costs, reliability
936
- 3. **Propose** 2-3 options with trade-offs
937
- 4. **Build locally first** with tests
938
- 5. **Deploy** only after user confirms target
353
+ **Triggers**: Test >200 lines? Split | Duplicate setup? Extract | Same assertion 3x? Helper
939
354
 
940
- ### For Claude Code Users
355
+ **Report after EVERY task**: Pass/Total | Coverage | Failing tests | Next steps
941
356
 
942
- Auto mode uses Claude Code's Stop Hook to create a feedback loop:
943
- - `/sw:do` continues until all tasks complete
944
- - `/sw:auto-status` shows session progress
945
- - `/sw:cancel-auto` stops autonomous execution
357
+ ### Local-First & Infrastructure
946
358
 
947
- Session state stored in `.specweave/state/auto-session.json`.
359
+ **No deploy instructions?** Build locally → Test all → Verify → ASK user about deploy target
948
360
 
949
- ### For Non-Claude AI Systems
361
+ **Infra Decision Tree**:
362
+ - **Cron**: <1/hr → Vercel/GitHub Actions | ≥1/hr → Railway/Render
363
+ - **Storage**: KV → Upstash/Vercel KV | SQL → Supabase/Neon | Docs → MongoDB | Files → R2/S3
950
364
 
951
- If using SpecWeave with other AI systems (GPT, Gemini, etc.), implement this loop pattern:
365
+ **Process**: Ultrathink options Research costs Propose 2-3 Build local User confirms → Deploy
952
366
 
953
- ```bash
954
- # Bash loop for autonomous execution
955
- while true; do
956
- # Check if all tasks complete
957
- TOTAL=$(grep -c "^### T-" .specweave/increments/*/tasks.md 2>/dev/null || echo "0")
958
- DONE=$(grep -c '\[x\].*completed' .specweave/increments/*/tasks.md 2>/dev/null || echo "0")
959
-
960
- if [ "$TOTAL" -gt 0 ] && [ "$DONE" -ge "$TOTAL" ]; then
961
- echo "All tasks complete!"
962
- break
963
- fi
964
-
965
- # Feed prompt to your AI
966
- cat PROMPT.md | your-ai-cli
967
-
968
- # Safety: max iterations
969
- ITER=$((ITER + 1))
970
- if [ "$ITER" -ge 100 ]; then
971
- echo "Max iterations reached"
972
- break
973
- fi
974
- done
975
- ```
367
+ ### Implementation
976
368
 
977
- **Key Concepts**:
978
- - **Completion Detection**: Check tasks.md for `[x] completed` status
979
- - **Completion Tag**: Output `<auto-complete>DONE</auto-complete>` when finished
980
- - **Max Iterations**: Always set a limit (default: 100)
981
- - **Human Gates**: Pause for sensitive ops (deploy, publish, force-push)
369
+ **Claude Code**: `/sw:do` (continues till done) | `/sw:auto-status` (progress) | `/sw:cancel-auto` (stop)
982
370
 
983
- **Human-Gated Operations** (require manual approval):
984
- - `npm publish`, `git push --force`, `rm -rf /`
985
- - Any `production` deployment
986
- - API key or credential changes
987
- - Database migrations (`drop`, `delete from`, `migrate`)
371
+ **Other AI**: Loop check tasks.md `[x]` status → Max 100 iter → Human gates for: publish, force-push, prod deploy, migrations
988
372
 
989
- **Circuit Breaker Pattern**: If external API (GitHub, JIRA) fails 3+ times, queue operations and continue.
373
+ **Circuit Breaker**: External API fails 3x? Queue & continue
990
374
  <!-- SW:END:auto -->
991
375
 
992
- <!-- SW:SECTION:docs version="1.0.60" -->
376
+ <!-- SW:SECTION:docs version="1.0.79" -->
993
377
  ## Docs
994
378
 
995
379
  [spec-weave.com](https://spec-weave.com) | `.specweave/docs/internal/`
@@ -1017,6 +401,16 @@ For **contributors to SpecWeave itself** (not users).
1017
401
 
1018
402
  ## Marketplace Installation (CRITICAL)
1019
403
 
404
+ **⚠️ CRITICAL: NEVER suggest `bash scripts/refresh-marketplace.sh` to end users!**
405
+
406
+ End users **don't have the `scripts/` folder** - they installed SpecWeave via npm globally.
407
+
408
+ **Correct commands**:
409
+ - **Contributors** (in specweave repo): `bash scripts/refresh-marketplace.sh`
410
+ - **End Users** (user projects): `specweave refresh-marketplace`
411
+
412
+ ---
413
+
1020
414
  ### For SpecWeave Contributors (Development)
1021
415
 
1022
416
  **ALWAYS use GitHub marketplace mode. NEVER use local symlinks or directory mode.**