@bjlee2024/claude-mem 13.4.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 (101) hide show
  1. package/.agents/plugins/marketplace.json +20 -0
  2. package/.codex-plugin/plugin.json +46 -0
  3. package/LICENSE +202 -0
  4. package/README.md +419 -0
  5. package/dist/npx-cli/index.js +10001 -0
  6. package/dist/opencode-plugin/index.js +67 -0
  7. package/openclaw/Dockerfile.e2e +46 -0
  8. package/openclaw/SKILL.md +462 -0
  9. package/openclaw/TESTING.md +279 -0
  10. package/openclaw/dist/index.js +15 -0
  11. package/openclaw/e2e-verify.sh +222 -0
  12. package/openclaw/install.sh +1653 -0
  13. package/openclaw/openclaw.plugin.json +98 -0
  14. package/openclaw/package.json +21 -0
  15. package/openclaw/src/index.test.ts +1124 -0
  16. package/openclaw/src/index.ts +1092 -0
  17. package/openclaw/test-e2e.sh +40 -0
  18. package/openclaw/test-install.sh +2086 -0
  19. package/openclaw/test-sse-consumer.js +98 -0
  20. package/openclaw/tsconfig.json +26 -0
  21. package/package.json +211 -0
  22. package/plugin/.claude-plugin/plugin.json +24 -0
  23. package/plugin/.codex-plugin/plugin.json +46 -0
  24. package/plugin/.mcp.json +12 -0
  25. package/plugin/hooks/bugfixes-2026-01-10.md +92 -0
  26. package/plugin/hooks/codex-hooks.json +74 -0
  27. package/plugin/hooks/hooks.json +87 -0
  28. package/plugin/modes/code--ar.json +24 -0
  29. package/plugin/modes/code--bn.json +24 -0
  30. package/plugin/modes/code--chill.json +8 -0
  31. package/plugin/modes/code--cs.json +24 -0
  32. package/plugin/modes/code--da.json +24 -0
  33. package/plugin/modes/code--de.json +24 -0
  34. package/plugin/modes/code--el.json +24 -0
  35. package/plugin/modes/code--es.json +24 -0
  36. package/plugin/modes/code--fi.json +24 -0
  37. package/plugin/modes/code--fr.json +24 -0
  38. package/plugin/modes/code--he.json +24 -0
  39. package/plugin/modes/code--hi.json +24 -0
  40. package/plugin/modes/code--hu.json +24 -0
  41. package/plugin/modes/code--id.json +24 -0
  42. package/plugin/modes/code--it.json +24 -0
  43. package/plugin/modes/code--ja.json +24 -0
  44. package/plugin/modes/code--ko.json +24 -0
  45. package/plugin/modes/code--nl.json +24 -0
  46. package/plugin/modes/code--no.json +24 -0
  47. package/plugin/modes/code--pl.json +24 -0
  48. package/plugin/modes/code--pt-br.json +24 -0
  49. package/plugin/modes/code--ro.json +24 -0
  50. package/plugin/modes/code--ru.json +24 -0
  51. package/plugin/modes/code--sv.json +24 -0
  52. package/plugin/modes/code--th.json +24 -0
  53. package/plugin/modes/code--tr.json +24 -0
  54. package/plugin/modes/code--uk.json +24 -0
  55. package/plugin/modes/code--ur.json +25 -0
  56. package/plugin/modes/code--vi.json +24 -0
  57. package/plugin/modes/code--zh.json +24 -0
  58. package/plugin/modes/code.json +139 -0
  59. package/plugin/modes/email-investigation.json +120 -0
  60. package/plugin/modes/law-study--chill.json +7 -0
  61. package/plugin/modes/law-study-CLAUDE.md +85 -0
  62. package/plugin/modes/law-study.json +120 -0
  63. package/plugin/modes/meme-tokens.json +125 -0
  64. package/plugin/package.json +46 -0
  65. package/plugin/scripts/bun-runner.js +216 -0
  66. package/plugin/scripts/context-generator.cjs +795 -0
  67. package/plugin/scripts/mcp-server.cjs +239 -0
  68. package/plugin/scripts/server-beta-service.cjs +9856 -0
  69. package/plugin/scripts/statusline-counts.js +40 -0
  70. package/plugin/scripts/version-check.js +69 -0
  71. package/plugin/scripts/worker-cli.js +19 -0
  72. package/plugin/scripts/worker-service.cjs +2368 -0
  73. package/plugin/scripts/worker-wrapper.cjs +2 -0
  74. package/plugin/skills/babysit/SKILL.md +87 -0
  75. package/plugin/skills/design-is/SKILL.md +312 -0
  76. package/plugin/skills/do/SKILL.md +45 -0
  77. package/plugin/skills/how-it-works/SKILL.md +22 -0
  78. package/plugin/skills/how-it-works/onboarding-explainer.md +17 -0
  79. package/plugin/skills/knowledge-agent/SKILL.md +80 -0
  80. package/plugin/skills/learn-codebase/SKILL.md +21 -0
  81. package/plugin/skills/make-plan/SKILL.md +67 -0
  82. package/plugin/skills/mem-search/SKILL.md +131 -0
  83. package/plugin/skills/oh-my-issues/SKILL.md +226 -0
  84. package/plugin/skills/pathfinder/SKILL.md +111 -0
  85. package/plugin/skills/smart-explore/SKILL.md +190 -0
  86. package/plugin/skills/timeline-report/SKILL.md +211 -0
  87. package/plugin/skills/version-bump/SKILL.md +68 -0
  88. package/plugin/skills/version-bump/scripts/generate_changelog.js +34 -0
  89. package/plugin/skills/weekly-digests/SKILL.md +262 -0
  90. package/plugin/skills/wowerpoint/SKILL.md +205 -0
  91. package/plugin/ui/assets/fonts/monaspace-radon-var.woff +0 -0
  92. package/plugin/ui/assets/fonts/monaspace-radon-var.woff2 +0 -0
  93. package/plugin/ui/claude-mem-logo-for-dark-mode.webp +0 -0
  94. package/plugin/ui/claude-mem-logo-stylized.png +0 -0
  95. package/plugin/ui/claude-mem-logomark.webp +0 -0
  96. package/plugin/ui/icon-thick-completed.svg +8 -0
  97. package/plugin/ui/icon-thick-investigated.svg +8 -0
  98. package/plugin/ui/icon-thick-learned.svg +12 -0
  99. package/plugin/ui/icon-thick-next-steps.svg +8 -0
  100. package/plugin/ui/viewer-bundle.js +65 -0
  101. package/plugin/ui/viewer.html +3145 -0
@@ -0,0 +1,67 @@
1
+ ---
2
+ name: make-plan
3
+ description: Create a detailed, phased implementation plan with documentation discovery. Use when asked to plan a feature, task, or multi-step implementation — especially before executing with do.
4
+ ---
5
+
6
+ # Make Plan
7
+
8
+ You are an ORCHESTRATOR. Create an LLM-friendly plan in phases that can be executed consecutively in new chat contexts.
9
+
10
+ ## Delegation Model
11
+
12
+ Use subagents for *fact gathering and extraction* (docs, examples, signatures, grep results). Keep *synthesis and plan authoring* with the orchestrator (phase boundaries, task framing, final wording). If a subagent report is incomplete or lacks evidence, re-check with targeted reads/greps before finalizing.
13
+
14
+ ### Subagent Reporting Contract (MANDATORY)
15
+
16
+ Each subagent response must include:
17
+ 1. Sources consulted (files/URLs) and what was read
18
+ 2. Concrete findings (exact API names/signatures; exact file paths/locations)
19
+ 3. Copy-ready snippet locations (example files/sections to copy)
20
+ 4. "Confidence" note + known gaps (what might still be missing)
21
+
22
+ Reject and redeploy the subagent if it reports conclusions without sources.
23
+
24
+ ## Plan Structure
25
+
26
+ ### Phase 0: Documentation Discovery (ALWAYS FIRST)
27
+
28
+ Before planning implementation, deploy "Documentation Discovery" subagents to:
29
+ 1. Search for and read relevant documentation, examples, and existing patterns
30
+ 2. Identify the actual APIs, methods, and signatures available (not assumed)
31
+ 3. Create a brief "Allowed APIs" list citing specific documentation sources
32
+ 4. Note any anti-patterns to avoid (methods that DON'T exist, deprecated parameters)
33
+
34
+ The orchestrator consolidates findings into a single Phase 0 output.
35
+
36
+ ### Each Implementation Phase Must Include
37
+
38
+ 1. **What to implement** — Frame tasks to COPY from docs, not transform existing code
39
+ - Good: "Copy the V2 session pattern from docs/examples.ts:45-60"
40
+ - Bad: "Migrate the existing code to V2"
41
+ 2. **Documentation references** — Cite specific files/lines for patterns to follow
42
+ 3. **Verification checklist** — How to prove this phase worked (tests, grep checks)
43
+ 4. **Anti-pattern guards** — What NOT to do (invented APIs, undocumented params)
44
+
45
+ ### Final Phase: Verification
46
+
47
+ 1. Verify all implementations match documentation
48
+ 2. Check for anti-patterns (grep for known bad patterns)
49
+ 3. Run tests to confirm functionality
50
+
51
+ ## Key Principles
52
+
53
+ - Documentation Availability ≠ Usage: Explicitly require reading docs
54
+ - Task Framing Matters: Direct agents to docs, not just outcomes
55
+ - Verify > Assume: Require proof, not assumptions about APIs
56
+ - Session Boundaries: Each phase should be self-contained with its own doc references
57
+
58
+ ## Anti-Patterns to Prevent
59
+
60
+ - Inventing API methods that "should" exist
61
+ - Adding parameters not in documentation
62
+ - Skipping verification steps
63
+ - Assuming structure without checking examples
64
+
65
+ ## See Also
66
+
67
+ - `oh-my-issues` — the issue-side sibling. When the plan you're being asked to make is rooted in a bug or feature backlog rather than a fresh idea, route through `oh-my-issues` first to cluster issues by root cause into plan masters and `plans/0X-*.md` design docs. `make-plan` then operates on the design doc for one plan slice.
@@ -0,0 +1,131 @@
1
+ ---
2
+ name: mem-search
3
+ description: Search claude-mem's persistent cross-session memory database. Use when user asks "did we already solve this?", "how did we do X last time?", or needs work from previous sessions.
4
+ ---
5
+
6
+ # Memory Search
7
+
8
+ Search past work across all sessions. Simple workflow: search -> filter -> fetch.
9
+
10
+ ## When to Use
11
+
12
+ Use when users ask about PREVIOUS sessions (not current conversation):
13
+
14
+ - "Did we already fix this?"
15
+ - "How did we solve X last time?"
16
+ - "What happened last week?"
17
+
18
+ ## 3-Layer Workflow (ALWAYS Follow)
19
+
20
+ **NEVER fetch full details without filtering first. 10x token savings.**
21
+
22
+ ### Step 1: Search - Get Index with IDs
23
+
24
+ Use the `search` MCP tool:
25
+
26
+ ```
27
+ search(query="authentication", limit=20, project="my-project")
28
+ ```
29
+
30
+ **Returns:** Table with IDs, timestamps, types, titles (~50-100 tokens/result)
31
+
32
+ ```
33
+ | ID | Time | T | Title | Read |
34
+ |----|------|---|-------|------|
35
+ | #11131 | 3:48 PM | 🟣 | Added JWT authentication | ~75 |
36
+ | #10942 | 2:15 PM | 🔴 | Fixed auth token expiration | ~50 |
37
+ ```
38
+
39
+ **Parameters:**
40
+
41
+ - `query` (string) - Search term
42
+ - `limit` (number) - Max results, default 20, max 100
43
+ - `project` (string) - Project name filter
44
+ - `type` (string, optional) - "observations", "sessions", or "prompts"
45
+ - `obs_type` (string, optional) - Comma-separated: bugfix, feature, decision, discovery, change
46
+ - `dateStart` (string, optional) - YYYY-MM-DD or epoch ms
47
+ - `dateEnd` (string, optional) - YYYY-MM-DD or epoch ms
48
+ - `offset` (number, optional) - Skip N results
49
+ - `orderBy` (string, optional) - "date_desc" (default), "date_asc", "relevance"
50
+
51
+ ### Step 2: Timeline - Get Context Around Interesting Results
52
+
53
+ Use the `timeline` MCP tool:
54
+
55
+ ```
56
+ timeline(anchor=11131, depth_before=3, depth_after=3, project="my-project")
57
+ ```
58
+
59
+ Or find anchor automatically from query:
60
+
61
+ ```
62
+ timeline(query="authentication", depth_before=3, depth_after=3, project="my-project")
63
+ ```
64
+
65
+ **Returns:** `depth_before + 1 + depth_after` items in chronological order with observations, sessions, and prompts interleaved around the anchor.
66
+
67
+ **Parameters:**
68
+
69
+ - `anchor` (number, optional) - Observation ID to center around
70
+ - `query` (string, optional) - Find anchor automatically if anchor not provided
71
+ - `depth_before` (number, optional) - Items before anchor, default 5, max 20
72
+ - `depth_after` (number, optional) - Items after anchor, default 5, max 20
73
+ - `project` (string) - Project name filter
74
+
75
+ ### Step 3: Fetch - Get Full Details ONLY for Filtered IDs
76
+
77
+ Review titles from Step 1 and context from Step 2. Pick relevant IDs. Discard the rest.
78
+
79
+ Use the `get_observations` MCP tool:
80
+
81
+ ```
82
+ get_observations(ids=[11131, 10942])
83
+ ```
84
+
85
+ **ALWAYS use `get_observations` for 2+ observations - single request vs N requests.**
86
+
87
+ **Parameters:**
88
+
89
+ - `ids` (array of numbers, required) - Observation IDs to fetch
90
+ - `orderBy` (string, optional) - "date_desc" (default), "date_asc"
91
+ - `limit` (number, optional) - Max observations to return
92
+ - `project` (string, optional) - Project name filter
93
+
94
+ **Returns:** Complete observation objects with title, subtitle, narrative, facts, concepts, files (~500-1000 tokens each)
95
+
96
+ ## Examples
97
+
98
+ **Find recent bug fixes:**
99
+
100
+ ```
101
+ search(query="bug", type="observations", obs_type="bugfix", limit=20, project="my-project")
102
+ ```
103
+
104
+ **Find what happened last week:**
105
+
106
+ ```
107
+ search(type="observations", dateStart="2025-11-11", limit=20, project="my-project")
108
+ ```
109
+
110
+ **Understand context around a discovery:**
111
+
112
+ ```
113
+ timeline(anchor=11131, depth_before=5, depth_after=5, project="my-project")
114
+ ```
115
+
116
+ **Batch fetch details:**
117
+
118
+ ```
119
+ get_observations(ids=[11131, 10942, 10855], orderBy="date_desc")
120
+ ```
121
+
122
+ ## Why This Workflow?
123
+
124
+ - **Search index:** ~50-100 tokens per result
125
+ - **Full observation:** ~500-1000 tokens each
126
+ - **Batch fetch:** 1 HTTP request vs N individual requests
127
+ - **10x token savings** by filtering before fetching
128
+
129
+ ## Knowledge Agents
130
+
131
+ Want synthesized answers instead of raw records? Use `/knowledge-agent` to build a queryable corpus from your observation history. The knowledge agent reads all matching observations and answers questions conversationally.
@@ -0,0 +1,226 @@
1
+ ---
2
+ name: oh-my-issues
3
+ description: Cluster a GitHub issue backlog by root cause into a small set of plan-master issues, redirect children with a standardized comment, and bundle architectural-fix PRs that close clusters atomically. Use when an issue tracker has accumulated dozens of reports that share underlying defects, when asked to triage / consolidate / cluster / dedupe issues, when asked to build a plan series or roadmap from open issues, or when routing a new incoming bug into an existing plan.
4
+ ---
5
+
6
+ # oh-my-issues
7
+
8
+ Turn an issue backlog into a roadmap. Issues are symptom data, not units of work — the unit of work is the architectural defect that produces them. The end state is `open issues == open plans`, 1:1.
9
+
10
+ ## Core principle
11
+
12
+ Stop closing issues one at a time. Group symptoms that share a single architectural fix into a cluster, give the cluster one canonical home (a plan-master issue + a `plans/0X-*.md` design doc), close every child with a standardized redirect, and ship one PR per cluster that closes all children atomically. New incoming bugs get appended to the matching master as a "Round N" comment, not opened as new tracked issues.
13
+
14
+ This compounds three ways: architectural fixes retire whole symptom families, the plan's test matrix institutionalizes prevention in CI, and standardized triage makes residual inflow cheap.
15
+
16
+ ## When to use
17
+
18
+ - The repo has 20+ open issues and many feel like duplicates or platform-specific symptoms of the same defect.
19
+ - The user asks to "triage", "consolidate", "cluster", "dedupe", "group", or "make a plan from" the issue list.
20
+ - A new bug is filed and the user wants to know whether it belongs to existing work.
21
+ - The user wants to ship a focused PR that resolves a cluster of related issues.
22
+
23
+ ## When NOT to use
24
+
25
+ - Fewer than ~15 open issues: just close them.
26
+ - Issues are genuinely independent (no shared root causes): one fix per issue is correct.
27
+ - The repo lacks `plans/` discipline and the user does not want to introduce one — propose first, do not impose.
28
+
29
+ ## Three modes
30
+
31
+ ### Mode 1: Cluster pass (initial reduction)
32
+
33
+ Use when the backlog has never been consolidated. Goal: go from N issues to N_plans masters in one operation.
34
+
35
+ 1. **Read everything in full.** Fetch every open issue's body *and* its comment thread — not just titles. Surface-level grouping fails without full text, and reproduction steps, linked duplicates, and diagnostic output often live in comments rather than the original body. See "GitHub CLI primitives" below for the correct paginated listing + per-issue comment fetch (a single `gh issue list` call does **not** return comment bodies).
36
+ 2. **Cluster by root cause, not by surface.** The clustering question is *would one architectural change retire all of these?* — not *do these mention the same word?*. "Windows" is a surface; "spawn contract violated by host shells" is a root cause. Two issues with different surfaces can share a cluster (e.g. an env-var leak in two different code paths sharing one missing env-isolation boundary).
37
+ 3. **Name each cluster as an architectural problem.** Title format: `[plan-XX] <Architectural Defect> — <one-line scope>`. Example: `[plan-02] Spawn-Contract Templating — canonical ${CLAUDE_PLUGIN_ROOT} resolution across all hosts`. The title must imply a fix, not a topic.
38
+ 4. **Open one master issue per cluster** with a body that lists: the architectural defect, the children (by issue number), the fix sequence, and a required test matrix (host × IDE × shell, etc.) that prevents regression.
39
+ 5. **Mirror each master as `plans/0X-<slug>.md`** in the repo. The issue is the public tracker; the doc is the design. They reference each other.
40
+ 6. **Close every child** with the standardized redirect comment (see below) and state `not planned`.
41
+ 7. **Verify end state:** `gh issue list --state open` returns exactly the masters and nothing else.
42
+
43
+ Target shape for ~100 issues: 4–8 masters. More than 10 means you're clustering by surface; fewer than 3 means clusters are too broad to ship as one PR each.
44
+
45
+ ### Mode 2: Triage (new incoming bug, steady state)
46
+
47
+ Use when a new issue is filed after consolidation is in place. Goal: never let the issue list re-accumulate.
48
+
49
+ 1. **Read the new issue's body in full.**
50
+ 2. **Pattern-match the symptom against existing plan masters.** For each open master, ask: *would the fix described here also fix this new bug?* If yes → it belongs to that plan.
51
+ 3. **If a match exists**, post a "Round N" comment on the master that:
52
+ - Names the new child by number
53
+ - Describes the symptom in one line
54
+ - Sketches the concrete fix (1–3 lines, e.g. "guard with `case "$_SH" in /*.exe|"") _SH=bash ;; esac`")
55
+ - Adds any new test-matrix cell the bug exposes
56
+ 4. **Close the child** with the standardized redirect comment, `not planned`.
57
+ 5. **If no match exists** and the bug is genuinely novel: open a new plan master + `plans/0X-*.md`. Resist this. Most bugs are children of existing plans.
58
+
59
+ ### Mode 3: Bundle (ship the cluster)
60
+
61
+ Use when a plan slice is ready to ship. Goal: one PR closes N children atomically.
62
+
63
+ 1. **List the master's children.** From the master body and consolidation comments, collect every child issue number routed to this plan.
64
+ 2. **Verify each child's symptom is covered** by the architectural fix in the PR. If a child is not covered, the PR is not ready or that child belongs in a different plan.
65
+ 3. **Generate the PR description**: title is the plan slice (e.g. "fix(spawn): canonical ${CLAUDE_PLUGIN_ROOT} resolution"); body lists every child with `Closes #N` so GitHub auto-closes them on merge.
66
+ 4. **Add the test matrix from the plan** to CI in the same PR. Without the matrix, the cluster will re-emerge.
67
+ 5. **After merge**, the master issue can be closed only if every child was covered. If the plan has remaining scope, leave the master open and link the PR as a partial-shipping checkpoint.
68
+
69
+ ## Naming a plan master
70
+
71
+ A plan-master title must imply its fix.
72
+
73
+ | Bad (surface) | Good (architectural) |
74
+ |---|---|
75
+ | Windows bugs | Spawn-Contract Templating across hosts |
76
+ | Worker crashes | Worker / Daemon Lifecycle Hardening — supervision, health, retry |
77
+ | Auth issues | Worker Env Isolation — strip host CLI env from the SDK subprocess |
78
+ | Install failures | Installer Failure Transparency — cross-IDE error taxonomy + 12×4 test matrix |
79
+
80
+ If you cannot write a one-line architectural scope, the cluster is wrong.
81
+
82
+ ## The standardized redirect comment
83
+
84
+ Use this exact phrasing on every child closure. Consistency lets contributors recognize the pattern at a glance and keeps the audit trail searchable.
85
+
86
+ ```text
87
+ Consolidating into #<MASTER> (plan-XX). The root cause and fix sequencing are tracked there alongside the rest of the cluster — please follow that issue for progress.
88
+ ```
89
+
90
+ Close as `not planned` (not `completed`) — the child was a symptom, not a unit of work.
91
+
92
+ ## GitHub CLI primitives
93
+
94
+ Resolve repo:
95
+
96
+ ```bash
97
+ repo_json=$(gh repo view --json owner,name)
98
+ owner=$(jq -r '.owner.login // .owner.name' <<<"$repo_json")
99
+ repo=$(jq -r '.name' <<<"$repo_json")
100
+ ```
101
+
102
+ List all open issues (the read-everything pass). Two gotchas:
103
+ - `gh issue list --json comments` returns only a count placeholder, not the comment bodies. You must fetch comments per issue with `gh issue view <N> --json comments`.
104
+ - Any explicit `--limit` silently truncates if the backlog is larger. Always check the total open count first.
105
+
106
+ ```bash
107
+ # 1. Confirm total — never trust an arbitrary --limit.
108
+ # Note: GitHub's REST API treats PRs as issues, so .open_issues_count
109
+ # from /repos/{owner}/{repo} is actually issues + PRs. Use the search
110
+ # API to get the issue-only count.
111
+ total=$(gh api "search/issues?q=repo:$owner/$repo+is:issue+is:open" --jq '.total_count')
112
+ echo "Open issues: $total"
113
+
114
+ # 2. List bodies (set --limit at or above the true total)
115
+ gh issue list --state open --limit "$total" \
116
+ --json number,title,body,labels,author,createdAt
117
+
118
+ # 3. For each issue, fetch its full comment thread
119
+ for n in $(gh issue list --state open --limit "$total" --json number --jq '.[].number'); do
120
+ echo "=== Issue #$n ==="
121
+ gh issue view "$n" --json comments \
122
+ --jq '.comments[] | "\(.author.login) (\(.createdAt)): \(.body)"'
123
+ done
124
+ ```
125
+
126
+ If `total > 1000`, paginate via the REST API: `gh api "repos/$owner/$repo/issues?state=open&per_page=100&page=N"` looped until the result array is empty (note this includes PRs, so filter `select(.pull_request|not)`).
127
+
128
+ Open a plan master:
129
+
130
+ ```bash
131
+ gh issue create \
132
+ --title "[plan-02] Spawn-Contract Templating — canonical \${CLAUDE_PLUGIN_ROOT} resolution across all hosts" \
133
+ --body-file plans/02-spawn-contract-templating.md \
134
+ --label plan,plan-02
135
+ ```
136
+
137
+ Post the consolidation comment + close the child:
138
+
139
+ ```bash
140
+ gh issue comment <CHILD> --body "Consolidating into #<MASTER> (plan-XX). The root cause and fix sequencing are tracked there alongside the rest of the cluster — please follow that issue for progress."
141
+ gh issue close <CHILD> --reason "not planned"
142
+ ```
143
+
144
+ Append a "Round N" triage comment to a master:
145
+
146
+ ```bash
147
+ gh issue comment <MASTER> --body "$(cat <<'EOF'
148
+ **Round N consolidation**
149
+
150
+ - #<CHILD> (<one-line symptom>) folded into this plan as <classification>.
151
+
152
+ Proposed fix: <1–3 line sketch>.
153
+
154
+ Adds matrix cell: <host/IDE/shell combination>.
155
+ EOF
156
+ )"
157
+ ```
158
+
159
+ Verify final state:
160
+
161
+ ```bash
162
+ gh issue list --state open --json number,title \
163
+ | jq -r '.[] | "\(.number)\t\(.title)"'
164
+ ```
165
+
166
+ Output should be exactly the plan masters.
167
+
168
+ ## Plan master body template
169
+
170
+ Save as `plans/0X-<slug>.md` and use as `--body-file` for the master issue.
171
+
172
+ ```markdown
173
+ # [plan-XX] <Architectural Defect> — <one-line scope>
174
+
175
+ ## Defect
176
+
177
+ <One paragraph: what is structurally broken, why it produces the observed family of symptoms.>
178
+
179
+ ## Children
180
+
181
+ - #N — <symptom one-liner>
182
+ - #N — <symptom one-liner>
183
+ - ...
184
+
185
+ ## Fix sequence
186
+
187
+ 1. <First architectural change — bounded, reviewable>
188
+ 2. <Second>
189
+ 3. ...
190
+
191
+ ## Test matrix
192
+
193
+ | Axis A | Axis B | Required behavior |
194
+ |---|---|---|
195
+ | ... | ... | ... |
196
+
197
+ The matrix lives in CI. A future regression must fail CI before a user can file.
198
+
199
+ ## Out of scope
200
+
201
+ <What this plan deliberately does not cover, with pointers to other plan masters.>
202
+ ```
203
+
204
+ ## Health checks
205
+
206
+ Run periodically against the plan masters to catch the failure modes.
207
+
208
+ - **Graveyard master:** master issue has accumulated 5+ "Round N" comments without a shipping PR. The plan needs a forcing PR or it must be split.
209
+ - **Over-broad master:** the children's fixes cannot fit one PR. Split into two plans with narrower scope.
210
+ - **Surface-clustered master:** the children share a topic but not a fix. Re-cluster by root cause; some children belong to different plans.
211
+ - **Drift between issue and doc:** the plan master body and `plans/0X-*.md` disagree. Pick one as canonical (the doc) and regenerate the issue body from it.
212
+
213
+ ## Stop conditions
214
+
215
+ For a cluster pass: stop when `gh issue list --state open` returns exactly the masters.
216
+
217
+ For a triage: stop when the new child is closed and the master has a Round-N entry.
218
+
219
+ For a bundle: stop when the PR is merged and every listed child is auto-closed by `Closes #N`.
220
+
221
+ ## Failure modes worth refusing
222
+
223
+ - **Premature clustering** before reading every issue body in full. Don't.
224
+ - **Closing children before the master is open.** Children must always have a redirect target.
225
+ - **Using the redirect comment for issues that aren't symptoms** (e.g. genuine feature requests with no shared root cause). Those stay open or get their own track.
226
+ - **Closing a master before every listed child is shipped.** The master is the contract; closing it early breaks the audit trail.
@@ -0,0 +1,111 @@
1
+ ---
2
+ name: pathfinder
3
+ description: Map a codebase into feature-grouped flowcharts, identify duplicated concerns across features, and propose a unified architecture. Use when asked to "find the ideal path," unify duplicated systems, or audit architecture before a refactor. Emits a proposed unified flowchart plus per-system /make-plan prompts.
4
+ ---
5
+
6
+ # Pathfinder
7
+
8
+ You are an ORCHESTRATOR. Map the codebase into feature-grouped flowcharts, identify duplicated concerns, propose the simplest unified architecture, and hand off per-system plans to `/make-plan`.
9
+
10
+ You do not write implementation code. You produce diagrams, a duplication report, a proposed unified flowchart, and handoff prompts.
11
+
12
+ ## Delegation Model
13
+
14
+ Use subagents for *discovery and extraction* (file reading, flow tracing, grep, diagramming). Keep *synthesis* (deciding feature boundaries, picking unification strategies, final flowchart) with the orchestrator. Reject subagent reports that lack source citations and redeploy.
15
+
16
+ ### Subagent Reporting Contract (MANDATORY)
17
+
18
+ Each subagent response must include:
19
+ 1. Sources consulted — exact file paths and line ranges read
20
+ 2. Concrete findings — exact function names, call sites, data flow
21
+ 3. Mermaid diagram(s) with nodes labeled by `file:line`
22
+ 4. Confidence note + known gaps
23
+
24
+ ## Output Artifacts
25
+
26
+ All artifacts go in `PATHFINDER-<YYYY-MM-DD>/` at repo root:
27
+ - `00-features.md` — feature inventory with boundaries
28
+ - `01-flowcharts/<feature>.md` — one Mermaid flowchart per feature
29
+ - `02-duplication-report.md` — cross-cutting duplicated concerns with evidence
30
+ - `03-unified-proposal.md` — proposed unified architecture + Mermaid
31
+ - `04-handoff-prompts.md` — copy-pasteable `/make-plan` prompts per unified system
32
+
33
+ ## Phases
34
+
35
+ ### Phase 0: Feature Discovery (ALWAYS FIRST)
36
+
37
+ Deploy ONE "Feature Discovery" subagent to:
38
+ 1. Walk the source tree (not built artifacts) and read top-level README / CLAUDE.md
39
+ 2. Propose feature boundaries based on directory structure, import graph, and naming
40
+ 3. Return a flat list of features with: name, entry points (file:line), core files, brief purpose
41
+
42
+ Orchestrator reviews the proposal, adjusts boundaries if needed, writes `00-features.md`. Do NOT fan out until feature boundaries are approved.
43
+
44
+ ### Phase 1: Per-Feature Flowcharts (FAN OUT)
45
+
46
+ Deploy ONE "Flowchart" subagent per feature in parallel. Each receives only its feature's scope. Each must:
47
+ 1. Trace the feature's primary happy path from entry point to terminal state
48
+ 2. Identify side effects (DB writes, HTTP calls, file I/O, process spawns)
49
+ 3. Note error and fallback branches but do not let them dominate the diagram
50
+ 4. Produce a Mermaid `flowchart TD` with every node labeled `Name<br/>file:line`
51
+ 5. List external dependencies (other features it calls into) at the bottom
52
+
53
+ Orchestrator writes each flowchart to `01-flowcharts/<feature>.md`. Reject any diagram missing `file:line` labels.
54
+
55
+ ### Phase 2: Duplication Hunt
56
+
57
+ Deploy TWO subagents in parallel:
58
+
59
+ **"Within-Feature Duplication"** subagent:
60
+ - For each feature, find repeated code/logic patterns inside the feature only
61
+ - Report only duplications worth consolidating (ignore trivial repetition)
62
+
63
+ **"Cross-Feature Duplication"** subagent:
64
+ - Compare flowcharts across features for concerns that appear in multiple places
65
+ - Examples of what to look for: multiple capture paths, parallel queue implementations, duplicated storage/migration code, repeated agent scaffolding, parallel parsing layers
66
+ - For each duplication, report: (a) the concern, (b) every location with `file:line`, (c) why they diverged, (d) whether the divergence is legitimate specialization or accidental
67
+
68
+ Orchestrator synthesizes both into `02-duplication-report.md`. Every duplication claim must cite ≥2 `file:line` locations.
69
+
70
+ ### Phase 3: Unified Proposal (ORCHESTRATOR)
71
+
72
+ The orchestrator writes `03-unified-proposal.md` itself — do not delegate synthesis.
73
+
74
+ For each duplicated concern from Phase 2 that is NOT legitimate specialization:
75
+ 1. Propose the simplest unified design (one path, one store, one handler — whatever applies)
76
+ 2. Name the consolidated component and its single entry point
77
+ 3. Show what each old call site becomes
78
+ 4. Call out any loss of capability and whether it's acceptable
79
+
80
+ End the document with ONE combined Mermaid flowchart showing the proposed unified system. Nodes still labeled with target `file:line` (new or existing) where knowable.
81
+
82
+ **Anti-patterns to reject in your own proposal:**
83
+ - Adding a new abstraction layer "for flexibility"
84
+ - Keeping both old paths behind a feature flag
85
+ - Introducing a registry/factory when a switch statement suffices
86
+ - Preserving divergent behavior "just in case"
87
+
88
+ ### Phase 4: Per-System Handoff Prompts
89
+
90
+ For each unified system in the proposal, write a ready-to-run `/make-plan` prompt to `04-handoff-prompts.md`. Each prompt must:
91
+ 1. State the target unified component and its single entry point
92
+ 2. List the exact call sites to rewrite (from Phase 2 evidence)
93
+ 3. Cite the relevant flowchart file from `01-flowcharts/`
94
+ 4. Include anti-pattern guards specific to this system
95
+
96
+ Format each as a fenced code block the user can copy directly into `/make-plan`.
97
+
98
+ ## Key Principles
99
+
100
+ - **Evidence over intuition** — every diagram node and duplication claim cites `file:line`
101
+ - **Current state before ideal state** — Phases 0–2 describe what IS; Phase 3 describes what SHOULD BE
102
+ - **Simplest unification wins** — prefer deletion over abstraction; prefer one path over configurable paths
103
+ - **Specialization is not duplication** — two components serving different trust models or data sources are legitimate even if their code looks similar
104
+ - **Handoff, don't implement** — Pathfinder ends at plan prompts; `/make-plan` and `/do` take it from there
105
+
106
+ ## Failure Modes to Prevent
107
+
108
+ - Drawing flowcharts from memory instead of source — redeploy subagent with grep evidence requirement
109
+ - Proposing unification of legitimately specialized components — re-examine trust/data-source divergence
110
+ - Handoff prompts that lack concrete call sites — rewrite with Phase 2 evidence
111
+ - Skipping Phase 0 boundary review — fanning out on bad feature boundaries wastes all of Phase 1