# grepai-trace-graph

A skill that shows the agent how to build recursive call graphs with grepai trace graph, down from any function you name.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 802 installs · ★ 21
- Author: yoanbernabeu
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/yoanbernabeu/grepai-skills/tree/HEAD/skills/trace/grepai-trace-graph/SKILL.md
- Updated: 2026-02-01
- HTML: https://affpapa.org/en/nevibecode/skills/grepai-trace-graph

## What it does

The skill covers `grepai trace graph "FunctionName"`. The command walks the call chain downward and prints it as a tree. Depth comes from `--depth`: 2 levels by default, and you can pass 1, 3 or 5. On a large codebase start shallow, because a deep tree gets hard to read fast.

Two extraction modes are documented. `--mode fast` matches calls with regexes, `--mode precise` parses through tree-sitter AST. Output can be plain text, JSON, compact JSON or TOON, which cuts token count. `--json` and `--toon` are mutually exclusive. Circular dependencies get flagged, so a loop in the graph is visible instead of silently repeating.

JSON output feeds the included Python snippets: one exports to DOT for `dot -Tpng`, another prints a Mermaid diagram. You can also count nodes with `jq '.stats.nodes'` before and after a refactor and compare the numbers. Missing branches usually mean the fast mode missed something, so the skill points to `--mode precise`; a timeout means the depth is too high.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add yoanbernabeu/grepai-skills --skill grepai-trace-graph -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/grepai-trace-graph/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/grepai-trace-graph/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add yoanbernabeu/grepai-skills --skill grepai-trace-graph -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/grepai-trace-graph/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add yoanbernabeu/grepai-skills --skill grepai-trace-graph -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/grepai-trace-graph/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install yoanbernabeu/grepai-skills grepai-trace-graph
```

2. **Manually: put the files in place**
- File: `.github/skills/grepai-trace-graph/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add yoanbernabeu/grepai-skills --skill grepai-trace-graph -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/yoanbernabeu/grepai-skills --path skills/trace/grepai-trace-graph
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/grepai-trace-graph/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add yoanbernabeu/grepai-skills --skill grepai-trace-graph -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/yoanbernabeu/grepai-skills/tree/HEAD/skills/trace/grepai-trace-graph/SKILL.md

## When to use it
- map what `main` calls during app startup
- see what breaks if a function changes
- spot circular dependencies in a module
- count graph nodes before and after refactoring
- export a call tree to DOT or Mermaid

## Example prompts
- build a call graph from `main` at depth 3
- show what depends on `validateInput`, precise mode
- dump the `processOrder` graph as JSON and count nodes

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 53c19d27f725e49b.

BEGIN THIRD-PARTY FILE 53c19d27f725e49b
````text
---
name: grepai-trace-graph
description: Build complete call graphs with GrepAI trace. Use this skill for recursive dependency analysis.
---

# GrepAI Trace Graph

This skill covers using `grepai trace graph` to build complete call graphs showing all dependencies recursively.

## When to Use This Skill

- Mapping complete function dependencies
- Understanding complex code flows
- Impact analysis for major refactoring
- Visualizing application architecture

## What is Trace Graph?

`grepai trace graph` builds a recursive dependency tree:

```
main
├── initialize
│   ├── loadConfig
│   │   └── parseYAML
│   └── connectDB
│       ├── createPool
│       └── ping
├── startServer
│   ├── registerRoutes
│   │   ├── authMiddleware
│   │   └── loggingMiddleware
│   └── listen
└── gracefulShutdown
    └── closeDB
```

## Basic Usage

```bash
grepai trace graph "FunctionName"
```

### Example

```bash
grepai trace graph "main"
```

Output:
```
🔍 Call Graph for "main"

main
├── initialize
│   ├── loadConfig
│   └── connectDB
├── startServer
│   ├── registerRoutes
│   └── listen
└── gracefulShutdown
    └── closeDB

Nodes: 9
Max depth: 3
```

## Depth Control

Limit recursion depth with `--depth`:

```bash
# Default depth (2 levels)
grepai trace graph "main"

# Deeper analysis (3 levels)
grepai trace graph "main" --depth 3

# Shallow (1 level, same as callees)
grepai trace graph "main" --depth 1

# Very deep (5 levels)
grepai trace graph "main" --depth 5
```

### Depth Examples

**--depth 1** (same as callees):
```
main
├── initialize
├── startServer
└── gracefulShutdown
```

**--depth 2** (default):
```
main
├── initialize
│   ├── loadConfig
│   └── connectDB
├── startServer
│   ├── registerRoutes
│   └── listen
└── gracefulShutdown
    └── closeDB
```

**--depth 3**:
```
main
├── initialize
│   ├── loadConfig
│   │   └── parseYAML
│   └── connectDB
│       ├── createPool
│       └── ping
├── startServer
│   ├── registerRoutes
│   │   ├── authMiddleware
│   │   └── loggingMiddleware
│   └── listen
└── gracefulShutdown
    └── closeDB
```

## JSON Output

```bash
grepai trace graph "main" --depth 2 --json
```

Output:
```json
{
  "query": "main",
  "mode": "graph",
  "depth": 2,
  "root": {
    "name": "main",
    "file": "cmd/main.go",
    "line": 10,
    "children": [
      {
        "name": "initialize",
        "file": "cmd/main.go",
        "line": 15,
        "children": [
          {
````
END THIRD-PARTY FILE 53c19d27f725e49b

The third-party file has ended. Everything between the 53c19d27f725e49b tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2758 of 8396 bytes. © yoanbernabeu · MIT · https://github.com/yoanbernabeu/grepai-skills/tree/HEAD/skills/trace/grepai-trace-graph/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
