moai-adk 0.5.2__py3-none-any.whl → 0.5.6__py3-none-any.whl

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.

Potentially problematic release.


This version of moai-adk might be problematic. Click here for more details.

Files changed (63) hide show
  1. moai_adk/__init__.py +1 -1
  2. moai_adk/cli/commands/backup.py +25 -1
  3. moai_adk/cli/commands/doctor.py +30 -4
  4. moai_adk/cli/commands/init.py +23 -2
  5. moai_adk/cli/commands/status.py +32 -2
  6. moai_adk/cli/commands/update.py +47 -8
  7. moai_adk/core/project/initializer.py +13 -11
  8. moai_adk/core/project/phase_executor.py +9 -4
  9. moai_adk/core/template/processor.py +60 -1
  10. moai_adk/templates/.claude/agents/alfred/cc-manager.md +8 -0
  11. moai_adk/templates/.claude/agents/alfred/debug-helper.md +18 -0
  12. moai_adk/templates/.claude/agents/alfred/doc-syncer.md +18 -0
  13. moai_adk/templates/.claude/agents/alfred/git-manager.md +38 -2
  14. moai_adk/templates/.claude/agents/alfred/implementation-planner.md +18 -0
  15. moai_adk/templates/.claude/agents/alfred/project-manager.md +6 -0
  16. moai_adk/templates/.claude/agents/alfred/quality-gate.md +6 -0
  17. moai_adk/templates/.claude/agents/alfred/skill-factory.md +8 -0
  18. moai_adk/templates/.claude/agents/alfred/spec-builder.md +17 -0
  19. moai_adk/templates/.claude/agents/alfred/tag-agent.md +7 -1
  20. moai_adk/templates/.claude/agents/alfred/tdd-implementer.md +18 -0
  21. moai_adk/templates/.claude/agents/alfred/trust-checker.md +6 -0
  22. moai_adk/templates/.claude/commands/alfred/0-project.md +5 -1
  23. moai_adk/templates/.claude/commands/alfred/1-plan.md +5 -1
  24. moai_adk/templates/.claude/commands/alfred/2-run.md +6 -2
  25. moai_adk/templates/.claude/commands/alfred/3-sync.md +28 -7
  26. moai_adk/templates/.claude/hooks/alfred/alfred_hooks.py +5 -1
  27. moai_adk/templates/.claude/output-styles/alfred/agentic-coding.md +5 -1
  28. moai_adk/templates/.claude/output-styles/alfred/moai-adk-learning.md +5 -1
  29. moai_adk/templates/.claude/output-styles/alfred/study-with-alfred.md +5 -1
  30. moai_adk/templates/.claude/skills/moai-alfred-interactive-questions/SKILL.md +30 -273
  31. moai_adk/templates/.claude/skills/moai-alfred-interactive-questions/examples.md +487 -129
  32. moai_adk/templates/.claude/skills/moai-alfred-interactive-questions/reference.md +603 -70
  33. moai_adk/templates/.claude/skills/moai-cc-agents/SKILL.md +22 -2
  34. moai_adk/templates/.claude/skills/moai-cc-claude-md/SKILL.md +22 -2
  35. moai_adk/templates/.claude/skills/moai-cc-commands/SKILL.md +22 -2
  36. moai_adk/templates/.claude/skills/moai-cc-hooks/SKILL.md +22 -2
  37. moai_adk/templates/.claude/skills/moai-cc-mcp-plugins/SKILL.md +22 -2
  38. moai_adk/templates/.claude/skills/moai-cc-memory/SKILL.md +22 -2
  39. moai_adk/templates/.claude/skills/moai-cc-settings/SKILL.md +22 -2
  40. moai_adk/templates/.claude/skills/moai-cc-skills/SKILL.md +25 -5
  41. moai_adk/templates/.claude/skills/moai-essentials-debug/SKILL.md +152 -547
  42. moai_adk/templates/.claude/skills/moai-essentials-debug/examples.md +835 -878
  43. moai_adk/templates/.claude/skills/moai-essentials-debug/reference.md +665 -1151
  44. moai_adk/templates/.claude/skills/moai-skill-factory/SKILL.md +138 -427
  45. moai_adk/templates/.claude/skills/moai-spec-authoring/README.md +61 -53
  46. moai_adk/templates/.claude/skills/moai-spec-authoring/SKILL.md +99 -1181
  47. moai_adk/templates/.claude/skills/moai-spec-authoring/examples.md +541 -0
  48. moai_adk/templates/.claude/skills/moai-spec-authoring/reference.md +622 -0
  49. moai_adk/templates/.moai/config.json +5 -5
  50. moai_adk/templates/.moai/memory/CLAUDE-AGENTS-GUIDE.md +208 -0
  51. moai_adk/templates/.moai/memory/CLAUDE-PRACTICES.md +369 -0
  52. moai_adk/templates/.moai/memory/CLAUDE-RULES.md +539 -0
  53. moai_adk/templates/.moai/memory/{development-guide.md → DEVELOPMENT-GUIDE.md} +3 -3
  54. moai_adk/templates/.moai/memory/SKILLS-DESCRIPTION-POLICY.md +218 -0
  55. moai_adk/templates/.moai/memory/config-schema.md +444 -0
  56. moai_adk/templates/CLAUDE.md +142 -702
  57. {moai_adk-0.5.2.dist-info → moai_adk-0.5.6.dist-info}/METADATA +294 -336
  58. {moai_adk-0.5.2.dist-info → moai_adk-0.5.6.dist-info}/RECORD +63 -56
  59. /moai_adk/templates/.moai/memory/{gitflow-protection-policy.md → GITFLOW-PROTECTION-POLICY.md} +0 -0
  60. /moai_adk/templates/.moai/memory/{spec-metadata.md → SPEC-METADATA.md} +0 -0
  61. {moai_adk-0.5.2.dist-info → moai_adk-0.5.6.dist-info}/WHEEL +0 -0
  62. {moai_adk-0.5.2.dist-info → moai_adk-0.5.6.dist-info}/entry_points.txt +0 -0
  63. {moai_adk-0.5.2.dist-info → moai_adk-0.5.6.dist-info}/licenses/LICENSE +0 -0
@@ -1,34 +1,22 @@
1
- # moai-alfred-interactive-questions - Working Examples
1
+ # Alfred Interactive Questions - Real-World Examples
2
2
 
3
- _Last updated: 2025-10-23_
3
+ > **Main Skill**: [SKILL.md](SKILL.md)
4
+ > **API Reference**: [reference.md](reference.md)
4
5
 
5
- ## Example 1: Simple Confirmation
6
+ ---
6
7
 
7
- **Scenario**: Destructive operation (delete 50 user records)
8
+ ## Example 1: Vague Feature Request
8
9
 
9
- ```typescript
10
- const answer = await AskUserQuestion({
11
- questions: [{
12
- question: "This will permanently delete 50 user records. Continue?",
13
- header: "Confirm",
14
- multiSelect: false,
15
- options: [
16
- { label: "Yes, proceed", description: "Irreversible operation. Delete now." },
17
- { label: "No, cancel", description: "Abort and return." }
18
- ]
19
- }]
20
- });
10
+ ### Scenario
21
11
 
22
- if (answer["Confirm"] === "Yes, proceed") {
23
- // Execute deletion
24
- }
25
- ```
26
-
27
- ---
12
+ **User**: "Add a completion page for the competition."
28
13
 
29
- ## Example 2: Implementation Approach
14
+ **Alfred detects ambiguity**:
15
+ - Where should it live? (new route vs modify existing)
16
+ - Who can access it? (public vs authenticated)
17
+ - What should it display? (results vs simple message)
30
18
 
31
- **Scenario**: "Add a completion page" (vague)
19
+ ### AskUserQuestion Invocation
32
20
 
33
21
  ```typescript
34
22
  const answer = await AskUserQuestion({
@@ -38,220 +26,590 @@ const answer = await AskUserQuestion({
38
26
  header: "Approach",
39
27
  multiSelect: false,
40
28
  options: [
41
- { label: "New public route", description: "Separate page at /competition-closed" },
42
- { label: "Modify /end page", description: "Add conditional logic to existing page" },
43
- { label: "Environment flag", description: "Use NEXT_PUBLIC_COMPETITION_CLOSED" }
29
+ {
30
+ label: "New public route",
31
+ description: "New page at /competition-complete, visible to all visitors."
32
+ },
33
+ {
34
+ label: "Modify existing page",
35
+ description: "Add conditional logic to existing /end page based on competition status."
36
+ },
37
+ {
38
+ label: "Environment flag",
39
+ description: "Set NEXT_PUBLIC_COMPETITION_CLOSED=true to show message on homepage."
40
+ }
44
41
  ]
45
42
  },
46
43
  {
47
- question: "For logged-in participants?",
44
+ question: "For logged-in participants, what should they see?",
48
45
  header: "Behavior",
49
46
  multiSelect: false,
50
47
  options: [
51
- { label: "Show results", description: "Redirect to /end with full history" },
52
- { label: "Show message", description: "'Competition concluded' only" }
48
+ {
49
+ label: "Show full results",
50
+ description: "Redirect to /end page with their submission history and rankings."
51
+ },
52
+ {
53
+ label: "Show simple message",
54
+ description: "Display 'Competition concluded. Thank you for participating!' only."
55
+ }
53
56
  ]
54
57
  }
55
58
  ]
56
59
  });
57
60
 
58
- const approach = answer["Approach"];
59
- const behavior = answer["Behavior"];
60
- // Proceed with confirmed specifications
61
+ // Result:
62
+ // {
63
+ // "Approach": "New public route",
64
+ // "Behavior": "Show full results"
65
+ // }
66
+ ```
67
+
68
+ ### Outcome
69
+
70
+ Alfred now knows **exactly** what to build:
71
+ - Create `/app/competition-complete/page.tsx`
72
+ - New public route
73
+ - Logged-in users redirected to `/end` page with full results
74
+ - Non-logged-in users see simple completion message
75
+
76
+ ---
77
+
78
+ ## Example 2: Implementation Approach (Pattern 1)
79
+
80
+ ### Scenario
81
+
82
+ **User**: "Add i18n support to the app."
83
+
84
+ **Alfred detects**:
85
+ - Multiple valid i18n libraries exist
86
+ - Each has different trade-offs (DX, complexity, performance)
87
+ - User hasn't specified preference
88
+
89
+ ### AskUserQuestion Invocation
90
+
91
+ ```typescript
92
+ const answer = await AskUserQuestion({
93
+ questions: [{
94
+ question: "Which i18n library should we use for Next.js 15?",
95
+ header: "Library",
96
+ multiSelect: false,
97
+ options: [
98
+ {
99
+ label: "next-intl",
100
+ description: "Native Next.js 15 support, best DX, automatic type safety."
101
+ },
102
+ {
103
+ label: "react-i18next",
104
+ description: "Most popular, flexible, more setup required, larger bundle."
105
+ },
106
+ {
107
+ label: "Format.js",
108
+ description: "ICU message format, powerful pluralization, steeper learning curve."
109
+ }
110
+ ]
111
+ }]
112
+ });
113
+
114
+ // Result: { "Library": "next-intl" }
115
+ ```
116
+
117
+ ### Outcome
118
+
119
+ Alfred proceeds with `next-intl`, avoiding:
120
+ - ❌ Guessing wrong library
121
+ - ❌ Implementing then refactoring later
122
+ - ❌ 3-5 rounds of "actually, can we use X instead?"
123
+
124
+ ---
125
+
126
+ ## Example 3: Risky Operation Confirmation (Pattern 2)
127
+
128
+ ### Scenario
129
+
130
+ **User**: "Delete all test users from production database."
131
+
132
+ **Alfred detects**:
133
+ - Destructive operation (data loss)
134
+ - Production environment (high risk)
135
+ - Explicit confirmation required
136
+
137
+ ### AskUserQuestion Invocation
138
+
139
+ ```typescript
140
+ const answer = await AskUserQuestion({
141
+ questions: [{
142
+ question: "⚠️ This will PERMANENTLY delete 50 test users from PRODUCTION database. Are you sure?",
143
+ header: "Confirm",
144
+ multiSelect: false,
145
+ options: [
146
+ {
147
+ label: "No, cancel",
148
+ description: "Abort operation. No changes will be made."
149
+ },
150
+ {
151
+ label: "Yes, proceed",
152
+ description: "🚨 IRREVERSIBLE. Delete 50 users now."
153
+ }
154
+ ]
155
+ }]
156
+ });
157
+
158
+ // Result: { "Confirm": "No, cancel" } (user cancelled)
61
159
  ```
62
160
 
161
+ ### Outcome
162
+
163
+ Alfred **aborts** operation without executing destructive command. User explicitly chose to cancel after seeing full risk disclosure.
164
+
63
165
  ---
64
166
 
65
- ## Example 3: Multi-Select (Independent Features)
167
+ ## Example 4: Multi-Select Feature Selection (Pattern 4)
66
168
 
67
- **Scenario**: "Which testing frameworks?"
169
+ ### Scenario
170
+
171
+ **User**: "Set up testing for the new project."
172
+
173
+ **Alfred detects**:
174
+ - Multiple testing frameworks can coexist
175
+ - User might want unit + E2E + visual testing
176
+ - No explicit preference stated
177
+
178
+ ### AskUserQuestion Invocation
68
179
 
69
180
  ```typescript
70
181
  const answer = await AskUserQuestion({
71
182
  questions: [{
72
- question: "Which testing frameworks to include?",
183
+ question: "Which testing frameworks should we set up? (Select all that apply)",
73
184
  header: "Test Tools",
74
- multiSelect: true, // User can select multiple
185
+ multiSelect: true, // Multiple selections allowed
75
186
  options: [
76
- { label: "Unit tests (Vitest)", description: "Fast unit testing." },
77
- { label: "E2E tests (Playwright)", description: "Browser automation." },
78
- { label: "Visual regression", description: "Screenshot comparison." }
187
+ {
188
+ label: "Unit tests (Vitest)",
189
+ description: "Fast, modern, Vite-native. ~2min setup."
190
+ },
191
+ {
192
+ label: "E2E tests (Playwright)",
193
+ description: "Browser automation, cross-browser. ~10min setup."
194
+ },
195
+ {
196
+ label: "Visual regression",
197
+ description: "Screenshot comparison with Playwright. ~5min setup."
198
+ }
79
199
  ]
80
200
  }]
81
201
  });
82
202
 
83
- const selectedTools = answer["Test Tools"]; // ["Unit tests (Vitest)", "E2E tests (Playwright)"]
84
- // Install selected frameworks
203
+ // Result: { "Test Tools": ["Unit tests (Vitest)", "E2E tests (Playwright)"] }
85
204
  ```
86
205
 
206
+ ### Outcome
207
+
208
+ Alfred installs and configures:
209
+ - ✅ Vitest for unit tests
210
+ - ✅ Playwright for E2E tests
211
+ - ❌ Skips visual regression (not selected)
212
+
87
213
  ---
88
214
 
89
- ## Example 4: Sequential Questions (Conditional)
215
+ ## Example 5: Sequential Questions (Conditional Flow, Pattern 5)
90
216
 
91
- **Scenario**: Q2 depends on Q1 answer
217
+ ### Scenario
218
+
219
+ **User**: "Add authentication to the app."
220
+
221
+ **Alfred detects**:
222
+ - First decision: Enable auth? (Yes/No)
223
+ - Second decision: If yes, which provider? (depends on Q1)
224
+
225
+ ### AskUserQuestion Invocation (Part 1)
92
226
 
93
227
  ```typescript
94
- // Question 1
228
+ // Question 1: Enable authentication?
95
229
  const q1 = await AskUserQuestion({
96
230
  questions: [{
97
- question: "Enable authentication?",
231
+ question: "Should we enable user authentication?",
98
232
  header: "Auth",
233
+ multiSelect: false,
99
234
  options: [
100
- { label: "Yes", description: "User login required." },
101
- { label: "No", description: "Public access." }
235
+ {
236
+ label: "Yes",
237
+ description: "User login required for protected routes."
238
+ },
239
+ {
240
+ label: "No",
241
+ description: "Public access only, no authentication."
242
+ }
102
243
  ]
103
244
  }]
104
245
  });
105
246
 
106
- // Question 2 (only if Q1 = "Yes")
247
+ // Result: { "Auth": "Yes" }
248
+ ```
249
+
250
+ ### AskUserQuestion Invocation (Part 2, Conditional)
251
+
252
+ ```typescript
253
+ // Question 2: Only ask if Q1 = "Yes"
107
254
  if (q1["Auth"] === "Yes") {
108
255
  const q2 = await AskUserQuestion({
109
256
  questions: [{
110
- question: "Which auth provider?",
257
+ question: "Which authentication provider?",
111
258
  header: "Provider",
259
+ multiSelect: false,
112
260
  options: [
113
- { label: "JWT + email", description: "Traditional email/password." },
114
- { label: "OAuth", description: "Third-party login (Google, GitHub)." }
261
+ {
262
+ label: "JWT + email",
263
+ description: "Traditional email/password with JWT tokens. ~30min setup."
264
+ },
265
+ {
266
+ label: "OAuth (Google)",
267
+ description: "Third-party login via Google. Faster for users. ~20min setup."
268
+ },
269
+ {
270
+ label: "SAML",
271
+ description: "Enterprise SSO (for corporate environments). ~2hr setup."
272
+ }
115
273
  ]
116
274
  }]
117
275
  });
118
-
119
- const provider = q2["Provider"];
120
- // Setup authentication
276
+
277
+ // Result: { "Provider": "OAuth (Google)" }
121
278
  }
122
279
  ```
123
280
 
281
+ ### Outcome
282
+
283
+ Alfred implements:
284
+ - ✅ Authentication enabled
285
+ - ✅ OAuth with Google provider
286
+ - ✅ Skips JWT setup (not selected)
287
+ - ❌ If Q1 was "No", Q2 never asked (saves time)
288
+
124
289
  ---
125
290
 
126
- ## Example 5: Feature Selection
291
+ ## Example 6: Option Grouping (Hierarchical Selection)
292
+
293
+ ### Scenario
294
+
295
+ **User**: "Set up a database for the project."
127
296
 
128
- **Scenario**: "Which i18n library?"
297
+ **Alfred detects**:
298
+ - 8+ database options exist
299
+ - Too many for one question → choice paralysis
300
+ - Need hierarchical selection: Category → Specific
301
+
302
+ ### AskUserQuestion Invocation (Step 1: Category)
129
303
 
130
304
  ```typescript
131
- const answer = await AskUserQuestion({
305
+ // Step 1: Narrow by database type
306
+ const category = await AskUserQuestion({
132
307
  questions: [{
133
- question: "Which i18n library?",
134
- header: "Library",
308
+ question: "What type of database does your project need?",
309
+ header: "DB Type",
135
310
  multiSelect: false,
136
311
  options: [
137
- { label: "next-intl", description: "Next.js 15+ native, best DX." },
138
- { label: "react-i18next", description: "Popular, flexible, more setup." },
139
- { label: "Format.js", description: "ICU format, complex but powerful." }
312
+ {
313
+ label: "Relational (SQL)",
314
+ description: "PostgreSQL, MySQL, SQLite. ACID guarantees, structured data."
315
+ },
316
+ {
317
+ label: "Document (NoSQL)",
318
+ description: "MongoDB, CouchDB. Flexible schema, JSON documents."
319
+ },
320
+ {
321
+ label: "Key-Value",
322
+ description: "Redis, Memcached. In-memory cache, fast reads."
323
+ }
140
324
  ]
141
325
  }]
142
326
  });
143
327
 
144
- const library = answer["Library"]; // "next-intl"
145
- // Install and configure library
328
+ // Result: { "DB Type": "Relational (SQL)" }
329
+ ```
330
+
331
+ ### AskUserQuestion Invocation (Step 2: Specific Choice)
332
+
333
+ ```typescript
334
+ // Step 2: Specific database within category
335
+ if (category["DB Type"] === "Relational (SQL)") {
336
+ const specific = await AskUserQuestion({
337
+ questions: [{
338
+ question: "Which SQL database?",
339
+ header: "SQL DB",
340
+ multiSelect: false,
341
+ options: [
342
+ {
343
+ label: "PostgreSQL",
344
+ description: "Advanced features (JSON, full-text search, extensions). Industry standard."
345
+ },
346
+ {
347
+ label: "MySQL",
348
+ description: "Most popular, wide hosting support, good performance."
349
+ },
350
+ {
351
+ label: "SQLite",
352
+ description: "Embedded, serverless, single-file. Good for prototypes and small apps."
353
+ }
354
+ ]
355
+ }]
356
+ });
357
+
358
+ // Result: { "SQL DB": "PostgreSQL" }
359
+ }
360
+ ```
361
+
362
+ ### Outcome
363
+
364
+ Alfred avoids:
365
+ - ❌ Presenting 8 options at once (choice paralysis)
366
+ - ❌ User confusion ("What's the difference between MariaDB and MySQL?")
367
+
368
+ Instead:
369
+ - ✅ First narrows to category (3 options)
370
+ - ✅ Then presents specific choices within category (3 options)
371
+ - ✅ Clear, manageable decision flow
372
+
373
+ ---
374
+
375
+ ## Example 7: Batch Related Questions
376
+
377
+ ### Scenario
378
+
379
+ **User**: "Initialize a new Next.js project with best practices."
380
+
381
+ **Alfred detects**:
382
+ - Multiple independent decisions needed
383
+ - All decisions are related to project setup
384
+ - Can ask 3 questions at once (no dependencies)
385
+
386
+ ### AskUserQuestion Invocation
387
+
388
+ ```typescript
389
+ const answers = await AskUserQuestion({
390
+ questions: [
391
+ {
392
+ question: "Which database?",
393
+ header: "Database",
394
+ multiSelect: false,
395
+ options: [
396
+ { label: "PostgreSQL", description: "Relational, ACID-compliant, advanced features." },
397
+ { label: "MongoDB", description: "Document store, flexible schema, rapid prototyping." }
398
+ ]
399
+ },
400
+ {
401
+ question: "Which testing frameworks? (Select all that apply)",
402
+ header: "Testing",
403
+ multiSelect: true, // Multiple selections allowed
404
+ options: [
405
+ { label: "Unit tests", description: "Vitest for fast unit testing." },
406
+ { label: "E2E tests", description: "Playwright for browser automation." },
407
+ { label: "Visual tests", description: "Screenshot comparison testing." }
408
+ ]
409
+ },
410
+ {
411
+ question: "Enable TypeScript strict mode?",
412
+ header: "TypeScript",
413
+ multiSelect: false,
414
+ options: [
415
+ { label: "Yes (recommended)", description: "Strict type checking, catch errors early." },
416
+ { label: "No", description: "Loose type checking, faster initial development." }
417
+ ]
418
+ }
419
+ ]
420
+ });
421
+
422
+ // Result:
423
+ // {
424
+ // "Database": "PostgreSQL",
425
+ // "Testing": ["Unit tests", "E2E tests"],
426
+ // "TypeScript": "Yes (recommended)"
427
+ // }
146
428
  ```
147
429
 
430
+ ### Outcome
431
+
432
+ Alfred configures project with:
433
+ - ✅ PostgreSQL database
434
+ - ✅ Vitest unit tests
435
+ - ✅ Playwright E2E tests
436
+ - ❌ No visual regression tests
437
+ - ✅ TypeScript strict mode enabled
438
+
439
+ All decided in **one interaction** instead of 3 separate back-and-forth exchanges.
440
+
148
441
  ---
149
442
 
150
- ## Example 6: Error Recovery
443
+ ## Example 8: Error Recovery After Test Failure
444
+
445
+ ### Scenario
151
446
 
152
- **Scenario**: 3 tests failed, ask how to proceed
447
+ **Context**: Alfred is in `/alfred:2-run` phase, tests are failing.
448
+
449
+ **Alfred detects**:
450
+ - Tests fail after implementation
451
+ - Multiple possible fixes exist
452
+ - User input needed to decide repair strategy
453
+
454
+ ### AskUserQuestion Invocation
153
455
 
154
456
  ```typescript
155
457
  const answer = await AskUserQuestion({
156
458
  questions: [{
157
- question: "3 tests failed in auth.test.ts. How should we proceed?",
158
- header: "Test Failure",
459
+ question: "Tests are failing. How should we proceed?",
460
+ header: "Fix Strategy",
159
461
  multiSelect: false,
160
462
  options: [
161
- { label: "Debug immediately", description: "Stop and fix now." },
162
- { label: "Skip tests", description: "NOT RECOMMENDED - continues with failing tests." },
163
- { label: "Rollback changes", description: "Revert to last passing commit." }
463
+ {
464
+ label: "Fix implementation",
465
+ description: "Adjust code to pass existing tests (tests are correct)."
466
+ },
467
+ {
468
+ label: "Update tests",
469
+ description: "Modify tests to match new implementation (implementation is correct)."
470
+ },
471
+ {
472
+ label: "Debug together",
473
+ description: "Review both implementation and tests to identify root cause."
474
+ }
164
475
  ]
165
476
  }]
166
477
  });
167
478
 
168
- if (answer["Test Failure"] === "Debug immediately") {
169
- // Trigger debug workflow
170
- } else if (answer["Test Failure"] === "Rollback changes") {
171
- // Rollback git changes
172
- }
479
+ // Result: { "Fix Strategy": "Fix implementation" }
173
480
  ```
174
481
 
175
- ---
482
+ ### Outcome
176
483
 
177
- ## Example 7: /alfred:1-plan Integration
484
+ Alfred:
485
+ - ✅ Keeps tests unchanged
486
+ - ✅ Fixes implementation to satisfy test expectations
487
+ - ✅ Avoids "test modification to make them pass" anti-pattern
488
+ - ✅ Follows RED → GREEN → REFACTOR TDD cycle correctly
178
489
 
179
- **Scenario**: spec-builder detects ambiguous SPEC title
490
+ ---
180
491
 
181
- ```typescript
182
- // Inside spec-builder
183
- function shouldAskForClarification(title: string): boolean {
184
- return title.length < 20 || title.includes("feature/add/implement");
185
- }
492
+ ## Example 9: SPEC Scope Clarification (spec-builder)
186
493
 
187
- if (shouldAskForClarification(userTitle)) {
188
- const answer = await AskUserQuestion({
189
- questions: [{
190
- question: "Can you clarify what this SPEC should cover?",
191
- header: "Scope",
192
- options: [
193
- { label: "Authentication system", description: "User login, JWT tokens, refresh logic." },
194
- { label: "UI components", description: "Reusable components library." },
195
- { label: "API endpoints", description: "REST API implementation." }
196
- ]
197
- }]
198
- });
494
+ ### Scenario
199
495
 
200
- specTitle = answer["Scope"];
201
- }
202
- ```
203
-
204
- ---
496
+ **User**: "Create SPEC for performance improvements."
205
497
 
206
- ## Example 8: /alfred:2-run Integration
498
+ **Alfred detects** (spec-builder sub-agent):
499
+ - SPEC title is vague ("performance improvements")
500
+ - Scope undefined (backend? frontend? database?)
501
+ - Multiple domains affected
207
502
 
208
- **Scenario**: code-builder detects multiple implementation paths
503
+ ### AskUserQuestion Invocation
209
504
 
210
505
  ```typescript
211
- // Inside code-builder
212
- if (multipleValidImplementationPaths) {
213
- const answer = await AskUserQuestion({
214
- questions: [{
215
- question: "How should we implement JWT storage?",
216
- header: "Storage",
506
+ const answer = await AskUserQuestion({
507
+ questions: [
508
+ {
509
+ question: "Which area needs performance improvements?",
510
+ header: "Domain",
511
+ multiSelect: false,
217
512
  options: [
218
- { label: "HttpOnly cookie", description: "Most secure, no JS access." },
219
- { label: "LocalStorage", description: "Accessible but vulnerable to XSS." },
220
- { label: "Memory + refresh", description: "Balance between security and UX." }
513
+ { label: "Backend API", description: "Optimize API response times, database queries." },
514
+ { label: "Frontend", description: "Improve page load times, bundle size, rendering." },
515
+ { label: "Database", description: "Add indexes, optimize queries, caching." },
516
+ { label: "All of the above", description: "Comprehensive performance audit." }
221
517
  ]
222
- }]
223
- });
518
+ },
519
+ {
520
+ question: "What's the performance target?",
521
+ header: "Target",
522
+ multiSelect: false,
523
+ options: [
524
+ { label: "< 200ms API", description: "API responses under 200ms (P95)." },
525
+ { label: "< 2s page load", description: "Pages load under 2 seconds (P95)." },
526
+ { label: "< 100ms queries", description: "Database queries under 100ms (P95)." }
527
+ ]
528
+ }
529
+ ]
530
+ });
224
531
 
225
- const storageStrategy = answer["Storage"];
226
- implementWithStrategy(storageStrategy);
227
- }
532
+ // Result:
533
+ // {
534
+ // "Domain": "Backend API",
535
+ // "Target": "< 200ms API"
536
+ // }
228
537
  ```
229
538
 
539
+ ### Outcome
540
+
541
+ spec-builder generates precise SPEC:
542
+ - ✅ Title: `[PERF-001] Optimize Backend API Response Times to <200ms`
543
+ - ✅ Scope: Backend API performance only
544
+ - ✅ Clear success criteria: P95 latency < 200ms
545
+ - ❌ Avoids vague SPEC like "Improve performance"
546
+
230
547
  ---
231
548
 
232
- ## Example 9: /alfred:3-sync Integration
549
+ ## Example 10: Doc Sync Mode Selection (doc-syncer)
550
+
551
+ ### Scenario
552
+
553
+ **User**: "Sync documentation."
554
+
555
+ **Alfred detects** (doc-syncer sub-agent):
556
+ - Sync mode unclear (auto-detect vs force-regenerate vs partial)
557
+ - User hasn't specified preference
558
+ - Different modes have different time/accuracy trade-offs
233
559
 
234
- **Scenario**: doc-syncer asks about sync mode
560
+ ### AskUserQuestion Invocation
235
561
 
236
562
  ```typescript
237
- // Inside doc-syncer
238
563
  const answer = await AskUserQuestion({
239
564
  questions: [{
240
- question: "Which sync mode?",
241
- header: "Mode",
565
+ question: "Which documentation sync mode?",
566
+ header: "Sync Mode",
242
567
  multiSelect: false,
243
568
  options: [
244
- { label: "auto", description: "Smart detection, sync affected docs only." },
245
- { label: "force", description: "Regenerate all docs from scratch." },
246
- { label: "status", description: "Show status without making changes." }
569
+ {
570
+ label: "auto",
571
+ description: "Smart detection of changes. Fast, minimal updates. (Recommended)"
572
+ },
573
+ {
574
+ label: "force",
575
+ description: "Regenerate ALL documentation. Slow but guaranteed accurate."
576
+ },
577
+ {
578
+ label: "partial",
579
+ description: "Update only specified sections. Fast, targeted."
580
+ }
247
581
  ]
248
582
  }]
249
583
  });
250
584
 
251
- const syncMode = answer["Mode"];
252
- runSync(syncMode);
585
+ // Result: { "Sync Mode": "auto" }
253
586
  ```
254
587
 
588
+ ### Outcome
589
+
590
+ doc-syncer:
591
+ - ✅ Uses auto-detection mode
592
+ - ✅ Only updates changed sections
593
+ - ✅ Faster execution (1-2 min vs 10 min for force mode)
594
+ - ✅ User sees clear time/accuracy trade-off before deciding
595
+
596
+ ---
597
+
598
+ ## Summary: Pattern Catalog
599
+
600
+ | Pattern | Use Case | Example Scenario |
601
+ |---------|----------|------------------|
602
+ | **Pattern 1: Implementation Approach** | Multiple valid implementation paths | "Add i18n support" (which library?) |
603
+ | **Pattern 2: Confirmation** | Risky/destructive operations | "Delete production data" (are you sure?) |
604
+ | **Pattern 3: Multi-Option Selection** | Choose ONE from multiple frameworks/tools | "Which testing framework?" |
605
+ | **Pattern 4: Multi-Select** | Enable/disable independent features | "Which features to enable?" (check multiple) |
606
+ | **Pattern 5: Sequential Questions** | Q2 depends on Q1 answer | "Enable auth?" → If yes, "Which provider?" |
607
+ | **Pattern 6: Option Grouping** | Too many options → hierarchical selection | Database type → Specific database |
608
+ | **Pattern 7: Batch Questions** | Multiple independent decisions | Project setup (DB + Testing + TypeScript) |
609
+ | **Pattern 8: Error Recovery** | Handle failures with user guidance | Test failure → Fix implementation vs update tests |
610
+ | **Pattern 9: SPEC Clarification** | Vague SPEC scope/title | "Performance improvements" → Which domain? |
611
+ | **Pattern 10: Mode Selection** | Choose workflow mode/strategy | Doc sync mode (auto vs force vs partial) |
612
+
255
613
  ---
256
614
 
257
- For detailed guidance, see **SKILL.md** and **reference.md**
615
+ **End of Examples** | 2025-10-27