memtrace 0.3.27 → 0.3.30

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.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: memtrace-index
3
- description: "Always use when the user asks to index, parse, ingest, reindex, watch, or prepare a source-code repo for Memtrace analysis, or when code exploration is needed but no Memtrace index exists. Use this before Grep, Glob, rg, find, or manual code search whenever the repo can be indexed."
3
+ description: "Always use when the user asks to index, parse, ingest, reindex, watch, or prepare a source-code repo for Memtrace analysis, when code exploration needs an index, or when searches return 0/partial results for source paths under an indexed root. Use this before Grep, Glob, rg, find, or manual code search whenever the repo can be indexed."
4
4
  allowed-tools:
5
5
  - mcp__memtrace__index_directory
6
6
  - mcp__memtrace__check_job_status
@@ -32,6 +32,11 @@ Use the `list_indexed_repositories` MCP tool first. If the repo is already index
32
32
 
33
33
  **Success criteria:** You have a list of repo_ids and their last-indexed timestamps.
34
34
 
35
+ If a repo is present but searches miss a source subdirectory under that repo
36
+ root (for example `ui/`, `memtrace-ui/`, `web/`, `frontend/`, or `src/`), treat
37
+ that as a stale/partial index. Do not use grep as a workaround. Run incremental
38
+ indexing on the repo root, then retry the Memtrace query.
39
+
35
40
  ### 2. Index the directory
36
41
 
37
42
  Use the `index_directory` MCP tool:
@@ -1,11 +1,6 @@
1
1
  ---
2
2
  name: memtrace-search
3
- description: "Always use to find, search, locate, or look up source-code symbols, functions, classes, types, constants, definitions, implementations, logic, error strings inside code, or where code lives. Do not use Grep, Glob, rg, find, or manual file search for code discovery; Memtrace uses BM25, vector search, RRF, and the AST graph."
4
- allowed-tools:
5
- - mcp__memtrace__find_code
6
- - mcp__memtrace__find_symbol
7
- - mcp__memtrace__list_indexed_repositories
8
- user-invocable: true
3
+ description: "Always use to find, search, locate, or look up source-code symbols, functions, classes, types, constants, definitions, implementations, logic, error strings inside code, or where code lives. Do not use Grep, Glob, rg, find, or manual file search for code discovery. If Memtrace returns 0 results, broaden the Memtrace query and diagnose/reindex; do not switch to grep."
9
4
  ---
10
5
 
11
6
  ## Overview
@@ -18,6 +13,7 @@ Find code using hybrid BM25 full-text + semantic vector search with Reciprocal R
18
13
  |------|----------|
19
14
  | `find_code` | Natural-language queries ("authentication middleware", "retry logic"), broad searches |
20
15
  | `find_symbol` | Exact identifier names ("getUserById", "PaymentService"), when you know the name |
16
+ | `get_source_window` | Optional: bounded source read after a Memtrace hit, when your harness lacks `Read(file, offset, limit)`. Otherwise prefer your harness's bounded read with the returned `start_line` / `end_line`. |
21
17
 
22
18
  ## Steps
23
19
 
@@ -52,6 +48,15 @@ Find code using hybrid BM25 full-text + semantic vector search with Reciprocal R
52
48
 
53
49
  ### 3. Use results for next steps
54
50
 
51
+ The default next step is a **graph tool** — `get_symbol_context`,
52
+ `analyze_relationships`, or `get_impact`. Those answer "who calls this",
53
+ "what's the blast radius", "what community is it part of" — context no
54
+ file read can give. That's what Memtrace uniquely provides.
55
+
56
+ Source bytes come last, only when you're about to edit or quote. Use a
57
+ bounded `Read(file_path, offset=start_line, limit=end_line-start_line+8)`,
58
+ or `get_source_window` if your harness lacks bounded reads. Do not whole-file.
59
+
55
60
  Save the symbol `id` from results — pass it to:
56
61
  - `analyze_relationships` to map callers/callees
57
62
  - `get_symbol_context` for a 360-degree view
@@ -65,3 +70,7 @@ Save the symbol `id` from results — pass it to:
65
70
  | Using find_symbol for vague queries | Use `find_code` for natural-language; `find_symbol` is for exact names |
66
71
  | Ignoring the `kind` filter | Narrow results with kind=Function, kind=Class etc. to reduce noise |
67
72
  | Re-searching to get more context | Use the symbol `id` with `get_symbol_context` instead of re-searching |
73
+ | Reading the whole file after a hit | First call `get_symbol_context` for callers/callees. If you still need source, do a bounded `Read(file, offset=start_line, limit=N)` — never whole-file. `get_source_window` is fine if your harness has no bounded read. |
74
+ | Going straight from `find_code` to source read | Memtrace's value is the graph. Default next step is `get_symbol_context` or `get_impact`, not source. |
75
+ | Treating 0 results as permission to grep | 0 results means broaden the Memtrace query, check repo_id/path filters, then reindex if coverage is missing |
76
+ | Assuming a UI subdirectory is unindexed because stats show backend files | If `ui/`, `memtrace-ui/`, or another source directory is under the indexed repo root, diagnose/reindex with Memtrace instead of searching files manually |
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: memtrace-first
3
- description: "Always use first for indexed source-code repos 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; only use file tools for configs, infra, docs, non-source artifacts, or exact paths already returned by Memtrace."
3
+ description: "Always use first for indexed source-code repos 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."
4
4
  ---
5
5
 
6
6
  # Memtrace First
@@ -28,11 +28,32 @@ Memtrace's hybrid search = **BM25 over symbol metadata** (name, signature, file_
28
28
 
29
29
  The semantic side means **string literals, error messages, magic constants, log strings, and any text inside an indexed symbol's body are findable through `find_code`**. The body got embedded; the embedding catches it. You do NOT need `Grep` to hunt for `STRIPE_KEY_FOO_BAR` if it lives inside a function in your indexed codebase.
30
30
 
31
+ ## Zero results are not a grep license
32
+
33
+ If Memtrace returns 0 results, or repository stats look incomplete, do **not**
34
+ infer that a source subdirectory is outside the index. Diagnose through
35
+ Memtrace:
36
+
37
+ 1. Call `list_indexed_repositories` and identify the repo root/repo_id.
38
+ 2. If the path is under that indexed repo root, keep using Memtrace.
39
+ 3. Retry with broader `find_code` terms and, when available, `file_path` filters
40
+ such as `ui/`, `memtrace-ui/`, `src/`, or the framework directory.
41
+ 4. If the language/path still appears missing, run `index_directory` on the repo
42
+ root with `incremental: true` (or ask before `clear_existing: true`).
43
+ 5. Report the indexing coverage problem instead of silently switching to grep.
44
+
45
+ **Never say "the index only covers X, so grep is right" when the target path is
46
+ inside the indexed repository.** That is an indexing freshness/coverage issue,
47
+ not permission to abandon Memtrace.
48
+
31
49
  ## The narrow exceptions where grep/glob are still right
32
50
 
33
51
  These are the ONLY cases where file tools beat memtrace:
34
52
 
35
- - **Files outside the indexed repo.** Vendored deps, system headers, dirs `walker::is_excluded_path` skipped (`.git`, `node_modules`, `target`, `dist`). Memtrace literally cannot see them.
53
+ - **Files outside every indexed repo root.** Confirm this with
54
+ `list_indexed_repositories`; 0 search results or missing language stats do not
55
+ prove it. Vendored deps, system headers, and excluded dirs
56
+ (`.git`, `node_modules`, `target`, `dist`) are examples Memtrace cannot see.
36
57
  - **Non-source artifacts.** `.env`, `package.json`, build scripts, top-level `README.md`, raw config files. Memtrace indexes parseable code, not configuration text.
37
58
  - **Pure file-inventory questions.** "How many `*.test.ts` files exist", "list every Markdown file in `docs/`". You're asking for a file count, not a symbol search.
38
59
  - **Reading at a known path.** Once memtrace has handed you `file_path:start_line:end_line`, use `Read` — never substitute `Grep` for `Read`.
@@ -132,6 +153,8 @@ You are violating this skill if you think:
132
153
  | "Let me read the whole file" | `get_symbol_context` gives you only what matters |
133
154
  | "It's just a quick search" | Grep has no understanding of call graphs, communities, or time |
134
155
  | "I don't know if it's indexed" | Check with `list_indexed_repositories` first — takes 1 second |
156
+ | "Memtrace returned 0 results" | Broaden the Memtrace query, check repo_id/path coverage, then reindex if needed |
157
+ | "Stats only show Rust, but I need `ui/` or `memtrace-ui/`" | That is a coverage diagnostic. Reindex the repo root; do not grep source code. |
135
158
  | "The user didn't say to use Memtrace" | User asked about the code. Repo is indexed. Use Memtrace. |
136
159
  | "This is a simple question" | Simple questions benefit most — one `find_symbol` vs 20 file reads |
137
160
 
@@ -140,7 +163,7 @@ You are violating this skill if you think:
140
163
  Use Grep/Glob/Read ONLY for:
141
164
  - Reading the **exact source lines** of a symbol you already located via Memtrace
142
165
  - Files that are config, data, or docs (not source code symbols)
143
- - Repos confirmed NOT indexed in Memtrace
166
+ - Repos or paths confirmed outside every Memtrace indexed root
144
167
 
145
168
  Never use file tools as a **discovery** mechanism when Memtrace is available.
146
169
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "memtrace",
3
- "version": "0.3.27",
3
+ "version": "0.3.30",
4
4
  "description": "Code intelligence graph — MCP server + AI agent skills + visualization UI",
5
5
  "keywords": [
6
6
  "mcp",
@@ -37,9 +37,9 @@
37
37
  "fs-extra": "^11.0.0"
38
38
  },
39
39
  "optionalDependencies": {
40
- "@memtrace/darwin-arm64": "0.3.26",
41
- "@memtrace/linux-x64": "0.3.26",
42
- "@memtrace/win32-x64": "0.3.26"
40
+ "@memtrace/darwin-arm64": "0.3.30",
41
+ "@memtrace/linux-x64": "0.3.30",
42
+ "@memtrace/win32-x64": "0.3.30"
43
43
  },
44
44
  "engines": {
45
45
  "node": ">=18"
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: memtrace-index
3
- description: "Always use when the user asks to index, parse, ingest, reindex, watch, or prepare a source-code repo for Memtrace analysis, or when code exploration is needed but no Memtrace index exists. Use this before Grep, Glob, rg, find, or manual code search whenever the repo can be indexed."
3
+ description: "Always use when the user asks to index, parse, ingest, reindex, watch, or prepare a source-code repo for Memtrace analysis, when code exploration needs an index, or when searches return 0/partial results for source paths under an indexed root. Use this before Grep, Glob, rg, find, or manual code search whenever the repo can be indexed."
4
4
  allowed-tools:
5
5
  - mcp__memtrace__index_directory
6
6
  - mcp__memtrace__check_job_status
@@ -32,6 +32,11 @@ Use the `list_indexed_repositories` MCP tool first. If the repo is already index
32
32
 
33
33
  **Success criteria:** You have a list of repo_ids and their last-indexed timestamps.
34
34
 
35
+ If a repo is present but searches miss a source subdirectory under that repo
36
+ root (for example `ui/`, `memtrace-ui/`, `web/`, `frontend/`, or `src/`), treat
37
+ that as a stale/partial index. Do not use grep as a workaround. Run incremental
38
+ indexing on the repo root, then retry the Memtrace query.
39
+
35
40
  ### 2. Index the directory
36
41
 
37
42
  Use the `index_directory` MCP tool:
@@ -1,11 +1,6 @@
1
1
  ---
2
2
  name: memtrace-search
3
- description: "Always use to find, search, locate, or look up source-code symbols, functions, classes, types, constants, definitions, implementations, logic, error strings inside code, or where code lives. Do not use Grep, Glob, rg, find, or manual file search for code discovery; Memtrace uses BM25, vector search, RRF, and the AST graph."
4
- allowed-tools:
5
- - mcp__memtrace__find_code
6
- - mcp__memtrace__find_symbol
7
- - mcp__memtrace__list_indexed_repositories
8
- user-invocable: true
3
+ description: "Always use to find, search, locate, or look up source-code symbols, functions, classes, types, constants, definitions, implementations, logic, error strings inside code, or where code lives. Do not use Grep, Glob, rg, find, or manual file search for code discovery. If Memtrace returns 0 results, broaden the Memtrace query and diagnose/reindex; do not switch to grep."
9
4
  ---
10
5
 
11
6
  ## Overview
@@ -18,6 +13,7 @@ Find code using hybrid BM25 full-text + semantic vector search with Reciprocal R
18
13
  |------|----------|
19
14
  | `find_code` | Natural-language queries ("authentication middleware", "retry logic"), broad searches |
20
15
  | `find_symbol` | Exact identifier names ("getUserById", "PaymentService"), when you know the name |
16
+ | `get_source_window` | Optional: bounded source read after a Memtrace hit, when your harness lacks `Read(file, offset, limit)`. Otherwise prefer your harness's bounded read with the returned `start_line` / `end_line`. |
21
17
 
22
18
  ## Steps
23
19
 
@@ -52,11 +48,37 @@ Find code using hybrid BM25 full-text + semantic vector search with Reciprocal R
52
48
 
53
49
  ### 3. Use results for next steps
54
50
 
51
+ The default next step is a **graph tool** — `get_symbol_context`,
52
+ `analyze_relationships`, or `get_impact`. Those answer "who calls this",
53
+ "what's the blast radius", "what community is it part of" — context no
54
+ file read can give. That's what Memtrace uniquely provides.
55
+
56
+ Source bytes come last, only when you're about to edit or quote. Use a
57
+ bounded `Read(file_path, offset=start_line, limit=end_line-start_line+8)`,
58
+ or `get_source_window` if your harness lacks bounded reads. Do not whole-file.
59
+
55
60
  Save the symbol `id` from results — pass it to:
56
61
  - `analyze_relationships` to map callers/callees
57
62
  - `get_symbol_context` for a 360-degree view
58
63
  - `get_impact` to assess blast radius before changes
59
64
 
65
+ ### Multi-word natural-language queries
66
+
67
+ When your query is 3+ words and feels descriptive (e.g. "validate auth token", "find HTTP server error"), don't stop at the first `find_code` call:
68
+
69
+ 1. First try the verbatim query.
70
+ 2. If results look generic or the right doc isn't at rank 1, fan out **in parallel** with up to 3 identifier-shaped reshapes:
71
+ - camelCase: "validate auth token" → `validateAuthToken`
72
+ - snake_case: → `validate_auth_token`
73
+ - Domain-likely identifiers: → `auth_token`, `tokenValidator`, `verifyToken`
74
+ 3. Memtrace's tokenizer splits camelCase / snake / kebab at index time, so reshaped queries hit identifier names directly.
75
+ 4. Take the union of top-5 from each call, dedupe by `file_path:start_line`.
76
+
77
+ **Worked examples** (verbatim → reshapes to try in parallel):
78
+ - "validate auth token" → `validateAuthToken`, `validate_auth_token`, `verifyToken`
79
+ - "find http server error" → `findHttpServerError`, `http_error`, `serverError`
80
+ - "render value panel" → `renderValuePanel`, `ValuePanel`, `value_panel`
81
+
60
82
  ## Common Mistakes
61
83
 
62
84
  | Mistake | Reality |
@@ -65,3 +87,7 @@ Save the symbol `id` from results — pass it to:
65
87
  | Using find_symbol for vague queries | Use `find_code` for natural-language; `find_symbol` is for exact names |
66
88
  | Ignoring the `kind` filter | Narrow results with kind=Function, kind=Class etc. to reduce noise |
67
89
  | Re-searching to get more context | Use the symbol `id` with `get_symbol_context` instead of re-searching |
90
+ | Reading the whole file after a hit | First call `get_symbol_context` for callers/callees. If you still need source, do a bounded `Read(file, offset=start_line, limit=N)` — never whole-file. `get_source_window` is fine if your harness has no bounded read. |
91
+ | Going straight from `find_code` to source read | Memtrace's value is the graph. Default next step is `get_symbol_context` or `get_impact`, not source. |
92
+ | Treating 0 results as permission to grep | 0 results means broaden the Memtrace query, check repo_id/path filters, then reindex if coverage is missing |
93
+ | Assuming a UI subdirectory is unindexed because stats show backend files | If `ui/`, `memtrace-ui/`, or another source directory is under the indexed repo root, diagnose/reindex with Memtrace instead of searching files manually |
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: memtrace-first
3
- description: "Always use first for indexed source-code repos 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; only use file tools for configs, infra, docs, non-source artifacts, or exact paths already returned by Memtrace."
3
+ description: "Always use first for indexed source-code repos 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."
4
4
  ---
5
5
 
6
6
  # Memtrace First
@@ -9,12 +9,15 @@ description: "Always use first for indexed source-code repos before searching fi
9
9
 
10
10
  ```
11
11
  IF THE REPO IS INDEXED IN MEMTRACE → USE MEMTRACE TOOLS FIRST.
12
- Memtrace returns exact file_path + start_line + end_line for every result.
13
- Read the file at THAT location. Do not Grep/Glob/Find to "locate" anything
14
- already in the graph.
12
+ After a search hit, route to GRAPH tools (get_symbol_context, get_impact,
13
+ analyze_relationships) that's what Memtrace uniquely provides. Read source
14
+ ONLY when you're about to edit or quote, and read only the bounded span
15
+ returned by Memtrace (start_line .. end_line + small context). Do not
16
+ Grep/Glob/Find to "locate" anything already in the graph, and do not read
17
+ the whole file when Memtrace has given you exact lines.
15
18
  ```
16
19
 
17
- Memtrace is the memory layer of the codebase. It has the full knowledge graph: every symbol, call, import, community, process, and API — with time dimension. File tools are blind to this structure.
20
+ 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.
18
21
 
19
22
  **97% better accuracy. 83% fewer wasted tokens. No exceptions for what's in the graph.**
20
23
 
@@ -28,14 +31,35 @@ Memtrace's hybrid search = **BM25 over symbol metadata** (name, signature, file_
28
31
 
29
32
  The semantic side means **string literals, error messages, magic constants, log strings, and any text inside an indexed symbol's body are findable through `find_code`**. The body got embedded; the embedding catches it. You do NOT need `Grep` to hunt for `STRIPE_KEY_FOO_BAR` if it lives inside a function in your indexed codebase.
30
33
 
34
+ ## Zero results are not a grep license
35
+
36
+ If Memtrace returns 0 results, or repository stats look incomplete, do **not**
37
+ infer that a source subdirectory is outside the index. Diagnose through
38
+ Memtrace:
39
+
40
+ 1. Call `list_indexed_repositories` and identify the repo root/repo_id.
41
+ 2. If the path is under that indexed repo root, keep using Memtrace.
42
+ 3. Retry with broader `find_code` terms and, when available, `file_path` filters
43
+ such as `ui/`, `memtrace-ui/`, `src/`, or the framework directory.
44
+ 4. If the language/path still appears missing, run `index_directory` on the repo
45
+ root with `incremental: true` (or ask before `clear_existing: true`).
46
+ 5. Report the indexing coverage problem instead of silently switching to grep.
47
+
48
+ **Never say "the index only covers X, so grep is right" when the target path is
49
+ inside the indexed repository.** That is an indexing freshness/coverage issue,
50
+ not permission to abandon Memtrace.
51
+
31
52
  ## The narrow exceptions where grep/glob are still right
32
53
 
33
54
  These are the ONLY cases where file tools beat memtrace:
34
55
 
35
- - **Files outside the indexed repo.** Vendored deps, system headers, dirs `walker::is_excluded_path` skipped (`.git`, `node_modules`, `target`, `dist`). Memtrace literally cannot see them.
56
+ - **Files outside every indexed repo root.** Confirm this with
57
+ `list_indexed_repositories`; 0 search results or missing language stats do not
58
+ prove it. Vendored deps, system headers, and excluded dirs
59
+ (`.git`, `node_modules`, `target`, `dist`) are examples Memtrace cannot see.
36
60
  - **Non-source artifacts.** `.env`, `package.json`, build scripts, top-level `README.md`, raw config files. Memtrace indexes parseable code, not configuration text.
37
61
  - **Pure file-inventory questions.** "How many `*.test.ts` files exist", "list every Markdown file in `docs/`". You're asking for a file count, not a symbol search.
38
- - **Reading at a known path.** Once memtrace has handed you `file_path:start_line:end_line`, use `Read` never substitute `Grep` for `Read`.
62
+ - **Reading at a known path outside Memtrace.** For configs, docs, or non-source artifacts that Memtrace cannot index, file `Read` is fine. For source-code spans returned by Memtrace, read the precise line range (your harness's `Read` with offset/limit, or `get_source_window` if your harness lacks bounded reads). Do not whole-file Read when you have a span.
39
63
 
40
64
  For everything else inside the indexed repo, memtrace is the right tool.
41
65
 
@@ -43,16 +67,18 @@ For everything else inside the indexed repo, memtrace is the right tool.
43
67
 
44
68
  | Question Claude is asking | Right tool |
45
69
  |---|---|
46
- | "Where is symbol `foo` defined?" | `find_symbol(name="foo")` → file:line. Then `Read` that range. |
70
+ | "Where is symbol `foo` defined?" | `find_symbol(name="foo")` → then `get_symbol_context` for callers/callees/community, NOT a source read unless you're editing. |
47
71
  | "What calls `foo`?" | `get_symbol_context(name="foo")` → callers with file:line each. |
48
- | "How does authentication work?" | `find_code(query="authentication")` → ranked symbols with file:line. |
72
+ | "How does authentication work?" | `find_code(query="authentication")` → `get_symbol_context` on the top hit, NOT a source read. |
73
+ | "Find behavior X" with multi-word phrase (3+ words) | `find_code(verbatim)` first; if low confidence, fan out with identifier-shaped reshapes (camelCase / snake_case). |
49
74
  | "Find the function that uses `STRIPE_KEY_FOO_BAR`" | `find_code(query="STRIPE_KEY_FOO_BAR")` → semantic finds it inside any embedded body. |
50
75
  | "Where's that error message `'connection refused for tenant'`?" | `find_code(query="connection refused for tenant")` → semantic catches it. |
51
76
  | "What breaks if I change `foo`?" | `get_impact(name="foo")` → blast radius with file:line. |
52
77
  | "What changed in `auth.ts` last week?" | `get_evolution(file_path="auth.ts", from="7d ago")`. |
53
78
  | "List all `*.test.ts` files." | `Glob` (file inventory, not symbol search). |
54
79
  | "Find this string in my `.env`." | `Grep` (non-source artifact). |
55
- | "Read file I already have the path of." | `Read` (path is known). |
80
+ | "I'm about to edit `foo` show me its source." | Bounded `Read(file_path, offset=start_line, limit=end_line-start_line+8)`, or `get_source_window` if your harness lacks bounded reads. Never whole-file. |
81
+ | "Read config/doc file I already have the path of." | `Read` (non-source artifact, path is known). |
56
82
 
57
83
  ## Parameter Types — Read This Before Calling Any Tool
58
84
 
@@ -80,7 +106,7 @@ If not indexed → offer to index with `mcp__memtrace__index_directory`, then fo
80
106
  | What you need | Use instead of Grep/Glob/Read |
81
107
  |---|---|
82
108
  | Find a function / class / symbol | `find_symbol` or `find_code` |
83
- | Understand how something works | `get_symbol_context` |
109
+ | Understand how something works | `get_symbol_context` (the default next step) |
84
110
  | Find all callers of a function | `get_symbol_context` (callers field) |
85
111
  | Find all callees / dependencies | `get_symbol_context` (callees field) |
86
112
  | Trace a request / execution path | `get_process_flow` |
@@ -95,14 +121,15 @@ If not indexed → offer to index with `mcp__memtrace__index_directory`, then fo
95
121
  | Dependency between two symbols | `find_dependency_path` |
96
122
  | What files change together? | `get_cochange_context` |
97
123
  | Architecture overview | `list_communities` + `find_central_symbols` |
124
+ | About to edit / quote — need exact lines | Bounded `Read(file, offset=start_line, limit=N)` (preferred), or `get_source_window` for path-resolution parity |
98
125
 
99
126
  ## Standard Workflows
100
127
 
101
128
  ### "How does X work?" / "Explain X"
102
129
  1. `find_symbol` or `find_code` → locate the symbol
103
- 2. `get_symbol_context` → callers, callees, community, processes
130
+ 2. `get_symbol_context` → callers, callees, community, processes (this usually answers "how it works")
104
131
  3. `get_process_flow` (if it's a process/request path)
105
- 4. Read source ONLY for the exact lines you need to quote
132
+ 4. Only if you need to quote source: bounded `Read` at start_line..end_line, or `get_source_window`
106
133
 
107
134
  ### Debugging "X is broken"
108
135
  1. `find_symbol` → locate the broken thing
@@ -114,7 +141,7 @@ If not indexed → offer to index with `mcp__memtrace__index_directory`, then fo
114
141
  ### "Where is X defined / called?"
115
142
  1. `find_symbol` with `fuzzy: true`
116
143
  2. `get_symbol_context` for full caller/callee map
117
- 3. Read specific file only after locating exact line
144
+ 3. Only if you need source text: bounded `Read` at start_line..end_line, or `get_source_window`
118
145
 
119
146
  ### Before any code modification
120
147
  1. `find_symbol` → confirm you have the right target
@@ -129,18 +156,25 @@ You are violating this skill if you think:
129
156
  |---|---|
130
157
  | "Let me grep for this" | `find_code` or `find_symbol` is faster and structurally aware |
131
158
  | "Let me glob for the file" | `find_symbol` returns exact location with context |
132
- | "Let me read the whole file" | `get_symbol_context` gives you only what matters |
159
+ | "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 |
133
160
  | "It's just a quick search" | Grep has no understanding of call graphs, communities, or time |
134
161
  | "I don't know if it's indexed" | Check with `list_indexed_repositories` first — takes 1 second |
162
+ | "Memtrace returned 0 results" | Broaden the Memtrace query, check repo_id/path coverage, then reindex if needed |
163
+ | "Stats only show Rust, but I need `ui/` or `memtrace-ui/`" | That is a coverage diagnostic. Reindex the repo root; do not grep source code. |
135
164
  | "The user didn't say to use Memtrace" | User asked about the code. Repo is indexed. Use Memtrace. |
136
165
  | "This is a simple question" | Simple questions benefit most — one `find_symbol` vs 20 file reads |
137
166
 
138
167
  ## When File Tools Are Still Correct
139
168
 
140
169
  Use Grep/Glob/Read ONLY for:
141
- - Reading the **exact source lines** of a symbol you already located via Memtrace
170
+ - Non-source files or paths outside every indexed source repo
142
171
  - Files that are config, data, or docs (not source code symbols)
143
- - Repos confirmed NOT indexed in Memtrace
172
+ - Repos or paths confirmed outside every Memtrace indexed root
173
+
174
+ For source-code spans already located by Memtrace, use a **bounded** read —
175
+ your harness's `Read(file, offset, limit)` with the returned `start_line` /
176
+ `end_line`, or `get_source_window` if your harness lacks bounded reads. Do
177
+ not read the whole file.
144
178
 
145
179
  Never use file tools as a **discovery** mechanism when Memtrace is available.
146
180