@tgoodington/intuition 6.0.0 → 7.0.0

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.
@@ -0,0 +1,1111 @@
1
+ # Intuition v7.0 Design Specification
2
+ ## Branch/Trunk Workflow + Coding Expert
3
+
4
+ ---
5
+
6
+ ## Table of Contents
7
+
8
+ 1. [Overview](#1-overview)
9
+ 2. [Folder Structure](#2-folder-structure)
10
+ 3. [State Schema v4.0](#3-state-schema-v40)
11
+ 4. [New Skill: intuition-engineer](#4-new-skill-intuition-engineer)
12
+ 5. [Skill Changes: intuition-start](#5-skill-changes-intuition-start)
13
+ 6. [Skill Changes: intuition-prompt](#6-skill-changes-intuition-prompt)
14
+ 7. [Skill Changes: intuition-plan](#7-skill-changes-intuition-plan)
15
+ 8. [Skill Changes: intuition-design](#8-skill-changes-intuition-design)
16
+ 9. [Skill Changes: intuition-execute](#9-skill-changes-intuition-execute)
17
+ 10. [Skill Changes: intuition-handoff](#10-skill-changes-intuition-handoff)
18
+ 11. [Skill Changes: intuition-initialize](#11-skill-changes-intuition-initialize)
19
+ 12. [Install Script Changes](#12-install-script-changes)
20
+ 13. [MEMORY.md Updates](#13-memorymd-updates)
21
+ 14. [Migration Path](#14-migration-path)
22
+
23
+ ---
24
+
25
+ ## 1. Overview
26
+
27
+ ### What Changes
28
+
29
+ v7.0 introduces two major capabilities:
30
+
31
+ 1. **Branch/Trunk Workflow Model**: The first prompt→execute cycle becomes the "trunk." After trunk completes, users can create branches — independent prompt→execute cycles that build on, extend, or diverge from trunk (or from other completed branches). Each branch is aware of its lineage and the plan considers how branch work intersects with its parent.
32
+
33
+ 2. **Coding Expert Skill (`intuition-engineer`)**: A new opus-level skill that serves dual roles:
34
+ - **Troubleshooter** (user-invoked): After a context completes execution, users can invoke the engineer to diagnose and fix issues in any completed context.
35
+ - **Execute Consultant** (subagent): Execute gains a new "Senior Engineer" opus subagent for tasks requiring holistic codebase reasoning.
36
+
37
+ ### Core Principles
38
+
39
+ - **Trunk is permanent**: Once complete, the trunk is the foundational reference. It is never re-run.
40
+ - **Branches are the iteration mechanism**: New features, changes, or explorations happen on branches.
41
+ - **Engineer is the maintenance mechanism**: Broken things get fixed, not re-planned.
42
+ - **Shared memory persists across all contexts**: `key_facts.md`, `decisions.md`, `issues.md`, `bugs.md` stay at the root and accumulate project-wide knowledge.
43
+ - **Context path abstraction**: All skills use a dynamic `{context_path}` for file operations, resolved from the active context in state.
44
+
45
+ ### Skill Count
46
+
47
+ v7.0: 11 skills (add `intuition-engineer`)
48
+
49
+ ### Post-Completion Flow
50
+
51
+ When start detects a completed context, it offers two choices:
52
+ 1. **Create a branch** — begins a new prompt→execute cycle informed by parent context
53
+ 2. **Open the engineer** — troubleshoot issues in any completed context
54
+
55
+ ---
56
+
57
+ ## 2. Folder Structure
58
+
59
+ ### New Layout
60
+
61
+ ```
62
+ docs/project_notes/
63
+ ├── trunk/ ← Trunk-specific workflow artifacts
64
+ │ ├── discovery_brief.md
65
+ │ ├── discovery_output.json
66
+ │ ├── planning_brief.md
67
+ │ ├── plan.md
68
+ │ ├── design_brief.md
69
+ │ ├── design_spec_*.md
70
+ │ ├── execution_brief.md
71
+ │ └── .planning_research/
72
+ │ ├── orientation.md
73
+ │ ├── decisions_log.md
74
+ │ └── decision_*.md
75
+
76
+ ├── branches/ ← Branch-specific workflow artifacts
77
+ │ ├── feature-auth/
78
+ │ │ ├── discovery_brief.md
79
+ │ │ ├── discovery_output.json
80
+ │ │ ├── planning_brief.md
81
+ │ │ ├── plan.md
82
+ │ │ ├── design_brief.md
83
+ │ │ ├── design_spec_*.md
84
+ │ │ ├── execution_brief.md
85
+ │ │ └── .planning_research/
86
+ │ │
87
+ │ └── ui-overhaul/
88
+ │ └── ...
89
+
90
+ ├── .project-memory-state.json ← Root level, tracks ALL contexts
91
+ ├── key_facts.md ← Shared across all contexts
92
+ ├── decisions.md ← Shared across all contexts
93
+ ├── issues.md ← Shared across all contexts
94
+ └── bugs.md ← Shared across all contexts
95
+ ```
96
+
97
+ ### Path Resolution
98
+
99
+ All skills resolve file paths through a **context path** derived from state:
100
+
101
+ | Active Context | Context Path | Example Full Path |
102
+ |---------------|-------------|-------------------|
103
+ | `trunk` | `docs/project_notes/trunk/` | `docs/project_notes/trunk/plan.md` |
104
+ | Branch `feature-auth` | `docs/project_notes/branches/feature-auth/` | `docs/project_notes/branches/feature-auth/plan.md` |
105
+
106
+ **Shared files** (key_facts, decisions, issues, bugs) always resolve to `docs/project_notes/` regardless of active context.
107
+
108
+ ### Context Path Formula
109
+
110
+ ```
111
+ IF active_context == "trunk":
112
+ context_path = "docs/project_notes/trunk/"
113
+ ELSE:
114
+ context_path = "docs/project_notes/branches/{active_context}/"
115
+ ```
116
+
117
+ Every skill that reads or writes workflow artifacts (discovery_brief.md, plan.md, design_spec_*.md, etc.) MUST use context_path. This is the single most pervasive change across all skills.
118
+
119
+ ---
120
+
121
+ ## 3. State Schema v4.0
122
+
123
+ ### Full Schema
124
+
125
+ ```json
126
+ {
127
+ "initialized": true,
128
+ "version": "4.0",
129
+ "active_context": "trunk",
130
+ "trunk": {
131
+ "status": "none | prompt | planning | design | executing | complete",
132
+ "workflow": {
133
+ "prompt": {
134
+ "started": false,
135
+ "completed": false,
136
+ "started_at": null,
137
+ "completed_at": null,
138
+ "output_files": []
139
+ },
140
+ "planning": {
141
+ "started": false,
142
+ "completed": false,
143
+ "completed_at": null,
144
+ "approved": false
145
+ },
146
+ "design": {
147
+ "started": false,
148
+ "completed": false,
149
+ "completed_at": null,
150
+ "items": [],
151
+ "current_item": null
152
+ },
153
+ "execution": {
154
+ "started": false,
155
+ "completed": false,
156
+ "completed_at": null
157
+ }
158
+ }
159
+ },
160
+ "branches": {},
161
+ "last_handoff": null,
162
+ "last_handoff_transition": null
163
+ }
164
+ ```
165
+
166
+ ### Branch Entry Schema
167
+
168
+ When a branch is created, it gets added to `branches`:
169
+
170
+ ```json
171
+ {
172
+ "branches": {
173
+ "feature-auth": {
174
+ "display_name": "OAuth2 Authentication",
175
+ "created_from": "trunk",
176
+ "created_at": "2026-02-13T10:00:00Z",
177
+ "purpose": "Add OAuth2 support for third-party login",
178
+ "status": "none | prompt | planning | design | executing | complete",
179
+ "workflow": {
180
+ "prompt": { "started": false, "completed": false, "started_at": null, "completed_at": null, "output_files": [] },
181
+ "planning": { "started": false, "completed": false, "completed_at": null, "approved": false },
182
+ "design": { "started": false, "completed": false, "completed_at": null, "items": [], "current_item": null },
183
+ "execution": { "started": false, "completed": false, "completed_at": null }
184
+ }
185
+ }
186
+ }
187
+ }
188
+ ```
189
+
190
+ ### Key Design Decisions
191
+
192
+ 1. **`active_context`** — Tracks which context is currently being worked on. Set by handoff when branch creation happens or when a branch workflow begins. All skills read this to determine their context_path.
193
+
194
+ 2. **Each context has its own workflow pipeline** — Trunk and every branch have independent `status` + `workflow` objects. A branch can be in "planning" while trunk is "complete."
195
+
196
+ 3. **`created_from` tracks lineage** — Branches reference their parent. This enables plan to read the parent's plan.md for intersection analysis. Branches can be created from other completed branches, forming a tree.
197
+
198
+ 4. **`purpose` is captured at creation** — Brief description captured when the user creates a branch, used by start for context display and by plan for intersection reasoning.
199
+
200
+ 5. **`display_name` is human-readable** — The branch key is snake_case for paths, display_name is for UI presentation.
201
+
202
+ ### Reading Active Context
203
+
204
+ All skills that need to find files use this pattern:
205
+
206
+ ```
207
+ 1. Read .project-memory-state.json
208
+ 2. Get active_context value
209
+ 3. IF active_context == "trunk":
210
+ context_path = "docs/project_notes/trunk/"
211
+ workflow = state.trunk
212
+ ELSE:
213
+ context_path = "docs/project_notes/branches/{active_context}/"
214
+ workflow = state.branches[active_context]
215
+ 4. Use context_path for all file reads/writes
216
+ 5. Use workflow for status checks
217
+ ```
218
+
219
+ ---
220
+
221
+ ## 4. New Skill: intuition-engineer
222
+
223
+ ### SKILL.md Specification
224
+
225
+ ```yaml
226
+ ---
227
+ name: intuition-engineer
228
+ description: Senior software engineer. Troubleshoots issues in completed workflow contexts with holistic codebase awareness. Delegates fixes to coding subagents while maintaining full-system context.
229
+ model: opus
230
+ tools: Read, Write, Glob, Grep, Task, AskUserQuestion, Bash, mcp__ide__getDiagnostics
231
+ allowed-tools: Read, Write, Glob, Grep, Task, Bash, mcp__ide__getDiagnostics
232
+ ---
233
+ ```
234
+
235
+ ### Behavioral Overview
236
+
237
+ The engineer is a senior software engineer who thinks holistically. Every change is evaluated in context of the entire codebase. The engineer never makes isolated fixes — it traces impact across the system before touching anything.
238
+
239
+ ### Protocol Flow
240
+
241
+ ```
242
+ Step 1: Read state, identify completed contexts
243
+ Step 2: Present context choice (if multiple completed)
244
+ Step 3: Load context artifacts (plan, design specs, execution brief)
245
+ Step 4: Ask user to describe the issue
246
+ Step 5: Investigate holistically (codebase analysis)
247
+ Step 6: Present diagnosis and proposed fix
248
+ Step 7: Delegate fix to coding subagents
249
+ Step 8: Verify fix (test, review, impact analysis)
250
+ Step 9: Report results
251
+ ```
252
+
253
+ ### Step 1-2: Context Selection
254
+
255
+ Read `.project-memory-state.json`. Build list of completed contexts:
256
+ - If `trunk.status == "complete"` → add "Trunk" to list
257
+ - For each branch where `status == "complete"` → add branch display_name to list
258
+
259
+ ```
260
+ IF only one completed context:
261
+ → Auto-select it. Tell user: "Working in [context name]."
262
+ IF multiple completed contexts:
263
+ → Use AskUserQuestion:
264
+ "Which area needs attention?"
265
+ Options: [list each completed context with its purpose]
266
+ IF no completed contexts:
267
+ → STOP: "No completed workflow contexts found. The engineer works on
268
+ completed implementations. Run the workflow to completion first."
269
+ ```
270
+
271
+ ### Step 3: Load Context
272
+
273
+ After selecting a context, read:
274
+ - `{context_path}/plan.md` — what was planned
275
+ - `{context_path}/execution_brief.md` — what was executed
276
+ - `{context_path}/design_spec_*.md` — design decisions (if any)
277
+ - `docs/project_notes/key_facts.md` — project-wide knowledge
278
+ - `docs/project_notes/decisions.md` — architectural decisions
279
+ - `docs/project_notes/bugs.md` — known bugs
280
+
281
+ Do NOT read code files yet. Wait for the user to describe the issue — then investigate targeted areas.
282
+
283
+ ### Step 4: Issue Description
284
+
285
+ Ask via AskUserQuestion:
286
+
287
+ ```
288
+ "I've loaded the [context name] context. What's the issue?
289
+
290
+ You can paste error messages, describe unexpected behavior,
291
+ or point me to specific files."
292
+
293
+ Header: "Issue"
294
+ Options:
295
+ - "Runtime error / crash"
296
+ - "Unexpected behavior"
297
+ - "Performance issue"
298
+ - "Code quality concern"
299
+ ```
300
+
301
+ After the user describes the issue, proceed to investigation.
302
+
303
+ ### Step 5: Holistic Investigation
304
+
305
+ This is what distinguishes the engineer from a simple code fixer.
306
+
307
+ **Investigation Protocol:**
308
+
309
+ 1. **Trace the symptom** — Read the file(s) directly related to the error/issue.
310
+ 2. **Map the blast radius** — Use Grep/Glob to find all files that import, reference, or depend on the affected code.
311
+ 3. **Check upstream** — What feeds into this code? Read callers, data sources, configuration.
312
+ 4. **Check downstream** — What does this code feed? Read consumers, outputs, side effects.
313
+ 5. **Cross-reference plan** — Does the implementation match what was planned? Check plan.md and design specs.
314
+ 6. **Check for systemic patterns** — Is this a one-off bug or a pattern that exists elsewhere?
315
+
316
+ **For large investigations:** Launch research subagents (haiku, Explore) to map dependencies without polluting your own context:
317
+
318
+ ```
319
+ Agent: Explore (haiku)
320
+ Task: "Map all imports and usages of [module/function] across the codebase.
321
+ Report: file paths, line numbers, how each usage depends on this module.
322
+ Under 400 words."
323
+ ```
324
+
325
+ ### Step 6: Diagnosis
326
+
327
+ Present findings to the user:
328
+
329
+ ```markdown
330
+ ## Diagnosis
331
+
332
+ **Root cause:** [Clear statement of what's wrong and why]
333
+
334
+ **Affected files:**
335
+ - path/to/file.ext — [what's wrong here]
336
+ - path/to/other.ext — [downstream impact]
337
+
338
+ **Systemic impact:** [Does this affect other parts of the codebase?]
339
+
340
+ **Proposed fix:**
341
+ - [Step 1: what to change and why]
342
+ - [Step 2: what to change and why]
343
+
344
+ **Risk assessment:** [What could this fix break? How do we verify?]
345
+ ```
346
+
347
+ Ask via AskUserQuestion: "Does this diagnosis look right? Should I proceed with the fix?"
348
+
349
+ ### Step 7: Delegate Fixes
350
+
351
+ **CRITICAL: The engineer delegates code changes to subagents to preserve its own context for holistic oversight.**
352
+
353
+ Decision framework for delegation:
354
+
355
+ ```
356
+ IF fix is trivial (1-3 lines, single file):
357
+ → Engineer MAY fix directly (acceptable exception)
358
+
359
+ IF fix is moderate (multiple lines, single file):
360
+ → Delegate to Code Writer subagent (sonnet)
361
+
362
+ IF fix is complex (multiple files, architectural):
363
+ → Delegate to Code Writer subagent (sonnet) with detailed instructions
364
+ → Include holistic context: "This file is used by X, Y, Z. Change must preserve..."
365
+
366
+ IF fix requires investigation + implementation:
367
+ → Launch research subagent first (haiku, Explore)
368
+ → Then delegate implementation (sonnet, general-purpose)
369
+ ```
370
+
371
+ **Subagent prompt template:**
372
+
373
+ ```
374
+ You are implementing a fix as part of a holistic code review.
375
+
376
+ CONTEXT:
377
+ - Issue: [root cause summary]
378
+ - Affected file(s): [paths]
379
+ - Plan reference: {context_path}/plan.md Task #[N]
380
+
381
+ CRITICAL — HOLISTIC AWARENESS:
382
+ - This code is imported/used by: [list dependents]
383
+ - Changes MUST preserve: [interfaces, behaviors, contracts]
384
+ - After making changes, verify: [specific things to check]
385
+
386
+ FIX:
387
+ [Specific instructions — what to change and why]
388
+
389
+ After fixing, read the modified file(s) and verify the fix is complete
390
+ and doesn't introduce new issues. Report what you changed.
391
+ ```
392
+
393
+ ### Step 8: Verify
394
+
395
+ After subagent returns:
396
+
397
+ 1. **Review the changes** — Read modified files to confirm the fix matches diagnosis.
398
+ 2. **Run tests** — Launch Test Runner (haiku) if test infrastructure exists.
399
+ 3. **Impact check** — Launch Explore subagent (haiku) to verify dependent code still works:
400
+ ```
401
+ "Read [list of dependent files]. Verify they are compatible with the changes
402
+ made to [modified files]. Report any broken imports, changed interfaces,
403
+ or behavioral mismatches."
404
+ ```
405
+ 4. **Log the fix** — Add entry to `docs/project_notes/bugs.md`:
406
+ ```markdown
407
+ ### [Date] - [Brief Bug Description]
408
+ - **Context**: [trunk/branch name]
409
+ - **Issue**: [What went wrong]
410
+ - **Root Cause**: [Why]
411
+ - **Solution**: [What was changed]
412
+ - **Files Modified**: [list]
413
+ - **Prevention**: [How to avoid in future]
414
+ ```
415
+
416
+ ### Step 9: Report
417
+
418
+ ```markdown
419
+ ## Fix Complete
420
+
421
+ **Issue:** [Brief description]
422
+ **Root Cause:** [One sentence]
423
+
424
+ **Changes Made:**
425
+ - path/to/file — [what changed]
426
+
427
+ **Verification:**
428
+ - Tests: PASS / FAIL / N/A
429
+ - Impact check: [clean / issues found]
430
+
431
+ **Additional recommendations:**
432
+ - [Any follow-up items or related issues spotted]
433
+ ```
434
+
435
+ ### Subagent Table
436
+
437
+ | Agent | Model | When to Use |
438
+ |-------|-------|-------------|
439
+ | **Code Writer** | sonnet | Implementing fixes (moderate to complex) |
440
+ | **Research/Explorer** | haiku | Mapping dependencies, investigating patterns |
441
+ | **Test Runner** | haiku | Running tests after fixes |
442
+ | **Impact Analyst** | haiku | Verifying dependent code after changes |
443
+
444
+ ### Critical Rules
445
+
446
+ 1. You MUST read `.project-memory-state.json` and verify at least one context is complete before proceeding.
447
+ 2. You MUST investigate holistically — trace upstream, downstream, and lateral dependencies before proposing fixes.
448
+ 3. You MUST delegate code changes to subagents for anything beyond trivial fixes (1-3 lines).
449
+ 4. You MUST verify fixes don't break dependent code. Never make an isolated fix.
450
+ 5. You MUST log every fix to `docs/project_notes/bugs.md`.
451
+ 6. You MUST present diagnosis to the user before implementing fixes.
452
+ 7. You MUST NOT make design decisions. If the fix requires architectural changes, tell the user to create a branch and run the full workflow.
453
+ 8. You MUST NOT modify plan.md, design specs, or other workflow artifacts. You fix code, not plans.
454
+ 9. When delegating to subagents, ALWAYS include the list of dependent files and what must be preserved.
455
+ 10. You MUST treat the entire codebase as your responsibility. No change exists in isolation.
456
+
457
+ ### Voice
458
+
459
+ - Precise and diagnostic — like a senior engineer explaining a bug to a colleague
460
+ - Confident but not dismissive — "Here's what I found" not "This is obvious"
461
+ - Systemic thinker — always mentions the broader impact
462
+ - Evidence-based — references specific files, line numbers, and code patterns
463
+
464
+ ---
465
+
466
+ ## 5. Skill Changes: intuition-start
467
+
468
+ ### Summary of Changes
469
+
470
+ Start gains post-completion awareness. When any context is complete, it presents the two-choice flow instead of suggesting `/intuition-prompt`.
471
+
472
+ ### Phase Detection Changes
473
+
474
+ Replace the current `complete` phase handler with context-aware logic:
475
+
476
+ ```
477
+ ELSE IF trunk.status == "complete" OR any branch has status == "complete":
478
+ → PHASE: post_completion
479
+ → ACTION: Show status tree, present two choices
480
+
481
+ Determine active context:
482
+ - If active_context has status != "complete" and is in-progress:
483
+ → PHASE: [appropriate in-progress phase for that context]
484
+ → ACTION: Resume that context's workflow
485
+
486
+ - If all contexts are complete or no in-progress context:
487
+ → PHASE: post_completion
488
+ → ACTION: Two-choice prompt
489
+ ```
490
+
491
+ ### New Phase Handler: Post-Completion
492
+
493
+ ```
494
+ Welcome back! Here's your project status:
495
+
496
+ **Trunk:** Complete
497
+ - [Trunk objective from plan.md — 1 sentence]
498
+
499
+ **Branches:**
500
+ - feature-auth: Complete — [purpose]
501
+ - ui-overhaul: In progress (planning) — [purpose]
502
+
503
+ [If a context is in-progress]:
504
+ You have work in progress on [branch name].
505
+ Run /intuition-[next skill] to continue.
506
+
507
+ [If all contexts are complete]:
508
+ What would you like to do next?
509
+ ```
510
+
511
+ Use AskUserQuestion:
512
+
513
+ ```
514
+ Question: "All current work is complete. What's next?"
515
+ Header: "Next Step"
516
+ Options:
517
+ - "Create a new branch (new feature or change)"
518
+ - "Troubleshoot an issue (/intuition-engineer)"
519
+ ```
520
+
521
+ If user selects "Create a new branch":
522
+ - Ask for branch name (short, descriptive, kebab-case)
523
+ - Ask for branch purpose (1 sentence)
524
+ - Ask which context to branch from (if multiple completed)
525
+ - Route to `/intuition-handoff` with branch creation intent
526
+
527
+ If user selects "Troubleshoot":
528
+ - Route to `/intuition-engineer`
529
+
530
+ ### Start Remains Read-Only
531
+
532
+ Start NEVER writes state. For branch creation, start collects the information (name, purpose, parent) and routes to handoff, which handles the state write and folder creation.
533
+
534
+ ### Status Tree Display
535
+
536
+ Start reads state and renders a tree:
537
+
538
+ ```
539
+ Project Status:
540
+ ├── Trunk: Complete ✓
541
+ │ └── "Build a REST API for document management"
542
+ ├── Branch: feature-auth (from trunk): Complete ✓
543
+ │ └── "Add OAuth2 authentication"
544
+ └── Branch: caching-layer (from trunk): Planning...
545
+ └── "Add Redis caching for API responses"
546
+ ```
547
+
548
+ ### Context Path Awareness
549
+
550
+ When start detects an in-progress context, it resolves the context_path and reads artifacts from the correct folder:
551
+
552
+ ```
553
+ IF active_context == "trunk":
554
+ Read docs/project_notes/trunk/plan.md for task count
555
+ ELSE:
556
+ Read docs/project_notes/branches/{active_context}/plan.md
557
+ ```
558
+
559
+ ---
560
+
561
+ ## 6. Skill Changes: intuition-prompt
562
+
563
+ ### Summary of Changes
564
+
565
+ Prompt needs context-path awareness for all file writes. The interaction flow stays the same — only the output paths change.
566
+
567
+ ### Changes Required
568
+
569
+ 1. **On startup**: Read `.project-memory-state.json` to determine `active_context` and resolve `context_path`.
570
+
571
+ 2. **File writes** in Phase 4 (CONFIRM) change from:
572
+ - `docs/project_notes/discovery_brief.md` → `{context_path}/discovery_brief.md`
573
+ - `docs/project_notes/discovery_output.json` → `{context_path}/discovery_output.json`
574
+
575
+ 3. **Resume logic**: Check for `{context_path}/discovery_brief.md` instead of the fixed path.
576
+
577
+ 4. **Branch context awareness**: When running on a branch, prompt's opening message should acknowledge the lineage:
578
+ ```
579
+ You're working on branch "[display_name]" (from [parent]).
580
+ Branch purpose: [purpose]
581
+
582
+ Tell me what you want to build or change for this branch.
583
+ I'll help you sharpen it into something the planning phase can run with.
584
+ ```
585
+
586
+ 5. **No structural changes** to the CAPTURE → REFINE → REFLECT → CONFIRM protocol. The prompt flow is identical regardless of context.
587
+
588
+ ### New Critical Rule
589
+
590
+ Add rule: "You MUST read `.project-memory-state.json` to determine the active context path before writing any files. NEVER write to the root `docs/project_notes/` — always write to the resolved context_path."
591
+
592
+ ---
593
+
594
+ ## 7. Skill Changes: intuition-plan
595
+
596
+ ### Summary of Changes
597
+
598
+ Plan gains branch awareness. When planning on a branch, it reads the parent context's plan and includes a "Trunk Intersection" analysis. File paths are context-aware.
599
+
600
+ ### Changes Required
601
+
602
+ 1. **On startup**: Read state for `active_context`. Resolve `context_path`.
603
+
604
+ 2. **All file paths** change to use context_path:
605
+ - Read: `{context_path}/discovery_brief.md`, `{context_path}/planning_brief.md`
606
+ - Write: `{context_path}/plan.md`, `{context_path}/.planning_research/*`
607
+
608
+ 3. **Branch-aware intake (new Phase 1 step)**:
609
+
610
+ When `active_context` is NOT trunk:
611
+
612
+ a. Determine parent: `state.branches[active_context].created_from`
613
+
614
+ b. Read parent's plan:
615
+ - If parent is trunk: read `docs/project_notes/trunk/plan.md`
616
+ - If parent is a branch: read `docs/project_notes/branches/{parent}/plan.md`
617
+
618
+ c. Read parent's design specs (if any): `{parent_path}/design_spec_*.md`
619
+
620
+ d. During orientation research, add a third agent:
621
+
622
+ ```
623
+ Agent 3 — Parent Intersection Analysis (subagent_type: Explore, model: haiku):
624
+ Prompt: "Compare the discovery brief at {context_path}/discovery_brief.md
625
+ with the plan at {parent_path}/plan.md. Identify:
626
+ (1) Shared files/components that both touch
627
+ (2) Decisions in the parent plan that constrain this branch
628
+ (3) Potential conflicts or dependencies
629
+ (4) Patterns from parent that should be reused
630
+ Under 500 words. Facts only."
631
+ ```
632
+
633
+ Write results to `{context_path}/.planning_research/parent_intersection.md`
634
+
635
+ 4. **New plan section: Parent Context (branch plans only)**
636
+
637
+ Add between Section 2 (Discovery Summary) and Section 3 (Technology Decisions):
638
+
639
+ ```markdown
640
+ ### 2.5. Parent Context
641
+
642
+ **Parent:** [trunk or branch name]
643
+ **Parent Objective:** [1 sentence from parent plan]
644
+
645
+ **Shared Components:**
646
+ - [Component]: [how this branch's work relates to parent's use]
647
+
648
+ **Inherited Decisions:**
649
+ - [Decision from parent that constrains this branch]
650
+
651
+ **Intersection Points:**
652
+ - [File/module touched by both parent and this branch]
653
+ - [Potential conflict or dependency]
654
+
655
+ **Divergence:**
656
+ - [Where this branch intentionally departs from parent patterns]
657
+ ```
658
+
659
+ 5. **ARCH framework extension**: When on a branch, the Reach dimension explicitly includes intersection with parent. The Choices dimension must acknowledge inherited decisions.
660
+
661
+ 6. **Scope scaling**: Parent Context section is included for ALL tiers when on a branch.
662
+
663
+ ### New Critical Rule
664
+
665
+ Add rule: "When planning on a branch, you MUST read the parent context's plan.md and include a Parent Context section. Inherited architectural decisions from the parent are binding unless the user explicitly overrides them."
666
+
667
+ ---
668
+
669
+ ## 8. Skill Changes: intuition-design
670
+
671
+ ### Summary of Changes
672
+
673
+ Minimal changes — design only needs context-path awareness for file reads and writes.
674
+
675
+ ### Changes Required
676
+
677
+ 1. **On startup**: Read state for `active_context`. Resolve `context_path`.
678
+
679
+ 2. **File paths** change:
680
+ - Read: `{context_path}/plan.md`, `{context_path}/design_brief.md`
681
+ - Write: `{context_path}/design_spec_{item}.md`
682
+ - Working files: `{context_path}/.design_research/{item}/`
683
+
684
+ 3. **Branch awareness in design**: When designing on a branch, if the parent has design specs for related components, read them for context. Add to the ECD exploration:
685
+
686
+ ```
687
+ "The parent context ([name]) has a design spec for [related component].
688
+ Read {parent_path}/design_spec_{item}.md for existing design decisions
689
+ that may constrain or inform this design."
690
+ ```
691
+
692
+ 4. **No structural changes** to the ECD protocol. The design flow is identical regardless of context.
693
+
694
+ ---
695
+
696
+ ## 9. Skill Changes: intuition-execute
697
+
698
+ ### Summary of Changes
699
+
700
+ Execute gains context-path awareness and a new Senior Engineer opus subagent.
701
+
702
+ ### Changes Required
703
+
704
+ 1. **On startup**: Read state for `active_context`. Resolve `context_path`.
705
+
706
+ 2. **All file paths** change to context_path:
707
+ - Read: `{context_path}/plan.md`, `{context_path}/discovery_brief.md`, `{context_path}/design_spec_*.md`, `{context_path}/execution_brief.md`
708
+
709
+ 3. **New subagent: Senior Engineer (opus)**
710
+
711
+ Add to the AVAILABLE SUBAGENTS table:
712
+
713
+ | Agent | Model | When to Use |
714
+ |-------|-------|-------------|
715
+ | **Senior Engineer** | opus | Complex tasks requiring holistic codebase reasoning. Multi-file architectural changes, tricky integrations, tasks where the implementation approach affects the broader system. |
716
+
717
+ Usage criteria — delegate to Senior Engineer instead of Code Writer when:
718
+ - The task touches 3+ files with dependencies between them
719
+ - The implementation choice affects system architecture
720
+ - The task requires understanding the full call chain
721
+ - The task was flagged for design (has a design spec)
722
+
723
+ **Senior Engineer subagent prompt template:**
724
+
725
+ ```
726
+ You are a senior software engineer implementing a task that requires holistic
727
+ codebase awareness. Every change you make must be evaluated in context of the
728
+ entire system.
729
+
730
+ TASK: [description] (see {context_path}/plan.md Task #[N])
731
+
732
+ CONTEXT DOCUMENTS:
733
+ - {context_path}/plan.md — Read Task #[N] for full acceptance criteria
734
+ - {context_path}/design_spec_[item].md — Read for design blueprint (if exists)
735
+ - docs/project_notes/decisions.md — Architectural decisions to respect
736
+
737
+ HOLISTIC PROTOCOL:
738
+ 1. Before writing any code, read ALL files that will be affected.
739
+ 2. Map the dependency graph — what imports this? What does this import?
740
+ 3. Identify interfaces that must be preserved.
741
+ 4. Implement the change.
742
+ 5. After implementation, read dependent files and verify compatibility.
743
+ 6. If your change affects an interface used by other code, update ALL consumers.
744
+ 7. Report: what you changed, why, and what dependent code you verified.
745
+
746
+ NO ISOLATED CHANGES. Every modification considers the whole.
747
+ ```
748
+
749
+ 4. **Branch-aware execution**: When executing on a branch, the execution brief should note the parent context. Subagent prompts should include:
750
+
751
+ ```
752
+ NOTE: This is branch work. The parent context ([name]) has existing
753
+ implementations at [relevant paths]. Your changes must be compatible
754
+ with the parent's architecture unless the plan explicitly states otherwise.
755
+ ```
756
+
757
+ ### New Critical Rule
758
+
759
+ Add rule: "For tasks flagged with design specs or touching 3+ interdependent files, you MUST delegate to the Senior Engineer (opus) subagent, not the standard Code Writer."
760
+
761
+ ---
762
+
763
+ ## 10. Skill Changes: intuition-handoff
764
+
765
+ ### Summary of Changes
766
+
767
+ Handoff undergoes the most significant changes. It must manage the tree state, handle branch creation, and resolve all file paths through context_path.
768
+
769
+ ### State Schema Update
770
+
771
+ Handoff's embedded state schema updates from v3.0 to v4.0 (see Section 3 above).
772
+
773
+ ### Context Path Resolution
774
+
775
+ Add to the top of the protocol:
776
+
777
+ ```
778
+ BEFORE ANY TRANSITION:
779
+ 1. Read .project-memory-state.json
780
+ 2. Get active_context
781
+ 3. Resolve context_path:
782
+ IF active_context == "trunk":
783
+ context_path = "docs/project_notes/trunk/"
784
+ ELSE:
785
+ context_path = "docs/project_notes/branches/{active_context}/"
786
+ 4. Use context_path for ALL file operations in this transition
787
+ ```
788
+
789
+ ### All Existing Transitions — Path Updates
790
+
791
+ Every file path in every transition changes:
792
+
793
+ | v6.0 Path | v7.0 Path |
794
+ |-----------|-----------|
795
+ | `docs/project_notes/discovery_brief.md` | `{context_path}/discovery_brief.md` |
796
+ | `docs/project_notes/discovery_output.json` | `{context_path}/discovery_output.json` |
797
+ | `docs/project_notes/planning_brief.md` | `{context_path}/planning_brief.md` |
798
+ | `docs/project_notes/plan.md` | `{context_path}/plan.md` |
799
+ | `docs/project_notes/design_brief.md` | `{context_path}/design_brief.md` |
800
+ | `docs/project_notes/design_spec_*.md` | `{context_path}/design_spec_*.md` |
801
+ | `docs/project_notes/execution_brief.md` | `{context_path}/execution_brief.md` |
802
+
803
+ Shared files remain at `docs/project_notes/`:
804
+ - `key_facts.md`, `decisions.md`, `issues.md`, `bugs.md`
805
+
806
+ ### State Write Changes
807
+
808
+ All state writes now target the correct context object:
809
+
810
+ ```
811
+ IF active_context == "trunk":
812
+ Update state.trunk.status and state.trunk.workflow.*
813
+ ELSE:
814
+ Update state.branches[active_context].status and state.branches[active_context].workflow.*
815
+ ```
816
+
817
+ ### New Transition 0: Branch Creation
818
+
819
+ Triggered when start routes to handoff with branch creation intent. The user has provided: branch name, purpose, parent context.
820
+
821
+ **Protocol:**
822
+
823
+ 1. Validate branch name:
824
+ - Convert to kebab-case for directory name (the state key)
825
+ - Reject if a branch with that key already exists
826
+
827
+ 2. Create branch directory: `docs/project_notes/branches/{branch_key}/`
828
+
829
+ 3. Add branch to state:
830
+ ```json
831
+ {
832
+ "branches": {
833
+ "{branch_key}": {
834
+ "display_name": "[User-provided name]",
835
+ "created_from": "[parent context key]",
836
+ "created_at": "[ISO timestamp]",
837
+ "purpose": "[User-provided purpose]",
838
+ "status": "none",
839
+ "workflow": {
840
+ "prompt": { "started": false, "completed": false, "started_at": null, "completed_at": null, "output_files": [] },
841
+ "planning": { "started": false, "completed": false, "completed_at": null, "approved": false },
842
+ "design": { "started": false, "completed": false, "completed_at": null, "items": [], "current_item": null },
843
+ "execution": { "started": false, "completed": false, "completed_at": null }
844
+ }
845
+ }
846
+ },
847
+ "active_context": "{branch_key}"
848
+ }
849
+ ```
850
+
851
+ 4. Route user: "Branch **[display_name]** created. Run `/intuition-prompt` to define what this branch will accomplish."
852
+
853
+ ### Transition Detection Update
854
+
855
+ The transition detection tree now reads the active context's workflow:
856
+
857
+ ```
858
+ Step 1: Read state, get active_context
859
+ Step 2: Get context_workflow:
860
+ IF active_context == "trunk": context_workflow = state.trunk
861
+ ELSE: context_workflow = state.branches[active_context]
862
+ Step 3: Apply existing transition logic against context_workflow
863
+ ```
864
+
865
+ The existing IF/ELSE transition logic stays the same — it just operates on `context_workflow` instead of `state.workflow`.
866
+
867
+ ### Transition 5 Update: Execution → Complete
868
+
869
+ After marking the context as complete, the route message changes:
870
+
871
+ ```
872
+ "Workflow cycle complete for [context name].
873
+
874
+ Run /intuition-start to see your project status and decide what's next."
875
+ ```
876
+
877
+ Do NOT suggest `/intuition-prompt` for a new cycle. Start now handles the post-completion flow.
878
+
879
+ ### New Critical Rule
880
+
881
+ Add rule: "You MUST resolve the active context and context_path before every transition. NEVER hardcode `docs/project_notes/` for workflow artifacts."
882
+
883
+ ---
884
+
885
+ ## 11. Skill Changes: intuition-initialize
886
+
887
+ ### Summary of Changes
888
+
889
+ Initialize creates the trunk/ and branches/ directory structure. State schema initializes as v4.0.
890
+
891
+ ### New Directory Structure
892
+
893
+ ```
894
+ docs/project_notes/
895
+ ├── trunk/ ← Created by initialize
896
+ ├── branches/ ← Created by initialize (empty)
897
+ ├── .project-memory-state.json ← v4.0 schema
898
+ ├── key_facts.md
899
+ ├── decisions.md
900
+ ├── issues.md
901
+ └── bugs.md
902
+ ```
903
+
904
+ ### State Template Update
905
+
906
+ The initial state file uses v4.0 schema:
907
+
908
+ ```json
909
+ {
910
+ "initialized": true,
911
+ "version": "4.0",
912
+ "active_context": "trunk",
913
+ "trunk": {
914
+ "status": "none",
915
+ "workflow": {
916
+ "prompt": { "started": false, "completed": false, "started_at": null, "completed_at": null, "output_files": [] },
917
+ "planning": { "started": false, "completed": false, "completed_at": null, "approved": false },
918
+ "design": { "started": false, "completed": false, "completed_at": null, "items": [], "current_item": null },
919
+ "execution": { "started": false, "completed": false, "completed_at": null }
920
+ }
921
+ },
922
+ "branches": {},
923
+ "last_handoff": null,
924
+ "last_handoff_transition": null
925
+ }
926
+ ```
927
+
928
+ ### CLAUDE.md Template Update
929
+
930
+ Update the workflow description to mention trunk/branch model:
931
+
932
+ ```
933
+ ## Workflow Model
934
+
935
+ The Intuition workflow uses a trunk-and-branch model:
936
+ - **Trunk**: The first prompt→plan→design→execute cycle. Represents the core vision.
937
+ - **Branches**: Subsequent cycles that build on, extend, or diverge from trunk or other branches.
938
+ - **Engineer**: Post-execution troubleshooting with holistic codebase awareness.
939
+
940
+ All phases: /intuition-prompt → /intuition-handoff → /intuition-plan → /intuition-handoff →
941
+ [/intuition-design loop] → /intuition-handoff → /intuition-execute → /intuition-handoff → complete
942
+
943
+ After completion: /intuition-start to create branches or /intuition-engineer to troubleshoot.
944
+ ```
945
+
946
+ ### INTUITION.md Template Update
947
+
948
+ Add trunk/branch explanation and engineer skill to the overview.
949
+
950
+ ---
951
+
952
+ ## 12. Install Script Changes
953
+
954
+ ### New Skill Registration
955
+
956
+ Add `intuition-engineer` to the skills array in `scripts/install-skills.js`:
957
+
958
+ ```javascript
959
+ const SKILLS = [
960
+ 'intuition-start',
961
+ 'intuition-prompt',
962
+ 'intuition-handoff',
963
+ 'intuition-plan',
964
+ 'intuition-design',
965
+ 'intuition-execute',
966
+ 'intuition-engineer', // NEW
967
+ 'intuition-initialize',
968
+ 'intuition-agent-advisor',
969
+ 'intuition-skill-guide',
970
+ 'intuition-update',
971
+ ];
972
+ ```
973
+
974
+ ### Uninstall Script
975
+
976
+ Add `intuition-engineer` to the cleanup list in `scripts/uninstall-skills.js`.
977
+
978
+ ### Source Skill Directory
979
+
980
+ Create `skills/intuition-engineer/SKILL.md` in the package source.
981
+
982
+ ---
983
+
984
+ ## 13. MEMORY.md Updates
985
+
986
+ ### Updated Project Overview
987
+
988
+ ```markdown
989
+ ## Project Overview
990
+ - npm package `@tgoodington/intuition` — Claude Code skill system
991
+ - 11 skills deployed to `~/.claude/skills/` via postinstall script
992
+ - Trunk-and-branch workflow: trunk (first cycle) → branches (subsequent cycles)
993
+ - Four-phase workflow per context: prompt → handoff → plan → handoff → [design loop] → handoff → execute → handoff
994
+ - **v7.0**: Branch/trunk model, intuition-engineer skill, state schema v4.0
995
+ ```
996
+
997
+ ### Updated All Skills Section
998
+
999
+ ```markdown
1000
+ ## All Skills (11 total)
1001
+ - `intuition-start` — haiku, read-only session primer + post-completion routing
1002
+ - `intuition-prompt` — opus, focused discovery (context-path aware)
1003
+ - `intuition-handoff` — haiku, state owner + transition logic + branch creation + design loop
1004
+ - `intuition-plan` — opus, ARCH architect + branch intersection analysis
1005
+ - `intuition-design` — opus, ECD design exploration (context-path aware)
1006
+ - `intuition-execute` — opus, execution orchestrator + Senior Engineer subagent
1007
+ - `intuition-engineer` — opus, holistic troubleshooter + coding expert (NEW)
1008
+ - `intuition-initialize` — project initialization (v4.0 state schema)
1009
+ - `intuition-agent-advisor` — opus, advisory skill
1010
+ - `intuition-skill-guide` — opus, advisory skill
1011
+ - `intuition-update` — haiku, package update manager
1012
+ ```
1013
+
1014
+ ### Updated State Ownership
1015
+
1016
+ ```markdown
1017
+ ### State Ownership
1018
+ - **Handoff is the ONLY skill that writes to `.project-memory-state.json`**
1019
+ - Other skills MUST NOT manage state
1020
+ - State schema v4.0: trunk object, branches map, active_context, per-context workflow pipelines
1021
+ - Engineer writes to bugs.md only (shared memory, not state)
1022
+ ```
1023
+
1024
+ ### Updated Workflow Architecture
1025
+
1026
+ ```markdown
1027
+ ## Workflow Architecture (v7.0)
1028
+ - Trunk = first prompt→execute cycle, permanent foundation
1029
+ - Branches = subsequent cycles, track lineage via `created_from`
1030
+ - `/intuition-start` — post-completion: create branch or open engineer
1031
+ - `/intuition-plan` on branches — reads parent plan, includes Parent Context section
1032
+ - `/intuition-execute` — new Senior Engineer (opus) subagent for complex tasks
1033
+ - `/intuition-engineer` — dual mode: user troubleshooter + execute consultant
1034
+ - All skills use context_path resolution for file operations
1035
+ - Shared memory (key_facts, decisions, issues, bugs) stays at root
1036
+ ```
1037
+
1038
+ ### Updated Handoff Transitions
1039
+
1040
+ ```markdown
1041
+ ## Handoff Transitions (v7.0)
1042
+ 0. branch_creation (start → handoff with branch info → creates branch, sets active_context)
1043
+ 1. prompt → plan (generates {context_path}/planning_brief.md)
1044
+ 2. plan → design (user confirms items, generates {context_path}/design_brief.md)
1045
+ 3. design → design (loop: updates {context_path}/design_brief.md for next item)
1046
+ 4. design → execute (all items done, generates {context_path}/execution_brief.md)
1047
+ 4B. plan → execute (skip design, no items flagged)
1048
+ 5. execute → complete
1049
+ Post-completion: start offers branch creation or engineer
1050
+ ```
1051
+
1052
+ ---
1053
+
1054
+ ## 14. Migration Path
1055
+
1056
+ ### v3.0 → v4.0 State Migration
1057
+
1058
+ Projects with existing v3.0 state need migration. Options:
1059
+
1060
+ **Option A: Auto-migration in handoff (recommended)**
1061
+
1062
+ When handoff reads a v3.0 state file, it:
1063
+ 1. Detects `version: "3.0"` (or missing `active_context` field)
1064
+ 2. Creates trunk directory: `docs/project_notes/trunk/`
1065
+ 3. Moves existing workflow artifacts into trunk/:
1066
+ - `discovery_brief.md`, `discovery_output.json`, `planning_brief.md`, `plan.md`, `design_brief.md`, `design_spec_*.md`, `execution_brief.md`, `.planning_research/`
1067
+ 4. Restructures state:
1068
+ ```json
1069
+ {
1070
+ "version": "4.0",
1071
+ "active_context": "trunk",
1072
+ "trunk": {
1073
+ "status": "[existing workflow.status]",
1074
+ "workflow": { /* existing workflow object */ }
1075
+ },
1076
+ "branches": {}
1077
+ }
1078
+ ```
1079
+ 5. Leaves shared files (key_facts, decisions, issues, bugs) at root.
1080
+
1081
+ **Option B: Manual re-initialize**
1082
+
1083
+ User runs `/intuition-initialize` which detects v3.0 and offers to upgrade.
1084
+
1085
+ **Recommendation:** Implement both. Handoff auto-migrates when it encounters v3.0. Initialize also offers upgrade as a deliberate action. Start should detect v3.0 and warn: "Project uses v3.0 state schema. Run `/intuition-handoff` or `/intuition-initialize` to upgrade to v4.0."
1086
+
1087
+ ### Backward Compatibility
1088
+
1089
+ - v7.0 skills should handle both v3.0 and v4.0 state during a transition period
1090
+ - If a skill reads state and finds `version: "3.0"`, it should warn and suggest migration
1091
+ - After migration, v3.0 compatibility can be removed in v8.0
1092
+
1093
+ ---
1094
+
1095
+ ## Summary of All Changes
1096
+
1097
+ | Skill | Change Level | Key Changes |
1098
+ |-------|-------------|-------------|
1099
+ | **intuition-start** | Moderate | Post-completion two-choice flow, status tree display, context-path awareness |
1100
+ | **intuition-prompt** | Light | Context-path for file writes, branch context in opening message |
1101
+ | **intuition-plan** | Moderate | Parent intersection analysis, new Section 2.5, third research agent on branches |
1102
+ | **intuition-design** | Light | Context-path for file reads/writes, optional parent spec reading |
1103
+ | **intuition-execute** | Moderate | Context-path, new Senior Engineer (opus) subagent, branch-aware prompts |
1104
+ | **intuition-handoff** | Heavy | Context-path everywhere, new Transition 0 (branch creation), tree state management, v3→v4 migration |
1105
+ | **intuition-engineer** | New | Entire skill — troubleshooter + holistic codebase expert |
1106
+ | **intuition-initialize** | Moderate | trunk/ and branches/ directories, v4.0 state template, updated CLAUDE.md/INTUITION.md templates |
1107
+ | **intuition-agent-advisor** | None | No changes needed |
1108
+ | **intuition-skill-guide** | None | No changes needed |
1109
+ | **intuition-update** | None | No changes needed |
1110
+ | **Install scripts** | Light | Add intuition-engineer to skill list |
1111
+ | **MEMORY.md** | Moderate | Updated overview, skill list, state ownership, transitions |