claude-prism 0.8.1 → 1.0.1

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/README.md CHANGED
@@ -9,6 +9,7 @@
9
9
  [![npm version](https://img.shields.io/npm/v/claude-prism)](https://www.npmjs.com/package/claude-prism)
10
10
  [![license](https://img.shields.io/npm/l/claude-prism)](https://github.com/lazysaturday91/claude-prism/blob/main/LICENSE)
11
11
  [![node](https://img.shields.io/node/v/claude-prism)](https://nodejs.org)
12
+ [![CI](https://github.com/lazysaturday91/claude-prism/actions/workflows/ci.yml/badge.svg)](https://github.com/lazysaturday91/claude-prism/actions/workflows/ci.yml)
12
13
 
13
14
  > `ai-coding` · `methodology` · `udec` · `claude-code`
14
15
 
@@ -26,9 +27,9 @@ AI coding agents fail in predictable ways:
26
27
  |---|---|---|
27
28
  | Skip understanding | Builds the wrong thing for 30 minutes | UNDERSTAND phase |
28
29
  | No decomposition | One massive change that's hard to review | DECOMPOSE into verifiable batches |
29
- | No verification | "should work" without evidence | Risk-based verification strategy |
30
- | Scope creep | "While I'm here..." changes nobody asked for | Scope Guard in methodology |
31
- | Context loss | New session = start from scratch | HANDOFF protocol |
30
+ | No verification | "should work" without evidence | Risk-based verification + Fallback Ladder |
31
+ | Scope creep | "While I'm here..." changes nobody asked for | Scope Guard + Thrashing Detector |
32
+ | Context loss | New session = start from scratch | HANDOFF + Project Memory |
32
33
 
33
34
  **The biggest failure mode of AI coding isn't bad code — it's building the wrong thing.**
34
35
 
@@ -38,7 +39,7 @@ AI coding agents fail in predictable ways:
38
39
 
39
40
  ## What Prism Provides
40
41
 
41
- ### 1. UDEC v2 Methodology (the core product)
42
+ ### 1. UDEC v3 Methodology (the core product)
42
43
 
43
44
  Injected into `CLAUDE.md`, UDEC is a behavioral framework that corrects how AI agents approach tasks:
44
45
 
@@ -48,26 +49,30 @@ Injected into `CLAUDE.md`, UDEC is a behavioral framework that corrects how AI a
48
49
 
49
50
  ┌─────────────────── UDEC Core Cycle ───────────────────┐
50
51
  │ UNDERSTAND ── Sufficiency assessment → ask → align │
51
- │ │
52
- │ DECOMPOSE ── Batches → plan file for 6+ files [S][M][L]
53
- │ │
52
+ │ │ Environment validation
53
+ │ DECOMPOSE ── Batches → plan file → quality gate
54
+ │ │ Codebase audit → cross-plan check
54
55
  │ EXECUTE ── Adaptive batches → risk-based verification │
55
- │ │
56
- │ CHECKPOINT ── Report with evidence → get approval ─────┤
56
+ │ │ Goal recitation → thrashing detection
57
+ │ CHECKPOINT ── Report with evidence → plan-reality sync
57
58
  │ (loops back for next batch) │
58
59
  └────────────────────────────────────────────────────────┘
59
60
 
60
61
 
61
- HANDOFF ── Session transition doc next steps
62
+ HANDOFF ── Session transition doc + Project Memory
62
63
  (exit protocol)
63
64
  ```
64
65
 
65
66
  **Task-type aware**: Each task type (bugfix, feature, migration, refactor, investigation) follows a different optimal path. Migrations skip per-file decomposition. Bugfixes skip straight to locate-fix-verify. Investigations skip decomposition entirely.
66
67
 
67
- **Risk-based verification**: Verification matches the risk of the change, not the file path:
68
- - **High risk** (business logic, auth, state machines): TDD required
68
+ **Risk-based verification** with Fallback Ladder:
69
+ - **High risk** (business logic, auth, state machines): TDD required + negative tests
69
70
  - **Medium risk** (new components, API integration): Build + runtime check
70
71
  - **Low risk** (imports, types, renaming): Build/lint passes
72
+ - **No test infra** (legacy PHP, WordPress): Grep-based static check + syntax validation
73
+ - Fallback: Automated Tests → Approval Testing → Build → Lint → Smoke Check → Manual Diff
74
+
75
+ **Quality gates** between phases prevent executing on broken baselines.
71
76
 
72
77
  ### 2. Three Focused Hooks
73
78
 
@@ -86,13 +91,23 @@ Hooks enforce the methodology at critical points. All three are deterministic (n
86
91
  | Command | Purpose |
87
92
  |---------|---------|
88
93
  | `/claude-prism:prism` | Run full UDEC cycle |
89
- | `/claude-prism:checkpoint` | Check batch progress |
94
+ | `/claude-prism:checkpoint` | Check batch progress with plan-reality sync |
90
95
  | `/claude-prism:plan` | List/create/view plan files |
96
+ | `/claude-prism:analytics` | Show usage analytics (blocks, warns, tests) |
91
97
  | `/claude-prism:doctor` | Diagnose installation health |
92
98
  | `/claude-prism:stats` | Version, hooks, plan count |
93
99
  | `/claude-prism:update` | Update to latest version |
94
100
  | `/claude-prism:help` | Command reference |
95
101
 
102
+ ### 4. Analytics
103
+
104
+ Hook events (blocks, warnings) are automatically logged to session files. View aggregated statistics:
105
+
106
+ ```bash
107
+ prism analytics # Summary across all sessions
108
+ prism analytics --detail # Include per-session breakdown
109
+ ```
110
+
96
111
  ## Installation
97
112
 
98
113
  ```bash
@@ -109,7 +124,7 @@ your-project/
109
124
  ├── CLAUDE.md # UDEC methodology injected
110
125
  ├── .claude-prism.json # Hook configuration
111
126
  ├── .claude/
112
- │ ├── commands/claude-prism/ # 7 slash commands
127
+ │ ├── commands/claude-prism/ # 8 slash commands
113
128
  │ ├── hooks/ # pre-tool.mjs, post-tool.mjs
114
129
  │ ├── rules/ # commit-guard, test-tracker, plan-enforcement
115
130
  │ ├── lib/ # Shared dependencies
@@ -123,6 +138,7 @@ Edit `.claude-prism.json`:
123
138
 
124
139
  ```json
125
140
  {
141
+ "version": 1,
126
142
  "hooks": {
127
143
  "commit-guard": { "enabled": true, "maxTestAge": 300 },
128
144
  "test-tracker": { "enabled": true },
@@ -133,6 +149,7 @@ Edit `.claude-prism.json`:
133
149
 
134
150
  | Setting | Default | Description |
135
151
  |---------|---------|-------------|
152
+ | `version` | 1 | Config schema version (for future migrations) |
136
153
  | `commit-guard.maxTestAge` | 300 | Seconds before test run is considered stale |
137
154
  | `plan-enforcement.warnAt` | 6 | Unique source file count that triggers plan warning |
138
155
 
@@ -143,6 +160,7 @@ prism init [--no-hooks] [--global] [--dry-run] # Install
143
160
  prism check [--ci] # Verify installation
144
161
  prism doctor # Diagnose issues
145
162
  prism stats # Installation summary
163
+ prism analytics [--detail] # Usage analytics
146
164
  prism reset # Clear hook state
147
165
  prism update [--global] # Update to latest
148
166
  prism uninstall [--global] # Remove
package/bin/cli.mjs CHANGED
@@ -175,6 +175,69 @@ switch (command) {
175
175
  break;
176
176
  }
177
177
 
178
+ case 'analytics': {
179
+ const { listSessions, getSessionSummary } = await import('../lib/session.mjs');
180
+ console.log('🌈 claude-prism analytics\n');
181
+
182
+ const sessions = listSessions();
183
+ if (sessions.length === 0) {
184
+ console.log(' No session data yet. Analytics will populate as hooks run.');
185
+ break;
186
+ }
187
+
188
+ let totalBlocks = 0;
189
+ let totalWarnings = 0;
190
+ let totalTestsRun = 0;
191
+ let totalTestsPassed = 0;
192
+ let totalTestsFailed = 0;
193
+ let totalFilesModified = 0;
194
+ let totalFilesCreated = 0;
195
+ let totalTurns = 0;
196
+ let sessionCount = 0;
197
+
198
+ for (const sid of sessions) {
199
+ const summary = getSessionSummary(sid);
200
+ if (!summary) continue;
201
+ sessionCount++;
202
+ totalBlocks += summary.blocks;
203
+ totalWarnings += summary.warnings;
204
+ totalTestsRun += summary.testsRun;
205
+ totalTestsPassed += summary.testsPassed;
206
+ totalTestsFailed += summary.testsFailed;
207
+ totalFilesModified += summary.filesModified;
208
+ totalFilesCreated += summary.filesCreated;
209
+ totalTurns += summary.turns;
210
+ }
211
+
212
+ console.log(` Sessions: ${sessionCount}`);
213
+ console.log(` Total events: ${totalTurns + totalBlocks + totalWarnings + totalTestsRun + totalFilesModified + totalFilesCreated}`);
214
+ console.log('');
215
+ console.log(' Hook Effectiveness:');
216
+ console.log(` Blocks: ${totalBlocks}`);
217
+ console.log(` Warnings: ${totalWarnings}`);
218
+ console.log('');
219
+ console.log(' Test Activity:');
220
+ console.log(` Runs: ${totalTestsRun}`);
221
+ console.log(` Passed: ${totalTestsPassed}`);
222
+ console.log(` Failed: ${totalTestsFailed}`);
223
+ console.log('');
224
+ console.log(' File Activity:');
225
+ console.log(` Modified: ${totalFilesModified}`);
226
+ console.log(` Created: ${totalFilesCreated}`);
227
+
228
+ if (hasFlag('detail')) {
229
+ console.log('\n Recent Sessions:\n');
230
+ const recent = sessions.slice(-5);
231
+ for (const sid of recent) {
232
+ const s = getSessionSummary(sid);
233
+ if (!s) continue;
234
+ const date = new Date(s.startedAt).toISOString().slice(0, 19).replace('T', ' ');
235
+ console.log(` ${date} | events: ${s.totalEvents} | blocks: ${s.blocks} | warns: ${s.warnings} | tests: ${s.testsRun}`);
236
+ }
237
+ }
238
+ break;
239
+ }
240
+
178
241
  default: {
179
242
  console.log(`🌈 claude-prism — UDEC methodology framework for AI coding agents
180
243
 
@@ -185,6 +248,7 @@ Usage:
185
248
  prism doctor Diagnose issues with fix suggestions
186
249
  prism stats Show installation summary
187
250
  prism reset Clear hook state
251
+ prism analytics [--detail] Show usage analytics
188
252
  prism update Re-install using current config
189
253
  prism update --global Update global commands + OMC skill
190
254
  prism uninstall Remove prism from current project
package/lib/installer.mjs CHANGED
@@ -28,7 +28,7 @@ export async function init(projectDir, options = {}) {
28
28
  const nsCommandsDir = join(claudeDir, 'commands', 'claude-prism');
29
29
  mkdirSync(nsCommandsDir, { recursive: true });
30
30
 
31
- const commandFiles = ['prism.md', 'checkpoint.md', 'plan.md', 'doctor.md', 'stats.md', 'help.md', 'update.md'];
31
+ const commandFiles = ['prism.md', 'checkpoint.md', 'plan.md', 'doctor.md', 'stats.md', 'help.md', 'update.md', 'analytics.md'];
32
32
  for (const cmd of commandFiles) {
33
33
  copyFileSync(
34
34
  join(TEMPLATES_DIR, 'commands', 'claude-prism', cmd),
@@ -58,7 +58,7 @@ export async function init(projectDir, options = {}) {
58
58
  const libDestDir = join(claudeDir, 'lib');
59
59
  mkdirSync(libDestDir, { recursive: true });
60
60
  const libSourceDir = join(__dirname);
61
- for (const file of ['state.mjs', 'config.mjs', 'utils.mjs', 'messages.mjs', 'pipeline.mjs']) {
61
+ for (const file of ['state.mjs', 'config.mjs', 'utils.mjs', 'messages.mjs', 'pipeline.mjs', 'session.mjs']) {
62
62
  copyFileSync(join(libSourceDir, file), join(libDestDir, file));
63
63
  }
64
64
 
@@ -73,6 +73,7 @@ export async function init(projectDir, options = {}) {
73
73
  const configPath = join(projectDir, '.claude-prism.json');
74
74
  if (!existsSync(configPath)) {
75
75
  writeFileSync(configPath, JSON.stringify({
76
+ version: 1,
76
77
  hooks: {
77
78
  'commit-guard': { enabled: true, maxTestAge: 300 },
78
79
  'test-tracker': { enabled: true },
@@ -272,8 +273,17 @@ export async function update(projectDir) {
272
273
  }
273
274
  }
274
275
 
275
- // Remove old config so init creates a fresh one
276
- if (existsSync(configPath)) rmSync(configPath);
276
+ // Migrate config: add version field if missing
277
+ if (existsSync(configPath)) {
278
+ try {
279
+ const existingConfig = JSON.parse(readFileSync(configPath, 'utf8'));
280
+ if (!existingConfig.version) {
281
+ existingConfig.version = 1;
282
+ writeFileSync(configPath, JSON.stringify(existingConfig, null, 2) + '\n');
283
+ }
284
+ } catch { /* proceed with fresh config */ }
285
+ rmSync(configPath);
286
+ }
277
287
 
278
288
  await init(projectDir, { hooks });
279
289
  }
@@ -292,7 +302,7 @@ export function doctor(projectDir, options = {}) {
292
302
 
293
303
  // Check namespaced commands
294
304
  const nsCommandsDir = join(claudeDir, 'commands', 'claude-prism');
295
- const expectedCommands = ['prism.md', 'checkpoint.md', 'plan.md', 'doctor.md', 'stats.md', 'help.md', 'update.md'];
305
+ const expectedCommands = ['prism.md', 'checkpoint.md', 'plan.md', 'doctor.md', 'stats.md', 'help.md', 'update.md', 'analytics.md'];
296
306
  for (const cmd of expectedCommands) {
297
307
  if (!existsSync(join(nsCommandsDir, cmd))) {
298
308
  issues.push(`Missing command: claude-prism/${cmd}`);
@@ -439,7 +449,7 @@ export function initGlobal(options = {}) {
439
449
  const commandsDir = join(claudeDir, 'commands', 'claude-prism');
440
450
  mkdirSync(commandsDir, { recursive: true });
441
451
 
442
- const commandFiles = ['prism.md', 'checkpoint.md', 'plan.md', 'doctor.md', 'stats.md', 'help.md', 'update.md'];
452
+ const commandFiles = ['prism.md', 'checkpoint.md', 'plan.md', 'doctor.md', 'stats.md', 'help.md', 'update.md', 'analytics.md'];
443
453
  for (const cmd of commandFiles) {
444
454
  copyFileSync(
445
455
  join(TEMPLATES_DIR, 'commands', 'claude-prism', cmd),
@@ -484,7 +494,7 @@ export function dryRun(projectDir, options = {}) {
484
494
 
485
495
  // Commands
486
496
  const nsCommandsDir = join(claudeDir, 'commands', 'claude-prism');
487
- const commandFiles = ['prism.md', 'checkpoint.md', 'plan.md', 'doctor.md', 'stats.md', 'help.md', 'update.md'];
497
+ const commandFiles = ['prism.md', 'checkpoint.md', 'plan.md', 'doctor.md', 'stats.md', 'help.md', 'update.md', 'analytics.md'];
488
498
  for (const cmd of commandFiles) {
489
499
  const target = join(nsCommandsDir, cmd);
490
500
  actions.push({
@@ -514,7 +524,7 @@ export function dryRun(projectDir, options = {}) {
514
524
  });
515
525
  }
516
526
 
517
- for (const lib of ['state.mjs', 'config.mjs', 'utils.mjs', 'messages.mjs', 'pipeline.mjs']) {
527
+ for (const lib of ['state.mjs', 'config.mjs', 'utils.mjs', 'messages.mjs', 'pipeline.mjs', 'session.mjs']) {
518
528
  const target = join(claudeDir, 'lib', lib);
519
529
  actions.push({
520
530
  type: 'lib',
package/lib/pipeline.mjs CHANGED
@@ -8,6 +8,7 @@ import { join } from 'path';
8
8
  import { sanitizeId } from './utils.mjs';
9
9
  import { loadConfig } from './config.mjs';
10
10
  import { getStateDir } from './state.mjs';
11
+ import { logEvent } from './session.mjs';
11
12
 
12
13
  const TOOL_ACTION_MAP = {
13
14
  'Edit': 'edit',
@@ -87,6 +88,18 @@ export function runPipeline(rules, hookEventName) {
87
88
 
88
89
  const result = rule.evaluate(ctx, hookConfig, stateDir);
89
90
 
91
+ // Log rule evaluation for analytics
92
+ if (ctx.sessionId && result.type !== 'pass') {
93
+ try {
94
+ logEvent(ctx.sessionId, {
95
+ type: result.type, // 'block', 'warn'
96
+ rule: name,
97
+ action: ctx.action,
98
+ file: ctx.filePath || undefined,
99
+ });
100
+ } catch { /* logging should never break the pipeline */ }
101
+ }
102
+
90
103
  if (result.type === 'block') {
91
104
  blocked = true;
92
105
  blockMessage = result.message || '🌈 Prism ✋ Action blocked.';
@@ -163,6 +176,18 @@ export async function runPipelineAsync(builtInRules, hookEventName) {
163
176
 
164
177
  const result = rule.evaluate(ctx, hookConfig, stateDir);
165
178
 
179
+ // Log rule evaluation for analytics
180
+ if (ctx.sessionId && result.type !== 'pass') {
181
+ try {
182
+ logEvent(ctx.sessionId, {
183
+ type: result.type, // 'block', 'warn'
184
+ rule: name,
185
+ action: ctx.action,
186
+ file: ctx.filePath || undefined,
187
+ });
188
+ } catch { /* logging should never break the pipeline */ }
189
+ }
190
+
166
191
  if (result.type === 'block') {
167
192
  blocked = true;
168
193
  blockMessage = result.message || '🌈 Prism ✋ Action blocked.';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-prism",
3
- "version": "0.8.1",
3
+ "version": "1.0.1",
4
4
  "description": "UDEC methodology framework for AI coding agents — Understand, Decompose, Execute, Checkpoint.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,35 @@
1
+ # /claude-prism:analytics — Usage Analytics
2
+
3
+ When this command is invoked, show aggregated statistics from session event logs:
4
+
5
+ ## Report
6
+
7
+ 1. **Read session data** using `listSessions()` and `getSessionSummary()` from session.mjs
8
+ 2. **Aggregate across all sessions**:
9
+ - Total sessions count
10
+ - Hook effectiveness: blocks and warnings by rule type
11
+ - Test activity: runs, passed, failed
12
+ - File activity: modified, created
13
+ 3. **Display using this format**:
14
+
15
+ ```
16
+ 🌈 claude-prism analytics
17
+
18
+ Sessions: N
19
+ Total events: N
20
+
21
+ Hook Effectiveness:
22
+ Blocks: N
23
+ Warnings: N
24
+
25
+ Test Activity:
26
+ Runs: N
27
+ Passed: N
28
+ Failed: N
29
+
30
+ File Activity:
31
+ Modified: N
32
+ Created: N
33
+ ```
34
+
35
+ 4. **With --detail flag**, also show last 5 sessions with timestamps and per-session counts
@@ -7,7 +7,11 @@ When this command is invoked:
7
7
  - `grep -c '\- \[x\]' <plan-file>` → completed count
8
8
  - `grep -c '\- \[ \]' <plan-file>` → remaining count
9
9
  - Calculate percentage: completed / (completed + remaining)
10
- 3. **Freshness check**: grep for plan's change targets to verify they still exist in codebase
10
+ 3. **Plan-Reality sync** (freshness check):
11
+ - Grep for plan's change targets (patterns, files, functions to modify) to verify they still exist in codebase
12
+ - If target no longer exists → mark task as "already completed (prior work)"
13
+ - If new targets discovered → add to plan's "Risks / Open Questions"
14
+ - Update plan file's `Codebase Audit` section with fresh counts if present
11
15
  4. **Report current status** using this standard format:
12
16
 
13
17
  ### Changes
@@ -20,7 +24,7 @@ When this command is invoked:
20
24
 
21
25
  | Check | Result |
22
26
  |-------|--------|
23
- | TypeScript | ✅/❌ [details] |
27
+ | Build | ✅/❌ [details] |
24
28
  | Tests | ✅/❌ [pass count] |
25
29
  | Lint | ✅/❌ or N/A |
26
30
 
@@ -29,6 +33,7 @@ When this command is invoked:
29
33
  ```
30
34
  Phase: [current phase] | Batch: [N/M] | Tasks: [done/total] ([%])
31
35
  [████████░░] 80% — Next: [next batch name]
36
+ Plan freshness: verified [date] | Remaining targets: [N] confirmed in code
32
37
  ```
33
38
 
34
39
  - Batches complete: N/M
@@ -44,11 +49,11 @@ When this command is invoked:
44
49
  | [M] Medium | N | N |
45
50
  | [L] Large | N | N |
46
51
 
47
- 4. **Show summary**:
52
+ 5. **Show summary**:
48
53
  - Files created/modified so far
49
54
  - Tests added and their status
50
55
  - Commits made
51
- 5. **Checkpoint policy check**:
56
+ 6. **Checkpoint policy check**:
52
57
  - If 3+ consecutive approvals → suggest expanding batch size to 5-8
53
58
  - If phase boundary → always stop
54
- 6. **Ask**: "Continue with the current plan, adjust, or stop?"
59
+ 7. **Ask**: "Continue with the current plan, adjust, or stop?"
@@ -7,15 +7,15 @@ When this command is invoked, check all components of the prism installation:
7
7
  1. **CLAUDE.md**: Does it contain `<!-- PRISM:START -->` marker?
8
8
  2. **Config**: Does `.claude-prism.json` exist? Is it valid JSON?
9
9
  3. **Commands**: Do these files exist in `.claude/commands/claude-prism/`?
10
- - prism.md, checkpoint.md, plan.md, doctor.md, stats.md, help.md
10
+ - prism.md, checkpoint.md, plan.md, doctor.md, stats.md, help.md, update.md
11
11
  4. **Hooks**: Do these files exist in `.claude/hooks/`?
12
- - commit-guard.mjs, debug-loop.mjs, test-tracker.mjs, scope-guard.mjs
12
+ - pre-tool.mjs, post-tool.mjs
13
13
  5. **Rules**: Do these files exist in `.claude/rules/`?
14
- - commit-guard.mjs, debug-loop.mjs, test-tracker.mjs, scope-guard.mjs
14
+ - commit-guard.mjs, test-tracker.mjs, plan-enforcement.mjs
15
15
  6. **Lib**: Do these files exist in `.claude/lib/`?
16
- - adapter.mjs, state.mjs, config.mjs, utils.mjs
16
+ - pipeline.mjs, state.mjs, config.mjs, utils.mjs, messages.mjs
17
17
  7. **Settings**: Does `.claude/settings.json` contain prism hook registrations?
18
- 8. **Legacy**: Are there old flat commands (`/prism`, `/checkpoint`) that need migration?
18
+ 8. **Legacy**: Are there old flat commands (`/prism`, `/checkpoint`) or deprecated files (`debug-loop.mjs`, `scope-guard.mjs`, `adapter.mjs`) that need cleanup?
19
19
 
20
20
  ## Report Format
21
21
 
@@ -25,11 +25,11 @@ When this command is invoked, check all components of the prism installation:
25
25
  CLAUDE.md: ✅ PRISM rules present
26
26
  Config: ✅ .claude-prism.json valid
27
27
  Commands: ✅ 7/7 installed
28
- Hooks: ✅ 4/4 installed
29
- Rules: ✅ 4/4 installed
30
- Lib: ✅ 4/4 installed
28
+ Hooks: ✅ 2/2 installed
29
+ Rules: ✅ 3/3 installed
30
+ Lib: ✅ 5/5 installed
31
31
  Settings: ✅ Hooks registered
32
- Legacy: ✅ No old commands found
32
+ Legacy: ✅ No old files found
33
33
 
34
34
  Status: ✅ Healthy
35
35
  ```
@@ -40,3 +40,4 @@ For each issue found, suggest the fix:
40
40
  - Missing files → "Run `prism update` to restore"
41
41
  - Legacy commands → "Run `prism update` to migrate to namespaced commands"
42
42
  - Missing PRISM block → "Run `prism update` to re-inject rules"
43
+ - Deprecated files → "Run `prism update` to clean up legacy files"
@@ -18,26 +18,37 @@ If user requests a new plan:
18
18
 
19
19
  1. **Determine topic** from user's description
20
20
  2. **Create file** at `docs/plans/YYYY-MM-DD-<topic>.md`
21
- 3. **Use UDEC template** (adapt language to project's `.claude-prism.json` language setting):
21
+ 3. **Use UDEC template**:
22
22
 
23
23
  ```
24
24
  ## Goal
25
- One sentence: what and why.
25
+ One sentence: what we're building and why.
26
26
 
27
27
  ## Architecture
28
- Tech stack, key decisions, 2-3 sentences.
28
+ Tech stack, key decisions, 2-3 sentences max.
29
29
 
30
- ## Batch 1: [Name]
31
- - [ ] Task 1.1: [Description] → `path/to/file`
32
- - Test: `path/to/test` [what to verify]
33
- - Pass criterion: [specific assertion]
34
- - [ ] Task 1.2: ...
30
+ ## Related Plans
31
+ - Depends on: `YYYY-MM-DD-<prior-plan>.md` (status: complete/in-progress)
32
+ - Shared files: list files that overlap with other active plans
33
+ - (Omit this section if no other plans exist)
34
+
35
+ ## Codebase Audit
36
+ - Audit date: YYYY-MM-DD
37
+ - Targets remaining: N files (verified by grep/search)
38
+ - Already completed: N items (by prior work or other branches)
39
+ - Evidence: `grep -r "pattern" --include="*.ext" | wc -l` → N
35
40
 
36
- ## Batch 2: [Name]
37
- - [ ] Task 2.1: ...
41
+ ## Files in Scope
42
+ - `path/to/file1.ts` — [what changes]
43
+ - `path/to/file2.ts` — [what changes]
44
+
45
+ ## Batch 1: [Name]
46
+ - [ ] Task 1.1: [S] [description] | Verify: [auto: build/test/lint]
47
+ - [ ] Task 1.2: [M] [description] | Verify: [auto: test] [manual: visual check]
48
+ - Prerequisite: Task 1.1
38
49
 
39
50
  ## Risks / Open Questions
40
- - [Known uncertainties or potential blockers]
51
+ - [Known unknowns or potential blockers]
41
52
  ```
42
53
 
43
54
  4. **Announce**: "Plan file created. Use /claude-prism:prism to start execution."
@@ -49,4 +60,4 @@ If user specifies a plan file:
49
60
  1. **Read** the specified plan file
50
61
  2. **Show progress** with completion percentage
51
62
  3. **Highlight** current batch (first batch with incomplete tasks)
52
- 4. **List blockers** from "리스크 / 미결 사항" section
63
+ 4. **List blockers** from "Risks / Open Questions" section
@@ -54,23 +54,23 @@ When this command is invoked, follow the UDEC framework strictly:
54
54
 
55
55
  ## E — EXECUTE
56
56
 
57
- 11. Execute in adaptive batches:
57
+ 14. Execute in adaptive batches:
58
58
  - Simple changes (imports, types, config): 5-8 per batch
59
59
  - Standard changes (feature add/modify): 3-4 per batch
60
60
  - Complex changes (new module, architecture): 1-2 per batch
61
- 12. Apply context-aware verification:
61
+ 15. Apply context-aware verification:
62
62
  - `lib/`, `utils/`, `store/`, `hooks/`, `services/` → TDD (failing test → implement → verify)
63
63
  - `components/`, `pages/`, `views/` → Build verification (escalate to TDD if complex logic)
64
64
  - `config/`, `styles/`, `types/` → Build/lint only
65
- 13. **Scope Guard**: Before each change, ask: "Was this requested?" If no → don't do it
66
- 14. **Self-correction triggers**:
65
+ 16. **Scope Guard**: Before each change, ask: "Was this requested?" If no → don't do it
66
+ 17. **Self-correction triggers**:
67
67
  - Same file edited 3+ times **on the same region/logic** → stop, investigate root cause (progressive edits across different regions — imports, logic, JSX — are normal)
68
68
  - File not in plan → pause, ask about scope change
69
69
  - 3 consecutive test failures → stop, reconsider approach
70
70
  - New package needed → ask user first
71
71
  - Adding workarounds on workarounds → design problem, step back
72
- 15. **Verification scoping**: When running build checks (tsc, lint, etc.), filter output to only changed files. Pre-existing errors in other files are not your concern. Example: `tsc --noEmit 2>&1 | grep -i "<changed-file>"`
73
- 16. **Agent failure recovery**: If a delegated agent partially fails or produces incomplete results:
72
+ 18. **Verification scoping**: When running build checks (tsc, lint, etc.), filter output to only changed files. Pre-existing errors in other files are not your concern. Example: `tsc --noEmit 2>&1 | grep -i "<changed-file>"`
73
+ 19. **Agent failure recovery**: If a delegated agent partially fails or produces incomplete results:
74
74
  1. Verify actual file state (read the file, not just the agent's report)
75
75
  2. If partially correct → complete the remaining work directly
76
76
  3. If fully wrong → retry with clearer instructions or execute directly
@@ -100,4 +100,4 @@ If oh-my-claudecode is detected in this environment:
100
100
  - Use `architect` agent for complex decomposition decisions
101
101
  - Use `executor` agents for parallel batch execution when tasks are independent
102
102
  - Use `verifier` agent for checkpoint verification
103
- - Scope Guard thresholds are automatically raised for sub-agents (8 warn / 12 block vs 4/7)
103
+ - Scope Guard thresholds are automatically raised for sub-agents (8 warn / 12 block vs default 4 warn / 7 block for standalone mode)
@@ -62,7 +62,7 @@ Before moving to DECOMPOSE:
62
62
  - MVP scope defined
63
63
  - User confirmed "proceed"
64
64
 
65
- ### 2-4. Assumption Detection (Red Flag Checklist)
65
+ ### 2-5. Assumption Detection (Red Flag Checklist)
66
66
 
67
67
  **If you think you understand fully on first read, you probably don't.**
68
68
 
@@ -109,7 +109,7 @@ Before moving to DECOMPOSE:
109
109
  **Batch composition**:
110
110
  - Mixed: S+S+M = 1 batch, L = 1 batch alone
111
111
  - **[S]-only: up to 8 per batch** (independent small changes can be batched aggressively)
112
- - Aligns with 4-1 adaptive batch size (simple/mechanical: 5-10 per batch)
112
+ - Aligns with 4-1 adaptive batch size (simple/mechanical: 5-8 per batch)
113
113
 
114
114
  ### 3-3. Plan File Persistence
115
115
 
@@ -175,7 +175,7 @@ If any gate fails → resolve before executing. Do not start implementation on a
175
175
  ### 4-1. Batch Execution
176
176
 
177
177
  1. **Adaptive batch size**:
178
- - Simple/mechanical changes (imports, types, config, migration): 5-10 per batch
178
+ - Simple/mechanical changes (imports, types, config, migration): 5-8 per batch
179
179
  - Standard changes (feature add/modify): 3-4 per batch
180
180
  - Complex changes (new module, architecture): 1-2 per batch
181
181
  2. **Git-as-Memory**: commit after each completed batch as a rollback point. Use `git diff` summaries to maintain context in long sessions.
@@ -38,7 +38,8 @@ AI agents optimize for speed, not correctness. Without structure, they skip unde
38
38
  - [Sufficient] Specific file, function, symptom mentioned → skip to DECOMPOSE
39
39
  - [Partial] Direction clear but details missing → explore then ask 1-2 questions
40
40
  - [Insufficient] Abstract, vague, multiple interpretations → must ask questions first
41
- 3. **Check for hidden assumptions** (Red Flag Detection):
41
+ 3. **Environment validation**: Verify project builds, dependencies match, env config identified. If any fail → resolve first.
42
+ 4. **Check for hidden assumptions** (Red Flag Detection):
42
43
 
43
44
  | Red Flag | Question to Ask Yourself |
44
45
  |----------|-------------------------|
@@ -50,63 +51,74 @@ AI agents optimize for speed, not correctness. Without structure, they skip unde
50
51
  | No file/function names | [Insufficient]. Must ask. |
51
52
  | "just", "simply" | Complexity being underestimated |
52
53
 
53
- 4. **Question rules** (if questions needed):
54
+ 5. **Question rules** (if questions needed):
54
55
  - One question at a time
55
56
  - Multiple choice with 2-3 options + recommendation
56
57
  - Include reasoning based on code exploration
57
58
  - Maximum 3 rounds of questions
58
- 5. **Confirm alignment**: Summarize goal in one sentence, get user approval
59
- 6. **Analysis-only requests**: If no code change is needed, report findings and ask: "Further action needed?" Do NOT proceed to D/E/C unless the user requests implementation.
59
+ 6. **Confirm alignment**: Summarize goal in one sentence, get user approval
60
+ 7. **Analysis-only requests**: If no code change is needed, report findings and ask: "Further action needed?" Do NOT proceed to D/E/C unless the user requests implementation.
60
61
 
61
62
  ## D — DECOMPOSE
62
63
 
63
- 7. **Assess complexity** (consider BOTH file count AND logic complexity):
64
+ 8. **Assess complexity** (consider BOTH file count AND logic complexity):
64
65
  - [Simple] 1-2 files, minor changes (<50 LOC) → execute directly, no decomposition needed
65
66
  - [Medium] 3-5 files, OR 1-2 files with significant logic changes (50-150 LOC) → 2-3 batches
66
67
  - [Complex] 6+ files, OR substantial architectural changes → 5+ batches, must create plan file
67
68
  - [Complex system] Unclear scope → reduce scope first, then decompose
68
- 8. **Create batches** following the 5 principles:
69
+ 9. **Create batches** following the 5 principles:
69
70
  - Unit size: 2-5 minutes each (test/implement/verify as separate steps)
70
71
  - Test first: test before implementation in each unit
71
72
  - Independent verification: each unit has a pass criterion
72
73
  - Files specified: list files to create/modify per unit
73
74
  - Dependencies noted: mark if unit depends on a previous one
74
- 9. **Assign size tags** to every task: [S] <30 LOC, [M] 30-100 LOC, [L] >100 LOC
75
- - Batch composition: S+S+M = 1 batch, L = 1 batch alone
76
- 10. **Assign verification strategy** per task: `| Verify: TDD` or `| Verify: Build` or `| Verify: Visual`
77
- 11. **Pre-decomposition checklist**:
75
+ 10. **Assign size tags** to every task: [S] <30 LOC, [M] 30-100 LOC, [L] >100 LOC
76
+ - Batch composition: S+S+M = 1 batch, L = 1 batch alone
77
+ 11. **Assign verification strategy** per task: `| Verify: TDD` or `| Verify: Build` or `| Verify: Visual`
78
+ 12. **Pre-decomposition checklist**:
79
+ - **Codebase audit**: grep/search to verify targets actually exist in code
80
+ - **Cross-plan check**: if other plans exist in `docs/plans/`, identify overlapping files
78
81
  - Required types/interfaces have the necessary fields?
79
82
  - External package APIs behave as expected?
80
83
  - Cross-package dependencies identified and noted as prerequisites?
81
- 12. **Save plan** to `docs/plans/YYYY-MM-DD-<topic>.md`
82
- 13. **Get approval**: "Proceed with this plan?"
84
+ 13. **Quality gate**: Plan file exists and targets verified, project builds, dependencies resolved, environment validated. All must pass before execution.
85
+ 14. **Save plan** to `docs/plans/YYYY-MM-DD-<topic>.md`
86
+ 15. **Get approval**: "Proceed with this plan?"
83
87
 
84
88
  ## E — EXECUTE
85
89
 
86
- 11. Execute in adaptive batches:
90
+ 16. Execute in adaptive batches:
87
91
  - Simple changes (imports, types, config): 5-8 per batch
88
92
  - Standard changes (feature add/modify): 3-4 per batch
89
93
  - Complex changes (new module, architecture): 1-2 per batch
90
- 12. Apply context-aware verification:
91
- - `lib/`, `utils/`, `store/`, `hooks/`, `services/` → TDD (failing test → implement → verify)
92
- - `components/`, `pages/`, `views/` Build verification (escalate to TDD if complex logic)
93
- - `config/`, `styles/`, `types/` Build/lint only
94
- 13. **Scope Guard**: Before each change, ask: "Was this requested?" If no → don't do it
95
- 14. **Self-correction triggers**:
96
- - Same file edited 3+ times **on the same region/logic**stop, investigate root cause (progressive edits across different regions imports, logic, JSX — are normal)
94
+ 17. **Git-as-Memory**: commit after each completed batch as a rollback point. Use `git diff` summaries to maintain context in long sessions.
95
+ 18. Apply risk-based verification:
96
+ - **High risk** (business logic, auth, data mutation): TDD failing test → implement → pass. Include negative tests.
97
+ - **Medium risk** (new components with logic, API integration): Build + lint pass
98
+ - **Low risk** (imports, types, style, renaming): Build/lint passes
99
+ - **No test infra** (legacy PHP, WordPress, etc.): Grep-based static check + syntax validation
100
+ - Use **Verification Fallback Ladder**: Automated Tests Approval TestingBuild Lint Smoke Check Manual Diff Review (use highest available level)
101
+ 19. **Scope Guard**: Before each change, ask: "Was this requested?" If no → don't do it
102
+ 20. **Goal Recitation**: At every batch boundary, re-read the plan and confirm: "Current work aligns with: [original goal]"
103
+ 21. **Self-correction triggers (Thrashing Detector)**:
104
+ - Same file edited 3+ times **on the same region/logic** → stop, investigate root cause
97
105
  - File not in plan → pause, ask about scope change
98
106
  - 3 consecutive test failures → stop, reconsider approach
99
107
  - New package needed → ask user first
100
108
  - Adding workarounds on workarounds → design problem, step back
101
- 15. **Verification scoping**: When running build checks (tsc, lint, etc.), filter output to only changed files. Pre-existing errors in other files are not your concern. Example: `tsc --noEmit 2>&1 | grep -i "<changed-file>"`
102
- 16. **Agent failure recovery**: If a delegated agent partially fails or produces incomplete results:
109
+ - Successive edits reverting previous changes (oscillation) wrong approach
110
+ - Scope expanding beyond plan scope creep, return to DECOMPOSE
111
+ - Error messages changing type across fixes → chasing symptoms, back to UNDERSTAND
112
+ 22. **Verification scoping**: Filter build output to only changed files. Pre-existing errors are not your concern.
113
+ 23. **Agent failure recovery**: If a delegated agent partially fails:
103
114
  1. Verify actual file state (read the file, not just the agent's report)
104
115
  2. If partially correct → complete the remaining work directly
105
116
  3. If fully wrong → retry with clearer instructions or execute directly
106
117
 
107
118
  ## C — CHECKPOINT
108
119
 
109
- 20. After each batch, report using this format:
120
+ 24. **Quality gate**: All batch tasks terminal, build passes with zero new errors, no uncommitted changes, plan file updated with `[x]` status. If any fail → continue in EXECUTE.
121
+ 25. After each batch, report using this format:
110
122
 
111
123
  | Item | Before | After |
112
124
  |------|--------|-------|
@@ -115,12 +127,14 @@ AI agents optimize for speed, not correctness. Without structure, they skip unde
115
127
  ```
116
128
  Phase: [current] | Batch: [N/M] | Tasks: [done/total] ([%])
117
129
  [████████░░] 80% — Next: [next batch name]
130
+ Plan freshness: verified [date] | Remaining targets: [N] confirmed in code
118
131
  ```
119
132
 
120
- 21. Include: verification results, files modified, tests status
121
- 22. **Checkpoint policy**: after 3 consecutive approvals, increase batch size to 5-8 for the rest of the phase
122
- 23. Ask: "Continue to next batch?"
123
- 24. User can redirect, adjust scope, or stop at any checkpoint
133
+ 26. **Plan-Reality sync**: Grep for plan targets, mark vanished targets as "already completed", add newly discovered targets.
134
+ 27. Include: verification results, files modified, tests status
135
+ 28. **Checkpoint policy**: after 3 consecutive approvals, increase batch size to 5-8 for the rest of the phase
136
+ 29. Ask: "Continue to next batch?"
137
+ 30. User can redirect, adjust scope, or stop at any checkpoint
124
138
 
125
139
  ## OMC Integration
126
140
 
@@ -129,6 +143,6 @@ If oh-my-claudecode is detected in this environment:
129
143
  - Use `architect` agent for complex decomposition decisions
130
144
  - Use `executor` agents for parallel batch execution when tasks are independent
131
145
  - Use `verifier` agent for checkpoint verification
132
- - Scope Guard thresholds are automatically raised for sub-agents (8 warn / 12 block vs 4/7)
146
+ - Scope Guard thresholds are automatically raised for sub-agents (8 warn / 12 block vs default 4 warn / 7 block for standalone mode)
133
147
 
134
148
  </Steps>