investigating-code-patterns
Systematically analyze code structure, trace execution flows, and troubleshoot system bottlenecks.
Install
mkdir -p .claude/skills/investigating-code-patterns && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/3906" && unzip -o skill.zip -d .claude/skills/investigating-code-patterns && rm skill.zipInstalls to .claude/skills/investigating-code-patterns
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
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.Key capabilities
- →Traces execution paths from entry points to outcomes
- →Systematically identifies functional implementation locations via grep
- →Profiles API/DB calls to locate bottlenecks
- →Maps architectural dependencies and system flows
How it works
Applies a three-phase diagnostic checklist to navigate code and isolate root causes of performance or functional issues.
Inputs & outputs
When to use investigating-code-patterns
- →Tracing end-to-end execution flow
- →Locating functional implementations in a repository
- →Diagnosing performance bottlenecks in API or DB calls
- →Mapping architectural dependencies
About this skill
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)
- Generate hypotheses ranked by likelihood
- Validate with evidence from code
Phase 3: Fix or instrument
- If fix clear → implement optimization
- If uncertain → add logging/profiling for user testing
Common performance patterns:
| Pattern | Symptoms | Fix Direction |
|---|---|---|
| N+1 queries | Sequential DB calls | Batch/eager loading |
| Algorithmic complexity | Grows with data | Optimize algorithm |
| Large payload | Network time high | Pagination/filtering |
| Missing cache | Same data fetched repeatedly | Add caching |
| Sequential operations | Waits in series | Parallelize |
4. Architecture Mapping: "How is X structured?"
Understand system organization, components, and integration points.
Steps:
- Map component boundaries and responsibilities
- Identify data flow patterns between layers
- Document integration points and dependencies
- Trace external service interactions
Investigation Strategy
Start with Documentation
Read in this order:
docs/product-requirements.md— project overview and features (F-##)docs/feature-spec/F-##-*.md— technical detailsdocs/system-design.md— architecturedocs/api-contracts.yaml— API reference
Choose Your Tools
For known file paths:
Read— examine specific files directly
For pattern searches:
Grep— find exact text matches (function names, imports, error messages)Glob— discover files by name pattern
For semantic queries:
- Launch
Exploreagent for complex, multi-file pattern discovery - Use
senior-engineeragent for subtle performance bottlenecks
Parallel Investigation
Launch 2-4 independent agents for large codebases:
Full-stack flow:
- Agent 1: Frontend (UI, state, API calls)
- Agent 2: Backend (endpoints, services, database)
- Agent 3: Integration (tests, config, external APIs)
Multi-service architecture:
- Agent 1: Auth (authentication, tokens)
- Agent 2: User service (profile, sync)
- Agent 3: Authorization (permissions, RBAC)
Performance issues:
- Agent 1: Frontend perf (renders, bundle, assets)
- Agent 2: API/network (queries, payloads, caching)
- Agent 3: Backend perf (algorithms, database, services)
Documenting Findings
Code Flow Template
## How [Feature] Works
### Purpose
[Brief description and why it exists]
### High-Level Flow
1. User action triggers [component/function] (file:line)
2. [Step 2 with file:line reference]
3. [Step 3 with file:line reference]
4. Final outcome
### Key Files
- `path/to/file.ts:123` - [Purpose]
- `path/to/other.ts:45` - [Purpose]
### Important Details
- Error handling: [Approach with file references]
- Edge cases: [How handled]
- Security: [Considerations if applicable]
Code Location Template
## Location: [Functionality]
### Main Implementation
`path/to/file.ts:45-120` - [Purpose]
### Related Files
- `path/component.tsx` - UI layer
- `path/service.ts` - Business logic
- `path/api.ts` - API integration
### Entry Points
1. [How users trigger this]
2. [System-initiated triggers]
Performance Analysis Template
## Performance Analysis: [Feature]
### Symptoms
- Slow when: [Condition]
- Observed: [X] seconds
- Expected: [Y] seconds
### Root Cause
[What's causing it with file:line evidence]
### Fix Options
**Option A: [Name]**
- Change: [What to do]
- Impact: [Expected improvement]
- Effort: [Time estimate]
**Recommendation:** [Which option and why]
Architecture Mapping Template
## Architecture: [System/Feature]
### Overview
[High-level description]
### Component Breakdown
**[Layer/Module Name]:**
- Responsibility: [What it does]
- Key files: [File paths]
- Dependencies: [What it needs]
### Data Flow
[Step-by-step or diagram]
### Integration Points
- [External services]
- [Related features]
Investigation Workflow
- Clarify the question — What are you trying to understand?
- Read project docs — Start with overview, feature specs, architecture
- Choose investigation type — Flow, location, performance, or architecture
- Search strategically — Use direct tools or delegate to agents
- Document with file references — Use
file:lineformat for all findings - Offer next steps — Deeper investigation, documentation, or implementation
Key Principles
- File references matter — Always cite
file:linefor evidence - Evidence-based — Quote actual code, don't guess
- Multi-domain issues need parallel agents — Frontend + backend require separate investigators
- Start simple — Use direct grep/read before delegating
- Consolidate findings — Synthesize parallel agent results into coherent explanation
When not to use it
- →For implementing new features
- →When the codebase is simple enough for trivial navigation
Limitations
- →Requires significant codebase depth to be effective
- →Performance diagnosis depends on finding evidence in the code
How it compares
It follows a strict investigative workflow instead of using general chat or exploratory code reading.
Compared to similar skills
investigating-code-patterns side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| investigating-code-patterns (this skill) | 1 | 8mo | No flags | Beginner |
| error-handling-patterns | 35 | 2mo | No flags | Intermediate |
| codebase-context-extractor | 4 | 9mo | Review | Intermediate |
| investigate | 1 | 6mo | Review | Beginner |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by CaptainCrouton89
View all by CaptainCrouton89 →You might also like
error-handling-patterns
wshobson
Master error handling patterns across languages including exceptions, Result types, error propagation, and graceful degradation to build resilient applications. Use when implementing error handling, designing APIs, or improving application reliability.
codebase-context-extractor
lofcz
This skill provides a comprehensive context extraction system for large codebases. It intelligently analyzes code structure, dependencies, and relationships to extract relevant context for understanding, debugging, or modifying code.
investigate
MadAppGang
Unified entry point for code investigation. Auto-routes to specialized detective based on query keywords. Use when investigation type is unclear or for general exploration.
codex-review
rymetry
|
connector-librarian
frvnkfrmchicago
>
claude
yuiseki
|