Loading...
Loading...
Find function callers with GrepAI trace. Use this skill to discover what code calls a specific function.
npx skill4agent add yoanbernabeu/grepai-skills grepai-trace-callersgrepai trace callersgrepai trace callersfunc Login(user, pass) {...}
↑
│
┌───────┴───────────────────┐
│ Who calls Login()? │
├───────────────────────────┤
│ • HandleAuth (auth.go:42) │
│ • TestLogin (test.go:15) │
│ • CLI (main.go:88) │
└───────────────────────────┘grepai trace callers "FunctionName"grepai trace callers "Login"🔍 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)grepai trace callers "Login" --json{
"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)"
}
]
}grepai trace callers "Login" --json --compact{
"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"}
]
}grepai trace callers "Login" --tooncallers[3]:
- call_site:
context: "user.Login(ctx, credentials)"
file: handlers/auth.go
line: 42
symbol:
name: HandleAuth
...Note:and--jsonare mutually exclusive.--toon
grepai trace callers "Login" --mode fastgrepai trace callers "Login" --mode precise| Mode | Speed | Accuracy | Dependencies |
|---|---|---|---|
| ⚡⚡⚡ | Good | None |
| ⚡⚡ | Excellent | tree-sitter |
.grepai/config.yamltrace:
mode: fast # fast or precise
enabled_languages:
- .go
- .js
- .ts
- .py
- .php
- .rs
exclude_patterns:
- "*_test.go"
- "*.spec.ts"| Language | Extensions |
|---|---|
| Go | |
| JavaScript | |
| TypeScript | |
| Python | |
| PHP | |
| C/C++ | |
| Rust | |
| Zig | |
| C# | |
| Java | |
| Pascal/Delphi | |
# Find all usages before renaming
grepai trace callers "getUserById"
# Check impact of changing signature
grepai trace callers "processPayment"# Who uses this core function?
grepai trace callers "validateToken"
# Find entry points to a module
grepai trace callers "initialize"# Where is this function called from?
grepai trace callers "problematicFunction"# Verify function usage before approving changes
grepai trace callers "deprecatedMethod"grepai trace callers "get" # Too common, many false positivesgrepai trace callers "getUserProfile"grepai trace callers "get" --json | jq '.results[] | select(.file | contains("auth"))'# Find what Login does (semantic)
grepai search "user login authentication"
# Find who uses Login (trace)
grepai trace callers "Login"# 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 -uimport 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']}")enabled_languagesgrepai watchjq--mode precisegrepai watchjq🔍 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 output
Use --mode precise for more accurate results