deep-analysis
⚡ 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.
What this skill does
# Deep Code Analysis
This Skill provides comprehensive codebase investigation capabilities using the codebase-detective agent with semantic search and pattern matching.
## Prerequisites (MANDATORY)
```
╔══════════════════════════════════════════════════════════════════════════════╗
║ 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 ║
║ ║
╚══════════════════════════════════════════════════════════════════════════════╝
```
## When to use this Skill
Claude should invoke this Skill when:
- User asks "how does [feature] work?"
- User wants to understand code architecture or patterns
- User is debugging and needs to trace code flow
- User asks "where is [functionality] implemented?"
- User needs to find all usages of a component/service
- User wants to understand dependencies between files
- User mentions: "investigate", "analyze", "find", "trace", "understand"
- User is exploring an unfamiliar codebase
- User needs to understand complex multi-file functionality
## Instructions
### Phase 1: Determine Investigation Scope
Understand what the user wants to investigate:
1. **Specific Feature**: "How does user authentication work?"
2. **Find Implementation**: "Where is the payment processing logic?"
3. **Trace Flow**: "What happens when I click the submit button?"
4. **Debug Issue**: "Why is the profile page showing undefined?"
5. **Find Patterns**: "Where are all the API calls made?"
6. **Analyze Architecture**: "What's the structure of the data layer?"
### Phase 2: Invoke codebase-detective Agent
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**:
```markdown
# 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
```
### ✅ PRIMARY METHOD: claudemem (Indexed Memory)
```bash
# 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:**
- Understands code MEANING, not just text patterns
- Finds related code even with different terminology
- Returns ranked, relevant results
- AST-aware (understands code structure)
### ❌ WHEN NOT TO USE GREP
| 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"` |
### ⚠️ DEGRADED FALLBACK (Only if claudemem unavailable)
**Only use grep/find if:**
1. claudemem is NOT installed, AND
2. User explicitly accepts degraded mode
```bash
# 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."
## Output Format
Structure your findings clearly with:
- File paths using backticks: `src/auth/login.ts:45`
- Code blocks for snippets
- Clear headings and sections
- Actionable next steps
```
### 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:
1. Find login API endpoint or form handler
2. TRelated in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.