# cartog — Usage
## Setup
```bash
cargo build --release
cargo install --path . # optional: puts cartog on your PATH
```
## Commands
### `cartog index <path>`
Build or update the graph. Run this first, then again after code changes.
```bash
cartog index . # index current directory
cartog index src/ # index a subdirectory only
```
Incremental — skips files whose content hash hasn't changed.
### `cartog outline <file>`
Show all symbols in a file with their types, signatures, and line ranges. Use this instead of reading a file when you need structure.
```bash
cartog outline src/db.rs
```
```
use anyhow L1
use rusqlite L2
class Database L62-500
method open(path: &str) -> Result<Self> L64-72
method insert_symbol(&self, sym: &Symbol) -> Result<()> L130-148
...
```
### `cartog callees <name>`
Find what a function calls — answers "what does this depend on?".
```bash
cartog callees validate_token
```
```
lookup_session auth/tokens.py:37
TokenError auth/tokens.py:39
ExpiredTokenError auth/tokens.py:42
```
### `cartog impact <name> [--depth N]`
Transitive impact analysis — follows the caller chain up to N hops (default 3). Answers "what breaks if I change this?".
```bash
cartog impact validate_token --depth 3
```
```
calls get_current_user auth/service.py:40
calls refresh_token auth/tokens.py:54
calls impersonate auth/service.py:52
```
Indentation shows depth.
### `cartog refs <name> [--kind <kind>]`
All references to a symbol (calls, imports, inherits, type references, raises). Optionally filter by edge kind.
```bash
cartog refs UserService # all reference types
cartog refs validate_token --kind calls # only call sites
```
```
imports ./service routes/auth.py:3
calls login routes/auth.py:15
inherits AdminService auth/service.py:47
references process routes/auth.py:22
```
Available `--kind` values: `calls`, `imports`, `inherits`, `references`, `raises`.
### `cartog hierarchy <class>`
Show inheritance relationships involving a class — both parents and children.
```bash
cartog hierarchy AuthService
```
```
AuthService -> BaseService
AdminService -> AuthService
```
### `cartog deps <file>`
File-level import graph — what does this file import?
```bash
cartog deps src/routes/auth.py
```
```
validate_token L5
generate_token L5
User L6
```
### `cartog stats`
Summary of the index — file count, symbol count, edge resolution rate.
```bash
cartog stats
```
```
Files: 42
Symbols: 387
Edges: 1204 (891 resolved)
Languages:
python: 30 files
typescript: 12 files
Symbols by kind:
function: 142
method: 98
class: 45
import: 62
variable: 40
```
## JSON Output
All commands accept `--json` for structured output:
```bash
cartog --json refs validate_token
cartog --json outline src/auth/tokens.py
cartog --json stats
```