5-phase-workflow 1.2.0 → 1.2.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "5-phase-workflow",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "A 5-phase feature development workflow for Claude Code",
5
5
  "bin": {
6
6
  "5-phase-workflow": "bin/install.js"
@@ -149,6 +149,129 @@ fi
149
149
  **1f. Scan existing skills:**
150
150
  - Check `.claude/skills/` for existing project-specific skills
151
151
 
152
+ **1g. Detect codebase patterns** for potential skills:
153
+
154
+ Use Glob to count files matching common architectural patterns:
155
+
156
+ | Pattern | Glob Patterns | Typical Location |
157
+ |---------|-------------------------------------------------------------------------------|------------------|
158
+ | **Core Architecture** | | |
159
+ | Controllers | `**/*Controller.{ts,js,java,py,rb}`, `**/controllers/**` | src/controllers/ |
160
+ | Services | `**/*Service.{ts,js,java,py,rb}`, `**/services/**` | src/services/ |
161
+ | Repositories | `**/*Repository.{ts,js,java,py}`, `**/repositories/**` | src/repositories/ |
162
+ | Models/Entities | `**/*Model.{ts,js}`, `**/*Entity.java`, `**/models/**` | src/models/ |
163
+ | Handlers | `**/*Handler.{ts,js,java,go}`, `**/handlers/**` | src/handlers/ |
164
+ | **Data Transfer** | | |
165
+ | DTOs | `**/*Dto.{ts,js,java}`, `**/*DTO.{ts,js,java}`, `**/dto/**` | src/dto/ |
166
+ | Requests | `**/*Request.{ts,js,java}`, `**/requests/**` | src/requests/ |
167
+ | Responses | `**/*Response.{ts,js,java}`, `**/responses/**` | src/responses/ |
168
+ | Mappers | `**/*Mapper.{ts,js,java}`, `**/mappers/**` | src/mappers/ |
169
+ | Validators | `**/*Validator.{ts,js,java}`, `**/validators/**` | src/validators/ |
170
+ | Schemas | `**/*Schema.{ts,js}`, `**/schemas/**` | src/schemas/ |
171
+ | **Frontend (React/Vue)** | | |
172
+ | Components | `**/components/**/*.{tsx,jsx,vue}` | src/components/ |
173
+ | Hooks | `**/hooks/**/*.{ts,js}`, `**/use*.{ts,js}` | src/hooks/ |
174
+ | Contexts | `**/contexts/**/*.{tsx,jsx}`, `**/*Context.{tsx,jsx}` | src/contexts/ |
175
+ | Stores | `**/stores/**/*.{ts,js}`, `**/*Store.{ts,js}` | src/stores/ |
176
+ | Pages | `**/pages/**/*.{tsx,jsx}`, `**/app/**/page.{tsx,jsx}` | pages/, app/ |
177
+ | Layouts | `**/layouts/**/*.{tsx,jsx,vue}`, `**/*Layout.{tsx,jsx}` | src/layouts/ |
178
+ | **API/Routes** | | |
179
+ | API Routes | `**/api/**/*.{ts,js}`, `**/routes/**` | src/api/, pages/api/ |
180
+ | Middleware | `**/*Middleware.{ts,js,java}`, `**/middleware/**` | src/middleware/ |
181
+ | Guards | `**/*.guard.{ts,js}`, `**/guards/**` | src/guards/ |
182
+ | Interceptors | `**/*.interceptor.{ts,js}`, `**/interceptors/**` | src/interceptors/ |
183
+ | Filters | `**/*.filter.{ts,js}`, `**/*Filter.java` | src/filters/ |
184
+ | **Testing** | | |
185
+ | Tests | `**/*.test.{ts,js,tsx,jsx}`, `**/*.spec.{ts,js,tsx,jsx}`, `**/tests/**` | src/, tests/ |
186
+ | Specs | `**/*_spec.rb`, `**/spec/**/*.rb`, `**/*_test.go`, `**/test_*.py` | spec/, tests/ |
187
+ | Test Fixtures | `**/fixtures/**`,`**/testFixtures/**`, `**/__fixtures__/**`, `**/testdata/**` | fixtures/, testdata/ |
188
+ | Factories | `**/*Factory.{ts,js,java,rb}`, `**/factories/**` | factories/ |
189
+ | Mocks | `**/__mocks__/**`, `**/mocks/**`, `**/*Mock.{ts,js}` | __mocks__/, mocks/ |
190
+ | **Utilities** | | |
191
+ | Utils | `**/utils/**/*.{ts,js,java,py}`, `**/*Utils.{ts,js,java}` | src/utils/ |
192
+ | Helpers | `**/helpers/**/*.{ts,js,java,py,rb}`, `**/*Helper.{ts,js,java}` | src/helpers/ |
193
+ | Constants | `**/constants/**/*.{ts,js}`, `**/*Constants.{ts,js}` | src/constants/ |
194
+ | Types/Interfaces | `**/types/**/*.{ts,js}`, `**/interfaces/**/*.{ts,java}` | src/types/ |
195
+ | Config | `**/config/**/*.{ts,js,py}`, `**/*Config.{ts,js}` | src/config/ |
196
+ | **Framework-Specific** | | |
197
+ | Modules (NestJS/Angular) | `**/*.module.{ts,js}` | src/modules/ |
198
+ | Pipes (NestJS) | `**/*.pipe.{ts,js}`, `**/pipes/**` | src/pipes/ |
199
+ | Decorators | `**/decorators/**/*.{ts,js}`, `**/*.decorator.{ts,js}` | src/decorators/ |
200
+ | Blueprints (Flask) | `**/blueprints/**/*.py` | blueprints/ |
201
+ | Views (Django) | `**/views.py`, `**/views/**/*.py` | app/views/ |
202
+ | Serializers (Django) | `**/serializers.py`, `**/serializers/**/*.py` | app/serializers/ |
203
+ | **Background/Async** | | |
204
+ | Jobs | `**/jobs/**/*.{ts,js,rb}`, `**/*Job.{ts,js,rb}` | src/jobs/ |
205
+ | Workers | `**/workers/**/*.{ts,js}`, `**/*Worker.{ts,js}` | src/workers/ |
206
+ | Events | `**/events/**/*.{ts,js,java}`, `**/*Event.{ts,js,java}` | src/events/ |
207
+ | Listeners | `**/listeners/**/*.{ts,js,java}`, `**/*Listener.{ts,js}` | src/listeners/ |
208
+ | Commands (CLI) | `**/commands/**/*.{ts,js,java}`, `**/*Command.{ts,js}` | src/commands/ |
209
+ | **Database** | | |
210
+ | Migrations | `**/migrations/**/*.{ts,js,sql,rb,py}` | migrations/ |
211
+ | Seeds | `**/seeds/**/*.{ts,js,rb}`, `**/seeders/**` | seeds/ |
212
+ | **Error Handling** | | |
213
+ | Exceptions | `**/exceptions/**/*.{ts,js,java}`, `**/*Exception.{ts,js,java}` | src/exceptions/ |
214
+ | Errors | `**/errors/**/*.{ts,js}`, `**/*Error.{ts,js}` | src/errors/ |
215
+
216
+ For each pattern found:
217
+ - Count matching files
218
+ - Identify primary location (most common directory)
219
+ - Sample 1 file name to show convention
220
+
221
+ **1h. Detect runnable commands** for potential command skills:
222
+
223
+ Scan project configuration files for commands that can become skills:
224
+
225
+ | Source | How to Detect | Example Commands |
226
+ |--------|---------------|------------------|
227
+ | package.json | Read `scripts` object | build, test, lint, format, dev, start, typecheck |
228
+ | Makefile | Grep for targets (lines ending with `:`) | build, test, lint, clean, docker-build |
229
+ | pyproject.toml | Read `[tool.poetry.scripts]` or `[project.scripts]` | test, lint, format, typecheck |
230
+ | Cargo.toml | Check for `[[bin]]` sections, common cargo commands | build, test, clippy, fmt |
231
+ | build.gradle | Grep for `task` definitions | build, test, lint, spotlessApply |
232
+ | composer.json | Read `scripts` object | test, lint, format, analyse |
233
+ | Rakefile | Grep for `task :name` patterns | test, lint, db:migrate, db:seed |
234
+
235
+ **Common command categories to detect:**
236
+
237
+ | Category | Common Names | Skill Name |
238
+ |----------|--------------|------------|
239
+ | **Build** | build, compile, bundle, pack | run-build |
240
+ | **Test** | test, test:unit, test:integration, test:e2e, spec | run-tests |
241
+ | **Lint** | lint, eslint, pylint, rubocop, clippy | run-lint |
242
+ | **Format** | format, prettier, fmt, black, gofmt | run-format |
243
+ | **Type Check** | typecheck, tsc, mypy, type-check | run-typecheck |
244
+ | **Dev Server** | dev, start, serve, watch | run-dev |
245
+ | **Database** | db:migrate, migrate, db:seed, seed, db:reset | run-db-migrate, run-db-seed |
246
+ | **Docker** | docker:build, docker:up, docker:down, compose | run-docker |
247
+ | **Deploy** | deploy, release, publish | run-deploy |
248
+ | **Clean** | clean, reset, purge | run-clean |
249
+ | **Generate** | generate, codegen, gen | run-generate |
250
+
251
+ For each command found:
252
+ - Record the exact command syntax
253
+ - Identify any required environment or flags
254
+ - Note if it has watch/CI variants
255
+
256
+ Store results internally as:
257
+ ```json
258
+ {
259
+ "detectedPatterns": {
260
+ "controller": { "count": 12, "location": "src/controllers/", "example": "UserController.ts" },
261
+ "service": { "count": 8, "location": "src/services/", "example": "AuthService.ts" },
262
+ "component": { "count": 25, "location": "src/components/", "example": "Button.tsx" }
263
+ },
264
+ "detectedCommands": {
265
+ "build": { "source": "package.json", "command": "npm run build", "variants": ["build:prod", "build:dev"] },
266
+ "test": { "source": "package.json", "command": "npm test", "variants": ["test:unit", "test:e2e"] },
267
+ "lint": { "source": "package.json", "command": "npm run lint", "variants": ["lint:fix"] },
268
+ "format": { "source": "package.json", "command": "npm run format", "variants": [] }
269
+ }
270
+ }
271
+ ```
272
+
273
+ Only include patterns/commands that are actually detected.
274
+
152
275
  ### Step 2: Gather User Preferences (interactive via AskUserQuestion)
153
276
 
154
277
  **2a. If config exists:**
@@ -201,10 +324,46 @@ fi
201
324
  - "Generate/update CLAUDE.md? This will analyze your codebase to document structure and conventions."
202
325
  - Options: "Yes (recommended)", "Skip"
203
326
 
204
- **2h. Confirm project-specific skills:**
205
- - Present proposed skills based on detected project type (see skill table in configure-project/SKILL.md)
206
- - "These project-specific skills were detected for your {project-type} project: {skill-list}. Confirm or customize?"
207
- - Options: "Use these (recommended)", "Customize", "Skip skill generation"
327
+ **2h. Review detected patterns for skill generation:**
328
+
329
+ Present ONLY patterns that were actually detected in steps 1g and 1h.
330
+
331
+ **Part 1: Architectural patterns (create-* skills)**
332
+
333
+ "I analyzed your codebase and found these architectural patterns:
334
+
335
+ | Pattern | Files Found | Location | Example |
336
+ |---------|-------------|----------|---------|
337
+ | Controller | 12 files | src/controllers/ | UserController.ts |
338
+ | Service | 8 files | src/services/ | AuthService.ts |
339
+ | Component | 25 files | src/components/ | Button.tsx |
340
+
341
+ Which patterns would you like `create-*` skills generated for?"
342
+
343
+ - Options: Multi-select checkboxes for each detected pattern (use AskUserQuestion with multiSelect: true)
344
+ - Include descriptions like: "Controller (12 files) - Generate `create-controller` skill"
345
+ - Plus "Other" option for patterns not detected but desired
346
+
347
+ **Part 2: Command skills (run-* skills)**
348
+
349
+ "I also found these runnable commands:
350
+
351
+ | Command | Source | Full Command | Variants |
352
+ |---------|--------|--------------|----------|
353
+ | build | package.json | npm run build | build:prod, build:dev |
354
+ | test | package.json | npm test | test:unit, test:e2e |
355
+ | lint | package.json | npm run lint | lint:fix |
356
+ | format | Makefile | make format | - |
357
+
358
+ Which commands would you like `run-*` skills generated for?"
359
+
360
+ - Options: Multi-select checkboxes for each detected command
361
+ - Include descriptions like: "test - Generate `run-tests` skill"
362
+ - Plus "Other" option for commands not detected
363
+
364
+ If no patterns/commands detected:
365
+ - Inform user: "No common patterns detected. Would you like to specify patterns manually?"
366
+ - Allow manual entry of pattern names/locations or command names
208
367
 
209
368
  ### Step 3: Create Feature Spec
210
369
 
@@ -260,18 +419,59 @@ Analyze the codebase and generate modular documentation:
260
419
  - If CLAUDE.md already exists, preserve user-written custom sections
261
420
 
262
421
  ### Requirement 3: Generate Project-Specific Skills
263
- Generate the following skills in `.claude/skills/`:
264
- {List of confirmed skills, e.g.:}
265
- - create-component: Creates a React component following project conventions
266
- - create-hook: Creates a custom React hook following project conventions
267
- - create-context: Creates a React context provider following project conventions
268
422
 
269
- Each skill should:
423
+ #### 3a. Create-* Skills (Architectural Patterns)
424
+
425
+ Generate skills based on detected file patterns:
426
+
427
+ | Pattern | Files | Location | Skill Name | Generate |
428
+ |---------|-------|----------|------------|----------|
429
+ | Controller | {count} | {location} | create-controller | ✓ |
430
+ | Service | {count} | {location} | create-service | ✓ |
431
+ | Component | {count} | {location} | create-component | ✓ |
432
+ | {pattern} | {count} | {location} | create-{pattern} | ✗ (user skipped) |
433
+
434
+ {Include only patterns where user selected "Generate = ✓"}
435
+
436
+ For each selected pattern skill:
437
+ 1. Analyze 2-3 existing files from the pattern location
438
+ 2. Extract naming conventions, file structure, imports
439
+ 3. Generate SKILL.md with project-specific template
440
+
441
+ Each create-* skill should:
270
442
  - Follow standard SKILL.md frontmatter pattern
443
+ - Set `user-invocable: true` so users can invoke directly (e.g., `/create-controller UserController`)
444
+ - Set `model: haiku` for fast, cheap pattern-following
271
445
  - Derive patterns from existing code in the project
272
446
  - Include file naming and location conventions
273
447
  - Include template/pattern based on existing examples
274
448
 
449
+ #### 3b. Run-* Skills (Command Skills)
450
+
451
+ Generate skills based on detected commands:
452
+
453
+ | Command | Source | Full Command | Skill Name | Generate |
454
+ |---------|--------|--------------|------------|----------|
455
+ | build | {source} | {command} | run-build | ✓ |
456
+ | test | {source} | {command} | run-tests | ✓ |
457
+ | lint | {source} | {command} | run-lint | ✓ |
458
+ | {command} | {source} | {full-command} | run-{command} | ✗ (user skipped) |
459
+
460
+ {Include only commands where user selected "Generate = ✓"}
461
+
462
+ For each selected command skill:
463
+ 1. Document the exact command and any variants
464
+ 2. Include common flags and options
465
+ 3. Document expected output and error handling
466
+
467
+ Each run-* skill should:
468
+ - Follow standard SKILL.md frontmatter pattern
469
+ - Set `user-invocable: true` so users can invoke directly (e.g., `/run-tests`, `/run-lint`)
470
+ - Set `model: haiku` for simple command execution
471
+ - Include the exact command syntax
472
+ - Document any environment requirements
473
+ - Include common options/flags
474
+
275
475
  ## Acceptance Criteria
276
476
  - [ ] `.claude/.5/config.json` exists with correct values (no `steps` array)
277
477
  - [ ] `.5/` directory created
@@ -339,8 +539,27 @@ User: "Yes"
339
539
  Claude: "Generate CLAUDE.md with codebase analysis?"
340
540
  User: "Yes"
341
541
 
342
- Claude: "Proposed skills for Next.js: create-page, create-api-route, create-component. Confirm?"
343
- User: "Use these"
542
+ Claude: "I analyzed your codebase and found these patterns:
543
+ | Pattern | Files | Location | Example |
544
+ |---------|-------|----------|---------|
545
+ | Component | 25 files | src/components/ | Button.tsx |
546
+ | Hook | 8 files | src/hooks/ | useAuth.ts |
547
+ | API Route | 12 files | pages/api/ | users.ts |
548
+ | Page | 15 files | pages/ | index.tsx |
549
+
550
+ Which patterns would you like `create-*` skills generated for?"
551
+ User: [Selects Component, Hook, API Route]
552
+
553
+ Claude: "I also found these runnable commands:
554
+ | Command | Source | Full Command |
555
+ |---------|--------|--------------|
556
+ | build | package.json | npm run build |
557
+ | test | package.json | npm test |
558
+ | lint | package.json | npm run lint |
559
+ | typecheck | package.json | npm run typecheck |
560
+
561
+ Which commands would you like `run-*` skills generated for?"
562
+ User: [Selects test, lint]
344
563
 
345
564
  Claude: [Writes .5/CONFIGURE/feature.md]
346
565
  Claude: "Configuration feature planned at `.5/CONFIGURE/feature.md`"
@@ -101,9 +101,14 @@ Use Task tool with subagent_type=Explore for complex exploration.
101
101
 
102
102
  **Goal:** Understand what already exists so you can ask informed questions.
103
103
 
104
- ### Step 4: Intensive Collaboration (5-10 Questions)
104
+ ### Step 4: Intensive Collaboration (5-10 Questions, ONE AT A TIME)
105
105
 
106
- **CRITICAL:** After exploring the codebase, engage in intensive Q&A using the AskUserQuestion tool. Ask 5-10 clarifying questions based on your findings. This is NOT optional.
106
+ **CRITICAL:** After exploring the codebase, engage in intensive Q&A. This is NOT optional.
107
+
108
+ - Ask 5-10 clarifying questions using AskUserQuestion
109
+ - **ONE question at a time** - wait for answer before next question
110
+ - Do NOT list multiple questions in one message
111
+ - Do NOT skip to creating feature.md before asking at least 5 questions
107
112
 
108
113
  **Question categories to explore:**
109
114
 
@@ -154,7 +159,7 @@ Use Task tool with subagent_type=Explore for complex exploration.
154
159
  - "Could we use existing Z component instead?"
155
160
  - "Is a full factory needed or just simple creation?"
156
161
 
157
- Use AskUserQuestion to present options and trade-offs. Multiple questions can be asked in batches.
162
+ **Ask questions ONE AT A TIME.** Use AskUserQuestion for each question. For clarifying questions, provide 2-4 options where meaningful. Wait for the user's answer before asking the next question. Open questions (like feature description) can use free text.
158
163
 
159
164
  ### Step 5: Determine Feature Name
160
165
 
@@ -39,7 +39,9 @@ Understand the project structure:
39
39
 
40
40
  This is a quick scan, not deep analysis. The executor agent will do detailed pattern matching.
41
41
 
42
- ### Step 3: Ask 2-3 Technical Questions
42
+ ### Step 3: Ask 2-3 Technical Questions (ONE AT A TIME)
43
+
44
+ **CRITICAL:** Ask questions ONE AT A TIME. Wait for the user's answer before asking the next question.
43
45
 
44
46
  Use AskUserQuestion to clarify:
45
47
  - Data layer decisions (if applicable)
@@ -48,7 +50,11 @@ Use AskUserQuestion to clarify:
48
50
  - Software Architecture
49
51
  - Testing behaviour
50
52
 
51
- Keep it brief. Don't over-question. Don't ask feature questions already answered in the plan-feature phase.
53
+ Keep it brief. Don't over-question. Don't ask feature questions already answered in the plan-feature phase.
54
+
55
+ - **ONE question at a time** - wait for answer before next question
56
+ - Do NOT list multiple questions in one message
57
+ - Do NOT skip to creating plan.md before asking your questions
52
58
 
53
59
  ### Step 4: Design Components
54
60
 
@@ -212,3 +218,5 @@ Components in the same step run in parallel. Structure your plan accordingly:
212
218
  - Don't over-analyze the codebase - the executor will do detailed pattern matching
213
219
  - Don't ask more than 3 questions
214
220
  - Don't create unnecessary sequential steps - group independent work together
221
+ - **Don't skip to implementation** - This command ONLY creates the plan
222
+ - **Don't batch questions** - Ask one question at a time
@@ -84,6 +84,8 @@ feature_name="${TICKET_ID}-${slug}"
84
84
  - Which existing patterns to follow?
85
85
  - Any edge cases to handle?
86
86
 
87
+ **Ask questions ONE AT A TIME.** Wait for the user's answer before asking the next question. Do NOT list multiple questions in one message.
88
+
87
89
  ### Step 5: Create Plan
88
90
 
89
91
  Write plan to `.5/${feature_name}/plan.md` using the template structure.
@@ -9,20 +9,20 @@ process.stdin.on('data', (chunk) => {
9
9
  inputData += chunk;
10
10
  });
11
11
 
12
- process.stdin.on('end', () => {
12
+ process.stdin.on('end', async () => {
13
13
  try {
14
14
  // Parse hook input (contains workspace info)
15
15
  const hookData = JSON.parse(inputData);
16
16
  const workspaceDir = hookData.workingDirectory || process.cwd();
17
17
 
18
- checkForUpdates(workspaceDir);
18
+ await checkForUpdates(workspaceDir);
19
19
  } catch (e) {
20
20
  // Silent failure - don't block on errors
21
21
  process.exit(0);
22
22
  }
23
23
  });
24
24
 
25
- function checkForUpdates(workspaceDir) {
25
+ async function checkForUpdates(workspaceDir) {
26
26
  const versionFile = path.join(workspaceDir, '.claude', '.5', 'version.json');
27
27
 
28
28
  // Check if version.json exists
@@ -57,38 +57,53 @@ function checkForUpdates(workspaceDir) {
57
57
 
58
58
  // Compare versions
59
59
  const installed = versionData.installedVersion;
60
- const packageVersion = getPackageVersion(workspaceDir);
60
+ const latestVersion = await getLatestVersion();
61
61
 
62
- if (!packageVersion || installed === packageVersion) {
62
+ if (!latestVersion || installed === latestVersion) {
63
63
  // No update available
64
64
  process.exit(0);
65
65
  }
66
66
 
67
- // Check if update is available (installed < package)
68
- if (compareVersions(installed, packageVersion) < 0) {
67
+ // Check if update is available (installed < latest)
68
+ if (compareVersions(installed, latestVersion) < 0) {
69
69
  // Show update notification
70
- console.log(`\n\x1b[34mℹ\x1b[0m Update available: ${installed} → ${packageVersion}`);
70
+ console.log(`\n\x1b[34mℹ\x1b[0m Update available: ${installed} → ${latestVersion}`);
71
71
  console.log(` Run: \x1b[1mnpx 5-phase-workflow --upgrade\x1b[0m\n`);
72
72
  }
73
73
 
74
74
  process.exit(0);
75
75
  }
76
76
 
77
- // Get package version from local package.json
78
- function getPackageVersion(workspaceDir) {
79
- // Try to find package.json in node_modules/5-phase-workflow
80
- const pkgPath = path.join(workspaceDir, 'node_modules', '5-phase-workflow', 'package.json');
81
-
82
- if (fs.existsSync(pkgPath)) {
83
- try {
84
- const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
85
- return pkg.version;
86
- } catch (e) {
87
- return null;
88
- }
89
- }
90
-
91
- return null;
77
+ // Get latest version from npm registry
78
+ async function getLatestVersion() {
79
+ return new Promise((resolve) => {
80
+ const https = require('https');
81
+ const req = https.get(
82
+ 'https://registry.npmjs.org/5-phase-workflow/latest',
83
+ { timeout: 3000 },
84
+ (res) => {
85
+ if (res.statusCode !== 200) {
86
+ resolve(null);
87
+ return;
88
+ }
89
+ let data = '';
90
+ res.on('data', (chunk) => (data += chunk));
91
+ res.on('end', () => {
92
+ try {
93
+ const pkg = JSON.parse(data);
94
+ resolve(pkg.version);
95
+ } catch (e) {
96
+ resolve(null);
97
+ }
98
+ });
99
+ }
100
+ );
101
+ req.on('error', () => resolve(null));
102
+ req.on('timeout', () => {
103
+ req.destroy();
104
+ resolve(null);
105
+ });
106
+ });
92
107
  }
93
108
 
94
109
  // Compare semver versions
@@ -250,75 +250,231 @@ If CLAUDE.md already exists:
250
250
 
251
251
  ## C. Generate Project-Specific Skills
252
252
 
253
+ **Reads:** Pattern selections from feature spec (`.5/CONFIGURE/feature.md`)
254
+
253
255
  **Creates:** SKILL.md files in `.claude/skills/{name}/SKILL.md`
254
256
 
255
- Each skill follows the standard frontmatter pattern and contains instructions derived from analyzing the actual project structure (reads existing files to derive patterns/templates).
256
-
257
- ### Skill Detection by Project Type
258
-
259
- | Project Type | Skills |
260
- |---|---|
261
- | Next.js | create-page, create-api-route, create-component |
262
- | NestJS | create-module, create-service, create-controller |
263
- | Express | create-route, create-middleware, create-service |
264
- | React | create-component, create-hook, create-context |
265
- | Django | create-model, create-view, create-serializer |
266
- | Flask | create-blueprint, create-model |
267
- | Java (Gradle/Maven) | create-entity, create-service, create-controller, create-repository |
268
- | Rust | create-module |
269
- | Go | create-handler, create-service |
270
- | Rails | create-model, create-controller |
271
- | Generic | create-module |
272
-
273
- ### Skill Generation Process
274
-
275
- For each skill to generate:
276
- 1. Identify existing examples of that pattern in the codebase (e.g., find existing components for `create-component`)
277
- 2. Read 1-2 examples to extract the project's conventions and structure
278
- 3. Create a SKILL.md that instructs the agent to follow those conventions
279
- 4. Each generated SKILL.md should include:
280
- - Standard frontmatter (name, description, allowed-tools, model: sonnet, context: fork, user-invocable: false)
281
- - What the skill creates
282
- - File naming and location conventions (derived from existing code)
283
- - Template/pattern to follow (derived from existing code)
284
- - Checklist of what to include
285
-
286
- ### Example Generated Skill
257
+ ### Pattern-Based Skill Generation
258
+
259
+ Skills are determined by what patterns exist in the codebase (detected during `/5:configure`) and what the user selected—NOT by project type.
260
+
261
+ For EACH pattern selected by the user in the feature spec:
262
+
263
+ 1. **Find examples** - Read 2-3 files from the pattern's location
264
+ 2. **Extract conventions:**
265
+ - File naming (PascalCase, kebab-case, suffix patterns)
266
+ - Directory structure (flat, nested, co-located tests)
267
+ - Import patterns (absolute, relative, aliases)
268
+ - Export patterns (default, named, barrel files)
269
+ - Common boilerplate (decorators, annotations, base classes)
270
+ 3. **Generate SKILL.md** with:
271
+ - Detected conventions as instructions
272
+ - Template derived from actual code
273
+ - Checklist based on common elements found
274
+
275
+ ### Skill Template Structure
276
+
277
+ For each skill, create `.claude/skills/create-{pattern}/SKILL.md`:
287
278
 
288
279
  ```yaml
289
280
  ---
290
- name: create-component
291
- description: Creates a React component following project conventions.
281
+ name: create-{pattern}
282
+ description: Creates a {Pattern} following project conventions at {location}.
292
283
  allowed-tools: Read, Write, Glob, Grep
293
- model: sonnet
284
+ model: haiku
294
285
  context: fork
295
- user-invocable: false
286
+ user-invocable: true
296
287
  ---
297
288
  ```
298
289
 
299
290
  ```markdown
300
- # Create Component
291
+ # Create {Pattern}
301
292
 
302
293
  ## What This Skill Creates
303
- A React component following this project's conventions.
294
+ A {pattern} following this project's conventions.
304
295
 
305
- ## Conventions (from project analysis)
306
- - Location: `src/components/{ComponentName}/`
307
- - Files: `index.tsx`, `{ComponentName}.tsx`, `{ComponentName}.test.tsx`
308
- - Style: CSS Modules at `{ComponentName}.module.css`
309
- - Exports: Named export from component file, re-exported from index
296
+ ## Detected Conventions
297
+ - **Location:** {detected-location}
298
+ - **Naming:** {detected-naming-pattern}
299
+ - **Structure:** {detected-structure}
300
+ - **Imports:** {detected-import-pattern}
310
301
 
311
302
  ## Template
312
- {Derived from existing components in the project}
303
+ Based on {example-file}, new {patterns} should follow:
304
+
305
+ \`\`\`{language}
306
+ {template-derived-from-analysis}
307
+ \`\`\`
313
308
 
314
309
  ## Checklist
315
- - [ ] Component file created
316
- - [ ] Props interface defined
317
- - [ ] Test file created
318
- - [ ] Index file with re-export
319
- - [ ] Follows naming conventions
310
+ - [ ] File created at correct location
311
+ - [ ] Naming convention followed
312
+ - [ ] Required imports added
313
+ - [ ] {pattern-specific-items}
314
+ ```
315
+
316
+ ### Pattern to Skill Name Mapping
317
+
318
+ | Detected Pattern | Skill Name |
319
+ |------------------|------------|
320
+ | **Core Architecture** | |
321
+ | controller | create-controller |
322
+ | service | create-service |
323
+ | repository | create-repository |
324
+ | model/entity | create-model |
325
+ | handler | create-handler |
326
+ | **Data Transfer** | |
327
+ | dto | create-dto |
328
+ | request | create-request |
329
+ | response | create-response |
330
+ | mapper | create-mapper |
331
+ | validator | create-validator |
332
+ | schema | create-schema |
333
+ | **Frontend** | |
334
+ | component | create-component |
335
+ | hook | create-hook |
336
+ | context | create-context |
337
+ | store | create-store |
338
+ | page | create-page |
339
+ | layout | create-layout |
340
+ | **API/Routes** | |
341
+ | api-route | create-api-route |
342
+ | middleware | create-middleware |
343
+ | guard | create-guard |
344
+ | interceptor | create-interceptor |
345
+ | filter | create-filter |
346
+ | **Testing** | |
347
+ | test | create-test |
348
+ | spec | create-spec |
349
+ | fixture | create-fixture |
350
+ | factory | create-factory |
351
+ | mock | create-mock |
352
+ | **Utilities** | |
353
+ | util | create-util |
354
+ | helper | create-helper |
355
+ | constant | create-constant |
356
+ | type | create-type |
357
+ | config | create-config |
358
+ | **Framework-Specific** | |
359
+ | module | create-module |
360
+ | pipe | create-pipe |
361
+ | decorator | create-decorator |
362
+ | blueprint | create-blueprint |
363
+ | view | create-view |
364
+ | serializer | create-serializer |
365
+ | **Background/Async** | |
366
+ | job | create-job |
367
+ | worker | create-worker |
368
+ | event | create-event |
369
+ | listener | create-listener |
370
+ | command | create-command |
371
+ | **Database** | |
372
+ | migration | create-migration |
373
+ | seed | create-seed |
374
+ | **Error Handling** | |
375
+ | exception | create-exception |
376
+ | error | create-error |
377
+
378
+ ### Why `user-invocable: true`
379
+
380
+ Generated skills are user-invocable so users can invoke them directly:
381
+ - `/create-controller UserController`
382
+ - `/create-component Button`
383
+ - `/create-service AuthService`
384
+
385
+ This is more useful than internal-only skills.
386
+
387
+ ### Why `model: haiku`
388
+
389
+ Pattern-following is simple once conventions are documented:
390
+ - Faster and cheaper than sonnet
391
+ - Deep analysis already happened during generation
392
+ - The skill just needs to follow the documented template
393
+
394
+ ---
395
+
396
+ ## C2. Generate Command Skills (run-*)
397
+
398
+ **Reads:** Command selections from feature spec (`.5/CONFIGURE/feature.md`)
399
+
400
+ **Creates:** SKILL.md files in `.claude/skills/run-{command}/SKILL.md`
401
+
402
+ ### Command-Based Skill Generation
403
+
404
+ For EACH command selected by the user in the feature spec:
405
+
406
+ 1. **Read the source** - Check package.json scripts, Makefile, etc.
407
+ 2. **Document the command:**
408
+ - Exact command syntax
409
+ - Available variants (e.g., test:unit, test:e2e)
410
+ - Common flags and options
411
+ - Expected output format
412
+ 3. **Generate SKILL.md** with:
413
+ - Command execution instructions
414
+ - Output parsing guidance
415
+ - Error handling patterns
416
+
417
+ ### Command Skill Template Structure
418
+
419
+ For each skill, create `.claude/skills/run-{command}/SKILL.md`:
420
+
421
+ ```yaml
422
+ ---
423
+ name: run-{command}
424
+ description: Runs {command} for this project using {source}.
425
+ allowed-tools: Bash
426
+ model: haiku
427
+ context: fork
428
+ user-invocable: true
429
+ ---
430
+ ```
431
+
432
+ ```markdown
433
+ # Run {Command}
434
+
435
+ ## What This Skill Does
436
+ Executes the project's {command} command.
437
+
438
+ ## Command
439
+ \`\`\`bash
440
+ {exact-command}
441
+ \`\`\`
442
+
443
+ ## Variants
444
+ {if variants exist}
445
+ - `{variant1}` - {description}
446
+ - `{variant2}` - {description}
447
+
448
+ ## Common Options
449
+ - `--watch` - Run in watch mode (if available)
450
+ - `--coverage` - Generate coverage report (for tests)
451
+ - `--fix` - Auto-fix issues (for lint/format)
452
+
453
+ ## Expected Output
454
+ {describe what success/failure looks like}
455
+
456
+ ## Error Handling
457
+ - If command fails, report the error output
458
+ - Common issues: {list common problems and solutions}
320
459
  ```
321
460
 
461
+ ### Command to Skill Name Mapping
462
+
463
+ | Detected Command | Skill Name |
464
+ |------------------|------------|
465
+ | build | run-build |
466
+ | test, spec | run-tests |
467
+ | lint, eslint | run-lint |
468
+ | format, prettier | run-format |
469
+ | typecheck, tsc | run-typecheck |
470
+ | dev, start | run-dev |
471
+ | db:migrate, migrate | run-migrate |
472
+ | db:seed, seed | run-seed |
473
+ | docker:build | run-docker-build |
474
+ | docker:up, compose up | run-docker-up |
475
+ | clean | run-clean |
476
+ | generate, codegen | run-generate |
477
+
322
478
  ---
323
479
 
324
480
  ## Output Contract
@@ -336,7 +492,8 @@ Component B (Documentation): SUCCESS - Created 7 documentation files + index
336
492
  - .5/INTEGRATIONS.md (PostgreSQL, 2 APIs, GitHub Actions)
337
493
  - .5/CONCERNS.md (3 TODO items, 1 deprecated dependency)
338
494
  - CLAUDE.md (index with references)
339
- Component C (Skills): SUCCESS - Generated 3 skills (create-component, create-hook, create-context)
495
+ Component C (Pattern Skills): SUCCESS - Generated 3 create-* skills (create-component, create-hook, create-context)
496
+ Component D (Command Skills): SUCCESS - Generated 2 run-* skills (run-tests, run-lint)
340
497
  ```
341
498
 
342
499
  Or on failure:
@@ -350,6 +507,8 @@ Component B (Documentation): FAILED - Unable to read template files
350
507
 
351
508
  - DO NOT overwrite existing user-written CLAUDE.md sections
352
509
  - DO NOT generate skills for patterns that don't exist in the project
510
+ - DO NOT generate command skills for commands that don't exist in the project
353
511
  - DO NOT include `steps` in config.json
354
512
  - DO NOT hardcode conventions - always derive from actual project analysis
355
513
  - DO NOT generate empty or placeholder skill files
514
+ - DO NOT assume command syntax - always read from actual config files (package.json, Makefile, etc.)