Code Investigator
Systematic codebase investigation using parallel subagents. Discover all features, analyze risks, and produce a prioritized action report.
Workflow
Phase 1: Feature Discovery
Use the Task tool with subagent_type=Explore to map the entire project:
- Identify project type (framework, language, architecture pattern)
- List all features/modules with file locations
- Map dependencies (package.json, requirements.txt, go.mod, etc.)
- Identify entry points, routes, API endpoints
- Note configuration files, environment setup, CI/CD
Output a structured feature inventory:
## Feature Inventory
| # | Feature/Module | Files | Description |
|---|---------------|-------|-------------|
| 1 | Authentication | src/auth/* | OAuth + session |
| 2 | Product CRUD | src/products/* | Admin API |
...
Present this inventory to the user before proceeding to Phase 2.
Phase 2: Parallel Investigation
Launch multiple Task subagents in a single message to investigate concurrently. Each subagent focuses on one investigation area. See references/investigation-areas.md for detailed checklists per area.
Required subagents (launch all in parallel):
| Subagent |
Type |
Focus |
| Security Auditor |
tech-lead |
Vulnerabilities, injection risks, auth gaps, secret exposure |
| Dead Code Detector |
Explore |
Unused exports, unreachable code, orphan files, unused dependencies |
| Architecture Reviewer |
tech-lead |
Pattern violations, circular deps, coupling issues, missing abstractions |
| Error & Edge Case Analyzer |
Explore |
Missing error handling, unhandled promises, race conditions |
| Dependency Auditor |
Bash |
npm audit, outdated packages, license issues, duplicate deps |
| Test Coverage Analyzer |
Explore |
Missing tests, untested critical paths, test quality |
Optional subagents (based on project type):
| Subagent |
Type |
When |
| Performance Profiler |
tech-lead |
Web apps, APIs with DB queries |
| TypeScript Strictness |
Explore |
TS projects with any usage |
| API Contract Checker |
Explore |
Projects with REST/GraphQL APIs |
| Accessibility Auditor |
Explore |
Frontend projects |
Each subagent prompt must include:
- The feature inventory from Phase 1
- Specific checklist items from references/investigation-areas.md
- Instruction to rate each finding: CRITICAL / HIGH / MEDIUM / LOW
- Instruction to provide file path and line number for each finding
Phase 3: Report Synthesis
Collect all subagent results and compile into a single prioritized report.
Report Structure
# Code Investigation Report
**Project:** [name] | **Date:** [date] | **Files Analyzed:** [count]
## Executive Summary
[2-3 sentences: overall health, top concerns, immediate actions needed]
## Critical Findings (Act Immediately)
| # | Finding | Category | File:Line | Impact | Recommendation |
|---|---------|----------|-----------|--------|----------------|
## High Priority
| # | Finding | Category | File:Line | Impact | Recommendation |
|---|---------|----------|-----------|--------|----------------|
## Medium Priority
| # | Finding | Category | File:Line | Impact | Recommendation |
|---|---------|----------|-----------|--------|----------------|
## Low Priority / Improvements
| # | Finding | Category | File:Line | Impact | Recommendation |
|---|---------|----------|-----------|--------|----------------|
## Dead Code & Redundancies
| # | Item | Type | File:Line | Safe to Remove? |
|---|------|------|-----------|-----------------|
## Missing Functionality
| # | Gap | Why It Matters | Suggested Implementation |
|---|-----|----------------|--------------------------|
## Dependency Health
| Package | Current | Latest | Risk | Action |
|---------|---------|--------|------|--------|
## Metrics Summary
- Total findings: X (Critical: X, High: X, Medium: X, Low: X)
- Dead code items: X
- Missing features: X
- Vulnerable dependencies: X
Sorting Rules
- CRITICAL: Security vulnerabilities, data loss risks, crashes in production
- HIGH: Bugs likely to affect users, missing auth checks, unhandled errors in critical paths
- MEDIUM: Code smells, minor security issues, performance concerns, missing tests
- LOW: Style issues, minor refactoring opportunities, nice-to-have improvements
Key Guidelines
- Never guess - always verify by reading actual code before reporting a finding
- Include file path and line number for every finding
- Distinguish between confirmed issues and potential concerns
- Do not report style preferences as issues unless they cause real problems
- Group related findings to avoid duplicate reports
- If a subagent finds nothing in its area, report that as a positive signal
1---2name: code-investigator3description: Comprehensive code investigation and audit tool. Discovers all project features, then dispatches parallel subagents to analyze issues, risks, dead code, missing functionality, and redundancies. Produces a prioritized risk report. Use this skill when the user asks to "investigate code", "audit project", "find risks", "check code quality", "analyze codebase", "what's wrong with this code", "project health check", "code review entire project", "find dead code", "find redundant code", or any request for a thorough codebase analysis.4---56# Code Investigator78Systematic codebase investigation using parallel subagents. Discover all features, analyze risks, and produce a prioritized action report.910## Workflow1112### Phase 1: Feature Discovery1314Use the Task tool with `subagent_type=Explore` to map the entire project:15161. Identify project type (framework, language, architecture pattern)172. List all features/modules with file locations183. Map dependencies (package.json, requirements.txt, go.mod, etc.)194. Identify entry points, routes, API endpoints205. Note configuration files, environment setup, CI/CD2122Output a structured feature inventory:2324```25## Feature Inventory26| # | Feature/Module | Files | Description |27|---|---------------|-------|-------------|28| 1 | Authentication | src/auth/* | OAuth + session |29| 2 | Product CRUD | src/products/* | Admin API |30...31```3233Present this inventory to the user before proceeding to Phase 2.3435### Phase 2: Parallel Investigation3637Launch **multiple Task subagents in a single message** to investigate concurrently. Each subagent focuses on one investigation area. See [references/investigation-areas.md](references/investigation-areas.md) for detailed checklists per area.3839Required subagents (launch all in parallel):4041| Subagent | Type | Focus |42|----------|------|-------|43| Security Auditor | `tech-lead` | Vulnerabilities, injection risks, auth gaps, secret exposure |44| Dead Code Detector | `Explore` | Unused exports, unreachable code, orphan files, unused dependencies |45| Architecture Reviewer | `tech-lead` | Pattern violations, circular deps, coupling issues, missing abstractions |46| Error & Edge Case Analyzer | `Explore` | Missing error handling, unhandled promises, race conditions |47| Dependency Auditor | `Bash` | `npm audit`, outdated packages, license issues, duplicate deps |48| Test Coverage Analyzer | `Explore` | Missing tests, untested critical paths, test quality |4950Optional subagents (based on project type):5152| Subagent | Type | When |53|----------|------|------|54| Performance Profiler | `tech-lead` | Web apps, APIs with DB queries |55| TypeScript Strictness | `Explore` | TS projects with `any` usage |56| API Contract Checker | `Explore` | Projects with REST/GraphQL APIs |57| Accessibility Auditor | `Explore` | Frontend projects |5859Each subagent prompt must include:60- The feature inventory from Phase 161- Specific checklist items from references/investigation-areas.md62- Instruction to rate each finding: CRITICAL / HIGH / MEDIUM / LOW63- Instruction to provide file path and line number for each finding6465### Phase 3: Report Synthesis6667Collect all subagent results and compile into a single prioritized report.6869#### Report Structure7071```markdown72# Code Investigation Report73**Project:** [name] | **Date:** [date] | **Files Analyzed:** [count]7475## Executive Summary76[2-3 sentences: overall health, top concerns, immediate actions needed]7778## Critical Findings (Act Immediately)79| # | Finding | Category | File:Line | Impact | Recommendation |80|---|---------|----------|-----------|--------|----------------|8182## High Priority83| # | Finding | Category | File:Line | Impact | Recommendation |84|---|---------|----------|-----------|--------|----------------|8586## Medium Priority87| # | Finding | Category | File:Line | Impact | Recommendation |88|---|---------|----------|-----------|--------|----------------|8990## Low Priority / Improvements91| # | Finding | Category | File:Line | Impact | Recommendation |92|---|---------|----------|-----------|--------|----------------|9394## Dead Code & Redundancies95| # | Item | Type | File:Line | Safe to Remove? |96|---|------|------|-----------|-----------------|9798## Missing Functionality99| # | Gap | Why It Matters | Suggested Implementation |100|---|-----|----------------|--------------------------|101102## Dependency Health103| Package | Current | Latest | Risk | Action |104|---------|---------|--------|------|--------|105106## Metrics Summary107- Total findings: X (Critical: X, High: X, Medium: X, Low: X)108- Dead code items: X109- Missing features: X110- Vulnerable dependencies: X111```112113#### Sorting Rules1141151. **CRITICAL**: Security vulnerabilities, data loss risks, crashes in production1162. **HIGH**: Bugs likely to affect users, missing auth checks, unhandled errors in critical paths1173. **MEDIUM**: Code smells, minor security issues, performance concerns, missing tests1184. **LOW**: Style issues, minor refactoring opportunities, nice-to-have improvements119120## Key Guidelines121122- Never guess - always verify by reading actual code before reporting a finding123- Include file path and line number for every finding124- Distinguish between confirmed issues and potential concerns125- Do not report style preferences as issues unless they cause real problems126- Group related findings to avoid duplicate reports127- If a subagent finds nothing in its area, report that as a positive signal