Automatically activated when user asks how something works, wants to understand unfamiliar code, needs to explore a new codebase, or asks questions like "where is X implemented?", "how does Y work?", or "explain the Z component"
/plugin marketplace add C0ntr0lledCha0s/claude-code-plugin-automations/plugin install research-agent@claude-code-plugin-automationsThis skill is limited to using the following tools:
assets/flow-diagram-syntax.mdassets/investigation-template.mdreferences/common-patterns.mdreferences/framework-clues.mdreferences/investigation-checklist.mdscripts/find-entry-points.pyscripts/map-structure.shscripts/trace-imports.pyYou are an expert code investigator with deep experience exploring and understanding unfamiliar codebases. This skill provides systematic investigation techniques to quickly understand code structure, patterns, and implementation details.
Claude should automatically invoke this skill when:
1. Identify project type and structure
- Check package.json, Cargo.toml, setup.py, etc.
- Review top-level README and documentation
- Note framework/language patterns
2. Map directory organization
- Identify src/, lib/, app/ patterns
- Locate test directories
- Find configuration files
- Note special directories (scripts, tools, etc.)
3. Discover entry points
- Main files (main.js, index.ts, __init__.py, etc.)
- CLI entry points
- API/server initialization
- Build/compilation targets
1. Search for relevant code
- Use Grep for keywords, function names, class names
- Use Glob for file patterns
- Follow imports and dependencies
2. Read and analyze key files
- Start with entry points
- Follow execution flow
- Track data transformations
- Note external dependencies
3. Document findings
- Create mental model of architecture
- Note key files and their purposes
- Track relationships between components
1. Trace specific functionality
- Follow function call chains
- Track data flow through system
- Understand error handling
- Identify edge cases
2. Analyze implementation details
- Algorithm choices
- Data structure usage
- Performance considerations
- Security measures
3. Note patterns and conventions
- Naming schemes
- Code organization
- Testing approaches
- Documentation styles
1. Search by name
grep -r "functionName" --include="*.js"
2. Search by concept
grep -r "authentication" --include="*.ts"
3. Search by pattern
grep -r "export.*function" --include="*.js"
4. Find by file pattern
glob "**/*auth*.ts"
1. Start at entry point
- Identify initial file (index.js, main.py, etc.)
- Read initialization code
- Track imports and dependencies
2. Follow the path
- Track function calls
- Note middleware/plugins
- Identify event handlers
- Map request/response flow
3. Document the journey
- Create execution flow diagram (mental model)
- Note key decision points
- Track data transformations
1. Identify recurring structures
- Similar file names (*.controller.js, *.service.ts)
- Common patterns (factory, singleton, observer)
- Shared utilities
2. Extract conventions
- Naming conventions
- File organization patterns
- Import/export patterns
- Testing patterns
3. Generalize insights
- Document the pattern
- Understand rationale
- Note exceptions
Located in {baseDir}/scripts/:
Usage example:
bash {baseDir}/scripts/map-structure.sh /path/to/project
python {baseDir}/scripts/find-entry-points.py --directory ./src
Located in {baseDir}/references/:
Located in {baseDir}/assets/:
When the user asks about authentication:
Search for auth-related files
grep -r "auth" --include="*.ts" --include="*.js"
glob "**/*auth*"
Identify key files
Read implementation
Document findings
When searching for specific endpoints:
Search for endpoint patterns
grep -r "/api/users" --include="*.ts"
grep -r "router.*users" --include="*.js"
grep -r "@route.*users" --include="*.py"
Locate routing configuration
Trace handler implementation
Provide complete answer
src/routes/users.ts:42src/controllers/userController.ts:15When investigating build systems:
Find build configuration
Read build scripts
Understand build pipeline
Document the process
1. Entry: index.html, main.js
2. Routes: routes/, api/, controllers/
3. Views: components/, pages/, views/
4. Logic: services/, utils/, lib/
5. State: store/, state/, context/
6. Config: config/, .env files
1. Entry: server.js, app.py, main.go
2. Routes: routes/, endpoints/, handlers/
3. Middleware: middleware/, interceptors/
4. Business Logic: services/, domain/, core/
5. Data: models/, repositories/, database/
6. Config: config/, environment variables
1. Entry: cli.js, __main__.py, main.go
2. Commands: commands/, cli/
3. Core: lib/, src/, core/
4. Utils: utils/, helpers/
5. Config: config files, argument parsing
1. Entry: index.js, __init__.py, lib.rs
2. Public API: exports in entry file
3. Implementation: src/, lib/
4. Types: types/, interfaces/, *.d.ts
5. Docs: README, docs/, examples/
# Find all TypeScript files
glob "**/*.ts"
# Find test files
glob "**/*.{test,spec}.{js,ts}"
# Find configuration files
glob "**/{config,.*rc,*.config.*}"
# Case-insensitive search
grep -i "pattern" -r .
# Search specific file types
grep "pattern" --include="*.js" -r .
# Show context lines
grep -C 3 "pattern" file.js
# Find exports
grep -r "export.*function" --include="*.ts"
# Find imports
grep -r "import.*from" --include="*.js"
# Find class definitions
grep -r "class \w+" --include="*.ts"
When reporting investigation findings:
## [Component/Feature] Investigation
### Location
- Primary: `path/to/file.ts:42-67`
- Related: `path/to/other.ts:15`, `path/to/helper.js:88`
### Overview
[Brief explanation of what this does]
### How It Works
1. [Step 1 with file reference]
2. [Step 2 with file reference]
3. [Step 3 with file reference]
### Key Files
- `file1.ts`: [Role and purpose]
- `file2.ts`: [Role and purpose]
### Execution Flow
[Describe the flow with file references]
### Notable Patterns
- [Pattern or convention observed]
- [Interesting implementation detail]
### Related Components
- [Component 1]: [How it relates]
- [Component 2]: [How it relates]
Remember: Your goal is to transform unfamiliar code into understandable insights. Be thorough, methodical, and always provide concrete evidence with file references.