Launches a codebase-detective agent to investigate architecture, trace functionality, find implementations, and analyze code patterns across the project.
Ships in code-analysis. Installing the plugin adds it to Claude Code.
Launch the codebase-detective agent to perform comprehensive code analysis, investigation, and navigation across complex codebases. This command helps understand how code works, find specific implementations, trace functionality flow, and analyze architectural patterns.
$ARGUMENTS
Use /analyze when you need to:
This command launches the codebase-detective agent, which:
Parse the user's analysis request from $ARGUMENTS:
Use the Task tool to launch the agent:
Task(
subagent_type: "code-analysis:detective",
description: "Analyze codebase for [brief description]",
prompt: `
Investigate the following in the codebase:
[User's analysis request from $ARGUMENTS]
Working directory: [current working directory]
Please provide:
1. Exact file locations with line numbers
2. Code snippets showing the implementation
3. Explanation of how the code works
4. Related files and dependencies
5. Code flow/architecture diagram if complex
Use semantic search (claudemem CLI) if available, otherwise
use grep/ripgrep/find for pattern matching.
`
)
After the agent completes:
User: /analyze Where is user authentication handled?
Agent launches with prompt:
"Find and explain the authentication implementation. Include:
- Login endpoint/handler
- Token generation/validation
- Authentication middleware
- Session management
- Related security code"
Results:
- src/auth/login.handler.ts:23-67 (login endpoint)
- src/middleware/auth.middleware.ts:12-45 (JWT validation)
- src/services/token.service.ts:89-120 (token generation)
User: /analyze The user profile page shows "undefined" for email field
Agent launches with prompt:
"Trace the user profile email display issue:
1. Find the profile page component
2. Locate where email data is fetched
3. Check how email is passed to the component
4. Identify where 'undefined' might be introduced"
Results:
- Identified missing null check in ProfilePage.tsx:156
- Found API returns 'e-mail' but code expects 'email'
- Provided exact line numbers for the mismatch
User: /analyze How does the payment processing flow work?
Agent launches with prompt:
"Map out the complete payment processing flow:
1. Entry point (API endpoint or UI trigger)
2. Validation and business logic
3. Payment gateway integration
4. Database persistence
5. Success/failure handling
6. Related services and utilities"
Results:
- Flow diagram from checkout button to confirmation
- 7 key files involved with their roles
- External dependencies (Stripe SDK)
- Error handling strategy
The agent will provide:
📍 Location Report: [What was analyzed]
**Primary Files**:
- path/to/main/file.ts:45-67 - [Brief description]
- path/to/related/file.ts:23 - [Brief description]
**Code Flow**:
1. Entry point: [File:line]
2. Processing: [File:line]
3. Result: [File:line]
**Related Components**:
- [Component name] - [Purpose]
- [Service name] - [Purpose]
**How to Navigate**:
[Commands to explore the code further]
**Recommendations**:
[Suggestions based on analysis]
The command is successful when:
claudemem --models to see embedding model options and pricingWhat the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
/code-analysis:analyzefrom code-analysis
npx claudepluginhub madappgang/claude-code --plugin code-analysis3 commands in this plugin
Other plugins' commands for the same job