// "โก PRIMARY SKILL for: 'how does X work', 'investigate', 'analyze architecture', 'trace flow', 'find implementations'. PREREQUISITE: code-search-selector must validate tool choice. Launches codebase-detective with claudemem INDEXED MEMORY."
| name | deep-analysis |
| description | โก PRIMARY SKILL for: 'how does X work', 'investigate', 'analyze architecture', 'trace flow', 'find implementations'. PREREQUISITE: code-search-selector must validate tool choice. Launches codebase-detective with claudemem INDEXED MEMORY. |
| allowed-tools | Task |
| prerequisites | ["code-search-selector"] |
| dependencies | ["claudemem must be indexed (claudemem status)"] |
This Skill provides comprehensive codebase investigation capabilities using the codebase-detective agent with semantic search and pattern matching.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ BEFORE INVOKING THIS SKILL โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฃ
โ โ
โ 1. INVOKE code-search-selector skill FIRST โ
โ โ Validates tool selection (claudemem vs grep) โ
โ โ Checks if claudemem is indexed โ
โ โ Prevents tool familiarity bias โ
โ โ
โ 2. VERIFY claudemem status โ
โ โ Run: claudemem status โ
โ โ If not indexed: claudemem index -y โ
โ โ
โ 3. DO NOT start with Read/Glob โ
โ โ Even if file paths are mentioned in the prompt โ
โ โ Semantic search first, Read specific lines after โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Claude should invoke this Skill when:
Understand what the user wants to investigate:
Use the Task tool to launch the codebase-detective agent with comprehensive instructions:
Use Task tool with:
- subagent_type: "code-analysis:detective"
- description: "Investigate [brief summary]"
- prompt: [Detailed investigation instructions]
Prompt structure for codebase-detective:
# Code Investigation Task
## Investigation Target
[What needs to be investigated - be specific]
## Context
- Working Directory: [current working directory]
- Purpose: [debugging/learning/refactoring/etc]
- User's Question: [original user question]
## Investigation Steps
1. **Initial Search** (CLAUDEMEM REQUIRED):
- FIRST: Check `claudemem status` - is index available?
- ALWAYS: Use `claudemem search "semantic query"` for investigation
- NEVER: Use grep/glob for semantic understanding tasks
- Search for: [concepts, functionality, patterns by meaning]
2. **Code Location**:
- Find exact file paths and line numbers
- Identify entry points and main implementations
- Note related files and dependencies
3. **Code Flow Analysis**:
- Trace how data/control flows through the code
- Identify key functions and their roles
- Map out component/service relationships
4. **Pattern Recognition**:
- Identify architectural patterns used
- Note code conventions and styles
- Find similar implementations for reference
## Deliverables
Provide a comprehensive report including:
1. **๐ Primary Locations**:
- Main implementation files with line numbers
- Entry points and key functions
- Configuration and setup files
2. **๐ Code Flow**:
- Step-by-step flow explanation
- How components interact
- Data transformation points
3. **๐บ๏ธ Architecture Map**:
- High-level structure diagram
- Component relationships
- Dependency graph
4. **๐ Code Snippets**:
- Key implementations (show important code)
- Patterns and conventions used
- Notable details or gotchas
5. **๐ Navigation Guide**:
- How to explore the code further
- Related files to examine
- Commands to run for testing
6. **๐ก Insights**:
- Why the code is structured this way
- Potential issues or improvements
- Best practices observed
## Search Strategy
### โ ๏ธ CRITICAL: Tool Selection
**BEFORE ANY SEARCH, CHECK CLAUDEMEM STATUS:**
```bash
claudemem status
# Index if needed
claudemem index -y
# Semantic search (ALWAYS use this for investigation)
claudemem search "authentication login session" -n 15
claudemem search "API endpoint handler route" -n 20
claudemem search "data transformation pipeline" -n 10
Why claudemem is REQUIRED for investigation:
| User Request | โ DON'T | โ DO |
|---|---|---|
| "How does auth work?" | grep -r "auth" src/ | claudemem search "authentication flow" |
| "Find API endpoints" | grep -r "router" src/ | claudemem search "API endpoint handler" |
| "Trace data flow" | grep -r "transform" src/ | claudemem search "data transformation" |
| "Audit architecture" | ls -la src/ | claudemem search "architecture layers" |
Only use grep/find if:
# DEGRADED MODE - inferior results expected
grep -r "pattern" src/ # Text match only, no semantic understanding
find . -name "*.ts" # File discovery only
Always warn user: "Using grep fallback - results will be less accurate than semantic search."
Structure your findings clearly with:
src/auth/login.ts:45
### Phase 3: Present Analysis Results
After the agent completes, present results to the user:
1. **Executive Summary** (2-3 sentences):
- What was found
- Where it's located
- Key insight
2. **Detailed Findings**:
- Primary file locations with line numbers
- Code flow explanation
- Architecture overview
3. **Visual Structure** (if complex):
EntryPoint (file:line) โโโ Validator (file:line) โโโ BusinessLogic (file:line) โ โโโ DataAccess (file:line) โโโ ResponseHandler (file:line)
4. **Code Examples**:
- Show key code snippets inline
- Highlight important patterns
5. **Next Steps**:
- Suggest follow-up investigations
- Offer to dive deeper into specific parts
- Provide commands to test/run the code
### Phase 4: Offer Follow-up
Ask the user:
- "Would you like me to investigate any specific part in more detail?"
- "Do you want to see how [related feature] works?"
- "Should I trace [specific function] further?"
## Example Scenarios
### Example 1: Understanding Authentication
User: "How does login work in this app?"
Skill invokes codebase-detective agent with: "Investigate user authentication and login flow:
Agent provides:
### Example 2: Debugging Undefined Error
User: "The dashboard shows 'undefined' for user name"
Skill invokes codebase-detective agent with: "Debug undefined user name in dashboard:
Agent provides:
### Example 3: Finding All API Calls
User: "Where are all the API calls made?"
Skill invokes codebase-detective agent with: "Find all API call locations:
Agent provides:
## Success Criteria
The Skill is successful when:
1. โ
User's question is comprehensively answered
2. โ
Exact code locations provided with line numbers
3. โ
Code relationships and flow clearly explained
4. โ
User can navigate to code and understand it
5. โ
Architecture patterns identified and explained
6. โ
Follow-up questions anticipated
## Tips for Optimal Results
1. **Be Comprehensive**: Don't just find one file, map the entire flow
2. **Provide Context**: Explain why code is structured this way
3. **Show Examples**: Include actual code snippets
4. **Think Holistically**: Connect related pieces across files
5. **Anticipate Questions**: Answer follow-up questions proactively
## Integration with Other Tools
This Skill works well with:
- **claudemem CLI**: For local semantic code search with Tree-sitter parsing
- **MCP gopls**: For Go-specific analysis
- **Standard CLI tools**: grep, ripgrep, find, git
- **Project-specific tools**: Use project's search/navigation tools
## Notes
- The codebase-detective agent uses extended thinking for complex analysis
- **claudemem is REQUIRED** - grep/find produce inferior results
- Fallback to grep ONLY if claudemem unavailable AND user accepts degraded mode
- claudemem requires OpenRouter API key (https://openrouter.ai)
- Default model: `voyage/voyage-code-3` (best code understanding)
- Run `claudemem --models` to see all options and pricing
- Results are actionable and navigable
- Great for onboarding to new codebases
- Helps prevent incorrect assumptions about code
## Tool Selection Quick Reference
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ BEFORE ANY CODE INVESTIGATION: โ โ โ โ 1. INVOKE code-search-selector skill โ โ 2. Run: claudemem status โ โ 3. If indexed โ USE claudemem search โ โ 4. If not indexed โ Index first OR ask user โ โ 5. NEVER default to grep when claudemem available โ โ 6. NEVER start with Read/Glob for semantic questions โ โ โ โ grep is for EXACT STRING MATCHES only, NOT semantic understanding โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
---
**Maintained by:** MadAppGang
**Plugin:** code-analysis v2.2.0
**Last Updated:** December 2025