Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

125 changes: 0 additions & 125 deletions cmd/codebase-memory-mcp/assets/skills/codebase-memory-tracing/SKILL.md

This file was deleted.

54 changes: 54 additions & 0 deletions cmd/codebase-memory-mcp/assets/skills/codebase-memory/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
name: codebase-memory
description: >
Use the codebase knowledge graph for structural code queries. Triggers on: "explore the codebase",
"understand the architecture", "what functions exist", "show me the structure", "who calls this function",
"what does X call", "trace the call chain", "find callers of", "show dependencies", "impact analysis",
"dead code", "unused functions", "high fan-out", "refactor candidates", "code quality audit",
"graph query syntax", "Cypher query examples", "edge types", "how to use search_graph".
---

# Codebase Memory — Knowledge Graph Tools

Graph tools return precise structural results in ~500 tokens vs ~80K for grep-based exploration.

## Step 1: Check if project is indexed

```
list_projects
```

If the project is missing: `index_repository(repo_path="/path/to/project")`. If already indexed, skip — auto-sync keeps the graph fresh.

## What do you want to do?

| Goal | Read |
|------|------|
| **Explore codebase structure** — find functions, classes, routes, understand architecture | [references/exploring.md](references/exploring.md) |
| **Trace call chains** — who calls X, what does X call, impact analysis, cross-service calls | [references/tracing.md](references/tracing.md) |
| **Code quality analysis** — dead code, high fan-out, hidden coupling, refactor candidates | [references/quality.md](references/quality.md) |
| **Tool reference** — all 14 tools, edge types, node labels, Cypher syntax, regex patterns | [references/tool-reference.md](references/tool-reference.md) |

## Quick Decision Matrix

| Question | Tool call |
|----------|-----------|
| Who calls X? | `trace_call_path(direction="inbound")` |
| What does X call? | `trace_call_path(direction="outbound")` |
| Full call context | `trace_call_path(direction="both")` |
| Find by name pattern | `search_graph(name_pattern="...")` |
| Dead code | `search_graph(max_degree=0, exclude_entry_points=true)` |
| Cross-service edges | `query_graph` with Cypher |
| Impact of local changes | `detect_changes()` |
| Risk-classified trace | `trace_call_path(risk_labels=true)` |
| Text search | `search_code` or Grep |

## Gotchas

1. **`search_graph(relationship="HTTP_CALLS")` does NOT return edges** — it filters nodes by degree. Use `query_graph` with Cypher to see actual edge properties (url_path, confidence).
2. **`query_graph` has a 200-row cap** before aggregation — COUNT queries silently undercount on large codebases. Use `search_graph` with `min_degree`/`max_degree` for counting.
3. **`trace_call_path` needs exact names** — use `search_graph(name_pattern=".*Partial.*")` first to discover the exact function name.
4. **`direction="outbound"` misses cross-service callers** — always use `direction="both"` for complete context. Cross-service HTTP_CALLS appear as inbound edges.
5. **Results default to 10 per page** — check `has_more` and use `offset` to paginate.
6. **Dead code detection requires entry point exclusion** — without `exclude_entry_points=true`, route handlers and `main()` show as false positives.
7. **`search_graph` with degree filters has no row cap** (unlike `query_graph`). Use it for counting, not `query_graph`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Codebase Exploration

## Get a structural overview

```
get_graph_schema
```

Returns node label counts (functions, classes, routes), edge type counts, and relationship patterns. Use it to understand what's in the graph before querying.

## Find specific code elements

Find functions by name pattern:
```
search_graph(label="Function", name_pattern=".*Handler.*")
```

Find classes:
```
search_graph(label="Class", name_pattern=".*Service.*")
```

Find all REST routes:
```
search_graph(label="Route")
```

Find modules/packages:
```
search_graph(label="Module")
```

Scope to a specific directory:
```
search_graph(label="Function", qn_pattern=".*services\\.order\\..*")
```

## Read source code

After finding a function via search, read its source:
```
get_code_snippet(qualified_name="project.path.to.FunctionName")
```

## File/directory exploration

```
list_directory(path="src/services")
```

## When to Use Grep Instead

- Searching for **string literals** or error messages → `search_code` or Grep
- Finding a file by exact name → Glob
- The graph indexes structural elements, not text content

## Tips

- Use `project` parameter when multiple repos are indexed.
- Route nodes have a `properties.handler` field with the handler function name.
- `exclude_labels` removes noise (e.g., `exclude_labels=["Route"]` when searching by name pattern).
Loading