@jaybeeuu/agent-cortex 1.38.1 → 1.40.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.
Files changed (88) hide show
  1. package/.agents/skills/style-versioning/SKILL.md +1 -1
  2. package/.github/workflows/ci.yml +47 -14
  3. package/AGENTS.md +19 -3
  4. package/CHANGELOG.md +42 -0
  5. package/README.md +118 -63
  6. package/agents/README.md +13 -10
  7. package/agents/ralph-plan/agent.md +1 -1
  8. package/agents/ralph-plan.agent.md +1 -1
  9. package/bin/agent-cortex.mjs +29 -8
  10. package/bin/installers/claude.mjs +569 -105
  11. package/bin/installers/copilot.mjs +22 -12
  12. package/bin/installers/pi.mjs +37 -34
  13. package/docs/claude-hooks.md +3 -3
  14. package/docs/ideas/extension-manifests.md +75 -0
  15. package/docs/ideas/record-ideas-as-beads.md +115 -0
  16. package/docs/ideas/subagent-visibility.md +72 -0
  17. package/docs/ideas/task-session-context.md +89 -0
  18. package/docs/research/skill-design-research.md +4 -4
  19. package/docs/research/skill-improvements-analysis.md +1 -1
  20. package/docs/skills/skill-anatomy.md +38 -2
  21. package/docs/technical-direction/migration-execution-labels.md +132 -0
  22. package/extensions/agent-modes/README.md +3 -2
  23. package/extensions/agent-modes/discover.test.ts +30 -7
  24. package/extensions/agent-modes/discover.ts +1 -1
  25. package/extensions/skill-stats/index.test.ts +3 -2
  26. package/lib/cli.mjs +24 -6
  27. package/package.json +4 -4
  28. package/plugin.json +1 -1
  29. package/pnpm-workspace.yaml +1 -1
  30. package/scripts/build-copilot-agents.mjs +1 -1
  31. package/scripts/check-no-sync.mjs +49 -0
  32. package/scripts/lib/compose-agent.mjs +32 -14
  33. package/skills/engineering/design-an-interface/SKILL.md +78 -58
  34. package/skills/engineering/grill-with-docs/REFERENCE.md +78 -0
  35. package/skills/engineering/grill-with-docs/SKILL.md +66 -63
  36. package/skills/engineering/improve-codebase-architecture/SKILL.md +66 -48
  37. package/skills/engineering/technical-direction/FORMAT.md +38 -0
  38. package/skills/engineering/technical-direction/SKILL.md +70 -77
  39. package/skills/planning/classify-bead/SKILL.md +59 -35
  40. package/skills/planning/create-task/REFERENCE.md +40 -0
  41. package/skills/planning/create-task/SKILL.md +70 -66
  42. package/skills/planning/create-task/scripts/create-chores.ts +6 -1
  43. package/skills/planning/create-task/scripts/node_modules/.bin/tsc +21 -0
  44. package/skills/planning/create-task/scripts/node_modules/.bin/tsserver +21 -0
  45. package/skills/planning/create-task/scripts/node_modules/.bin/tsx +21 -0
  46. package/skills/planning/prd-to-tasks/REFERENCE.md +66 -0
  47. package/skills/planning/prd-to-tasks/SKILL.md +86 -170
  48. package/skills/planning/record-idea/FORMAT.md +44 -0
  49. package/skills/planning/record-idea/SKILL.md +70 -53
  50. package/skills/planning/request-refactor-plan/FORMAT.md +45 -0
  51. package/skills/planning/request-refactor-plan/SKILL.md +57 -46
  52. package/skills/planning/write-a-prd/FORMAT.md +54 -0
  53. package/skills/planning/write-a-prd/SKILL.md +49 -48
  54. package/skills/planning/write-a-ticket/SKILL.md +68 -53
  55. package/skills/productivity/handoff/SKILL.md +12 -0
  56. package/skills/productivity/init-beads/SKILL.md +48 -40
  57. package/skills/productivity/validate-agent-dir/scripts/node_modules/.bin/tsc +21 -0
  58. package/skills/productivity/validate-agent-dir/scripts/node_modules/.bin/tsserver +21 -0
  59. package/skills/productivity/validate-agent-dir/scripts/node_modules/.bin/tsx +21 -0
  60. package/skills/productivity/write-a-skill/SKILL.md +2 -1
  61. package/skills/review/maintain-agent-docs/SKILL.md +71 -51
  62. package/skills/workflow/hitl-collab/SKILL.md +86 -17
  63. package/skills/workflow/ralph/REFERENCE.md +22 -17
  64. package/skills/workflow/ralph/SKILL.md +88 -74
  65. package/skills/workflow/run-pipeline-stage/REFERENCE.md +22 -0
  66. package/skills/workflow/run-pipeline-stage/SKILL.md +91 -93
  67. package/skills/workflow/run-pipeline-stage/scripts/generate-progress.test.ts +6 -107
  68. package/skills/workflow/run-pipeline-stage/scripts/node_modules/.bin/tsc +21 -0
  69. package/skills/workflow/run-pipeline-stage/scripts/node_modules/.bin/tsserver +21 -0
  70. package/skills/workflow/run-pipeline-stage/scripts/node_modules/.bin/tsx +21 -0
  71. package/test/claude-installer.test.mjs +308 -0
  72. package/test/cli.test.mjs +40 -30
  73. package/test/copilot-installer.test.mjs +92 -82
  74. package/test/helpers/fake-claude.mjs +152 -0
  75. package/test/installer.test.mjs +309 -57
  76. package/test/pi-installer.test.mjs +115 -99
  77. package/token-map.README.md +21 -10
  78. package/token-map.json +7 -6
  79. package/.claude-plugin/marketplace.json +0 -16
  80. package/claude/.claude-plugin/plugin.json +0 -11
  81. package/claude/agents/plan.md +0 -58
  82. package/claude/agents/ralph-plan.md +0 -121
  83. package/claude/agents/ralph.md +0 -193
  84. package/claude/agents/strategy.md +0 -111
  85. package/claude/hooks/scripts/notify.mjs +0 -54
  86. package/claude/hooks.json +0 -38
  87. /package/{claude → claude-extras}/.mcp.json +0 -0
  88. /package/{claude → claude-extras}/scripts/statusline-command.sh +0 -0
@@ -1,94 +1,114 @@
1
1
  ---
2
2
  name: design-an-interface
3
- description: Generate multiple radically different interface designs for a module using parallel sub-agents. Use when user wants to design an API, explore interface options, compare module shapes, or mentions "design it twice".
3
+ description: "Generate multiple radically different interface designs for a module via parallel sub-agents, then compare and synthesize. Use when designing an API, exploring interface options, or \"design it twice\"."
4
4
  ---
5
5
 
6
6
  # Design an Interface
7
7
 
8
- Based on "Design It Twice" from "A Philosophy of Software Design": your first idea is unlikely to be the best. Generate multiple radically different designs, then compare.
8
+ ## When to use
9
9
 
10
- ## Workflow
11
-
12
- ### 1. Gather Requirements
10
+ - The user wants to design an API, module boundary, or public interface.
11
+ - The user asks to explore interface options or compare module shapes.
12
+ - The user mentions "design it twice" or says the first idea is unlikely to be the best.
13
+ - An interface design step needs a guided parallel exploration — `improve-codebase-architecture` invokes this skill for its multi-design step.
13
14
 
14
- Before designing, understand:
15
+ ## When NOT to use
15
16
 
16
- - [ ] What problem does this module solve?
17
- - [ ] Who are the callers? (other modules, external users, tests)
18
- - [ ] What are the key operations?
19
- - [ ] Any constraints? (performance, compatibility, existing patterns)
20
- - [ ] What should be hidden inside vs exposed?
17
+ - The user wants a single justified recommendation with tradeoff analysis — use `technical-direction` instead.
18
+ - The module's shape is already fixed by an upstream contract or framework, so exploring alternatives is wasted effort.
19
+ - The question is about implementation strategy, not interface shape.
21
20
 
22
- Ask: "What does this module need to do? Who will use it?"
21
+ ## Philosophy / rationale
23
22
 
24
- ### 2. Generate Designs (Parallel Sub-Agents)
23
+ - **Your first idea is unlikely to be the best.** "Design It Twice" (John Ousterhout, *A Philosophy of Software Design*) holds that the first design is almost never the strongest. Generating multiple radically different candidates forces the comparison that finds the best shape.
24
+ - **Contrast, not volume, creates insight.** Similar designs from parallel agents only confirm one idea. Each agent is assigned a different constraint so divergence is guaranteed by construction.
25
+ - **Interface shape is the whole problem here.** The process stops at the interface — implementation effort is irrelevant to the comparison, because a good interface usually makes the implementation easier, not harder. Judging designs by implementation cost rewards shallow modules.
25
26
 
26
- Spawn 3+ sub-agents simultaneously using {{TOOL:task}}. Each must produce a **radically different** approach.
27
+ ## Workflow
27
28
 
28
- ```
29
- Prompt template for each sub-agent:
29
+ 1. **Gather requirements.** Before designing, pin down:
30
+ - What problem does the module solve?
31
+ - Who are the callers (other modules, external users, tests)?
32
+ - What are the key operations?
33
+ - What constraints apply (performance, compatibility, existing patterns)?
34
+ - What should be hidden inside vs exposed?
30
35
 
31
- Design an interface for: [module description]
36
+ Ask: "What does this module need to do? Who will use it?"
32
37
 
33
- Requirements: [gathered requirements]
38
+ 2. **Generate designs with parallel sub-agents.** Spawn 3+ sub-agents simultaneously with {{TOOL:task}}, each assigned a **different** constraint to guarantee radical difference. Use this prompt template per agent:
34
39
 
35
- Constraints for this design: [assign a different constraint to each agent]
36
- - Agent 1: "Minimize method count - aim for 1-3 methods max"
37
- - Agent 2: "Maximize flexibility - support many use cases"
38
- - Agent 3: "Optimize for the most common case"
39
- - Agent 4: "Take inspiration from [specific paradigm/library]"
40
+ ```
41
+ Design an interface for: [module description]
40
42
 
41
- Output format:
42
- 1. Interface signature (types/methods)
43
- 2. Usage example (how caller uses it)
44
- 3. What this design hides internally
45
- 4. Trade-offs of this approach
46
- ```
43
+ Requirements: [gathered requirements]
47
44
 
48
- ### 3. Present Designs
45
+ Constraints for this design: [assign a different constraint to each agent]
46
+ - Agent 1: "Minimize method count — aim for 1-3 methods max"
47
+ - Agent 2: "Maximize flexibility — support many use cases"
48
+ - Agent 3: "Optimize for the most common case"
49
+ - Agent 4: "Take inspiration from [specific paradigm/library]"
49
50
 
50
- Show each design with:
51
+ Output format:
52
+ 1. Interface signature (types/methods)
53
+ 2. Usage example (how a caller uses it)
54
+ 3. What this design hides internally
55
+ 4. Trade-offs of this approach
56
+ ```
51
57
 
52
- 1. **Interface signature** - types, methods, params
53
- 2. **Usage examples** - how callers actually use it in practice
54
- 3. **What it hides** - complexity kept internal
58
+ Collect each agent's output with {{TOOL:read_agent}} when it finishes.
55
59
 
56
- Present designs sequentially so user can absorb each approach before comparison.
60
+ 3. **Present designs.** Show each design sequentially — signature, usage examples, what it hides — so the user absorbs each approach before any comparison happens.
57
61
 
58
- ### 4. Compare Designs
62
+ 4. **Compare designs.** Compare in prose, not tables, on:
63
+ - **Interface simplicity** — fewer methods, simpler params
64
+ - **General-purpose vs specialized** — flexibility vs focus
65
+ - **Implementation efficiency** — does the shape allow efficient internals?
66
+ - **Depth** — small interface hiding significant complexity (deep module, good) vs large interface with thin implementation (shallow module, avoid)
67
+ - **Ease of correct use** vs ease of misuse
59
68
 
60
- After showing all designs, compare them on:
69
+ Highlight where the designs diverge most — that divergence is where the decision lives.
61
70
 
62
- - **Interface simplicity**: fewer methods, simpler params
63
- - **General-purpose vs specialized**: flexibility vs focus
64
- - **Implementation efficiency**: does shape allow efficient internals?
65
- - **Depth**: small interface hiding significant complexity (good) vs large interface with thin implementation (bad)
66
- - **Ease of correct use** vs **ease of misuse**
71
+ 5. **Synthesize.** Ask: "Which design best fits your primary use case?" and "What elements from other designs are worth incorporating?" Often the best design combines insights from multiple options.
67
72
 
68
- Discuss trade-offs in prose, not tables. Highlight where designs diverge most.
73
+ ## Red Flags
69
74
 
70
- ### 5. Synthesize
75
+ - **Sub-agents converging on similar designs** — if two agents produce near-identical shapes, re-run with sharper, more opposed constraints. Similarity means the contrast step lost its value.
76
+ - **Skipping comparison** — jumping from presentation to a favorite design discards the whole point of exploring alternatives.
77
+ - **Sliding into implementation** — this process concerns interface shape only. Implementation details belong in a follow-up task.
78
+ - **Judging designs by implementation effort** — a design that looks harder to build may still be the deeper, better interface.
71
79
 
72
- Often the best design combines insights from multiple options. Ask:
80
+ ## Common Rationalizations
73
81
 
74
- - "Which design best fits your primary use case?"
75
- - "Any elements from other designs worth incorporating?"
82
+ | Rationalization | Rebuttal |
83
+ |---|---|
84
+ | "My first design is probably fine" | That is exactly the assumption "design it twice" exists to break. Generate the alternatives before committing. |
85
+ | "The agents will just produce similar things, so why bother" | Similarity is a failure mode you control — assign opposed constraints so divergence is guaranteed by construction. |
86
+ | "I can compare these myself, no need to present each one" | Sequential presentation forces you to articulate what each design actually is before judging it, which is where the insight comes from. |
76
87
 
77
- ## Evaluation Criteria
88
+ ## Phase-gate checklists
78
89
 
79
- From "A Philosophy of Software Design":
90
+ - [ ] Phase 1 complete: requirements gathered and constraints listed
91
+ - [ ] Phase 2 complete: 3+ designs returned, each constrained differently
92
+ - [ ] Phase 3 complete: all designs presented sequentially
93
+ - [ ] Phase 4 complete: comparison shared and divergence highlighted
94
+ - [ ] Phase 5 complete: candidate synthesized with user input
80
95
 
81
- **Interface simplicity**: Fewer methods, simpler params = easier to learn and use correctly.
96
+ ## Cross-skill references
82
97
 
83
- **General-purpose**: Can handle future use cases without changes. But beware over-generalization.
98
+ - `improve-codebase-architecture` invokes this skill for its multi-design step (step 5 of its workflow).
99
+ - Run `grill-with-docs` when the module's domain terminology is unsettled — design names should match the ubiquitous language.
84
100
 
85
- **Implementation efficiency**: Does interface shape allow efficient implementation? Or force awkward internals?
101
+ ## Examples
86
102
 
87
- **Depth**: Small interface hiding significant complexity = deep module (good). Large interface with thin implementation = shallow module (avoid).
103
+ Input: "Design the interface for a rate limiter module"
104
+ Output: four radically different interface sketches (minimal-method, flexible, common-case-optimized, paradigm-inspired), presented sequentially, compared on simplicity, depth, and trade-offs, then synthesized into one recommended shape with the user.
88
105
 
89
- ## Anti-Patterns
106
+ ## Verification checklist
90
107
 
91
- - Don't let sub-agents produce similar designs - enforce radical difference
92
- - Don't skip comparison - the value is in contrast
93
- - Don't implement - this is purely about interface shape
94
- - Don't evaluate based on implementation effort
108
+ - [ ] Requirements captured before any sub-agent is spawned
109
+ - [ ] At least 3 sub-agents spawned, each with a distinct constraint
110
+ - [ ] Each design reports signature, usage example, hidden complexity, and trade-offs
111
+ - [ ] Designs presented sequentially before any comparison
112
+ - [ ] Comparison covers simplicity, generality, efficiency, depth, and ease of correct use
113
+ - [ ] Synthesis asks the user which design fits their primary use case
114
+ - [ ] No implementation work performed — interface shape only
@@ -0,0 +1,78 @@
1
+ # Grill-with-docs reference
2
+
3
+ Rarely-needed detail the workflow points to when you must create or update project documents.
4
+
5
+ ## Finding the domain model
6
+
7
+ ### Single-context repos
8
+
9
+ ```
10
+ /
11
+ ├── CONTEXT.md
12
+ ├── docs/
13
+ │ └── adr/
14
+ │ ├── 0001-event-sourced-orders.md
15
+ │ └── 0002-postgres-for-write-model.md
16
+ └── src/
17
+ ```
18
+
19
+ ### Multi-context repos
20
+
21
+ A `CONTEXT-MAP.md` at the root points to where each context lives:
22
+
23
+ ```
24
+ /
25
+ ├── CONTEXT-MAP.md
26
+ ├── docs/
27
+ │ └── adr/ ← system-wide decisions
28
+ ├── src/
29
+ │ ├── ordering/
30
+ │ │ ├── CONTEXT.md
31
+ │ │ └── docs/adr/ ← context-specific decisions
32
+ │ └── billing/
33
+ │ ├── CONTEXT.md
34
+ │ └── docs/adr/
35
+ ```
36
+
37
+ Create files lazily — only when you have something to write. If no `CONTEXT.md` exists, create one when the first term resolves. If no `docs/adr/` exists, create it when the first ADR is needed.
38
+
39
+ ## CONTEXT.md entry format
40
+
41
+ One `# term` heading per entry with a plain-prose definition and cross-links to related terms:
42
+
43
+ ```md
44
+ # cancellation
45
+ An order may be cancelled only before fulfilment begins. See refund for the
46
+ post-fulfilment reversal path.
47
+ ```
48
+
49
+ Rules:
50
+
51
+ - Glossary only — no implementation details, no specs, no scratch notes.
52
+ - Prefer one concise definition over long paragraphs.
53
+ - Cross-link related terms so the vocabulary is navigable.
54
+
55
+ ## ADR format
56
+
57
+ One file per decision in `docs/adr/`, zero-padded sequence number plus kebab-case title:
58
+
59
+ ```
60
+ 0003-cancel-before-fulfilment-only.md
61
+ ```
62
+
63
+ Structure:
64
+
65
+ ```md
66
+ # Title
67
+
68
+ ## Context
69
+ What problem forced the decision and why the question arose.
70
+
71
+ ## Decision
72
+ The choice, stated precisely.
73
+
74
+ ## Consequences
75
+ What becomes easier or harder as a result; what a future reader must know.
76
+ ```
77
+
78
+ Offer an ADR only when all three hold — hard to reverse, surprising without context, real trade-off. If any is missing, skip it.
@@ -1,88 +1,91 @@
1
1
  ---
2
2
  name: grill-with-docs
3
- description: Grilling session that challenges your plan against the existing domain model, sharpens terminology, and updates documentation (CONTEXT.md, ADRs) inline as decisions crystallise. Use when user wants to stress-test a plan against their project's language and documented decisions.
3
+ description: "Grilling session that challenges your plan against the existing domain model, sharpens terminology, and updates documentation (CONTEXT.md, ADRs) inline as decisions crystallise. Use when the user wants to stress-test a plan against their project's language and documented decisions: \"grill my plan\", \"check this against our docs\"."
4
4
  ---
5
5
 
6
- <what-to-do>
6
+ # Grill With Docs
7
7
 
8
- Interview me relentlessly about every aspect of this plan until we reach a shared understanding. Walk down each branch of the design tree, resolving dependencies between decisions one-by-one. For each question, provide your recommended answer.
8
+ ## When to use
9
9
 
10
- Ask the questions one at a time, waiting for feedback on each question before continuing.
10
+ - The user wants to stress-test a plan against the project's existing language: "grill my plan", "grill me on this design".
11
+ - Domain terms are fuzzy or drifting and you need to pin them against `CONTEXT.md`.
12
+ - A decision needs recording as an ADR before the design moves on.
13
+ - Invoked by `ralph-plan` when the domain language is unclear or inconsistent.
11
14
 
12
- If a question can be answered by exploring the codebase, explore the codebase instead.
15
+ ## When NOT to use
13
16
 
14
- </what-to-do>
17
+ - Grilling a plan with no documentation dimension — use `grill-me` for a pure design interview.
18
+ - Deciding architecture or technology trade-offs — use `technical-direction` for a justified recommendation.
19
+ - Writing project docs without an interview; this skill extracts language from the user, it does not generate it.
15
20
 
16
- <supporting-info>
21
+ ## Workflow
17
22
 
18
- ## Domain awareness
23
+ 1. **Load the domain model.** Locate and read `CONTEXT.md` (single context) or `CONTEXT-MAP.md` (multi-context; the map points to each context's glossary and `docs/adr/`). Read existing ADRs so you question from the project's actual vocabulary. If neither file exists, you are starting a fresh glossary.
24
+ 2. **Grill one question at a time.** State the decision branch, give your recommended answer, and wait for feedback before continuing. If a question can be answered by exploring the codebase, explore instead of asking.
25
+ 3. **Challenge against the glossary.** When a term conflicts with `CONTEXT.md`, call it out immediately: "Your glossary defines 'cancellation' as X, but you seem to mean Y — which is it?" When the user uses vague or overloaded terms, propose a precise canonical term.
26
+ 4. **Stress-test with concrete scenarios.** Probe domain relationships with invented edge cases that force precision about concept boundaries.
27
+ 5. **Cross-reference with code.** When the user states how something works, check whether the code agrees. Surface contradictions the moment you find them.
28
+ 6. **Update `CONTEXT.md` inline.** When a term resolves, write the entry right there — do not batch. Keep it a pure glossary: no implementation details, no specs, no scratch notes. Entry format and file-discovery rules live in `REFERENCE.md`.
29
+ 7. **Offer ADRs sparingly.** Propose an ADR only when all three hold: hard to reverse, surprising without context, and the result of a real trade-off. If any is missing, skip it. ADR format lives in `REFERENCE.md`.
30
+ 8. **Close when shared understanding is reached.** Confirm every design-tree branch is resolved or explicitly deferred, and that the glossary diff captures the session's new language.
19
31
 
20
- During codebase exploration, also look for existing documentation:
32
+ ## Red Flags
21
33
 
22
- ### File structure
34
+ - **Batching questions** — asking several at once lets the user answer the easy ones while the hard branch dies silently.
35
+ - **Drifting into generic design Q&A** — every question must anchor in the domain model, not general software opinion.
36
+ - **Deferring `CONTEXT.md` writes** — "I'll write it up later" loses the precision of the moment; terms resolved in context get reinterpreted from memory.
37
+ - **Stuffing implementation detail into `CONTEXT.md`** — it is a glossary; specs and scratch notes belong elsewhere.
38
+ - **Offering ADRs on autopilot** — an ADR for an easily-reversed choice bloats the log and buries the real decisions.
23
39
 
24
- Most repos have a single context:
40
+ ## Common Rationalizations
25
41
 
26
- ```
27
- /
28
- ├── CONTEXT.md
29
- ├── docs/
30
- │ └── adr/
31
- │ ├── 0001-event-sourced-orders.md
32
- │ └── 0002-postgres-for-write-model.md
33
- └── src/
34
- ```
35
-
36
- If a `CONTEXT-MAP.md` exists at the root, the repo has multiple contexts. The map points to where each one lives:
37
-
38
- ```
39
- /
40
- ├── CONTEXT-MAP.md
41
- ├── docs/
42
- │ └── adr/ ← system-wide decisions
43
- ├── src/
44
- │ ├── ordering/
45
- │ │ ├── CONTEXT.md
46
- │ │ └── docs/adr/ ← context-specific decisions
47
- │ └── billing/
48
- │ ├── CONTEXT.md
49
- │ └── docs/adr/
50
- ```
51
-
52
- Create files lazily — only when you have something to write. If no `CONTEXT.md` exists, create one when the first term is resolved. If no `docs/adr/` exists, create it when the first ADR is needed.
53
-
54
- ## During the session
55
-
56
- ### Challenge against the glossary
42
+ | Rationalization | Rebuttal |
43
+ |---|---|
44
+ | "I'll ask three questions at once to save a round trip" | Branches depend on each other's answers; batching forces guesswork. |
45
+ | "We both know what this term means — no need to write it" | If you won't write it down, it isn't resolved; unwritten terms get relitigated. |
46
+ | "This decision feels important, let me write an ADR" | Only hard-to-reverse, surprising, real-trade-off decisions earn an ADR. |
47
+ | "The code contradicts you, but I'll note it later" | The contradiction changes the next answer — surface it now. |
57
48
 
58
- When the user uses a term that conflicts with the existing language in `CONTEXT.md`, call it out immediately. "Your glossary defines 'cancellation' as X, but you seem to mean Y — which is it?"
49
+ ## Philosophy / rationale
59
50
 
60
- ### Sharpen fuzzy language
51
+ - **One question at a time, with a recommended answer** — every exchange settles a branch instead of opening several, so shared understanding accumulates.
52
+ - **Capture inline, not batched** — decisions recorded in context are precise; decisions reconstructed from memory drift.
53
+ - **`CONTEXT.md` is a glossary and nothing else** — the vocabulary stays stable while the design churns around it.
54
+ - **ADRs are rare** — the three criteria keep the ADR log a history of decisions, not a diary.
61
55
 
62
- When the user uses vague or overloaded terms, propose a precise canonical term. "You're saying 'account' — do you mean the Customer or the User? Those are different things."
56
+ ## Cross-skill references
63
57
 
64
- ### Discuss concrete scenarios
58
+ | When you need… | Use |
59
+ |---|---|
60
+ | A design interview without touching project docs | `grill-me` |
61
+ | A justified recommendation on architecture or technology | `technical-direction` |
65
62
 
66
- When domain relationships are being discussed, stress-test them with specific scenarios. Invent scenarios that probe edge cases and force the user to be precise about the boundaries between concepts.
63
+ ## Examples
67
64
 
68
- ### Cross-reference with code
65
+ **Sharpening a fuzzy term**
69
66
 
70
- When the user states how something works, check whether the code agrees. If you find a contradiction, surface it: "Your code cancels entire Orders, but you just said partial cancellation is possible — which is right?"
71
-
72
- ### Update CONTEXT.md inline
73
-
74
- When a term is resolved, update `CONTEXT.md` right there. Don't batch these up — capture them as they happen. Use the format in [CONTEXT-FORMAT.md](./CONTEXT-FORMAT.md).
75
-
76
- `CONTEXT.md` should be totally devoid of implementation details. Do not treat `CONTEXT.md` as a spec, a scratch pad, or a repository for implementation decisions. It is a glossary and nothing else.
77
-
78
- ### Offer ADRs sparingly
67
+ ```
68
+ User: "So cancelled orders can still ship."
69
+ You: "CONTEXT.md defines cancellation as 'void before fulfilment begins'.
70
+ What you describe is reversing after shipping — that's a refund. Which is it?"
71
+ User: "A refund."
72
+ ```
79
73
 
80
- Only offer to create an ADR when all three are true:
74
+ Entry appended to CONTEXT.md the moment it resolves:
81
75
 
82
- 1. **Hard to reverse** — the cost of changing your mind later is meaningful
83
- 2. **Surprising without context** — a future reader will wonder "why did they do it this way?"
84
- 3. **The result of a real trade-off** — there were genuine alternatives and you picked one for specific reasons
76
+ ```
77
+ # refund
78
+ Reversal of an order after fulfilment has begun. Distinct from cancellation,
79
+ which voids an order before fulfilment. See cancellation.
80
+ ```
85
81
 
86
- If any of the three is missing, skip the ADR. Use the format in [ADR-FORMAT.md](./ADR-FORMAT.md).
82
+ ## Verification checklist
87
83
 
88
- </supporting-info>
84
+ - [ ] Questions asked one at a time, each with a recommended answer
85
+ - [ ] Every question answerable by code was explored in the codebase instead
86
+ - [ ] Each resolved term written to `CONTEXT.md` during the session — none batched at the end
87
+ - [ ] `CONTEXT.md` holds only glossary entries — no implementation detail, specs, or scratch notes
88
+ - [ ] Terminology conflicts and vague terms called out the moment they appeared
89
+ - [ ] Claims cross-referenced against code; contradictions surfaced
90
+ - [ ] ADRs offered only when all three criteria held (offering none is a valid outcome)
91
+ - [ ] All design-tree branches resolved or explicitly deferred before closing
@@ -1,81 +1,99 @@
1
1
  ---
2
2
  name: improve-codebase-architecture
3
- description: Explore a codebase to find opportunities for architectural improvement, focusing on making the codebase more testable by deepening shallow modules. Use when user wants to improve architecture, find refactoring opportunities, consolidate tightly-coupled modules, or make a codebase more AI-navigable.
3
+ description: Explore a codebase to surface architectural friction and turn it into module-deepening refactors that improve testability and AI-navigability. Use when the user wants to improve the architecture, find refactoring opportunities, consolidate tightly-coupled modules, or says a codebase is hard to navigate.
4
4
  ---
5
5
 
6
6
  # Improve Codebase Architecture
7
7
 
8
- Explore a codebase like an AI would, surface architectural friction, discover opportunities for improving testability, and propose module-deepening refactors as beads.
8
+ Explore a codebase the way an AI would, surface where understanding requires bouncing between many small files, and propose module-deepening refactors as executable beads.
9
9
 
10
- A **deep module** (John Ousterhout, "A Philosophy of Software Design") has a small interface hiding a large implementation. Deep modules are more testable, more AI-navigable, and let you test at the boundary instead of inside.
10
+ A **deep module** (John Ousterhout, "A Philosophy of Software Design") has a small interface hiding a large implementation. Deep modules are more testable, more AI-navigable, and testable at the boundary instead of inside the seams.
11
11
 
12
- ## Process
12
+ ## When to use
13
13
 
14
- ### 1. Explore the codebase
14
+ - The user wants to improve the architecture or find refactoring opportunities.
15
+ - The user asks to consolidate tightly-coupled modules or "make this more testable".
16
+ - The user says a codebase is "hard to navigate" or hard for AI to work with.
15
17
 
16
- Explore the codebase using your available tools ({{TOOL:bash}}, {{TOOL:rg}}, {{TOOL:view}}, {{TOOL:glob}}). Navigate organically and note where you experience friction:
18
+ ## When NOT to use
17
19
 
18
- - Where does understanding one concept require bouncing between many small files?
19
- - Where are modules so shallow that the interface is nearly as complex as the implementation?
20
- - Where have pure functions been extracted just for testability, but the real bugs hide in how they're called?
21
- - Where do tightly-coupled modules create integration risk in the seams between them?
22
- - Which parts of the codebase are untested, or hard to test?
20
+ - The refactor target is decided and only an implementation plan is missing — run `request-refactor-plan` instead.
21
+ - The task is comparing two specific options with trade-offs — run `technical-direction` instead.
22
+ - The user wants interface shapes for one known module — run `design-an-interface` instead.
23
+ - The work is a new feature needing scoping — run `plan` or `write-a-prd` instead.
23
24
 
24
- The friction you encounter IS the signal.
25
+ ## Workflow
25
26
 
26
- ### 2. Present candidates
27
+ 1. **Explore the codebase.** Navigate with {{TOOL:bash}}, {{TOOL:rg}}, {{TOOL:view}}, and {{TOOL:glob}}, and note where you experience friction: concepts spread across many small files, interfaces nearly as complex as their implementations, pure functions extracted for testability while bugs hide in their call sites, tight coupling creating integration risk, or untested hard-to-test areas. The friction you encounter is the signal — record it as you go.
27
28
 
28
- Present a numbered list of deepening opportunities. For each candidate, show:
29
+ 2. **Present candidates.** Give a numbered list of deepening opportunities. For each, show the cluster of modules involved, why they are coupled (shared types, call patterns, co-ownership of a concept), the dependency category (see [REFERENCE.md](REFERENCE.md)), and the test impact. Do not propose interfaces yet — ask "Which of these would you like to explore?"
29
30
 
30
- - **Cluster**: Which modules/concepts are involved
31
- - **Why they're coupled**: Shared types, call patterns, co-ownership of a concept
32
- - **Dependency category**: See [REFERENCE.md](REFERENCE.md) for the four categories
33
- - **Test impact**: What existing tests would be replaced by boundary tests
31
+ 3. **User picks a candidate.**
34
32
 
35
- Do NOT propose interfaces yet. Ask the user: "Which of these would you like to explore?"
33
+ 4. **Frame the problem space.** Before designing anything, write a user-facing frame for the chosen candidate: the constraints any new interface must satisfy, the dependencies it must rely on, and a rough illustrative code sketch. A sketch is not a proposal — it grounds the constraints. Show the frame and proceed immediately; the user reads it while you design.
36
34
 
37
- ### 3. User picks a candidate
35
+ 5. **Design multiple interfaces.** Cycle through radically different constraints, writing each design out fully before the next:
38
36
 
39
- ### 4. Frame the problem space
37
+ 1. **Minimal** — aim for 1-3 entry points; what complexity hides behind a small surface?
38
+ 2. **Flexible** — open for future use cases and extension.
39
+ 3. **Caller-optimised** — make the most common calling pattern trivial.
40
+ 4. **Ports & adapters** (if cross-boundary deps) — isolate side effects from pure logic.
40
41
 
41
- Before spawning sub-agents, write a user-facing explanation of the problem space for the chosen candidate:
42
+ For each design, output the interface signature, a usage example, the complexity it hides, the dependency strategy (see [REFERENCE.md](REFERENCE.md)), and its trade-offs. Present designs sequentially, then compare them in prose and give your own recommendation — propose a hybrid where elements combine well. The user wants a strong read, not a menu.
42
43
 
43
- - The constraints any new interface would need to satisfy
44
- - The dependencies it would need to rely on
45
- - A rough illustrative code sketch to make the constraints concrete — this is not a proposal, just a way to ground the constraints
44
+ 6. **User picks an interface** (or accepts the recommendation).
46
45
 
47
- Show this to the user, then immediately proceed to Step 5. The user reads and thinks about the problem while the sub-agents work in parallel.
46
+ 7. **Create the refactor bead.** Run the `create-task` skill with a concise title, the description from the template in [REFERENCE.md](REFERENCE.md), and priority P2. Always use `create-task` — never `bd create` directly — because it classifies the bead and expands AFK work into pipeline stages ralph can execute. Do not ask the user to review before creating; share the bead ID.
48
47
 
49
- ### 5. Design multiple interfaces
48
+ ## Red Flags
50
49
 
51
- Design multiple radically different interfaces for the deepened module yourself, cycling through different constraints. For each design, write out the complete interface and evaluate it before moving to the next:
50
+ - Red flag: proposing an interface during candidate presentation — it biases which problem space the user picks.
51
+ - Red flag: skipping the problem-space frame to save a step — designs without stated constraints drift.
52
+ - Red flag: designing a single interface — the first design is rarely the strongest ("Design It Twice").
53
+ - Red flag: filing the bead with `bd create` instead of `create-task` — the pipeline expansion is skipped.
54
+ - Red flag: judging designs by implementation effort — a deeper interface often looks harder to build.
52
55
 
53
- 1. **Minimal interface** — aim for 1-3 entry points max. What complexity can you hide behind a small surface area?
54
- 2. **Flexible interface** — support many use cases and extension. How do you make it open for future needs?
55
- 3. **Caller-optimised** — make the most common calling pattern trivial. What does the primary caller look like?
56
- 4. **Ports & adapters** (if cross-boundary deps) — isolate side effects from pure logic.
56
+ ## Common Rationalizations
57
57
 
58
- For each design, output:
58
+ | Rationalization | Rebuttal |
59
+ |---|---|
60
+ | "I already know the best interface" | The first design is rarely the best. Generating alternatives is where the comparison insight comes from. |
61
+ | "The candidates are obvious — list them quickly" | The presentation is what lets the user pick deliberately; short-circuiting it forces a guess. |
62
+ | "The problem space is clear enough — skip the frame" | An unframed design session produces interfaces that satisfy imagined constraints. |
63
+ | "It's one task — `bd create` is fine" | `create-task` classifies the bead and expands pipeline stages; bypassing it strands the work for ralph. |
59
64
 
60
- 1. Interface signature (types, methods, params)
61
- 2. Usage example showing how callers use it
62
- 3. What complexity it hides internally
63
- 4. Dependency strategy (how deps are handled — see [REFERENCE.md](REFERENCE.md))
64
- 5. Trade-offs
65
+ ## Philosophy / rationale
65
66
 
66
- The `design-an-interface` skill provides a structured approach for this step — invoke it if you want a guided parallel-design flow with sub-agents.
67
+ - **Deep modules beat shallow ones.** A small interface hiding real complexity is easier to learn, test, and navigate; a shallow module forces callers to know as much as the implementation does.
68
+ - **An AI's navigation friction is the signal.** Wherever exploration requires bouncing between files, a missing seam or a shallow module is hiding — the explorer's pain maps directly to where a deep module is needed.
69
+ - **Replace, don't layer tests.** Once boundary tests exist at the deepened interface, the old shallow-module tests are waste — tests should assert observable outcomes through the public interface, not internal state.
70
+ - **Candidate-first, interface-later.** Interfaces proposed before the user picks a problem space pre-commit the exploration to a shape they did not choose.
67
71
 
68
- Present designs sequentially, then compare them in prose.
72
+ ## Phase-gate checklists
69
73
 
70
- After comparing, give your own recommendation: which design you think is strongest and why. If elements from different designs would combine well, propose a hybrid. Be opinionated — the user wants a strong read, not just a menu.
74
+ - [ ] Phase 1 complete: exploration done and candidates presented without proposing interfaces
75
+ - [ ] Phase 2 complete: problem space framed and shown to the user before any design work
76
+ - [ ] Phase 3 complete: at least two radically different designs presented and compared, with a recommendation given
77
+ - [ ] Phase 4 complete: refactor bead created via `create-task` and the bead ID reported
71
78
 
72
- ### 6. User picks an interface (or accepts recommendation)
79
+ ## Cross-skill references
73
80
 
74
- ### 7. Create refactor bead
81
+ - Run `design-an-interface` at step 5 for a guided parallel sub-agent design flow.
82
+ - Run `create-task` at step 7 to file the refactor bead.
83
+ - Run `grill-with-docs` when the deepened module's terminology is unsettled — interface names should match the ubiquitous language.
75
84
 
76
- Invoke the `create-task` skill, passing:
77
- - **title**: a concise name for the refactor
78
- - **description**: the bead body using the template in [REFERENCE.md](REFERENCE.md)
79
- - **priority**: P2
85
+ ## Examples
80
86
 
81
- **Always use `create-task`** — never call `bd create` directly for tasks. `create-task` classifies the bead and expands AFK tasks into pipeline stage children that ralph can execute. Do NOT ask the user to review before creating — just create it and share the bead ID.
87
+ Input: "This codebase is hard to navigate — can you make it more testable?"
88
+ Output: numbered deepening candidates (cluster, coupling, dependency category, test impact) → chosen candidate → problem-space frame → at least two interface designs with a recommendation → a P2 refactor bead ID from `create-task`, with the bead description following the template in [REFERENCE.md](REFERENCE.md).
89
+
90
+ ## Verification checklist
91
+
92
+ - [ ] Friction notes recorded during exploration
93
+ - [ ] Candidates presented with cluster, coupling, dependency category, and test impact — no interfaces proposed
94
+ - [ ] Problem-space frame shown to the user before any design work
95
+ - [ ] At least two radically different designs, each with signature, usage example, hidden complexity, dependency strategy, and trade-offs
96
+ - [ ] Recommendation given in prose, with a hybrid proposed where elements combine well
97
+ - [ ] Refactor bead created via `create-task` at P2 using the REFERENCE.md description template
98
+ - [ ] Bead ID reported and no review gate imposed before creation
99
+ - [ ] No unrelated areas explored or refactors proposed outside the chosen candidate
@@ -0,0 +1,38 @@
1
+ # Decision Memo Format
2
+
3
+ The decision memo is the deliverable of `technical-direction`. Save it as `docs/technical-direction/<feature-slug>.md`:
4
+
5
+ ```md
6
+ # Technical Direction: <Feature Name>
7
+ ## Problem and target outcome
8
+ - What we are solving
9
+ - Why this matters now
10
+ ## Current-state constraints
11
+ - Architecture and integration constraints
12
+ - Team/runtime/operational constraints
13
+ - Unknowns and assumptions
14
+ ## Options considered
15
+ ### Option A: <name>
16
+ - Approach
17
+ - Pros
18
+ - Cons
19
+ - Risks
20
+ ### Option B: <name>
21
+ ...
22
+ ### Option C: <name>
23
+ ...
24
+ ## Recommendation
25
+ - Chosen approach
26
+ - Why this is best under current constraints
27
+ - Why alternatives were not selected
28
+ ## Tradeoffs accepted
29
+ - Explicit compromises and consequences
30
+ ## Validation plan
31
+ - Fastest experiments/spikes to de-risk decision
32
+ - Success/failure signals
33
+ ## Revisit triggers
34
+ - Conditions that should force re-evaluation
35
+ ## References
36
+ - Web sources used for decisions (title + URL)
37
+ - Code evidence links (repo path + line range, and permalink URL when available)
38
+ ```