memtrace 0.8.3 → 0.8.5

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 (41) hide show
  1. package/bin/memtrace.js +43 -15
  2. package/hooks/posttool-mcp-telemetry.sh +0 -0
  3. package/hooks/userprompt-claude.sh +0 -0
  4. package/installer/dist/commands/doctor.js +11 -0
  5. package/installer/dist/index.js +1 -1
  6. package/installer/dist/rail-install.js +4 -15
  7. package/installer/dist/transformers/codex.js +7 -80
  8. package/installer/dist/transformers/index.d.ts +2 -1
  9. package/installer/dist/transformers/index.js +3 -1
  10. package/installer/dist/transformers/opencode.js +5 -21
  11. package/installer/dist/transformers/rail-hooks.d.ts +13 -0
  12. package/installer/dist/transformers/rail-hooks.js +50 -0
  13. package/installer/dist/transformers/types.d.ts +1 -1
  14. package/installer/dist/transformers/warp.d.ts +4 -0
  15. package/installer/dist/transformers/warp.js +83 -0
  16. package/installer/package.json +1 -1
  17. package/installer/skills/commands/memtrace-decision-recall.md +7 -4
  18. package/installer/skills/commands/memtrace-docs-ask.md +99 -0
  19. package/installer/skills/commands/memtrace-docs-read.md +91 -0
  20. package/installer/skills/commands/memtrace-docs-search.md +94 -0
  21. package/installer/skills/commands/memtrace-preflight.md +17 -1
  22. package/installer/skills/commands/memtrace-provenance.md +7 -4
  23. package/installer/skills/workflows/memtrace-change-impact-analysis.md +23 -7
  24. package/installer/skills/workflows/memtrace-decision-memory.md +16 -12
  25. package/installer/skills/workflows/memtrace-docs.md +129 -0
  26. package/installer/skills/workflows/memtrace-first.md +25 -3
  27. package/installer/skills/workflows/memtrace-refactoring-guide.md +25 -9
  28. package/lib/child-supervisor.js +104 -0
  29. package/lib/install-consent.js +1 -1
  30. package/package.json +7 -7
  31. package/skills/commands/memtrace-decision-recall.md +7 -4
  32. package/skills/commands/memtrace-docs-ask.md +99 -0
  33. package/skills/commands/memtrace-docs-read.md +91 -0
  34. package/skills/commands/memtrace-docs-search.md +94 -0
  35. package/skills/commands/memtrace-preflight.md +17 -1
  36. package/skills/commands/memtrace-provenance.md +7 -4
  37. package/skills/workflows/memtrace-change-impact-analysis.md +23 -7
  38. package/skills/workflows/memtrace-decision-memory.md +16 -12
  39. package/skills/workflows/memtrace-docs.md +129 -0
  40. package/skills/workflows/memtrace-first.md +25 -3
  41. package/skills/workflows/memtrace-refactoring-guide.md +25 -9
@@ -1,10 +1,13 @@
1
1
  ---
2
2
  name: memtrace-preflight
3
- description: "Run a one-call pre-flight check on a single existing symbol before editing it: blast radius (who depends on it), co-change partners (files that historically change with it), complexity, 30-day churn, and a generated verification checklist. Use before modifying any existing function or symbol you did not just write. Do not start editing a non-trivial existing function without a pre-flight check; Memtrace knows the dependency graph and change history. For a full multi-symbol change plan or what-will-break analysis, use memtrace-change-impact-analysis."
3
+ description: "Run a one-call pre-flight check on a single existing symbol before editing it: blast radius, co-change partners, complexity, 30-day churn, and verification checklist, then check Cortex decision memory for rationale/bans when intent may matter. Use before modifying any existing function or symbol you did not just write. Do not start editing a non-trivial existing function without pre-flight plus decision-memory recall/provenance; Memtrace knows the dependency graph, change history, and recorded decisions."
4
4
  allowed-tools:
5
5
  - mcp__memtrace__preflight_check
6
6
  - mcp__memtrace__get_impact
7
7
  - mcp__memtrace__get_cochange_context
8
+ - mcp__memtrace__recall_decision
9
+ - mcp__memtrace__why_is_this_here
10
+ - mcp__memtrace__governing_contracts
8
11
  metadata:
9
12
  author: "Syncable <support@syncable.dev>"
10
13
  version: "1.0.0"
@@ -26,6 +29,8 @@ symbol.
26
29
  | `preflight_check` | Full radar for one symbol: blast radius + co-change + churn + checklist |
27
30
  | `get_impact` | Deeper blast-radius walk when the radar flags HIGH/CRITICAL |
28
31
  | `get_cochange_context` | Wider co-change window when partners look surprising |
32
+ | `recall_decision` | Recorded choices, bans, and conventions for the symbol/subsystem/behavior |
33
+ | `why_is_this_here` / `governing_contracts` | Symbol-scoped rationale and constraints when a symbol id is available |
29
34
 
30
35
  > **Parameter types:** MCP parameters are strictly typed. Numbers must be
31
36
 
@@ -65,12 +70,23 @@ frequent partner, say so explicitly and why.
65
70
  - The complexity number should not have grown without a stated reason;
66
71
  if it did, simplify before declaring the work done.
67
72
 
73
+ ### Cortex gate before editing
74
+
75
+ Before changing behavior, deleting code, or refactoring odd/legacy code:
76
+
77
+ 1. Run `recall_decision("<symbol/subsystem/behavior>")`.
78
+ 2. If the preflight/graph result gives you a numeric `symbol_id`, run
79
+ `why_is_this_here(symbol_id)` and `governing_contracts(symbol_id)`.
80
+ 3. Honor matching held decisions/bans. Treat CannotProve as unknown, not approval.
81
+
68
82
  ## Verdict guidance
69
83
 
70
84
  - `risk: CRITICAL/HIGH` — propose the change plan before editing; consider
71
85
  a feature flag or staged rollout.
72
86
  - `dependents: 0` — edit freely; note the symbol may be newly added or an
73
87
  entry point.
88
+ - A matching Cortex decision/ban — surface it before editing and do not
89
+ contradict it without explicit user sign-off.
74
90
 
75
91
  ## Output
76
92
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: memtrace-provenance
3
- description: "Retrieve the governing decision lineage (why is this here) and the contracts that bind a symbol, from Cortex decision memory. Use before deleting, rewriting, or 'cleaning up' code that looks unused, odd, or redundant, and when the user asks why a symbol exists or what rules constrain it. Symbol-scoped; for free-text decision search use memtrace-decision-recall. Do not infer intent from the diff or assume unfamiliar code is safe to remove."
3
+ description: "Retrieve the governing decision lineage (why is this here) and contracts that bind a symbol from Cortex decision memory through the normal Memtrace MCP server. Use before deleting, rewriting, refactoring, or 'cleaning up' existing code that looks unused, odd, redundant, legacy, or policy-sensitive, and when the user asks why a symbol exists or what rules constrain it. Symbol-scoped; for free-text decision search use memtrace-decision-recall first. Do not infer intent from the diff or assume unfamiliar code is safe to remove."
4
4
  allowed-tools:
5
5
  - mcp__memtrace__why_is_this_here
6
6
  - mcp__memtrace__governing_contracts
@@ -46,7 +46,10 @@ Full parameter spec for every Memtrace tool: `references/mcp-parameters.md` (bun
46
46
  ### 1. Get the symbol_id
47
47
 
48
48
  If you have a name or a "why" question, run `recall_decision(...)` first and take the
49
- `symbol_id` from the result (or the Cortex view). The id-based tools need a numeric id.
49
+ `symbol_id` from the result if present, or use the id returned by a graph/Cortex view.
50
+ The id-based tools need a numeric id. If you cannot get a symbol id, do not skip
51
+ decision memory entirely: use `recall_decision("<symbol/subsystem/behavior>")` and
52
+ report any matching decision/bans before changing the code.
50
53
 
51
54
  ### 2. Ask why it's here
52
55
 
@@ -71,8 +74,8 @@ was superseded via `recall_decision`) changes whether the code should still look
71
74
  | Situation | Action |
72
75
  |-----------|--------|
73
76
  | Code looks unused/dead and you want to delete it | `why_is_this_here` + `governing_contracts` BEFORE deleting; CannotProve is not a green light |
74
- | Code is written in a strange/non-obvious way | `why_is_this_here` there's likely a decision explaining the oddity |
75
- | About to refactor a symbol's internals | `governing_contracts` — preserve every constraint, not just the test surface |
77
+ | Code is written in a strange/non-obvious way | `why_is_this_here` if you have a symbol id; otherwise `recall_decision` for the symbol/subsystem |
78
+ | About to refactor a symbol's internals | `why_is_this_here` + `governing_contracts` — preserve the rationale and every constraint, not just the test surface |
76
79
  | User asks "why is this here?" | `why_is_this_here(symbol_id)`; if you only have a name, `recall_decision` first |
77
80
  | All provenance returns CannotProve | Treat as unknown; combine with `memtrace-impact` (blast radius) and ask the user before removing |
78
81
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: memtrace-change-impact-analysis
3
- description: "Compute what a planned source-code change will break — blast radius, affected processes, cross-repo callers — and produce a risk-rated change plan. Use when the user needs to know what will break before a change: edits, refactors, API changes, renames, removals, PR reviews, or risk assessments. Do not manually grep references or browse files for impact; this workflow uses Memtrace graph context, impact, and change history. For a quick blast-radius check on one symbol, use memtrace-impact."
3
+ description: "Compute what a planned source-code change will break — blast radius, affected processes, cross-repo callers, temporal stability, and Cortex decision-memory constraints — and produce a risk-rated change plan. Use before edits, refactors, API changes, renames, removals, PR reviews, or risk assessments, especially when changing established behavior or deleting code. Do not manually grep references or browse files for impact; use Memtrace graph context, change history, and decision recall/provenance."
4
4
  allowed-tools:
5
5
  - mcp__memtrace__find_symbol
6
6
  - mcp__memtrace__find_code
@@ -9,6 +9,10 @@ allowed-tools:
9
9
  - mcp__memtrace__get_evolution
10
10
  - mcp__memtrace__get_timeline
11
11
  - mcp__memtrace__analyze_relationships
12
+ - mcp__memtrace__recall_decision
13
+ - mcp__memtrace__why_is_this_here
14
+ - mcp__memtrace__governing_contracts
15
+ - mcp__memtrace__verify_intent
12
16
  metadata:
13
17
  author: "Syncable <support@syncable.dev>"
14
18
  version: "1.0.0"
@@ -18,7 +22,7 @@ user-invocable: true
18
22
 
19
23
  ## Overview
20
24
 
21
- Pre-change risk assessment workflow. Before modifying code, this workflow maps the full blast radius, identifies affected processes, checks recent change history for instability signals, and produces a risk-rated change plan.
25
+ Pre-change risk assessment workflow. Before modifying code, this workflow maps the full blast radius, identifies affected processes, checks recent change history for instability signals, checks Cortex decision memory for recorded decisions/bans/contracts, and produces a risk-rated change plan.
22
26
 
23
27
  ## Steps
24
28
 
@@ -55,20 +59,30 @@ For each target, call `get_impact` (`repo_id`, `target`) with `direction: "both"
55
59
  | High | Plan incremental migration; consider feature flags |
56
60
  | Critical | Full migration strategy; backward-compatible changes required |
57
61
 
58
- ### 4. Check temporal stability
62
+ ### 4. Check Cortex decision memory
63
+
64
+ For each target or subsystem, call `recall_decision("<target/subsystem/approach>")`.
65
+ If the graph result exposes a numeric `symbol_id`, also call
66
+ `why_is_this_here(symbol_id)` and `governing_contracts(symbol_id)`.
67
+
68
+ - Matching decision/ban/convention → include it in the plan before recommending a change.
69
+ - Decision you intend to rely on → run `verify_intent(decision_id)` first.
70
+ - CannotProve → record "no decision proven"; do not treat it as approval.
71
+
72
+ ### 5. Check temporal stability
59
73
 
60
74
  Call `get_evolution` (`repo_id`, `from: "30d ago"`, `mode: "compound"`), then `get_timeline` on each target symbol (requires `scope_path` + `file_path` from `find_symbol`):
61
75
  - Sparse timeline history + you're about to change it → structurally surprising; extra scrutiny warranted.
62
76
  - Target appears in `top_touched_symbols` → high churn + high impact = volatile hotspot.
63
77
 
64
- ### 5. Map affected execution flows
78
+ ### 6. Map affected execution flows
65
79
 
66
80
  From step 2, you already know which processes are affected. For critical changes, use `analyze_relationships` (`repo_id`, `target`) with `query_type: "find_callers"` at `depth: 3` to trace the full transitive caller chain.
67
81
 
68
82
  `depth: 3` is a JSON number, not a string — the validator rejects `"3"`.
69
83
  Full parameter spec for every Memtrace tool: `references/mcp-parameters.md` (bundled at the memtrace-skills plugin root).
70
84
 
71
- ### 6. Produce the risk assessment
85
+ ### 7. Produce the risk assessment
72
86
 
73
87
  Synthesize into a change plan:
74
88
 
@@ -77,8 +91,9 @@ Synthesize into a change plan:
77
91
  3. **Affected Processes** — which execution flows will be impacted
78
92
  4. **Cross-Service Impact** — any external callers or consumers
79
93
  5. **Stability Signal** — sparse `get_timeline` history (stable) vs frequent appearance in `top_touched_symbols` (volatile)
80
- 6. **Recommended Approach** — based on risk: direct change, incremental migration, or backward-compatible evolution
81
- 7. **Test Coverage** — which callers/processes to verify after the change
94
+ 6. **Decision Memory** — relevant decisions/bans/contracts, or CannotProve as unknown
95
+ 7. **Recommended Approach** — based on risk and decision constraints: direct change, incremental migration, or backward-compatible evolution
96
+ 8. **Test Coverage** — which callers/processes to verify after the change
82
97
 
83
98
  ## Decision Points
84
99
 
@@ -89,6 +104,7 @@ Synthesize into a change plan:
89
104
  | Symbol has sparse timeline but high impact | Extra review — this rarely changes; make sure the change is intentional |
90
105
  | Multiple processes affected | List each affected flow; recommend testing each one |
91
106
  | Symbol is a bridge point | Change may disconnect parts of the architecture — verify alternative paths exist |
107
+ | Cortex returns a held ban/contract | Do not recommend contradicting it without explicit user sign-off |
92
108
 
93
109
  ## Output
94
110
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: memtrace-decision-memory
3
- description: "Check Cortex decision memory — the umbrella entry point for decision recall, provenance (why is this here), intent verification, and governing contracts. Use before assuming WHY code exists, before making a choice that may contradict a past one, or before deleting/rewriting code that looks odd or redundant. Route: free-text what-was-decided → memtrace-decision-recall; why does this symbol exist / what constrains it → memtrace-provenance; did the decision hold → memtrace-intent-verification. Do not guess rationale from the diff or git log; Cortex remembers the decision, the ban, and whether it still holds."
3
+ description: "Check Cortex decision memory through the normal Memtrace MCP tools — the umbrella entry point for decision recall, provenance (why is this here), intent verification, and governing contracts. Use before assuming WHY code exists, before any non-trivial edit/refactor/delete of existing code, before re-picking a library/pattern/architecture, or before contradicting an apparent convention. Route: free-text decisions/bans/conventions → memtrace-decision-recall; symbol lineage/contracts → memtrace-provenance; did the decision hold → memtrace-intent-verification. Do not guess rationale from the diff or git log."
4
4
  allowed-tools:
5
5
  - mcp__memtrace__recall_decision
6
6
  - mcp__memtrace__why_is_this_here
@@ -52,12 +52,14 @@ These five tools are **deterministic, zero-LLM**. Every call returns a labeled
52
52
  `CannotProve` is a real, trustworthy answer ("memory has nothing on this"), not a
53
53
  failure and not a green light. Never invent a rationale to fill the gap.
54
54
 
55
- ## Server check (once per session)
55
+ ## Tool availability (once per session)
56
56
 
57
- These tools are served by the **`memcortex`** MCP server (decision memory), separate
58
- from the `memtrace` code-graph server. If `recall_decision` isn't available, decision
59
- memory isn't wired in this environment say so and use `memtrace-first` instead;
60
- don't fabricate decisions.
57
+ These tools are exposed on the normal **`memtrace` MCP server**:
58
+ `recall_decision`, `why_is_this_here`, `verify_intent`, `get_arc`, and
59
+ `governing_contracts`. Hosts do not need a second MemCortex MCP connection. If a
60
+ tool call returns CannotProve because Cortex is unavailable (for example native
61
+ Windows without WSL2), say decision memory was unavailable/unknown and continue
62
+ with `memtrace-first`; do not fabricate decisions.
61
63
 
62
64
  ## The decision rule
63
65
 
@@ -65,9 +67,9 @@ don't fabricate decisions.
65
67
  |---|---|---|
66
68
  | "Did we already decide/choose/reject X?" "What's our convention on Y?" | `recall_decision("X")` | `memtrace-decision-recall` |
67
69
  | "Is there a ban / a 'don't do this' on Z?" | `recall_decision("Z")` — bans surface as decisions | `memtrace-decision-recall` |
68
- | About to re-pick a library/pattern/approach | `recall_decision` FIRST — don't re-litigate a settled call | `memtrace-decision-recall` |
70
+ | About to edit behavior, re-pick a library/pattern/architecture, or change a subsystem policy | `recall_decision` FIRST — don't re-litigate a settled call | `memtrace-decision-recall` |
69
71
  | "Why is this code here?" "Why is it done this odd way?" | `why_is_this_here(symbol_id)` | `memtrace-provenance` |
70
- | About to delete/refactor code that looks unused or strange | `why_is_this_here` + `governing_contracts` before touching it | `memtrace-provenance` |
72
+ | About to delete/refactor/clean up existing code, especially odd or "dead" code | `why_is_this_here` + `governing_contracts` before touching it | `memtrace-provenance` |
71
73
  | "What rules/contracts constrain this symbol?" | `governing_contracts(symbol_id)` | `memtrace-provenance` |
72
74
  | "Did decision D actually hold, or did we drift?" | `verify_intent(decision_id)` | `memtrace-intent-verification` |
73
75
  | "What commits/episodes implemented decision D?" | `get_arc(decision_id)` | `memtrace-intent-verification` |
@@ -95,10 +97,11 @@ have a name or a free-text question, start with `recall_decision`.** Do not inve
95
97
  ## Standard workflows
96
98
 
97
99
  ### "Why does this code exist / can I delete it?"
98
- 1. `why_is_this_here(symbol_id)` the governing decision, if any
99
- 2. `governing_contracts(symbol_id)` → constraints that must survive a rewrite
100
- 3. If a decision governs it → `verify_intent(decision_id)` to see if it still holds
101
- 4. **CannotProve on all three safe to delete** — confirm with `memtrace-impact` (blast radius) and the user
100
+ 1. If you only have a name/free-text target, `recall_decision("<symbol/subsystem>")` first.
101
+ 2. If you have a `symbol_id`, `why_is_this_here(symbol_id)` → the governing decision, if any.
102
+ 3. `governing_contracts(symbol_id)` constraints that must survive a rewrite.
103
+ 4. If a decision governs it `verify_intent(decision_id)` to see if it still holds.
104
+ 5. **CannotProve on all checks ≠ safe to delete** — confirm with `memtrace-impact` (blast radius) and the user.
102
105
 
103
106
  ### "Should I do X?" (about to make a choice)
104
107
  1. `recall_decision("X")` → did we already decide or ban this?
@@ -114,6 +117,7 @@ have a name or a free-text question, start with `recall_decision`.** Do not inve
114
117
  | Thought | Reality |
115
118
  |---|---|
116
119
  | "This code looks unused, I'll delete it" | `why_is_this_here` first — a decision may govern it; deletion may reopen a closed issue |
120
+ | "I'll just edit/refactor this existing behavior" | `recall_decision("<behavior/subsystem>")` first — the change may violate a recorded decision or ban |
117
121
  | "I'll just use library/pattern X" | `recall_decision("X")` — you may be undoing a deliberate ban |
118
122
  | "The diff/git log will tell me why" | Git shows *what changed*, not *what was decided or rejected*. Decision memory has the rationale and the bans. |
119
123
  | "CannotProve, so it's fine/approved" | CannotProve = unknown, not approved. Don't treat absence of a record as permission. |
@@ -0,0 +1,129 @@
1
+ ---
2
+ name: memtrace-docs
3
+ description: "Route Memtrace product documentation questions to the hosted docs MCP tools before guessing, searching the web, or reading stale local copies. Use when the user asks how Memtrace works, how to install/configure CLI/MCP/fleet/Cortex/enterprise MemDB, what tools or skills exist, what a command does, or wants the agent to read up on official docs. Calls search_docs, ask_docs, or read_doc on memtrace.io (override with MEMTRACE_DOCS_API_URL). Do not hallucinate Memtrace behavior — query docs first. Separate from memtrace-first (your repo's code graph)."
4
+ allowed-tools:
5
+ - mcp__memtrace__search_docs
6
+ - mcp__memtrace__ask_docs
7
+ - mcp__memtrace__read_doc
8
+ metadata:
9
+ author: "Syncable <support@syncable.dev>"
10
+ version: "1.0.0"
11
+ category: development
12
+ ---
13
+
14
+ # Memtrace Docs First
15
+
16
+ ## The Iron Law
17
+
18
+ ```
19
+ IF THE USER ASKS ABOUT MEMTRACE PRODUCT DOCS → USE DOCS MCP TOOLS FIRST.
20
+ Do not guess CLI flags, MCP tool lists, enterprise deploy steps, or fleet rules
21
+ from memory. Query the hosted documentation corpus at memtrace.io (or
22
+ MEMTRACE_DOCS_API_URL), then answer with citations.
23
+
24
+ memtrace-first = your indexed SOURCE CODE (find_code, get_impact, …)
25
+ memtrace-docs = official MEMTRACE DOCUMENTATION (search_docs, ask_docs, read_doc)
26
+ ```
27
+
28
+ Docs tools call the **hosted** Memtrace docs API over HTTPS. They do **not** read
29
+ your local MemDB or your repo. Core graph tools stay offline; docs tools degrade
30
+ gracefully when the network is down (`ok: false` + hint).
31
+
32
+ ## Server check (once per session)
33
+
34
+ Confirm the docs tools are available on your `memtrace` MCP server:
35
+
36
+ - `search_docs` — ranked chunks (slug, title, H2, excerpt)
37
+ - `ask_docs` — grounded Q&A `{ answer, citations[], refused }`
38
+ - `read_doc` — full page text by slug
39
+ - Resources: `memtrace://docs/<slug>` via `read_resource` (optional)
40
+
41
+ If none of these exist, the MCP build may be outdated — tell the user to update
42
+ Memtrace and run `npx -y memtrace-skills@latest install`.
43
+
44
+ Override API host: `MEMTRACE_DOCS_API_URL` (default `https://memtrace.io`).
45
+
46
+ ## The decision rule
47
+
48
+ | User is asking | Right tool | Sub-skill |
49
+ |---|---|---|
50
+ | "How do I install / configure / deploy X in Memtrace?" | `ask_docs(question=…)` | `memtrace-docs-ask` |
51
+ | "What MCP tools / skills / CLI commands exist?" | `ask_docs` or `search_docs` then `read_doc` on hit slugs | `memtrace-docs-ask` / `memtrace-docs-search` |
52
+ | "What does `memtrace rail enable` do?" | `ask_docs` | `memtrace-docs-ask` |
53
+ | "Find docs about fleet coordination" | `search_docs(query=…)` | `memtrace-docs-search` |
54
+ | "Read the full getting-started page" | `read_doc(slug="getting-started")` | `memtrace-docs-read` |
55
+ | "Read enterprise MemDB deploy guide" | `read_doc(slug="enterprise/memdb-deploy")` | `memtrace-docs-read` |
56
+ | Need several related sections | `search_docs` → `read_doc` on top slugs | `memtrace-docs-search` + `memtrace-docs-read` |
57
+
58
+ **Default for natural-language questions:** `ask_docs` — it retrieves context and
59
+ returns a cited answer in one call.
60
+
61
+ **Default for "find the doc about…":** `search_docs` — scan chunks, then `read_doc`
62
+ if you need the full page.
63
+
64
+ ## Standard workflows
65
+
66
+ ### "How does X work in Memtrace?" (most common)
67
+
68
+ 1. `ask_docs(question="<user question verbatim>")`
69
+ 2. If `refused: true` or `ok: false` → `search_docs` with shorter keywords → `read_doc` on best slug
70
+ 3. Quote the answer; link slugs as `/docs/<slug>` when helpful
71
+ 4. If docs say "not found", say so — do not invent flags or behavior
72
+
73
+ ### "What tools / commands / skills are available?"
74
+
75
+ 1. `ask_docs(question="What MCP tools are available?")` or fleet/skills variant
76
+ 2. If the answer lists categories but user wants exhaustive detail → `read_doc(slug="mcp/tools")`
77
+ 3. For agent skills → `read_doc(slug="mcp/skills")`
78
+
79
+ ### "Read up on X before we implement"
80
+
81
+ 1. `search_docs(query="X", limit=8)`
82
+ 2. `read_doc(slug=<top hit>)` for each page you will rely on
83
+ 3. Summarize with citations; use `memtrace-first` only when switching to **their repo's code**
84
+
85
+ ### Enterprise / self-hosted MemDB
86
+
87
+ 1. `ask_docs(question="How do I deploy MemDB with Helm on Azure?")` or user wording
88
+ 2. Follow-up `read_doc(slug="enterprise/memdb-deploy")` for operator steps
89
+ 3. Engineer connect → `read_doc(slug="enterprise/connect")` or `cli/connect`
90
+
91
+ ## Red flags — STOP, use docs tools
92
+
93
+ | Thought | Reality |
94
+ |---|---|
95
+ | "I know how Memtrace fleet works from training data" | Product docs change — `ask_docs` first |
96
+ | "I'll grep the repo for README" | User repo ≠ official docs — use `search_docs` / `read_doc` |
97
+ | "I'll web-search Memtrace" | Use hosted docs API — same corpus as memtrace.io/docs |
98
+ | `ask_docs` returned `refused: true` | Docs corpus had no match — say so; try `search_docs` with different terms |
99
+ | `ok: false` network error | Report offline; core Memtrace graph tools still work locally |
100
+
101
+ ## Relationship to other skills
102
+
103
+ | Skill | When |
104
+ |---|---|
105
+ | `memtrace-docs` | Questions about **Memtrace product** (install, MCP, fleet, Cortex, enterprise) |
106
+ | `memtrace-first` | Questions about **the user's indexed source code** |
107
+ | `memtrace-decision-memory` | **Why** code exists (Cortex decisions) — not product docs |
108
+
109
+ Use both when needed: docs for "how is Memtrace supposed to work?", graph tools for
110
+ "how does *this repo* implement it?"
111
+
112
+ ## Output
113
+
114
+ Prefer citing doc slugs returned in `citations` or `search_docs` results:
115
+
116
+ ```
117
+ ask_docs → { ok: true, answer: "…", citations: ["cli/rail", "mcp/skills"], refused: false }
118
+ search_docs → { ok: true, results: [{ slug, pageTitle, h2Title, excerpt }] }
119
+ read_doc → { ok: true, slug, title, body }
120
+ ```
121
+
122
+ When `refused: true`, tell the user the docs did not cover it and suggest browsing
123
+ https://memtrace.io/docs or rephrasing.
124
+
125
+ ## Sub-skills
126
+
127
+ - Discovery / chunk search → `memtrace-docs-search`
128
+ - Grounded Q&A → `memtrace-docs-ask`
129
+ - Full page read → `memtrace-docs-read`
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: memtrace-first
3
- description: "Route code discovery, debugging, flow tracing, and how-code-works questions in indexed source-code repos to Memtrace graph tools. Use first before searching files, reading code for discovery, debugging, tracing flows, finding implementations, understanding behavior, or answering how code works. Do not use Grep, Glob, rg, find, or manual file browsing for code discovery when Memtrace is indexed. Zero results, missing languages, or partial-looking stats are not permission to grep; diagnose/reindex with Memtrace."
3
+ description: "Route code discovery, debugging, flow tracing, how-code-works questions, and pre-edit rationale checks in indexed source-code repos to Memtrace graph plus Cortex decision tools. Use first before searching/reading code, and before editing, refactoring, deleting, or re-picking an approach that may have a recorded decision, ban, convention, or contract. Do not use Grep, Glob, rg, find, or manual file browsing for code discovery when Memtrace is indexed. Zero results are not permission to grep; diagnose/reindex with Memtrace."
4
4
  allowed-tools:
5
5
  - mcp__memtrace__list_indexed_repositories
6
6
  - mcp__memtrace__index_directory
@@ -23,6 +23,10 @@ allowed-tools:
23
23
  - mcp__memtrace__get_style_fingerprint
24
24
  - mcp__memtrace__find_most_complex_functions
25
25
  - mcp__memtrace__get_source_window
26
+ - mcp__memtrace__recall_decision
27
+ - mcp__memtrace__verify_intent
28
+ - mcp__memtrace__why_is_this_here
29
+ - mcp__memtrace__governing_contracts
26
30
  - Read
27
31
  - Grep
28
32
  - Glob
@@ -44,6 +48,12 @@ ONLY when you're about to edit or quote, and read only the bounded span
44
48
  returned by Memtrace (start_line .. end_line + small context). Do not
45
49
  Grep/Glob/Find to "locate" anything already in the graph, and do not read
46
50
  the whole file when Memtrace has given you exact lines.
51
+
52
+ BEFORE you edit/refactor/delete existing code or choose/re-pick a pattern,
53
+ call Cortex decision memory: recall_decision for the symbol/subsystem/approach,
54
+ and use provenance/contracts when a symbol_id is available. Use Memtrace's graph
55
+ tools for structure and blast radius; use Cortex for rationale, bans, and
56
+ contracts.
47
57
  ```
48
58
 
49
59
  Memtrace is the **memory layer** of the codebase, not a search engine that returns code. It has the full knowledge graph — every symbol, call, import, community, process, and API — with a time dimension. The point is to navigate that graph: who calls this, what's the blast radius, when did this change, what community is it part of. File tools are blind to all of that.
@@ -103,6 +113,8 @@ For everything else inside the indexed repo, memtrace is the right tool.
103
113
  | "Find the function that uses `STRIPE_KEY_FOO_BAR`" | `find_code(query="STRIPE_KEY_FOO_BAR")` → semantic finds it inside any embedded body. |
104
114
  | "Where's that error message `'connection refused for tenant'`?" | `find_code(query="connection refused for tenant")` → semantic catches it. |
105
115
  | "What breaks if I change `foo`?" | `get_impact(repo_id, target="foo")` → blast radius. |
116
+ | "Should I change/delete/refactor `foo`?" | `find_symbol`/`get_symbol_context` → `recall_decision("foo / subsystem / approach")`; if a symbol id is available, `why_is_this_here` + `governing_contracts`; then `get_impact`. |
117
+ | "Can I use/switch to pattern or library X?" | `recall_decision("X")` FIRST; bans and conventions are decisions. Verify a matching decision with `verify_intent(decision_id)` before relying on it. |
106
118
  | "What changed in `auth.ts` last week?" | `get_evolution(repo_id, from="7d ago", mode="recent", file_path="auth.ts")`. |
107
119
  | "List all `*.test.ts` files." | `Glob` (file inventory, not symbol search). |
108
120
  | "Find this string in my `.env`." | `Grep` (non-source artifact). |
@@ -160,6 +172,8 @@ If not indexed → offer to index with `mcp__memtrace__index_directory`, then fo
160
172
  | What files change together? | `get_cochange_context` |
161
173
  | Architecture overview | `list_communities` + `find_central_symbols` |
162
174
  | About to edit / quote — need exact lines | Bounded `Read(file, offset=start_line, limit=N)` (preferred), or `get_source_window` for path-resolution parity |
175
+ | About to edit/refactor/delete existing code | `recall_decision` for the intent + `why_is_this_here`/`governing_contracts` when a symbol id is available, then `get_impact` |
176
+ | About to choose or replace a library/pattern/architecture | `recall_decision` first; use `verify_intent` on any matching decision before contradicting it |
163
177
  | About to choose between competing idioms (ternary vs if-else, arrow vs fn-decl, const vs let, await vs `.then`) | `get_style_fingerprint(repo_id, file_path)` — empirical codebase norm; see `memtrace-style-fingerprint` workflow |
164
178
 
165
179
  ## Standard Workflows
@@ -185,8 +199,10 @@ If not indexed → offer to index with `mcp__memtrace__index_directory`, then fo
185
199
  ### Before any code modification
186
200
  1. `find_symbol` → confirm you have the right target
187
201
  2. `get_symbol_context` → understand full context
188
- 3. `get_impact` → know blast radius before touching anything
189
- 4. `get_style_fingerprint(repo_id, file_path=<file>)` match the codebase's empirical idiom (ternary vs if-else, arrow vs fn-decl, etc.) see `memtrace-style-fingerprint` workflow for the full decision rule
202
+ 3. `recall_decision("<symbol/subsystem/approach>")` → surface recorded choices, bans, and conventions before deciding what to do
203
+ 4. If a `symbol_id` is available, `why_is_this_here(symbol_id)` + `governing_contracts(symbol_id)` before deleting, rewriting, or "cleaning up" odd code
204
+ 5. `get_impact` → know blast radius before touching anything
205
+ 6. `get_style_fingerprint(repo_id, file_path=<file>)` → match the codebase's empirical idiom (ternary vs if-else, arrow vs fn-decl, etc.) — see `memtrace-style-fingerprint` workflow for the full decision rule
190
206
 
191
207
  ## Red Flags — STOP, Use Memtrace Instead
192
208
 
@@ -197,6 +213,9 @@ You are violating this skill if you think:
197
213
  | "Let me grep for this" | `find_code` or `find_symbol` is faster and structurally aware |
198
214
  | "Let me glob for the file" | `find_symbol` returns exact location with context |
199
215
  | "Let me read the whole file" | `get_symbol_context` for the WHY (callers/callees/community); a bounded source read at start_line..end_line for the WHAT |
216
+ | "I know why this is written this way" | Check Cortex first. Use `recall_decision`; use `why_is_this_here`/`governing_contracts` when you have a symbol id. |
217
+ | "This looks unused/weird; I'll remove it" | `why_is_this_here` + `governing_contracts` first, then blast radius. CannotProve is unknown, not permission. |
218
+ | "I'll just switch to library/pattern X" | `recall_decision("X")` first — you may be reintroducing a banned approach. |
200
219
  | "It's just a quick search" | Grep has no understanding of call graphs, communities, or time |
201
220
  | "I don't know if it's indexed" | Check with `list_indexed_repositories` first — takes 1 second |
202
221
  | "Memtrace returned 0 results" | Broaden the Memtrace query, check repo_id/path coverage, then reindex if needed |
@@ -210,6 +229,7 @@ Use Grep/Glob/Read ONLY for:
210
229
  - Non-source files or paths outside every indexed source repo
211
230
  - Files that are config, data, or docs (not source code symbols)
212
231
  - Repos or paths confirmed outside every Memtrace indexed root
232
+ - **Official Memtrace product documentation** — use `memtrace-docs` (`ask_docs` / `search_docs` / `read_doc`), not file tools or web search
213
233
 
214
234
  For source-code spans already located by Memtrace, use a **bounded** read —
215
235
  your harness's `Read(file, offset, limit)` with the returned `start_line` /
@@ -227,9 +247,11 @@ When this skill applies, it overrides default file-search behavior. Use the spec
227
247
  - Discovery → `memtrace-search`
228
248
  - Impact analysis → `memtrace-impact`
229
249
  - Temporal / change analysis → `memtrace-evolution`
250
+ - Rationale / prior decisions / bans / contracts → `memtrace-decision-memory`
230
251
  - Incident investigation → `memtrace-incident-investigation`
231
252
  - Architecture overview → `memtrace-codebase-exploration`
232
253
  - Refactoring → `memtrace-refactoring-guide`
254
+ - Memtrace **product docs** (install, CLI, MCP, enterprise) → `memtrace-docs`
233
255
 
234
256
  ## Output
235
257
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: memtrace-refactoring-guide
3
- description: "Build a phased, risk-scored refactoring plan from Memtrace complexity, dead-code, bridge, and impact analysis. Use when the user wants to refactor source code, reduce complexity, clean technical debt, split large functions, extract modules, reorganize code, or choose refactoring priorities. Do not use Grep or manual reference search to plan refactors; Memtrace provides complexity, dead-code, relationships, and impact context."
3
+ description: "Build a phased, risk-scored refactoring plan from Memtrace complexity, dead-code, bridge, impact analysis, and Cortex decision-memory constraints. Use when the user wants to refactor source code, reduce complexity, clean technical debt, delete dead code, split large functions, extract modules, reorganize code, or choose refactoring priorities. Do not plan refactors from grep/manual reference search alone; check graph impact and decision rationale/bans/contracts before changing existing code."
4
4
  allowed-tools:
5
5
  - mcp__memtrace__find_most_complex_functions
6
6
  - mcp__memtrace__find_dead_code
@@ -10,6 +10,10 @@ allowed-tools:
10
10
  - mcp__memtrace__get_symbol_context
11
11
  - mcp__memtrace__analyze_relationships
12
12
  - mcp__memtrace__list_communities
13
+ - mcp__memtrace__recall_decision
14
+ - mcp__memtrace__why_is_this_here
15
+ - mcp__memtrace__governing_contracts
16
+ - mcp__memtrace__verify_intent
13
17
  metadata:
14
18
  author: "Syncable <support@syncable.dev>"
15
19
  version: "1.0.0"
@@ -19,7 +23,7 @@ user-invocable: true
19
23
 
20
24
  ## Overview
21
25
 
22
- Guided refactoring workflow — identifies refactoring candidates using structural analysis, scores them by risk and priority, and produces a phased refactoring plan. Combines complexity metrics, dead code detection, bridge analysis, and temporal evolution to prioritize what to refactor first and how to do it safely.
26
+ Guided refactoring workflow — identifies refactoring candidates using structural analysis, scores them by risk and priority, checks Cortex decision memory for rationale/bans/contracts, and produces a phased refactoring plan. Combines complexity metrics, dead code detection, bridge analysis, temporal evolution, and decision memory to prioritize what to refactor first and how to do it safely.
23
27
 
24
28
  ## Steps
25
29
 
@@ -63,7 +67,17 @@ Also call `get_symbol_context` to check:
63
67
  - How many processes does this symbol participate in? (More = more testing needed)
64
68
  - Is it part of a cross-repo API? (If yes, coordinate with consumers)
65
69
 
66
- ### 4. Understand the neighbourhood
70
+ ### 4. Check decision memory before refactoring/removing
71
+
72
+ For each top candidate, call `recall_decision("<symbol/subsystem/refactor intent>")`.
73
+ If you have a numeric `symbol_id`, call `why_is_this_here(symbol_id)` and
74
+ `governing_contracts(symbol_id)`.
75
+
76
+ - A matching held decision/ban can veto or reshape the refactor.
77
+ - Contracts become acceptance criteria for the new design.
78
+ - CannotProve is unknown, not permission to delete.
79
+
80
+ ### 5. Understand the neighbourhood
67
81
 
68
82
  For each refactoring target, call `analyze_relationships`:
69
83
  - `find_callees` — what does it depend on? These become candidates for extraction
@@ -72,13 +86,13 @@ For each refactoring target, call `analyze_relationships`:
72
86
 
73
87
  Full parameter spec for every Memtrace tool: `references/mcp-parameters.md` (bundled at the memtrace-skills plugin root).
74
88
 
75
- ### 5. Check community boundaries
89
+ ### 6. Check community boundaries
76
90
 
77
91
  Call `list_communities` and check: does the refactoring target sit at a community boundary?
78
92
  - If yes, the refactoring may involve splitting responsibilities across modules
79
93
  - If it belongs clearly to one community, the refactoring is more contained
80
94
 
81
- ### 6. Produce the refactoring plan
95
+ ### 7. Produce the refactoring plan
82
96
 
83
97
  Synthesize into a phased plan:
84
98
 
@@ -98,8 +112,9 @@ For each item, include:
98
112
  1. **Target** — function/class name, file, current complexity score
99
113
  2. **Why** — complexity + volatility + blast radius rationale
100
114
  3. **How** — specific refactoring approach (extract method, split class, introduce interface)
101
- 4. **Risk** — impact analysis rating + affected processes
102
- 5. **Test Plan** — which callers/processes to verify
115
+ 4. **Decision Memory** — relevant Cortex decisions/bans/contracts, or CannotProve as unknown
116
+ 5. **Risk** — impact analysis rating + affected processes
117
+ 6. **Test Plan** — which callers/processes to verify
103
118
 
104
119
  ## Decision Points
105
120
 
@@ -107,9 +122,10 @@ For each item, include:
107
122
  |-----------|--------|
108
123
  | Complex + volatile + high blast radius | Highest priority — but plan carefully; incremental approach |
109
124
  | Complex + stable + low blast radius | Can wait; refactor when you're already touching nearby code |
110
- | Dead code with zero callers | Safe to delete quick win |
125
+ | Dead code with zero callers | Run Cortex provenance/recall first; zero callers is not proof that no decision/contract keeps it |
111
126
  | Bridge symbol with many dependents | Extract interface first, then refactor implementation behind it |
112
127
  | Symbol in cross-repo API | Coordinate with consumers; backward-compatible changes only |
128
+ | Cortex returns a held ban/contract | Preserve it or ask before overriding it |
113
129
 
114
130
  ## Output
115
131
 
@@ -123,7 +139,7 @@ A phased plan (Phases 1–3). One worked entry:
123
139
  | Risk | High — upstream spans 3 processes incl. `checkout_flow`; incremental migration |
124
140
 
125
141
  Acceptance criteria:
126
- - Every plan item cites complexity, volatility, and blast radius — no gut-feel picks.
142
+ - Every plan item cites complexity, volatility, blast radius, and decision-memory status — no gut-feel picks.
127
143
  - High/Critical-risk items include a test plan naming affected callers/processes.
128
144
 
129
145
  ## Common Mistakes