/research-agent:investigate [feature/component to investigate]from research-agent
Deep-dive investigation of code, features, or components with execution tracing and detailed analysis
Ships in research-agent. Installing the plugin adds it to Claude Code.
Perform deep investigation of code, features, or components to understand how they work, where they're implemented, and how they fit into the larger system.
$ARGUMENTS: The feature, component, or code element to investigate (e.g., "user authentication", "payment processing", "ErrorBoundary component")When this command is invoked with /investigate <target>:
For investigating complete features:
1. Find entry points (routes, commands, UI triggers)
2. Trace through handlers/controllers
3. Follow to business logic/services
4. Track data layer interactions
5. Note UI/presentation components
6. Map the complete flow
For specific components or modules:
1. Locate component definition
2. Read implementation details
3. Find where it's used (imports)
4. Understand props/API
5. Check related components
6. Note patterns and conventions
For understanding subsystems:
1. Map directory structure
2. Identify main modules
3. Trace component relationships
4. Understand data flows
5. Document architecture
6. Note design patterns
/investigate user authentication
Expected behavior:
Searches for auth-related files:
grep -r "auth" --include="*.ts"
glob "**/*auth*"
Identifies key components:
src/components/LoginForm.tsxsrc/contexts/AuthContext.tsxsrc/middleware/auth.tssrc/api/auth/login.tssrc/utils/jwt.tsTraces authentication flow:
LoginForm submission
→ POST /api/auth/login
→ Validate credentials (src/api/auth/login.ts:25)
→ Generate JWT (src/utils/jwt.ts:42)
→ Set cookie (src/api/auth/login.ts:55)
→ Update auth context (src/contexts/AuthContext.tsx:78)
→ Redirect to dashboard
Provides detailed report:
/investigate ErrorBoundary
Expected behavior:
Locates component:
src/components/ErrorBoundary.tsx:1-89Reads implementation:
Finds usage:
grep -r "ErrorBoundary" --include="*.tsx"
Analyzes pattern:
Provides summary:
/investigate /api/users endpoint
Expected behavior:
Finds endpoint definition:
grep -r "/api/users" --include="*.ts"
grep -r "router.*users" --include="*.ts"
Locates handler:
src/api/routes.ts:45src/api/users/controller.ts:15-88src/services/userService.ts:120-165src/repositories/userRepository.ts:55-90Traces request flow:
GET /api/users/:id
→ Auth middleware check (middleware/auth.ts:30)
→ Route handler (api/routes.ts:45)
→ User controller (api/users/controller.ts:25)
→ User service (services/userService.ts:130)
→ User repository (repositories/userRepository.ts:60)
→ Database query
→ Response formatting
Documents:
/investigate state management
Expected behavior:
Scans for state management patterns:
grep -r "useState\|useContext\|Redux\|Zustand" --include="*.ts"
find . -type d -name "*store*" -o -name "*state*"
Identifies approach:
Maps state structure:
src/contexts/AuthContext.tsxsrc/contexts/ThemeContext.tsxAnalyzes patterns:
Provides architectural overview:
Investigation reports are structured as:
# Investigation: [Target]
## Summary
[Quick overview of what was found and key characteristics]
## Location
### Primary Files
- `path/to/main.ts:10-120` - [Role]
- `path/to/helper.ts:45-78` - [Role]
### Related Files
- `path/to/related.ts` - [How it relates]
- `path/to/another.ts` - [How it relates]
## How It Works
### Overview
[High-level explanation of functionality]
### Execution Flow
1. **[Step 1]** (`file.ts:42`)
- [What happens]
- [Key logic]
2. **[Step 2]** (`file.ts:88`)
- [What happens]
- [Key logic]
3. **[Step 3]** (`file.ts:120`)
- [What happens]
- [Key logic]
### Data Flow
[Input] → [Transformation 1] → [Transformation 2] → [Output]
## Implementation Details
### Key Components
1. **[Component Name]** (`path:line`)
- Purpose: [What it does]
- Responsibilities: [What it handles]
- Dependencies: [What it uses]
### Patterns Used
- [Pattern name]: [How it's applied]
- [Pattern name]: [How it's applied]
### Notable Code
```language
// path/to/file.ts:42-55
[Interesting code snippet with explanation]
[Component A] → uses → [Component B]
[Component B] → calls → [Service]
[Service] → queries → [Repository]
// File: path/to/usage.ts:20
[Code showing how it's used]
// File: path/to/another-usage.ts:15
[Code showing different usage]
For further investigation:
## Important Notes
### Investigation Depth
- Adapt depth to complexity of target
- Start with overview, go deeper as needed
- Balance thoroughness with actionability
### Evidence & References
- Always include file paths with line numbers
- Show code snippets for clarity
- Reference related components
- Note where code is used
### Clarity & Organization
- Use clear headings and structure
- Make findings scannable
- Include diagrams/flows when helpful
- Separate what from why
### Context & Implications
- Explain not just what code does, but why
- Note design decisions and trade-offs
- Identify patterns and conventions
- Connect to broader system architecture
## Advanced Usage
### Investigate Multiple Related Features
/investigate user management and permissions
Investigates both user management and permission system and their interactions.
### Investigate with Specific Focus
/investigate payment processing security measures
Focuses investigation on security aspects specifically.
### Investigate Implementation Approach
/investigate how caching is implemented
Looks for caching patterns across the codebase.
## Error Handling
### If no target provided:
Error: No investigation target specified.
Usage: /investigate <feature/component/code>
Examples: /investigate user authentication /investigate ErrorBoundary component /investigate /api/users endpoint /investigate state management approach
### If target not found:
Report what was searched and suggest alternatives:
Investigation: [target]
No direct matches found for "[target]".
Searched:
Suggestions:
### If target is ambiguous:
Ask for clarification:
Multiple matches found for "[target]":
Which would you like to investigate? Or use /investigate
## Tips for Effective Investigation
1. **Be Specific**: Instead of "investigate API", try "investigate /api/users CRUD endpoints"
2. **Start Broad**: Get overview first, then dive into specifics
3. **Follow Trails**: Let initial findings guide deeper investigation
4. **Cross-Reference**: Check multiple files to understand complete picture
5. **Note Patterns**: Identify conventions and patterns as you investigate
---
**Pro Tip**: Combine with /research for comprehensive understanding. First /investigate to see how something works, then /research to compare with best practices.
What the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
npx claudepluginhub c0ntr0lledcha0s/claude-code-plugin-automations --plugin research-agent4 commands in this plugin
/best-practiceBest Practice CommandLook up current best practices for a technology, pattern, or implementation approach with recommendations/compareCompare CommandCompare multiple approaches, technologies, or implementations with trade-off analysis and recommendations/researchResearch CommandConduct comprehensive research on a topic, technology, or question with evidence and recommendationsOther plugins' commands for the same job