grepai-trace-callers
Skill20 starsChanged 35 days agoMITView on GitHub
Find function callers with GrepAI trace. Use this skill to discover what code calls a specific function.
In this repository26 other files it gives its agents.
- grepai-languagesSkill
- grepai-troubleshootingSkill
- grepai-workspacesSkill
- grepai-config-referenceSkill
- grepai-ignore-patternsSkill
- grepai-initSkill
- grepai-embeddings-lmstudioSkill
- grepai-embeddings-ollamaSkill
- grepai-embeddings-openaiSkill
- grepai-installationSkill
- grepai-ollama-setupSkill
- grepai-quickstartSkill
- grepai-chunkingSkill
- grepai-watch-daemonSkill
- grepai-mcp-claudeSkill
- grepai-mcp-cursorSkill
- grepai-mcp-toolsSkill
- grepai-search-advancedSkill
- grepai-search-basicsSkill
- grepai-search-boostingSkill
- grepai-search-tipsSkill
- grepai-storage-gobSkill
- grepai-storage-postgresSkill
- grepai-storage-qdrantSkill
- grepai-trace-calleesSkill
- grepai-trace-graphSkill
The file
We split this skill into the rules it gives an agent
12 rules. About 0 are common, 6 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 226
If your function name is common, results may include unrelated code:
- Distinctive: line 236
Use more specific name:
- Distinctive: line 248
Use together for comprehensive understanding:
- Distinctive: line 308
Check function name spelling (case-sensitive)
- Very specific: line 309
Ensure file type is in enabled_languages
- Very specific: line 310
Run grepai watch to update symbol index
- Distinctive: line 314
Use more specific function name
- Very specific: line 315
Add test or generated paths to the top-level ignore list
- Distinctive: line 320
Check if files are in ignore patterns
- Very specific: line 321
Check the extension is in trace.enabled_languages
- Very specific: line 327
Check symbol index: Run grepai watch first
- Very specific: line 330
Filter large results: Use jq or grep
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
GrepAI Trace Callers
This skill covers using grepai trace callers to find all code locations that call a specific function or method.
When to Use This Skill
- Finding all usages of a function before refactoring
- Understanding function dependencies
- Impact analysis before changes
- Code navigation and exploration
What is Trace Callers?
grepai trace callers answers: "Who calls this function?"
func Login(user, pass) {...}
↑
│
┌───────┴───────────────────┐
│ Who calls Login()? │
├───────────────────────────┤
│ • HandleAuth (auth.go:42) │
│ • TestLogin (test.go:15) │
│ • CLI (main.go:88) │
└───────────────────────────┘Basic Usage
grepai trace callers "FunctionName"Example
grepai trace callers "Login"Output:
🔍 Callers of "Login"
Found 3 callers:
1. HandleAuth
File: handlers/auth.go:42
Context: user.Login(ctx, credentials)
2. TestLoginSuccess
File: handlers/auth_test.go:15
Context: result := Login(testUser, testPass)
3. RunCLI
File: cmd/main.go:88
Context: err := auth.Login(username, password)JSON Output
For programmatic use:
grepai trace callers "Login" --jsonOutput:
{
"query": "Login",
"mode": "callers",
"count": 3,
"results": [
{
"file": "handlers/auth.go",
"line": 42,
"caller": "HandleAuth",
"context": "user.Login(ctx, credentials)"
},
{
"file": "handlers/auth_test.go",
"line": 15,
"caller": "TestLoginSuccess",
"context": "result := Login(testUser, testPass)"
},
{
"file": "cmd/main.go",
"line": 88,
"caller": "RunCLI",
"context": "err := auth.Login(username, password)"
}
]
}Compact JSON (AI Optimized)
grepai trace callers "Login" --json --compactOutput:
{
"q": "Login",
"m": "callers",
"c": 3,
"r": [
{"f": "handlers/auth.go", "l": 42, "fn": "HandleAuth"},
{"f": "handlers/auth_test.go", "l": 15, "fn": "TestLoginSuccess"},
{"f": "cmd/main.go", "l": 88, "fn": "RunCLI"}
]
}TOON Output (v0.26.0+)
TOON format offers ~50% fewer tokens than JSON:
grepai trace callers "Login" --toonOutput:
callers[3]:
- call_site:
context: "user.Login(ctx, credentials)"
file: handlers/auth.go
line: 42
symbol:
name: HandleAuth
...Note:
--jsonand--toonare mutually exclusive.
Extraction Mode
Symbols and calls are always extracted with regular expressions (the "fast" extractor used by grepai watch and grepai index); output reports "mode": "fast". The --mode flag is deprecated since grepai 1.0.0: it is still accepted for existing scripts, prints a deprecation warning and changes nothing. Do not pass --mode precise.
Configuration
Configure trace in .grepai/config.yaml:
trace:
enabled_languages:
- .go
- .js
- .ts
- .py
- .php
- .rsTo keep files (tests, generated code) out of the symbol index, use the top-level ignore list. trace.mode and trace.exclude_patterns never had any effect and were removed in grepai 1.0.0.
Supported Languages
| Language | Extensions |
| Go | .go |
| JavaScript | .js, .jsx |
| TypeScript | .ts, .tsx |
| Vue SFC | .vue |
| Python | .py |
| PHP | .php |
| Lua | .lua |
| Java | .java |
| C/C++ | .c, .h, .cpp, .hpp, .cc, .cxx, .hxx |
| Rust | .rs |
| Zig | .zig |
| C# | .cs |
| F# | .fs, .fsx, .fsi |
| Pascal/Delphi | .pas, .dpr |
| Ruby | .rb |
| GDScript | .gd |
A config created by an older version may lack newer extensions (.vue, .lua, .java, F#, .rb, .gd): add them to trace.enabled_languages by hand.
Use Cases
Before Refactoring
# Find all usages before renaming
grepai trace callers "getUserById"
# Check impact of changing signature
grepai trace callers "processPayment"Understanding Codebase
# Who uses this core function?
grepai trace callers "validateToken"
# Find entry points to a module
grepai trace callers "initialize"Debugging
# Where is this function called from?
grepai trace callers "problematicFunction"Code Review
# Verify function usage before approving changes
grepai trace callers "deprecatedMethod"Handling Common Names
If your function name is common, results may include unrelated code:
Problem
grepai trace callers "get" # Too common, many false positivesSolutions
- Use more specific name:
grepai trace callers "getUserProfile"- Filter results by path:
grepai trace callers "get" --json | jq '.results[] | select(.file | contains("auth"))'Combining with Semantic Search
Use together for comprehensive understanding:
# Find what Login does (semantic)
grepai search "user login authentication"
# Find who uses Login (trace)
grepai trace callers "Login"Scripting Examples
Bash
# Count callers
grepai trace callers "MyFunction" --json | jq '.count'
# Get caller function names
grepai trace callers "MyFunction" --json | jq -r '.results[].caller'
# Get file paths only
grepai trace callers "MyFunction" --json | jq -r '.results[].file' | sort -uPython
import subprocess
import json
result = subprocess.run(
['grepai', 'trace', 'callers', 'Login', '--json'],
capture_output=True,
text=True
)
data = json.loads(result.stdout)
print(f"Found {data['count']} callers of Login:")
for r in data['results']:
print(f" - {r['caller']} in {r['file']}:{r['line']}")Same-Name Definitions
When several functions share the name you trace (methods of different classes, functions in different files), grepai picks the definition deterministically: first by file path, then by line. The CLI and the MCP tools make the same choice, and it no longer depends on the order in which files were indexed.
Pass the bare name: Class::method or other qualified names are not supported.
grepai trace callers "save" # ✅
grepai trace callers "User::save" # ❌ not supportedEach caller is resolved in the file (and at the declaration line) where its call was found, so two same-name callers in one file are reported separately.
Common Issues
❌ Problem: No callers found ✅ Solutions:
- Check function name spelling (case-sensitive)
- Ensure file type is in
enabled_languages - Run
grepai watchto update symbol index
❌ Problem: Too many false positives ✅ Solutions:
- Use more specific function name
- Add test or generated paths to the top-level
ignorelist - Filter results with
jq
❌ Problem: Missing some callers ✅ Solutions:
- Check if files are in ignore patterns
- Check the extension is in
trace.enabled_languages - Dynamic calls (callbacks, reflection) are not detected by the regex extractor
Best Practices
- Use exact function name: Case matters
- Check symbol index: Run
grepai watchfirst - Use JSON for scripts: Easier to parse
- Combine with search: Semantic + trace = full picture
- Filter large results: Use
jqor grep
Output Format
Trace callers result:
🔍 Callers of "Login"
Mode: fast
Language files scanned: 245
Found 3 callers:
1. HandleAuth
File: handlers/auth.go:42
Context: user.Login(ctx, credentials)
2. TestLoginSuccess
File: handlers/auth_test.go:15
Context: result := Login(testUser, testPass)
3. RunCLI
File: cmd/main.go:88
Context: err := auth.Login(username, password)
Tip: Use --json for machine-readable outputDoes it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

