developer-detective
Developer Detective is a Claude Code skill for investigating implementation details and data flow in codebases using abstract syntax tree analysis. It leverages claudemem's callers and callees commands to efficiently locate function definitions, trace dependencies, find all usages, and perform impact analysis before code modifications. Use this skill when answering questions about how code works, where specific implementations are defined, how data flows through functions, or what breaks when changes are made.
git clone --depth 1 https://github.com/MadAppGang/claude-code /tmp/developer-detective && cp -r /tmp/developer-detective/plugins/code-analysis/skills/developer-detective ~/.claude/skills/developer-detectiveSKILL.md
# Developer Detective Skill
This skill uses claudemem's callers/callees analysis for implementation investigation.
## Why Claudemem Works Better for Development
| Task | claudemem | Native Tools |
|------|-----------|--------------|
| Find usages | `callers` shows all call sites | Grep (text match) |
| Trace dependencies | `callees` shows called functions | Manual reading |
| Understand context | `context` gives full picture | Multiple reads |
| Impact analysis | Caller chain reveals risk | Unknown |
**Primary commands:**
- `claudemem --agent callers <name>` - What calls this code
- `claudemem --agent callees <name>` - What this code calls
- `claudemem --agent context <name>` - Full understanding
# Developer Detective Skill
**Version:** 3.3.0
**Role:** Software Developer
**Purpose:** Implementation investigation using AST callers/callees and impact analysis
## Role Context
You are investigating this codebase as a **Software Developer**. Your focus is on:
- **Implementation details** - How code actually works
- **Data flow** - How data moves through the system (via callees)
- **Usage patterns** - How code is used (via callers)
- **Dependencies** - What a function needs to work
- **Impact analysis** - What breaks if you change something
## Why callers/callees is Perfect for Development
The `callers` and `callees` commands show you:
- **callers** = Every place that calls this code (impact of changes)
- **callees** = Every function this code calls (its dependencies)
- **Exact file:line** = Precise locations for reading/editing
- **Call kinds** = call, import, extends, implements
## Developer-Focused Commands (v0.3.0)
### Find Implementation
```bash
# Find where a function is defined
claudemem --agent symbol processPayment
# Get full context with callers and callees
claudemem --agent context processPayment```
### Trace Data Flow
```bash
# What does this function call? (data flows OUT)
claudemem --agent callees processPayment
# Follow the chain
claudemem --agent callees validateCardclaudemem --agent callees chargeStripe```
### Find All Usages
```bash
# Who calls this function? (usage patterns)
claudemem --agent callers processPayment
# This shows EVERY place that uses this code
```
### Impact Analysis (v0.4.0+ Required)
```bash
# Before modifying ANY code, check full impact
claudemem --agent impact functionToChange
# Output shows ALL transitive callers:
# direct_callers:
# - LoginController.authenticate:34
# - SessionMiddleware.validate:12
# transitive_callers (depth 2):
# - AppRouter.handleRequest:45
# - TestSuite.runAuth:89
```
**Why impact matters**:
- `callers` shows only direct callers (1 level)
- `impact` shows ALL transitive callers (full tree)
- Critical for refactoring decisions
**Handling Empty Results:**
```bash
IMPACT=$(claudemem --agent impact functionToChange)
if echo "$IMPACT" | grep -q "No callers"; then
echo "No callers found. This is either:"
echo " 1. An entry point (API handler, main function) - expected"
echo " 2. Dead code - verify with: claudemem dead-code"
echo " 3. Dynamically called - check for import(), reflection"
fi
```
### Impact Analysis (BEFORE Modifying)
```bash
# Quick check - direct callers only (v0.3.0)
claudemem --agent callers functionToChange
# Deep check - ALL transitive callers (v0.4.0+ Required)
IMPACT=$(claudemem --agent impact functionToChange)
# Handle results
if [ -z "$IMPACT" ] || echo "$IMPACT" | grep -q "No callers"; then
echo "No static callers found - verify dynamic usage patterns"
else
echo "$IMPACT"
echo ""
echo "This tells you:"
echo "- Direct callers (immediate impact)"
echo "- Transitive callers (ripple effects)"
echo "- Grouped by file (for systematic updates)"
fi
```
### Understanding Complex Code
```bash
# Get full picture: definition + callers + callees
claudemem --agent context complexFunction```
## PHASE 0: MANDATORY SETUP
### Step 1: Verify claudemem v0.3.0
```bash
which claudemem && claudemem --version
# Must be 0.3.0+
```
### Step 2: If Not Installed → STOP
Use AskUserQuestion (see ultrathink-detective for template)
### Step 3: Check Index Status
```bash
# Check claudemem installation and index
claudemem --version && ls -la .claudemem/index.db 2>/dev/null
```
### Step 3.5: Check Index Freshness
Before proceeding with investigation, verify the index is current:
```bash
# First check if index exists
if [ ! -d ".claudemem" ] || [ ! -f ".claudemem/index.db" ]; then
# Use AskUserQuestion to prompt for index creation
# Options: [1] Create index now (Recommended), [2] Cancel investigation
exit 1
fi
# Count files modified since last index
STALE_COUNT=$(find . -type f \( -name "*.ts" -o -name "*.tsx" -o -name "*.js" -o -name "*.jsx" -o -name "*.py" -o -name "*.go" -o -name "*.rs" \) \
-newer .claudemem/index.db 2>/dev/null | grep -v "node_modules" | grep -v ".git" | grep -v "dist" | grep -v "build" | wc -l)
STALE_COUNT=$((STALE_COUNT + 0)) # Normalize to integer
if [ "$STALE_COUNT" -gt 0 ]; then
# Get index time with explicit platform detection
if [[ "$OSTYPE" == "darwin"* ]]; then
INDEX_TIME=$(stat -f "%Sm" -t "%Y-%m-%d %H:%M" .claudemem/index.db 2>/dev/null)
else
INDEX_TIME=$(stat -c "%y" .claudemem/index.db 2>/dev/null | cut -d'.' -f1)
fi
INDEX_TIME=${INDEX_TIME:-"unknown time"}
# Get sample of stale files
STALE_SAMPLE=$(find . -type f \( -name "*.ts" -o -name "*.tsx" \) \
-newer .claudemem/index.db 2>/dev/null | grep -v "node_modules" | grep -v ".git" | head -5)
# Use AskUserQuestion (see template in ultrathink-detective)
fi
```
### Step 4: Index if Needed
```bash
claudemem index
```
---
## Workflow: Implementation Investigation (v0.3.0)
### Phase 1: Map the Area
```bash
# Get overview of the feature area
claudemem --agent map "payment processing"```
### Phase 2: Find the Entry Point
```bash
# Locate the main function (highest PageRank in area)
claudemem --agent symbol PaymentService```
### Phase 3: Trace the Flow
`Architecture Decision Records (ADR) documentation practice. Use when documenting architectural decisions, recording technical trade-offs, creating decision logs, or establishing architectural patterns. Trigger keywords - "ADR", "architecture decision", "decision record", "trade-offs", "architectural decision", "decision log".
Use when deciding whether to launch an agent, selecting which agent to use, or coordinating multiple agents. Covers delegation criteria, external-model patterns, task isolation, and agent selection strategies.
Use when designing REST or GraphQL APIs, defining endpoints, implementing pagination/filtering, handling API versioning, or establishing API documentation with OpenAPI/Swagger.
Use when integrating Apidog + OpenAPI specifications with your React app. Covers MCP server setup, type generation, and query layer integration. Use when setting up API clients, generating types from OpenAPI, or integrating with Apidog MCP.
Analyzes API documentation from OpenAPI specs to provide TypeScript interfaces, request/response formats, and implementation guidance. Use when implementing API integrations, debugging API errors (400, 401, 404), replacing mock APIs, verifying data types, or when user mentions endpoints, API calls, or backend integration.
Use when analyzing architecture and system design. Find design patterns, map layers, identify core abstractions via PageRank. Uses claudemem AST structural analysis for efficient architecture investigation.
On-demand security and code quality audit. Use when checking for vulnerabilities, security issues, code smells, or compliance problems. Trigger keywords - "audit", "security check", "vulnerability scan", "code quality", "compliance", "security audit".
Use when implementing authentication (JWT, sessions, OAuth), authorization (RBAC, ABAC), password hashing, MFA, or security best practices for backend services.