| name | Investigating Code Patterns |
| description | Systematically trace code flows, locate implementations, diagnose performance issues, and map system architecture. Use when understanding how existing systems work, researching concepts, exploring code structure, or answering "how/where/why is X implemented?" questions. |
Investigating Code Patterns
When to Use This Skill
- Understanding how existing systems work end-to-end
- Researching concepts or technologies in your codebase
- Exploring code structure, patterns, and dependencies
- Answering "how/where/what" questions about implementations
- NOT for building new features (use implementation skills for that)
Core Investigation Types
1. Code Flow: "How does X work?"
Trace execution end-to-end from entry point to outcome.
Steps:
- Find the entry point (API endpoint, component, function)
- Trace function calls and data transformations
- Follow imports and dependencies
- Identify key decision points and error handling
2. Code Location: "Where is X implemented?"
Find where functionality lives in the codebase.
Steps:
- Search for relevant keywords using grep
- Check related files and modules
- Identify main implementation and supporting files
- Verify entry points and usage patterns
3. Performance Analysis: "Why is X slow?"
Diagnose bottlenecks using 3-phase approach.
Phase 1: Locate bottleneck
- Find entry point where slowness occurs
- Trace execution path
- Identify all operations (DB queries, API calls, compute, I/O)
- Look for obvious issues: N+1 queries, nested loops, large payloads
Phase 2: Root cause (if unclear)