Skip to content

Commit f948c3f

Browse files
docs: add CLI graph files explainer
1 parent 50b581d commit f948c3f

2 files changed

Lines changed: 159 additions & 1 deletion

File tree

cli/graph-files.mdx

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
---
2+
title: 'Graph Files'
3+
description: 'How .graph.* sidecars give AI agents a live map of your codebase'
4+
icon: 'diagram-project'
5+
---
6+
7+
Supermodel's CLI workflow is built around graph files: small `.graph.*` sidecars written next to your source files.
8+
9+
If your repo has this file:
10+
11+
```text
12+
src/cache.ts
13+
```
14+
15+
Supermodel writes this file next to it:
16+
17+
```text
18+
src/cache.graph.ts
19+
```
20+
21+
The graph file is plain text. Your AI coding agent can read it with the same tools it already uses to read source code: `cat`, `grep`, editor context, or normal file search. No MCP server is required. No special editor integration is required.
22+
23+
## Why graph files live next to source files
24+
25+
AI agents spend a lot of time rebuilding a map of your repo. Before they can safely change one function, they need to know:
26+
27+
- What imports this file
28+
- What this file imports
29+
- What functions call this function
30+
- What this function calls
31+
- What could break if this file changes
32+
33+
Without graph files, the agent usually discovers that by searching over and over. It greps for names, opens callers, opens dependencies, follows imports, and still misses relationships.
34+
35+
Supermodel does that mapping once, writes the answer next to the code, and keeps it fresh while the watcher runs.
36+
37+
## What is inside a graph file
38+
39+
A graph file is a compact text summary of the relationships around one source file.
40+
41+
Most graph files include three sections:
42+
43+
```text
44+
[deps]
45+
imports: internal/config, internal/api
46+
imported_by: cmd/analyze.go, cmd/graph.go
47+
48+
[calls]
49+
Run calls createZip at internal/analyze/zip.go:41
50+
Run calls Client.Analyze at internal/api/client.go:52
51+
Run is called by newAnalyzeCommand at cmd/analyze.go:34
52+
53+
[impact]
54+
risk: medium
55+
domains: CLI, API client
56+
direct dependents: cmd/analyze.go, cmd/graph.go
57+
transitive dependents: cmd/audit.go, cmd/share.go
58+
```
59+
60+
The exact content depends on the language and the graph data available for that file. The important part is the shape: dependencies, calls, and impact are already summarized before the agent starts reading source.
61+
62+
## How agents use graph files
63+
64+
The recommended pattern is:
65+
66+
1. Run the watcher:
67+
68+
```bash
69+
supermodel
70+
```
71+
72+
2. Tell your agent that graph files exist:
73+
74+
```bash
75+
supermodel skill >> CLAUDE.md
76+
```
77+
78+
3. When the agent works on `src/cache.ts`, it reads `src/cache.graph.ts` first.
79+
80+
That gives the agent the map before it reads the implementation. It can still open source files, run tests, and grep when needed. The difference is that it starts with structure instead of guessing structure from raw text.
81+
82+
## Watcher vs one-shot analysis
83+
84+
The bare `supermodel` command is the live graph watcher:
85+
86+
```bash
87+
supermodel
88+
```
89+
90+
It builds the graph, writes sidecars, listens for file-change notifications, and refreshes affected graph files as you code. Stop it with `Ctrl+C`; generated sidecars are cleaned up on shutdown.
91+
92+
Use `analyze` when you only want one graph refresh and then exit:
93+
94+
```bash
95+
supermodel analyze
96+
```
97+
98+
Both commands write `.graph.*` sidecars by default. Use `--no-shards` with `analyze` if you want cache/API output without writing graph files:
99+
100+
```bash
101+
supermodel analyze --no-shards
102+
```
103+
104+
## Cache and freshness
105+
106+
Supermodel caches analysis results locally by repo content hash. Commands like `dead-code`, `blast-radius`, `focus`, `find`, and `graph` reuse that cache when possible.
107+
108+
Use `--force` on analysis commands when you want to bypass the cache:
109+
110+
```bash
111+
supermodel analyze --force
112+
supermodel dead-code --force
113+
supermodel graph --force
114+
```
115+
116+
Use `clean` when you want to remove generated graph files without running the watcher:
117+
118+
```bash
119+
supermodel clean
120+
```
121+
122+
Preview cleanup first:
123+
124+
```bash
125+
supermodel clean --dry-run
126+
```
127+
128+
## Before and after
129+
130+
Without graph files, a typical agent task starts like this:
131+
132+
```text
133+
grep for parseConfig
134+
open config.ts
135+
grep for imports
136+
open caller files
137+
grep again for indirect callers
138+
guess which tests matter
139+
```
140+
141+
With graph files, the task starts like this:
142+
143+
```text
144+
open config.graph.ts
145+
read [deps], [calls], and [impact]
146+
open the relevant source and test files
147+
make the change
148+
```
149+
150+
The graph file does not replace source code. It gives the agent a map before it reads the source code.
151+
152+
## Next
153+
154+
- Start with the [CLI quickstart](/cli/quickstart)
155+
- Read the [`supermodel` watcher reference](/cli/commands/supermodel)
156+
- Use [`analyze`](/cli/commands/analyze) for one-shot graph generation
157+
- Use [`skill`](/cli/commands/skill) to add graph-file instructions to your agent prompt

docs.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
"group": "Get started",
5050
"pages": [
5151
"cli/install",
52-
"cli/quickstart"
52+
"cli/quickstart",
53+
"cli/graph-files"
5354
]
5455
},
5556
{

0 commit comments

Comments
 (0)