@jaybeeuu/agent-cortex 1.38.1 → 1.39.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 (62) hide show
  1. package/AGENTS.md +3 -1
  2. package/CHANGELOG.md +30 -0
  3. package/README.md +34 -16
  4. package/agents/README.md +7 -5
  5. package/agents/ralph-plan/agent.md +1 -1
  6. package/agents/ralph-plan.agent.md +1 -1
  7. package/bin/agent-cortex.mjs +13 -5
  8. package/bin/installers/claude.mjs +129 -15
  9. package/claude/.claude-plugin/plugin.json +1 -1
  10. package/claude/agents/ralph-plan.md +1 -1
  11. package/docs/ideas/extension-manifests.md +75 -0
  12. package/docs/ideas/record-ideas-as-beads.md +115 -0
  13. package/docs/ideas/subagent-visibility.md +72 -0
  14. package/docs/ideas/task-session-context.md +89 -0
  15. package/docs/research/skill-design-research.md +4 -4
  16. package/docs/research/skill-improvements-analysis.md +1 -1
  17. package/docs/skills/skill-anatomy.md +38 -2
  18. package/docs/technical-direction/migration-execution-labels.md +132 -0
  19. package/lib/cli.mjs +9 -3
  20. package/package.json +2 -2
  21. package/plugin.json +1 -1
  22. package/pnpm-workspace.yaml +1 -1
  23. package/skills/engineering/design-an-interface/SKILL.md +78 -58
  24. package/skills/engineering/grill-with-docs/REFERENCE.md +78 -0
  25. package/skills/engineering/grill-with-docs/SKILL.md +66 -63
  26. package/skills/engineering/improve-codebase-architecture/SKILL.md +66 -48
  27. package/skills/engineering/technical-direction/FORMAT.md +38 -0
  28. package/skills/engineering/technical-direction/SKILL.md +70 -77
  29. package/skills/planning/classify-bead/SKILL.md +59 -35
  30. package/skills/planning/create-task/REFERENCE.md +40 -0
  31. package/skills/planning/create-task/SKILL.md +70 -66
  32. package/skills/planning/create-task/scripts/create-chores.ts +6 -1
  33. package/skills/planning/create-task/scripts/node_modules/.bin/tsc +21 -0
  34. package/skills/planning/create-task/scripts/node_modules/.bin/tsserver +21 -0
  35. package/skills/planning/create-task/scripts/node_modules/.bin/tsx +21 -0
  36. package/skills/planning/prd-to-tasks/REFERENCE.md +66 -0
  37. package/skills/planning/prd-to-tasks/SKILL.md +86 -170
  38. package/skills/planning/record-idea/FORMAT.md +44 -0
  39. package/skills/planning/record-idea/SKILL.md +70 -53
  40. package/skills/planning/request-refactor-plan/FORMAT.md +45 -0
  41. package/skills/planning/request-refactor-plan/SKILL.md +57 -46
  42. package/skills/planning/write-a-prd/FORMAT.md +54 -0
  43. package/skills/planning/write-a-prd/SKILL.md +49 -48
  44. package/skills/planning/write-a-ticket/SKILL.md +68 -53
  45. package/skills/productivity/handoff/SKILL.md +12 -0
  46. package/skills/productivity/init-beads/SKILL.md +48 -40
  47. package/skills/productivity/validate-agent-dir/scripts/node_modules/.bin/tsc +21 -0
  48. package/skills/productivity/validate-agent-dir/scripts/node_modules/.bin/tsserver +21 -0
  49. package/skills/productivity/validate-agent-dir/scripts/node_modules/.bin/tsx +21 -0
  50. package/skills/productivity/write-a-skill/SKILL.md +2 -1
  51. package/skills/review/maintain-agent-docs/SKILL.md +71 -51
  52. package/skills/workflow/hitl-collab/SKILL.md +86 -17
  53. package/skills/workflow/ralph/REFERENCE.md +22 -17
  54. package/skills/workflow/ralph/SKILL.md +88 -74
  55. package/skills/workflow/run-pipeline-stage/REFERENCE.md +22 -0
  56. package/skills/workflow/run-pipeline-stage/SKILL.md +91 -93
  57. package/skills/workflow/run-pipeline-stage/scripts/generate-progress.test.ts +6 -107
  58. package/skills/workflow/run-pipeline-stage/scripts/node_modules/.bin/tsc +21 -0
  59. package/skills/workflow/run-pipeline-stage/scripts/node_modules/.bin/tsserver +21 -0
  60. package/skills/workflow/run-pipeline-stage/scripts/node_modules/.bin/tsx +21 -0
  61. package/test/claude-installer.test.mjs +248 -0
  62. package/token-map.README.md +5 -3
@@ -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
+ ```
@@ -1,86 +1,79 @@
1
1
  ---
2
2
  name: technical-direction
3
- description: Drive collaborative technical design by challenging assumptions, mapping constraints, comparing alternatives, and producing a justified recommendation. Use when user wants to decide technical direction after PRD, evaluate architecture/technology choices, or asks to design a solution with tradeoff analysis.
3
+ description: Challenge assumptions, map constraints, compare options, and justify the choice. Use when deciding technical direction, choosing architecture or technology, or designing a solution with tradeoffs.
4
4
  ---
5
5
 
6
6
  # Technical Direction
7
7
 
8
- Act like a pragmatic, challenging staff engineer: constructive, direct, evidence-driven.
8
+ Act as a pragmatic, challenging staff engineer: constructive, direct, and evidence-driven. The deliverable is a justified recommendation, not consensus.
9
+
10
+ ## When to use
11
+
12
+ - "Decide technical direction" for a change with real architectural weight.
13
+ - Evaluating architecture or technology choices that carry tradeoffs.
14
+ - A PRD or brief is approved and the solution shape is still open.
15
+ - "Design a solution" where alternatives need mapping and comparison before picking one.
16
+
17
+ ## When NOT to use
18
+
19
+ - Stress-testing an existing plan or sharpening domain language — use `grill-with-docs`.
20
+ - Scoping a feature into PRD and tasks — use `plan` before direction makes sense.
21
+ - Exploring a codebase for refactoring opportunities — use `improve-codebase-architecture`.
22
+ - Reversible decisions with no meaningful tradeoffs — a memo costs more than it saves.
9
23
 
10
24
  ## Workflow
11
25
 
12
- 1. **Anchor on problem context**
13
- - Start from PRD or user brief
14
- - Confirm technical goals, non-goals, and decision horizon
15
-
16
- 2. **Discover constraints from codebase first**
17
- - Investigate architecture, existing interfaces, deployment/runtime constraints, data model boundaries, and team conventions
18
- - Note unknowns and risks
19
-
20
- 3. **Challenge loop (one question at a time)**
21
- - Ask focused, high-leverage questions
22
- - Challenge vague claims and hidden assumptions
23
- - Require explicit justification for each major decision
24
- - Keep drilling until constraints and tradeoffs are concrete
25
-
26
- 4. **Generate options**
27
- - Always include Option A (extend current approach), Option B (moderate architectural shift), and Option C (stronger alternative using new tech/pattern)
28
- - For each option: feasibility, complexity, migration cost, operational impact, testability, performance, and failure modes
29
-
30
- 5. **Use web research when needed**
31
- - Do this autonomously when codebase evidence is insufficient or a high-impact decision needs external comparison
32
- - Prefer authoritative sources (official docs, maintainers, widely adopted production guidance)
33
- - Bring findings back as tradeoffs, and retain source links as references
34
-
35
- 6. **Converge on a recommendation**
36
- - Select the best-fit option for current constraints
37
- - Explicitly explain why alternatives were not chosen
38
- - List decision triggers that would justify revisiting later
39
-
40
- 7. **Write decision memo**
41
- - Ensure `docs/technical-direction/` exists
42
- - Save to `docs/technical-direction/<feature-slug>.md` using this template:
43
-
44
- ```md
45
- # Technical Direction: <Feature Name>
46
- ## Problem and target outcome
47
- - What we are solving
48
- - Why this matters now
49
- ## Current-state constraints
50
- - Architecture and integration constraints
51
- - Team/runtime/operational constraints
52
- - Unknowns and assumptions
53
- ## Options considered
54
- ### Option A: <name>
55
- - Approach
56
- - Pros
57
- - Cons
58
- - Risks
59
- ### Option B: <name>
60
- ...
61
- ### Option C: <name>
62
- ...
63
- ## Recommendation
64
- - Chosen approach
65
- - Why this is best under current constraints
66
- - Why alternatives were not selected
67
- ## Tradeoffs accepted
68
- - Explicit compromises and consequences
69
- ## Validation plan
70
- - Fastest experiments/spikes to de-risk decision
71
- - Success/failure signals
72
- ## Revisit triggers
73
- - Conditions that should force re-evaluation
74
- ## References
75
- - Web sources used for decisions (title + URL)
76
- - Code evidence links (repo path + line range, and permalink URL when available)
77
- ```
78
-
79
- ## Rules
80
-
81
- - Ask questions one at a time.
82
- - If the answer exists in the codebase, investigate before asking.
83
- - Be challenging but collaborative; do not optimize for agreement.
84
- - Avoid premature implementation details until direction is selected.
85
- - Every recommendation must include explicit constraints and tradeoffs.
86
- - When web or code sources materially inform decisions, include them in `## References`.
26
+ 1. **Anchor on problem context.** Start from the PRD or user brief. Confirm goals, non-goals, and the decision horizon (how long this choice must hold).
27
+ 2. **Discover constraints from the codebase first.** Investigate architecture, existing interfaces, deployment and runtime constraints, data-model boundaries, and team conventions using {{TOOL:rg}}, {{TOOL:view}}, and {{TOOL:glob}}. Record unknowns and risks explicitly.
28
+ 3. **Run the challenge loop, one question at a time.** Ask focused, high-leverage questions. Challenge vague claims and hidden assumptions; require explicit justification for each major decision. Keep drilling until constraints and tradeoffs are concrete. If an answer exists in the codebase, find it before asking.
29
+ 4. **Generate options.** Always include Option A (extend the current approach), Option B (moderate architectural shift), and Option C (a stronger alternative using new tech or patterns). Evaluate each on feasibility, complexity, migration cost, operational impact, testability, performance, and failure modes.
30
+ 5. **Use web research when the codebase is insufficient.** Do this autonomously for high-impact decisions needing external comparison. Prefer authoritative sources (official docs, maintainers, widely adopted production guidance) via {{TOOL:web_fetch}}; bring findings back as tradeoffs with source links.
31
+ 6. **Converge on a recommendation.** Select the best-fit option under current constraints. Explain explicitly why each alternative was not chosen. List decision triggers that would justify revisiting.
32
+ 7. **Write the decision memo.** Ensure `docs/technical-direction/` exists and save `docs/technical-direction/<feature-slug>.md` using the template in [FORMAT.md](FORMAT.md).
33
+
34
+ ## Red Flags
35
+
36
+ - Red flag: proposing options before constraints are mapped — alternatives become uncomparable.
37
+ - Red flag: asking a question the codebase can answer without looking first.
38
+ - Red flag: optimising for agreement instead of surfacing hard tradeoffs.
39
+ - Red flag: recommending direction without stated tradeoffs, revisit triggers, or validation signals.
40
+ - Red flag: sliding into premature implementation details before direction is selected.
41
+
42
+ ## Common Rationalizations
43
+
44
+ | Rationalization | Rebuttal |
45
+ |---|---|
46
+ | "We already know the answer" | Stated answers often rest on unstated assumptions. Test the recommendation against the constraints before accepting it. |
47
+ | "The tradeoffs are obvious" | Obvious today is forgotten in a month. The memo exists so reversible choices stay reversible and irreversible ones are signposted. |
48
+ | "Web research is overkill" | For high-impact choices with insufficient codebase evidence, external comparison is the cheapest way to kill a plausible-but-wrong option. |
49
+ | "One option is clearly right" | A single option is a statement, not a decision. Alternatives and their failure modes are what justify the choice. |
50
+
51
+ ## Philosophy / rationale
52
+
53
+ - **Constraints first, options second.** Options only compare against the constraints that bound them, so map the codebase and decision horizon before generating alternatives.
54
+ - **Challenge is the deliverable.** The value of a direction session is the assumptions it surfaces and kills. Optimising for agreement produces a recommendation nobody tested.
55
+ - **Every recommendation carries its tradeoffs.** A choice without documented tradeoffs, revisit triggers, and validation signals cannot be revisited intelligently later.
56
+
57
+ ## Cross-skill references
58
+
59
+ - `write-a-prd` produces the input brief when no PRD exists yet.
60
+ - `grill-with-docs` sharpens contested terminology and stress-tests the memo against domain docs.
61
+ - `design-an-interface` structures the option-generation step when the decision is about interface shape.
62
+ - `style-documentation` governs the memo's what/whether criteria before writing.
63
+
64
+ ## Examples
65
+
66
+ Input: "Decide on the write-path storage for the events service."
67
+ Output: a decision memo at `docs/technical-direction/events-write-path.md` covering constraints, three options scored against them, a justified recommendation, tradeoffs accepted, a validation plan, revisit triggers, and references. See [FORMAT.md](FORMAT.md) for the full template.
68
+
69
+ ## Verification checklist
70
+
71
+ - [ ] Goals, non-goals, and decision horizon confirmed before options were generated
72
+ - [ ] Codebase constraints explored before asking questions; unknowns and risks recorded
73
+ - [ ] Questions asked one at a time; nothing answerable from the codebase asked of the user
74
+ - [ ] At least three options considered, including an extend-current approach and a stronger alternative
75
+ - [ ] Each option scored on feasibility, complexity, migration cost, operational impact, testability, performance, and failure modes
76
+ - [ ] Recommendation states why alternatives were not chosen and lists revisit triggers
77
+ - [ ] Decision memo saved to `docs/technical-direction/<feature-slug>.md` using the FORMAT.md template
78
+ - [ ] Tradeoffs accepted, validation plan, and references (web and code, with links) included
79
+ - [ ] No premature implementation detail in the memo — direction only