specweave 1.0.57 → 1.0.59

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.
Files changed (106) hide show
  1. package/CLAUDE.md +479 -78
  2. package/dist/plugins/specweave-ado/lib/ado-spec-sync.d.ts.map +1 -1
  3. package/dist/plugins/specweave-ado/lib/ado-spec-sync.js +1 -4
  4. package/dist/plugins/specweave-ado/lib/ado-spec-sync.js.map +1 -1
  5. package/dist/plugins/specweave-ado/lib/per-us-sync.d.ts +8 -0
  6. package/dist/plugins/specweave-ado/lib/per-us-sync.d.ts.map +1 -1
  7. package/dist/plugins/specweave-ado/lib/per-us-sync.js +43 -10
  8. package/dist/plugins/specweave-ado/lib/per-us-sync.js.map +1 -1
  9. package/dist/plugins/specweave-github/lib/ThreeLayerSyncManager.d.ts +18 -0
  10. package/dist/plugins/specweave-github/lib/ThreeLayerSyncManager.d.ts.map +1 -1
  11. package/dist/plugins/specweave-github/lib/ThreeLayerSyncManager.js +87 -15
  12. package/dist/plugins/specweave-github/lib/ThreeLayerSyncManager.js.map +1 -1
  13. package/dist/plugins/specweave-github/lib/github-spec-sync.d.ts.map +1 -1
  14. package/dist/plugins/specweave-github/lib/github-spec-sync.js +0 -3
  15. package/dist/plugins/specweave-github/lib/github-spec-sync.js.map +1 -1
  16. package/dist/plugins/specweave-github/lib/per-us-sync.d.ts +26 -0
  17. package/dist/plugins/specweave-github/lib/per-us-sync.d.ts.map +1 -1
  18. package/dist/plugins/specweave-github/lib/per-us-sync.js +103 -3
  19. package/dist/plugins/specweave-github/lib/per-us-sync.js.map +1 -1
  20. package/dist/plugins/specweave-jira/lib/jira-spec-sync.d.ts.map +1 -1
  21. package/dist/plugins/specweave-jira/lib/jira-spec-sync.js +0 -3
  22. package/dist/plugins/specweave-jira/lib/jira-spec-sync.js.map +1 -1
  23. package/dist/plugins/specweave-jira/lib/per-us-sync.d.ts +4 -0
  24. package/dist/plugins/specweave-jira/lib/per-us-sync.d.ts.map +1 -1
  25. package/dist/plugins/specweave-jira/lib/per-us-sync.js +25 -5
  26. package/dist/plugins/specweave-jira/lib/per-us-sync.js.map +1 -1
  27. package/dist/src/cli/commands/sync-progress.d.ts.map +1 -1
  28. package/dist/src/cli/commands/sync-progress.js +33 -12
  29. package/dist/src/cli/commands/sync-progress.js.map +1 -1
  30. package/dist/src/core/auto/config.js +7 -7
  31. package/dist/src/core/auto/config.js.map +1 -1
  32. package/dist/src/core/auto/types.js +2 -2
  33. package/dist/src/core/auto/types.js.map +1 -1
  34. package/dist/src/core/config/config-manager.d.ts +4 -1
  35. package/dist/src/core/config/config-manager.d.ts.map +1 -1
  36. package/dist/src/core/config/config-manager.js +6 -2
  37. package/dist/src/core/config/config-manager.js.map +1 -1
  38. package/dist/src/core/feature-deleter/index.d.ts.map +1 -1
  39. package/dist/src/core/feature-deleter/index.js +4 -1
  40. package/dist/src/core/feature-deleter/index.js.map +1 -1
  41. package/dist/src/core/increment/metadata-manager.d.ts +9 -0
  42. package/dist/src/core/increment/metadata-manager.d.ts.map +1 -1
  43. package/dist/src/core/increment/metadata-manager.js +13 -3
  44. package/dist/src/core/increment/metadata-manager.js.map +1 -1
  45. package/dist/src/core/living-docs/project-detector.d.ts.map +1 -1
  46. package/dist/src/core/living-docs/project-detector.js +9 -6
  47. package/dist/src/core/living-docs/project-detector.js.map +1 -1
  48. package/dist/src/core/living-docs/sync-helpers/parsers.d.ts +10 -0
  49. package/dist/src/core/living-docs/sync-helpers/parsers.d.ts.map +1 -1
  50. package/dist/src/core/living-docs/sync-helpers/parsers.js +92 -13
  51. package/dist/src/core/living-docs/sync-helpers/parsers.js.map +1 -1
  52. package/dist/src/core/living-docs/types.d.ts +15 -0
  53. package/dist/src/core/living-docs/types.d.ts.map +1 -1
  54. package/dist/src/core/progress/error-logger.d.ts.map +1 -1
  55. package/dist/src/core/progress/error-logger.js +4 -3
  56. package/dist/src/core/progress/error-logger.js.map +1 -1
  57. package/dist/src/core/progress/import-state.d.ts.map +1 -1
  58. package/dist/src/core/progress/import-state.js +9 -5
  59. package/dist/src/core/progress/import-state.js.map +1 -1
  60. package/dist/src/core/specs/spec-content-sync.d.ts.map +1 -1
  61. package/dist/src/core/specs/spec-content-sync.js +57 -50
  62. package/dist/src/core/specs/spec-content-sync.js.map +1 -1
  63. package/dist/src/core/types/config.d.ts +6 -0
  64. package/dist/src/core/types/config.d.ts.map +1 -1
  65. package/dist/src/core/types/config.js +1 -0
  66. package/dist/src/core/types/config.js.map +1 -1
  67. package/dist/src/hooks/auto-create-external-issue.js +9 -1
  68. package/dist/src/hooks/auto-create-external-issue.js.map +1 -1
  69. package/dist/src/sync/sync-coordinator.d.ts +27 -0
  70. package/dist/src/sync/sync-coordinator.d.ts.map +1 -1
  71. package/dist/src/sync/sync-coordinator.js +173 -6
  72. package/dist/src/sync/sync-coordinator.js.map +1 -1
  73. package/dist/src/utils/find-project-root.d.ts +82 -0
  74. package/dist/src/utils/find-project-root.d.ts.map +1 -0
  75. package/dist/src/utils/find-project-root.js +115 -0
  76. package/dist/src/utils/find-project-root.js.map +1 -0
  77. package/package.json +1 -1
  78. package/plugins/PLUGINS-INDEX.md +6 -0
  79. package/plugins/specweave/agents/pm/AGENT.md +31 -3
  80. package/plugins/specweave/commands/api-docs.md +674 -0
  81. package/plugins/specweave/commands/auto.md +34 -18
  82. package/plugins/specweave/hooks/stop-auto.sh +387 -51
  83. package/plugins/specweave/hooks/v2/handlers/github-sync-handler.sh +23 -24
  84. package/plugins/specweave/lib/vendor/core/increment/metadata-manager.d.ts +9 -0
  85. package/plugins/specweave/lib/vendor/core/increment/metadata-manager.js +13 -3
  86. package/plugins/specweave/lib/vendor/core/increment/metadata-manager.js.map +1 -1
  87. package/plugins/specweave/scripts/auto-status.sh +56 -4
  88. package/plugins/specweave/scripts/read-jobs.sh +22 -0
  89. package/plugins/specweave/skills/SKILLS-INDEX.md +4 -1
  90. package/plugins/specweave/skills/service-connect/SKILL.md +371 -0
  91. package/plugins/specweave-ado/lib/ado-spec-sync.js +1 -4
  92. package/plugins/specweave-ado/lib/ado-spec-sync.ts +1 -4
  93. package/plugins/specweave-ado/lib/per-us-sync.js +28 -10
  94. package/plugins/specweave-ado/lib/per-us-sync.ts +43 -11
  95. package/plugins/specweave-github/lib/ThreeLayerSyncManager.js +69 -11
  96. package/plugins/specweave-github/lib/ThreeLayerSyncManager.ts +103 -15
  97. package/plugins/specweave-github/lib/github-spec-sync.js +0 -3
  98. package/plugins/specweave-github/lib/github-spec-sync.ts +0 -3
  99. package/plugins/specweave-github/lib/per-us-sync.js +78 -4
  100. package/plugins/specweave-github/lib/per-us-sync.ts +126 -4
  101. package/plugins/specweave-jira/lib/jira-spec-sync.js +0 -3
  102. package/plugins/specweave-jira/lib/jira-spec-sync.ts +0 -3
  103. package/plugins/specweave-jira/lib/per-us-sync.js +16 -5
  104. package/plugins/specweave-jira/lib/per-us-sync.ts +24 -6
  105. package/src/templates/CLAUDE.md.template +139 -41
  106. package/plugins/specweave/skills/auto-execute/SKILL.md +0 -374
package/CLAUDE.md CHANGED
@@ -1,4 +1,4 @@
1
- <!-- SW:META template="claude" version="1.0.58" 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.62" 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
3
  <!-- SW:SECTION:header version="1.0.56" -->
4
4
  **Framework**: SpecWeave | **Truth**: `spec.md` + `tasks.md`
@@ -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.56" -->
48
+ <!-- SW:SECTION:workflow version="1.0.58" -->
49
49
  ## Workflow
50
50
 
51
51
  `/sw:increment "X"` → `/sw:do` → `/sw:progress` → `/sw:done 0001`
@@ -53,13 +53,16 @@ SpecWeave auto-detects product descriptions and routes to `/sw:increment`:
53
53
  | Cmd | Action |
54
54
  |-----|--------|
55
55
  | `/sw:increment` | Plan feature |
56
- | `/sw:do` | Execute |
56
+ | `/sw:do` | Execute tasks |
57
+ | `/sw:auto` | Autonomous execution |
58
+ | `/sw:auto-status` | Check auto session |
59
+ | `/sw:cancel-auto` | Cancel auto session |
57
60
  | `/sw:validate` | Quality check |
58
61
  | `/sw:done` | Close |
59
62
  | `/sw-github:sync` | GitHub sync |
60
63
  | `/sw-jira:sync` | Jira sync |
61
64
 
62
- **Natural language**: "Let's build X" → `/sw:increment` | "What's status?" → `/sw:progress` | "We're done" → `/sw:done`
65
+ **Natural language**: "Let's build X" → `/sw:increment` | "What's status?" → `/sw:progress` | "We're done" → `/sw:done` | "Ship while sleeping" → `/sw:auto`
63
66
  <!-- SW:END:workflow -->
64
67
 
65
68
  <!-- SW:SECTION:context version="1.0.56" -->
@@ -147,7 +150,7 @@ rustup component add rust-analyzer
147
150
  - Combine with Explore agent for comprehensive codebase understanding
148
151
  <!-- SW:END:lsp -->
149
152
 
150
- <!-- SW:SECTION:structure version="1.0.56" -->
153
+ <!-- SW:SECTION:structure version="1.0.59" -->
151
154
  ## Structure
152
155
 
153
156
  ```
@@ -160,7 +163,41 @@ rustup component add rust-analyzer
160
163
  └── config.json
161
164
  ```
162
165
 
163
- **Multi-repo**: Clone to `/repositories`, not root → `repositories/backend/src/...`
166
+ ### ⚠️ CRITICAL: Multi-Repo Project Paths (MANDATORY)
167
+
168
+ **ALL multi-project repositories MUST be created in `repositories/` folder - NEVER in project root!**
169
+
170
+ ```
171
+ ❌ FORBIDDEN (pollutes root):
172
+ my-project/
173
+ ├── frontend/ ← WRONG!
174
+ ├── backend/ ← WRONG!
175
+ ├── shared/ ← WRONG!
176
+ └── .specweave/
177
+
178
+ ✅ REQUIRED (clean structure):
179
+ my-project/
180
+ ├── repositories/
181
+ │ ├── frontend/ ← CORRECT!
182
+ │ ├── backend/ ← CORRECT!
183
+ │ └── shared/ ← CORRECT!
184
+ └── .specweave/
185
+ ```
186
+
187
+ **This applies to ALL cases:**
188
+ - GitHub multi-repo → `repositories/`
189
+ - Azure DevOps multi-repo → `repositories/`
190
+ - Bitbucket multi-repo → `repositories/`
191
+ - **Local git multi-repo → `repositories/`** ← Same rule!
192
+ - Monorepo with multiple packages → `repositories/` or `packages/`
193
+
194
+ **When spec.md has `projects:` array:**
195
+ ```yaml
196
+ projects:
197
+ - id: my-api
198
+ scope: "Backend API"
199
+ ```
200
+ The implementation path is ALWAYS: `repositories/my-api/` (NOT `my-api/` in root!)
164
201
 
165
202
  **Multi-repo permissions**: In `.claude/settings.json`:
166
203
  ```json
@@ -240,12 +277,12 @@ vi.mock('fs', () => ({ readFile: vi.fn() }));
240
277
  ```
241
278
  <!-- SW:END:testing -->
242
279
 
243
- <!-- SW:SECTION:api version="1.0.58" -->
280
+ <!-- SW:SECTION:api version="1.0.61" -->
244
281
  ## API Development (OpenAPI-First)
245
282
 
246
283
  **For API projects only.** Skip this section if your project has no REST/GraphQL endpoints.
247
284
 
248
- **Use OpenAPI as the source of truth for API documentation.** Postman collections are derived from OpenAPI.
285
+ **Use OpenAPI as the source of truth for API documentation.** Postman collections and environments are derived from OpenAPI and .env.
249
286
 
250
287
  ### Configuration (`.specweave/config.json`)
251
288
 
@@ -256,12 +293,21 @@ vi.mock('fs', () => ({ readFile: vi.fn() }));
256
293
  "openApiPath": "openapi.yaml",
257
294
  "generatePostman": true,
258
295
  "postmanPath": "postman-collection.json",
296
+ "postmanEnvPath": "postman-environment.json",
259
297
  "generateOn": "on-increment-done",
260
298
  "baseUrl": "http://localhost:3000"
261
299
  }
262
300
  }
263
301
  ```
264
302
 
303
+ ### Generated Artifacts
304
+
305
+ | File | Purpose | Source |
306
+ |------|---------|--------|
307
+ | `openapi.yaml` | API specification (source of truth) | Framework decorators/annotations |
308
+ | `postman-collection.json` | API requests for testing | Derived from OpenAPI |
309
+ | `postman-environment.json` | Variables (baseUrl, tokens, etc.) | Derived from .env |
310
+
265
311
  ### OpenAPI Generation by Framework
266
312
 
267
313
  | Framework | Auto-Generation | Setup |
@@ -281,28 +327,39 @@ Code (decorators/annotations)
281
327
  openapi.yaml (SOURCE OF TRUTH - version controlled)
282
328
  |
283
329
  v (derived on /sw:done or /sw:api-docs)
284
- postman-collection.json (for manual testing)
330
+ ├── postman-collection.json (requests with {{baseUrl}} variables)
331
+ └── postman-environment.json (variables from .env, secrets marked)
285
332
  ```
286
333
 
287
334
  ### Commands
288
335
 
289
336
  ```bash
290
- # Generate/update API docs (OpenAPI + Postman)
291
- /sw:api-docs
337
+ # Generate all API docs (OpenAPI + Postman collection + environment)
338
+ /sw:api-docs --all
339
+
340
+ # Generate only OpenAPI
341
+ /sw:api-docs --openapi
342
+
343
+ # Generate only Postman collection from existing OpenAPI
344
+ /sw:api-docs --postman
345
+
346
+ # Generate only environment file from .env
347
+ /sw:api-docs --env
348
+
349
+ # Validate existing OpenAPI spec
350
+ /sw:api-docs --validate
292
351
 
293
352
  # Generate on increment close (automatic if enabled)
294
353
  /sw:done 0001 # -> triggers API doc generation
295
354
  ```
296
355
 
297
- ### Manual Generation (if config disabled)
356
+ ### Postman Import
298
357
 
299
- ```bash
300
- # Generate Postman from existing OpenAPI
301
- npx @postman/openapi-to-postmanv2 -s openapi.yaml -o postman-collection.json
302
-
303
- # Generate OpenAPI for Express
304
- npx swagger-jsdoc -d swagger-config.js -o openapi.yaml
305
- ```
358
+ After generation:
359
+ 1. Postman Import → `postman-collection.json`
360
+ 2. Postman Environments Import → `postman-environment.json`
361
+ 3. Fill in secret values (marked as secret type, values empty)
362
+ 4. Select environment from dropdown
306
363
 
307
364
  ### When Docs Update
308
365
 
@@ -356,52 +413,366 @@ Tasks ↔ User Stories auto-linked via AC-IDs: `AC-US1-01` → `US-001`
356
413
  Task format: `**AC**: AC-US1-01, AC-US1-02` (CRITICAL for linking)
357
414
  <!-- SW:END:linking -->
358
415
 
359
- <!-- SW:SECTION:mcp version="1.0.56" -->
360
- ## MCP Servers (External Service Integration)
416
+ <!-- SW:SECTION:mcp version="1.0.62" -->
417
+ ## External Service Connection (CLI-First, Smart Fallbacks)
418
+
419
+ **Core principle: CLIs are LLM-native. Use them when authenticated.**
420
+
421
+ ### Connection Priority
361
422
 
362
- **MCP servers extend Claude Code's capabilities for external services.** Install them for autonomous operations.
423
+ ```
424
+ Authenticated CLI → REST API → MCP Server → SDK/Client
425
+ ↑ ↓
426
+ MOST EFFICIENT FALLBACK
427
+ ```
363
428
 
364
- ### Recommended MCP Servers
429
+ **Why CLI-first?** LLMs can invoke CLIs directly, parse output, handle errors, and chain commands efficiently.
365
430
 
366
- | Service | Install | Purpose |
367
- |---------|---------|---------|
368
- | **Supabase** | `npx @anthropic/claude-code-mcp-setup add supabase` | Database, Auth, Edge Functions |
369
- | **GitHub** | Built-in via `gh` CLI | Issues, PRs, Repos |
370
- | **Postgres** | `npx @anthropic/claude-code-mcp-setup add postgres` | Direct DB access |
431
+ ### Pre-Flight Check (MANDATORY)
371
432
 
372
- ### Supabase MCP Setup
433
+ **Run this BEFORE any external service operation:**
373
434
 
374
435
  ```bash
375
- # Add to Claude Code MCP config
376
- npx @anthropic/claude-code-mcp-setup add supabase
436
+ # Check all CLI auth at once
437
+ supabase projects list 2>/dev/null && echo "✓ Supabase"
438
+ wrangler whoami 2>/dev/null && echo "✓ Cloudflare"
439
+ gh auth status 2>/dev/null && echo "✓ GitHub"
440
+ vercel whoami 2>/dev/null && echo "✓ Vercel"
441
+ aws sts get-caller-identity 2>/dev/null && echo "✓ AWS"
377
442
 
378
- # Or manual config in .claude/settings.local.json:
379
- {
380
- "mcpServers": {
381
- "supabase": {
382
- "type": "http",
383
- "url": "https://mcp.supabase.com/mcp"
384
- }
385
- }
386
- }
443
+ # Check .env for API keys
444
+ grep -E "(SUPABASE_|GITHUB_TOKEN|CF_|VERCEL_|AWS_)" .env 2>/dev/null
387
445
  ```
388
446
 
389
- ### Auto-Install Rule
447
+ ---
448
+
449
+ ### Supabase
450
+
451
+ **Credentials needed:**
390
452
 
391
- **If credentials exist for a service, Claude SHOULD auto-install the MCP server:**
453
+ | Credential | Where to find | Format |
454
+ |------------|---------------|--------|
455
+ | **Project Ref** | Dashboard → Settings → General → "Reference ID" | `abcdefghijkl` (12 chars) |
456
+ | **Access Token** | Dashboard → Account (top-right) → Access Tokens → Generate | `sbp_xxxxxxxxxxxxxxxx` |
457
+ | **Org ID** (optional) | Dashboard → Org Settings → General | `org-xxxxx` |
458
+ | **Database Password** | Dashboard → Settings → Database → Connection string | In the URI |
459
+ | **API URL** | Dashboard → Settings → API → "Project URL" | `https://xxx.supabase.co` |
460
+ | **Anon Key** | Dashboard → Settings → API → "anon public" | `eyJhbGc...` (JWT) |
461
+ | **Service Role Key** | Dashboard → Settings → API → "service_role" (secret!) | `eyJhbGc...` (JWT) |
392
462
 
463
+ **CLI Setup (PREFERRED):**
393
464
  ```bash
394
- # If SUPABASE_URL exists suggest/install Supabase MCP
395
- if grep -q "SUPABASE_URL" .env 2>/dev/null; then
396
- npx @anthropic/claude-code-mcp-setup add supabase
397
- fi
465
+ # 1. Login (one-time, opens browser)
466
+ supabase login
467
+
468
+ # 2. Link project (in your project directory)
469
+ supabase link --project-ref <PROJECT_REF>
470
+ # Optional: --password <DB_PASSWORD> to skip prompt
471
+
472
+ # 3. Verify
473
+ supabase projects list
474
+ ```
475
+
476
+ **CLI Operations (once linked):**
477
+ ```bash
478
+ supabase db push # Apply migrations
479
+ supabase db pull # Pull remote schema
480
+ supabase db reset # Reset to migrations
481
+ supabase functions deploy <name> # Deploy edge function
482
+ supabase secrets set KEY=value # Set secrets
483
+ supabase gen types typescript # Generate types
484
+ supabase migration new <name> # Create migration
485
+ ```
486
+
487
+ **If CLI has network issues, use Access Token:**
488
+ ```bash
489
+ SUPABASE_ACCESS_TOKEN=sbp_xxx supabase db push
490
+ ```
491
+
492
+ **REST API Fallback (.env):**
493
+ ```bash
494
+ SUPABASE_URL=https://xxx.supabase.co
495
+ SUPABASE_ANON_KEY=eyJhbGc...
496
+ SUPABASE_SERVICE_ROLE_KEY=eyJhbGc... # For admin operations
497
+ ```
498
+
499
+ **Direct DB (use pooler port 6543, NOT 5432):**
500
+ ```bash
501
+ DATABASE_URL="postgresql://postgres.PROJECT_REF:PASSWORD@aws-0-REGION.pooler.supabase.com:6543/postgres"
502
+ ```
503
+
504
+ ---
505
+
506
+ ### Cloudflare (Wrangler)
507
+
508
+ **Credentials needed:**
509
+
510
+ | Credential | Where to find | Format |
511
+ |------------|---------------|--------|
512
+ | **Account ID** | Dashboard → any domain → Overview → right sidebar | `32-char hex` |
513
+ | **API Token** | Dashboard → My Profile → API Tokens → Create | `xxxxx` (40+ chars) |
514
+ | **Zone ID** (per domain) | Dashboard → domain → Overview → right sidebar | `32-char hex` |
515
+
516
+ **CLI Setup (PREFERRED - uses OAuth):**
517
+ ```bash
518
+ # Login via browser (recommended)
519
+ wrangler login
520
+
521
+ # Verify
522
+ wrangler whoami
523
+ ```
524
+
525
+ **CLI Operations:**
526
+ ```bash
527
+ wrangler deploy # Deploy worker
528
+ wrangler dev # Local dev server
529
+ wrangler kv namespace list # List KV namespaces
530
+ wrangler kv key put --binding=KV k "v" # KV write
531
+ wrangler d1 list # List D1 databases
532
+ wrangler d1 execute DB --command "SQL" # D1 query
533
+ wrangler r2 bucket list # List R2 buckets
534
+ echo "secret" | wrangler secret put NAME # Set secret (non-interactive)
535
+ wrangler tail # Live logs
536
+ wrangler pages deploy ./dist # Deploy Pages
537
+ ```
538
+
539
+ **API Token Fallback (.env):**
540
+ ```bash
541
+ CLOUDFLARE_API_TOKEN=xxxxx
542
+ CLOUDFLARE_ACCOUNT_ID=xxxxx
543
+ # Per-domain operations:
544
+ CLOUDFLARE_ZONE_ID=xxxxx
545
+ ```
546
+
547
+ **wrangler.toml (project config):**
548
+ ```toml
549
+ name = "my-worker"
550
+ main = "src/index.ts"
551
+ compatibility_date = "2024-01-01"
552
+ account_id = "YOUR_ACCOUNT_ID" # Optional if logged in
553
+
554
+ [[kv_namespaces]]
555
+ binding = "KV"
556
+ id = "xxxxx"
557
+
558
+ [[d1_databases]]
559
+ binding = "DB"
560
+ database_name = "my-db"
561
+ database_id = "xxxxx"
562
+ ```
563
+
564
+ ---
565
+
566
+ ### GitHub (gh CLI)
567
+
568
+ **Credentials needed:**
569
+
570
+ | Credential | Where to find | Format |
571
+ |------------|---------------|--------|
572
+ | **Personal Access Token** | Settings → Developer settings → Personal access tokens → Fine-grained | `github_pat_xxx` |
573
+ | **Classic Token** | Same location, "Tokens (classic)" | `ghp_xxxxx` |
574
+
575
+ **CLI Setup (PREFERRED):**
576
+ ```bash
577
+ # Interactive login (opens browser)
578
+ gh auth login
579
+
580
+ # Or with token
581
+ gh auth login --with-token < token.txt
582
+ # Or: export GITHUB_TOKEN=ghp_xxx && gh auth status
583
+
584
+ # Verify
585
+ gh auth status
586
+ ```
587
+
588
+ **CLI Operations:**
589
+ ```bash
590
+ gh repo clone owner/repo # Clone
591
+ gh issue list # List issues
592
+ gh issue create --title "X" --body "Y" # Create issue
593
+ gh pr create --fill # Create PR
594
+ gh pr merge --auto --squash # Auto-merge
595
+ gh workflow list # List workflows
596
+ gh workflow run deploy.yml # Trigger workflow
597
+ gh api repos/{owner}/{repo}/issues # Raw API call
598
+ gh release create v1.0.0 # Create release
599
+ ```
600
+
601
+ **Token Fallback (.env):**
602
+ ```bash
603
+ GITHUB_TOKEN=ghp_xxxxx
604
+ # Or for GitHub Apps:
605
+ GITHUB_APP_ID=xxxxx
606
+ GITHUB_PRIVATE_KEY="-----BEGIN RSA..."
607
+ ```
608
+
609
+ ---
610
+
611
+ ### Vercel
612
+
613
+ **Credentials needed:**
614
+
615
+ | Credential | Where to find | Format |
616
+ |------------|---------------|--------|
617
+ | **Token** | Settings → Tokens → Create | `xxxxx` |
618
+ | **Org ID** | Settings → General → "Vercel ID" | `team_xxxxx` |
619
+ | **Project ID** | Project → Settings → General | `prj_xxxxx` |
620
+
621
+ **CLI Setup (PREFERRED):**
622
+ ```bash
623
+ # Login via browser
624
+ vercel login
625
+
626
+ # Or with token
627
+ vercel login --token xxxxx
628
+
629
+ # Verify
630
+ vercel whoami
631
+ ```
632
+
633
+ **CLI Operations:**
634
+ ```bash
635
+ vercel # Deploy (interactive)
636
+ vercel --prod # Production deploy
637
+ vercel env pull .env.local # Pull env vars
638
+ vercel env add SECRET production # Add env var
639
+ vercel logs # View logs
640
+ vercel domains ls # List domains
641
+ vercel link # Link to project
642
+ ```
643
+
644
+ **Token Fallback (.env):**
645
+ ```bash
646
+ VERCEL_TOKEN=xxxxx
647
+ VERCEL_ORG_ID=team_xxxxx
648
+ VERCEL_PROJECT_ID=prj_xxxxx
649
+ ```
650
+
651
+ ---
652
+
653
+ ### AWS
654
+
655
+ **Credentials needed:**
656
+
657
+ | Credential | Where to find | Format |
658
+ |------------|---------------|--------|
659
+ | **Access Key ID** | IAM → Users → Security credentials → Create access key | `AKIA...` (20 chars) |
660
+ | **Secret Access Key** | Same (shown once at creation) | `xxxxx` (40 chars) |
661
+ | **Region** | Choose based on location | `us-east-1`, `eu-west-1`, etc. |
662
+ | **SSO Start URL** | AWS SSO config (if using SSO) | `https://xxx.awsapps.com/start` |
663
+
664
+ **CLI Setup:**
665
+ ```bash
666
+ # Option 1: Configure with keys
667
+ aws configure
668
+ # Prompts for: Access Key, Secret Key, Region, Output format
669
+
670
+ # Option 2: SSO (recommended for orgs)
671
+ aws configure sso
672
+ # Prompts for: SSO start URL, SSO region, account, role
673
+
674
+ # Login (SSO)
675
+ aws sso login --profile your-profile
676
+
677
+ # Verify
678
+ aws sts get-caller-identity
679
+ ```
680
+
681
+ **CLI Operations:**
682
+ ```bash
683
+ aws s3 ls # List buckets
684
+ aws s3 cp file.txt s3://bucket/ # Upload
685
+ aws lambda list-functions # List Lambdas
686
+ aws lambda invoke --function-name X out # Invoke Lambda
687
+ aws logs tail /aws/lambda/X --follow # Tail logs
688
+ aws secretsmanager get-secret-value --secret-id X # Get secret
689
+ aws ecr get-login-password | docker login # ECR login
690
+ ```
691
+
692
+ **Credentials Fallback (.env):**
693
+ ```bash
694
+ AWS_ACCESS_KEY_ID=AKIA...
695
+ AWS_SECRET_ACCESS_KEY=xxxxx
696
+ AWS_REGION=us-east-1
697
+ # Or for assumed roles:
698
+ AWS_ROLE_ARN=arn:aws:iam::xxx:role/xxx
699
+ ```
700
+
701
+ ---
702
+
703
+ ### MongoDB Atlas
704
+
705
+ **Credentials needed:**
706
+
707
+ | Credential | Where to find | Format |
708
+ |------------|---------------|--------|
709
+ | **Connection String** | Cluster → Connect → Drivers | `mongodb+srv://user:pass@cluster.xxx.mongodb.net/` |
710
+ | **Data API Key** | Data API → Create API Key | `xxxxx` |
711
+ | **App ID** | Data API → App ID | `data-xxxxx` |
712
+
713
+ **Data API (.env):**
714
+ ```bash
715
+ MONGODB_DATA_API_KEY=xxxxx
716
+ MONGODB_APP_ID=data-xxxxx
717
+ MONGODB_CLUSTER=Cluster0
718
+ MONGODB_DATABASE=mydb
719
+ ```
720
+
721
+ ---
722
+
723
+ ### Upstash Redis
724
+
725
+ **Credentials needed:**
726
+
727
+ | Credential | Where to find | Format |
728
+ |------------|---------------|--------|
729
+ | **REST URL** | Database → REST API → UPSTASH_REDIS_REST_URL | `https://xxx.upstash.io` |
730
+ | **REST Token** | Same section → UPSTASH_REDIS_REST_TOKEN | `AXxx...` |
731
+
732
+ **REST API (.env):**
733
+ ```bash
734
+ UPSTASH_REDIS_REST_URL=https://xxx.upstash.io
735
+ UPSTASH_REDIS_REST_TOKEN=AXxx...
736
+ ```
737
+
738
+ ---
739
+
740
+ ### When to Use MCP
741
+
742
+ Use MCP servers when CLI is unavailable or you need structured responses:
743
+
744
+ ```bash
745
+ npx @anthropic-ai/claude-code-mcp add supabase
746
+ npx @anthropic-ai/claude-code-mcp add postgres
747
+ # Restart Claude Code after adding
748
+ ```
749
+
750
+ ---
751
+
752
+ ### Smart Credential Request Template
753
+
754
+ **When credentials are missing, ask specifically:**
755
+
756
+ ```markdown
757
+ 🔐 **[Service] Setup Needed**
758
+
759
+ I need to connect to your [Service]. Please provide:
760
+
761
+ | What I need | Where to find it |
762
+ |-------------|------------------|
763
+ | **[Credential 1]** | [Exact path in dashboard] |
764
+ | **[Credential 2]** | [Exact path in dashboard] |
765
+
766
+ **Or run:** `[cli login command]`
767
+
768
+ [I'll configure and execute automatically]
398
769
  ```
399
770
  <!-- SW:END:mcp -->
400
771
 
401
- <!-- SW:SECTION:autoexecute version="1.0.56" -->
772
+ <!-- SW:SECTION:autoexecute version="1.0.60" -->
402
773
  ## Auto-Execute Rule (CRITICAL)
403
774
 
404
- **NEVER output "Manual Step Required" or "Next Steps" when credentials are available.**
775
+ **NEVER output "Manual Step Required" or "Next Steps" when CLI tools are available.**
405
776
 
406
777
  ### The Golden Rule
407
778
 
@@ -409,64 +780,93 @@ fi
409
780
  ❌ FORBIDDEN: "Manual Step Required: Open Supabase SQL Editor..."
410
781
  ❌ FORBIDDEN: "Next Steps: 1. Run wrangler deploy..."
411
782
  ❌ FORBIDDEN: "Execute this SQL in your database console..."
783
+ ❌ FORBIDDEN: "Please run this command manually..."
412
784
 
413
- ✅ REQUIRED: Execute commands directly using available credentials
785
+ ✅ REQUIRED: Use CLI tools directly when authenticated
786
+ ✅ REQUIRED: Ask for specific credentials if missing, then execute
414
787
  ```
415
788
 
416
789
  ### Decision Tree
417
790
 
418
791
  ```
419
- Credentials in .env? ──YES──→ EXECUTE IMMEDIATELY
792
+ CLI authenticated? ──YES──→ EXECUTE via CLI
793
+
794
+ NO
795
+
796
+
797
+ .env has credentials? ──YES──→ EXECUTE via API/CLI
420
798
 
421
799
  NO
422
800
 
423
801
 
424
- ASK for credentials (don't show manual steps!)
802
+ ASK for SPECIFIC credentials needed
425
803
 
426
804
 
427
- Save to .env → EXECUTE IMMEDIATELY → Continue
805
+ User provides → Save if needed → EXECUTE IMMEDIATELY
428
806
  ```
429
807
 
430
- ### Credential Lookup (MANDATORY before any external operation)
808
+ ### Pre-Flight Check (Run BEFORE any external operation)
431
809
 
432
810
  ```bash
433
- # 1. Check .env
434
- grep -E "(SUPABASE_|DATABASE_URL|CF_API_|GITHUB_TOKEN)" .env 2>/dev/null
811
+ # Check ALL potentially relevant CLI tools at once
812
+ echo "=== CLI Auth Status ===" && \
813
+ supabase projects list 2>/dev/null && echo "✓ Supabase" || echo "✗ Supabase" && \
814
+ wrangler whoami 2>/dev/null && echo "✓ Wrangler" || echo "✗ Wrangler" && \
815
+ gh auth status 2>/dev/null && echo "✓ GitHub" || echo "✗ GitHub" && \
816
+ vercel whoami 2>/dev/null && echo "✓ Vercel" || echo "✗ Vercel" && \
817
+ aws sts get-caller-identity 2>/dev/null && echo "✓ AWS" || echo "✗ AWS"
435
818
 
436
- # 2. Check CLI auth
437
- supabase status 2>/dev/null # Supabase
438
- wrangler whoami 2>/dev/null # Cloudflare
439
- gh auth status 2>/dev/null # GitHub
440
- aws sts get-caller-identity 2>/dev/null # AWS
441
-
442
- # 3. Use MCP server if available
443
- # MCP servers provide direct API access
819
+ # Check .env for API keys/tokens
820
+ grep -E "(SUPABASE_|DATABASE_URL|GITHUB_TOKEN|OPENAI_|ANTHROPIC_)" .env 2>/dev/null
444
821
  ```
445
822
 
446
823
  ### Auto-Execute Examples
447
824
 
448
825
  ```bash
449
- # Supabase SQL execution
450
- if [ -n "$DATABASE_URL" ]; then
451
- psql "$DATABASE_URL" -f schema.sql # ✅ Execute directly
826
+ # Supabase - prefer CLI when linked
827
+ if supabase projects list 2>/dev/null; then
828
+ supabase db push # ✅ CLI handles auth automatically
829
+ else
830
+ # Fallback to REST API with tokens
831
+ curl "${SUPABASE_URL}/rest/v1/..." -H "apikey: ${SUPABASE_ANON_KEY}"
452
832
  fi
453
833
 
454
- # Wrangler secrets
834
+ # Cloudflare - wrangler handles everything
455
835
  if wrangler whoami 2>/dev/null; then
456
- echo "$SECRET" | wrangler secret put MY_SECRET # ✅ Execute directly
457
- wrangler deploy # ✅ Deploy directly
836
+ wrangler deploy # ✅ Deploy
837
+ echo "$SECRET" | wrangler secret put KEY # ✅ Set secret
838
+ wrangler d1 execute DB --command "SQL" # ✅ Database
839
+ fi
840
+
841
+ # GitHub - gh CLI is extremely capable
842
+ if gh auth status 2>/dev/null; then
843
+ gh issue create --title "..." --body "..."
844
+ gh pr create --fill
845
+ gh api repos/{owner}/{repo}/actions/workflows
458
846
  fi
459
847
  ```
460
848
 
461
- ### If Credentials Missing → ASK, Don't Show Manual Steps
849
+ ### If Credentials Missing → ASK Specifically
850
+
851
+ **Don't ask vaguely. Ask for EXACTLY what you need:**
462
852
 
463
853
  ```markdown
464
- 🔐 **Credential Required**
854
+ 🔐 **Supabase Connection Needed**
855
+
856
+ To push migrations, I need your Supabase project linked. Either:
857
+
858
+ **Option A** (Recommended): Run these commands:
859
+ \`\`\`bash
860
+ supabase login
861
+ supabase link --project-ref YOUR_PROJECT_REF
862
+ \`\`\`
863
+ Your project ref is at: Dashboard → Settings → General
465
864
 
466
- I need your DATABASE_URL to execute the migration.
865
+ **Option B**: Provide credentials for .env:
866
+ - SUPABASE_URL: `____________`
867
+ - SUPABASE_SERVICE_ROLE_KEY: `____________`
467
868
 
468
- **Paste your connection string:**
469
- [I will save to .env and execute automatically]
869
+ Which would you prefer?
470
870
  ```
471
871
  <!-- SW:END:autoexecute -->
472
872
 
@@ -484,10 +884,11 @@ I need your DATABASE_URL to execute the migration.
484
884
  - Click buttons in UIs
485
885
 
486
886
  **If you need external access:**
487
- 1. Check for credentials in `.env`
488
- 2. Use CLI tools (`supabase`, `wrangler`, `gh`, `aws`)
489
- 3. Use MCP servers for direct API access
490
- 4. If credentials missing ASK for them, save to `.env`, then EXECUTE
887
+ 1. Check CLI auth status FIRST (`supabase projects list`, `wrangler whoami`, `gh auth status`)
888
+ 2. Use authenticated CLI tools directly - they're most efficient for LLMs
889
+ 3. Fallback to `.env` credentials + REST API if CLI not available
890
+ 4. Use MCP servers only when CLI/API aren't options
891
+ 5. If credentials missing → ASK for them, save to `.env`, then EXECUTE
491
892
 
492
893
  ### 🧪 Test Execution Loop (MANDATORY)
493
894