5-phase-workflow 1.8.4 → 1.8.5

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.8.4",
3
+ "version": "1.8.5",
4
4
  "description": "A 5-phase feature development workflow for Claude Code",
5
5
  "bin": {
6
6
  "5-phase-workflow": "bin/install.js"
@@ -211,6 +211,11 @@ The skill-creator plugin from the official Claude store helps generate higher-qu
211
211
  - "Generate/update CLAUDE.md? This will analyze your codebase to document structure and conventions."
212
212
  - Options: "Yes (recommended)", "Skip"
213
213
 
214
+ **2k2. Confirm rules generation:**
215
+ - "Generate `.claude/rules/` files? These are scoped instruction files that automatically load when Claude works with matching file types (e.g., testing rules load only when editing test files, code-style rules load only for source files)."
216
+ - Options: "Yes (recommended)", "Skip"
217
+ - Note: Rules complement CLAUDE.md — they provide focused, file-type-scoped directives derived from your project's actual conventions.
218
+
214
219
  **2l. Review detected patterns for skill generation:**
215
220
 
216
221
  Present ONLY patterns that were actually detected in steps 1g and 1h.
@@ -270,7 +275,7 @@ Using the values gathered from Steps 1 and 2, write `.5/config.json` directly.
270
275
  mkdir -p .5
271
276
  ```
272
277
 
273
- **Schema:** Read `.claude/references/configure-tables.md` section "Config Schema" for the full JSON structure. Fill all values from user responses. Write with pretty-printed JSON. Read back to verify correctness.
278
+ **Schema:** Read `.claude/references/configure-tables.md` section "Config Schema" for the full JSON structure. Fill all values from user responses (including `rules.generate` from step 2k2). Write with pretty-printed JSON. Read back to verify correctness.
274
279
 
275
280
  **Update `.5/version.json` with configure timestamp:**
276
281
 
@@ -347,6 +352,15 @@ Analyze the codebase and generate modular documentation:
347
352
 
348
353
  Include only patterns/commands where user selected "Generate".
349
354
 
355
+ ### Requirement 3: Generate Scoped Rules (if selected)
356
+ Generate `.claude/rules/` files with project-specific conventions scoped to relevant file types.
357
+ Rules are concise directives (15-40 lines, NOT documentation) derived from codebase analysis.
358
+ Only generate rules for patterns that were actually detected:
359
+ - `code-style.md` — naming, formatting, import conventions (scoped to source files)
360
+ - `testing.md` — test patterns, mocking, fixtures (scoped to test files)
361
+ - `api-patterns.md` — API conventions, error handling (scoped to API/route/controller files)
362
+ - `dependencies.md` — dependency usage patterns, env var conventions (unconditional)
363
+
350
364
  ## Acceptance Criteria
351
365
  - [ ] `.5/` directory created
352
366
  - [ ] All 7 documentation files exist and are populated:
@@ -363,6 +377,10 @@ Include only patterns/commands where user selected "Generate".
363
377
  - [ ] All specified project-specific skills are generated in `.claude/skills/`
364
378
  - [ ] Generated skills reference actual project conventions
365
379
  - [ ] If CLAUDE.md existed before, user-written sections are preserved
380
+ - [ ] `.claude/rules/` directory exists with scoped rule files (if rules generation selected)
381
+ - [ ] Generated rules use `paths:` frontmatter for scoping where applicable
382
+ - [ ] Rules contain concise directives, not documentation
383
+ - [ ] No rules generated for undetected patterns
366
384
  ```
367
385
 
368
386
  **Important:** Use `mkdir -p .5/features/CONFIGURE` before writing the feature spec.
@@ -90,6 +90,11 @@ Perform the same detection as configure Steps 1b-1h:
90
90
  - Read each skill's SKILL.md frontmatter
91
91
  - Categorize as workflow-generated (create-*, run-*) or user-created
92
92
 
93
+ **2f. Scan existing rules** — list ALL rule files in `.claude/rules/`:
94
+ - Read each `.md` file
95
+ - Note which are workflow-generated (code-style, testing, api-patterns, dependencies) vs user-created
96
+ - User-created rules are never modified or removed
97
+
93
98
  ### Step 3: Compare and Prepare Summary
94
99
 
95
100
  Use the existing skills in `.claude/skills/` (from Step 2e) as the source of truth — not config.json. Compare what's installed with what's detected in the codebase:
@@ -102,14 +107,22 @@ Use the existing skills in `.claude/skills/` (from Step 2e) as the source of tru
102
107
  - **Stale commands**: a `run-*` skill exists but the command is no longer detected → offer to remove or keep
103
108
  - **User-created skills** (not matching `create-*` or `run-*` naming) → always refresh with current conventions, never remove
104
109
 
110
+ **Rules comparison** (if `rules.generate` is `true` in config.json):
111
+ - **Existing workflow rules** (from Step 2f) — code-style, testing, api-patterns, dependencies
112
+ - **Stale rules**: a workflow rule exists but its prerequisite patterns are no longer detected → offer to remove
113
+ - **New rules**: patterns detected that could benefit from a rule but none exists yet → offer to create
114
+ - **User-created rules** → never modify or remove
115
+
105
116
  ### Step 4: Confirm with User
106
117
 
107
118
  Use `AskUserQuestion` to show a summary and get confirmation. Present:
108
119
 
109
120
  1. **Documentation files that will be rewritten** — list all 7 `.5/*.md` files + CLAUDE.md
110
121
  2. **Skills that will be refreshed** — list ALL skills found in `.claude/skills/` (both workflow-generated and user-created)
111
- 3. **New patterns detected** (if any) — "These patterns were found in your codebase but don't have skills yet: [list]. Create skills for them?"
112
- 4. **Stale patterns** (if any) — "These patterns are in your config but weren't found in the codebase: [list]. Remove them?"
122
+ 3. **Rules that will be refreshed** (if rules enabled) — list workflow-generated rule files in `.claude/rules/`
123
+ 4. **New patterns detected** (if any) — "These patterns were found in your codebase but don't have skills yet: [list]. Create skills for them?"
124
+ 5. **Stale patterns** (if any) — "These patterns are in your config but weren't found in the codebase: [list]. Remove them?"
125
+ 6. **Stale rules** (if any) — "These rule files no longer have matching patterns in the codebase: [list]. Remove them?"
113
126
 
114
127
  Options:
115
128
  - "Proceed with refresh" — regenerate everything as shown
@@ -133,12 +146,20 @@ Refresh ALL existing skills in .claude/skills/:
133
146
  - New skills to create: [list from user confirmation, if any]
134
147
  - Skills to remove: [list from user confirmation, if any]
135
148
 
149
+ Refresh rules in .claude/rules/ (if rules.generate is true):
150
+ - Existing workflow rules: [list from Step 2f]
151
+ - Rules to remove: [list from user confirmation, if any]
152
+ - New rules to create: [if applicable]
153
+
136
154
  Re-analyze the entire codebase (A1 analysis) and:
137
155
  1. Rewrite all 7 .5/*.md documentation files
138
156
  2. Update CLAUDE.md (preserve user-written sections)
139
157
  3. Refresh ALL skills in .claude/skills/ — read current conventions from codebase and update each skill
140
158
  4. Create new skills for newly-added patterns
141
- 5. Remove skills the user chose to drop"
159
+ 5. Remove skills the user chose to drop
160
+ 6. Refresh all workflow-generated rule files in .claude/rules/ with updated conventions
161
+ 7. Create new rule files for newly-detected patterns
162
+ 8. Remove rule files the user chose to drop"
142
163
  ```
143
164
 
144
165
  Use `subagent_type: "general-purpose"` for the Task.
@@ -166,6 +187,9 @@ Show the user a summary:
166
187
  - List of skills refreshed
167
188
  - List of new skills created (if any)
168
189
  - List of skills removed (if any)
190
+ - List of rules refreshed (if any)
191
+ - List of new rules created (if any)
192
+ - List of rules removed (if any)
169
193
  - Timestamp of reconfiguration
170
194
  - Suggest running `/clear` to reset context
171
195
 
@@ -109,6 +109,9 @@ For each command found: record exact syntax, note variants (e.g., `test:unit`, `
109
109
  },
110
110
  "dotFiveFolder": {
111
111
  "gitignore": true
112
+ },
113
+ "rules": {
114
+ "generate": true
112
115
  }
113
116
  }
114
117
  ```
@@ -327,6 +327,97 @@ Executes the project's {command} command.
327
327
 
328
328
  ---
329
329
 
330
+ ## C. Generate Scoped Rules
331
+
332
+ If `rules.generate` is `true` in `.5/config.json`, generate `.claude/rules/` files with project-specific conventions scoped to relevant file types.
333
+
334
+ Rules are **concise directives** (15-40 lines each), NOT documentation. Documentation lives in `.5/*.md` files. Rules tell Claude what to do when working with specific file types.
335
+
336
+ ### C1. Determine Which Rules to Generate
337
+
338
+ Based on the A1 analysis results, determine which rules apply:
339
+
340
+ | Rule File | Generate When | Source Analysis |
341
+ |-----------|---------------|-----------------|
342
+ | `code-style.md` | Always (if source files exist) | Conventions Analysis |
343
+ | `testing.md` | Test files detected | Testing Analysis |
344
+ | `api-patterns.md` | Controller/route/handler patterns detected | Architecture Analysis |
345
+ | `dependencies.md` | External integrations detected | Integration Analysis |
346
+
347
+ **Skip** any rule whose prerequisite patterns were not detected. Do NOT generate empty or placeholder rule files.
348
+
349
+ ### C2. Extract Directives and Write Rules
350
+
351
+ For each applicable rule:
352
+
353
+ 1. **Derive `paths:` globs** from detected file locations (e.g., if tests are at `src/**/*.test.ts` and `tests/**/*.spec.ts`, use those patterns)
354
+ 2. **Convert analysis observations into imperative directives** — "Use X", "Always Y", "Never Z"
355
+ 3. **Keep each file 15-40 lines** — be concise and actionable
356
+ 4. **Do NOT repeat** the 6 mandatory coding guidelines from CLAUDE.md
357
+
358
+ Write files to `.claude/rules/`:
359
+
360
+ ```bash
361
+ mkdir -p .claude/rules
362
+ ```
363
+
364
+ ### C3. Rule File Format
365
+
366
+ Each rule file uses YAML frontmatter with `paths:` for scoping. Rules without `paths:` load unconditionally.
367
+
368
+ **Example — `testing.md`:**
369
+
370
+ ```markdown
371
+ ---
372
+ paths:
373
+ - "**/*.test.ts"
374
+ - "**/*.spec.ts"
375
+ ---
376
+
377
+ # Testing Conventions
378
+
379
+ - Use `describe`/`it` blocks with descriptive names
380
+ - Mock external dependencies with jest.mock, never mock internal modules
381
+ - Use factory functions from `tests/factories/` for test data
382
+ - Each test file mirrors its source file path: `src/foo/Bar.ts` → `src/foo/__tests__/Bar.test.ts`
383
+ - Assert one behavior per test
384
+ ```
385
+
386
+ **Example — `code-style.md`:**
387
+
388
+ ```markdown
389
+ ---
390
+ paths:
391
+ - "src/**/*.{ts,tsx}"
392
+ ---
393
+
394
+ # Code Style
395
+
396
+ - Use PascalCase for classes and types, camelCase for functions and variables
397
+ - Import order: external packages → internal modules → relative imports
398
+ - Use absolute imports with `@/` alias
399
+ - Prefer named exports over default exports
400
+ ```
401
+
402
+ **Example — `dependencies.md` (unconditional):**
403
+
404
+ ```markdown
405
+ # Dependency Conventions
406
+
407
+ - Database access through Prisma client only, never raw SQL
408
+ - HTTP requests use axios instance from `src/lib/http.ts`
409
+ - Environment variables accessed via `src/config/env.ts`, never `process.env` directly
410
+ ```
411
+
412
+ ### Refresh Mode Behavior for Rules
413
+
414
+ When running in REFRESH MODE:
415
+ - Re-analyze codebase and overwrite all existing rule files with updated directives
416
+ - Remove rule files for patterns no longer detected in the codebase
417
+ - Create new rule files if new patterns are detected that weren't present before
418
+
419
+ ---
420
+
330
421
  ## Output Contract
331
422
 
332
423
  Returns structured results for each component:
@@ -343,6 +434,7 @@ Component A (Documentation): SUCCESS - Created 7 documentation files + index
343
434
  - CLAUDE.md (index with references)
344
435
  Component B (Pattern Skills): SUCCESS - Generated 3 create-* skills (create-component, create-hook, create-context)
345
436
  Component C (Command Skills): SUCCESS - Generated 2 run-* skills (run-tests, run-lint)
437
+ Component D (Rules): SUCCESS - Generated 3 rule files (code-style, testing, dependencies)
346
438
  ```
347
439
 
348
440
  Or on failure:
@@ -350,6 +442,7 @@ Or on failure:
350
442
  ```
351
443
  Component A (Documentation): FAILED - Unable to read template files
352
444
  Component B (Pattern Skills): FAILED - No patterns found in codebase
445
+ Component D (Rules): SKIPPED - rules.generate is false in config
353
446
  ```
354
447
 
355
448
  ## DO NOT
@@ -357,7 +450,9 @@ Component B (Pattern Skills): FAILED - No patterns found in codebase
357
450
  - DO NOT overwrite existing user-written CLAUDE.md sections
358
451
  - DO NOT generate skills for patterns that don't exist in the project
359
452
  - DO NOT generate command skills for commands that don't exist in the project
453
+ - DO NOT generate rules for patterns not detected in the codebase
360
454
  - DO NOT include `steps` in config.json
361
455
  - DO NOT hardcode conventions - always derive from actual project analysis
362
- - DO NOT generate empty or placeholder skill files
456
+ - DO NOT generate empty or placeholder skill or rule files
363
457
  - DO NOT assume command syntax - always read from actual config files (package.json, Makefile, etc.)
458
+ - DO NOT repeat the 6 mandatory coding guidelines from CLAUDE.md in rule files