---
name: codebase-analysis
description: Use when exploring an unfamiliar codebase, onboarding to a project, or needing to understand module structure before making changes
effort: medium
---

# Codebase Analysis Skill

Delegates to the **codebase-deep-analyzer** agent (model: sonnet).

## When This Skill Activates

- Exploring a new codebase or module before making changes
- Onboarding to a project — understanding structure and patterns
- Trying to understand how a feature works or where something is defined
- Before undertaking major refactoring
- Mapping dependencies between components or modules

## Pre-Dispatch: Seed Link Context (optional)

If the analysis is for a specific RDR or architectural decision, seed link-context so findings stored to T3 auto-link. See `/nx:catalog` for details. Skip for general exploration.

## Agent Invocation

Use the Agent tool to invoke **codebase-deep-analyzer**:

```markdown
## Relay: codebase-deep-analyzer

**Task**: [what needs to be done]
**Bead**: [ID] or 'none'

### Input Artifacts
- Files: [relevant files]

### Deliverable
Architecture analysis with patterns and dependencies

### Quality Criteria
- [ ] Architecture overview documented
- [ ] Key patterns identified and explained
- [ ] Dependency relationships mapped
```

For full relay structure and optional fields, see [RELAY_TEMPLATE.md](../../agents/_shared/RELAY_TEMPLATE.md).

## Analysis Methodology

The codebase-deep-analyzer uses `mcp__plugin_nx_sequential-thinking__sequentialthinking`:
1. Form hypothesis about architecture (e.g., "This appears to be MVC pattern")
2. Gather evidence from code structure, naming, dependencies
3. Validate/refute hypothesis against actual code
4. Map module/package structure and document patterns
5. Persist findings to nx store: mcp__plugin_nx_nexus__store_put(content="...", collection="knowledge", title="architecture-{project}-{component}", tags="architecture"

## Success Criteria

- [ ] Architecture overview documented
- [ ] Module/component map created
- [ ] Key patterns identified and explained
- [ ] Dependency relationships mapped
- [ ] Findings stored in nx store for future reference
- [ ] Subtask findings promoted from T1 to T2

## Agent-Specific PRODUCE

Outputs generated by the codebase-deep-analyzer agent:

- **T3 knowledge**: Architecture findings via store_put tool: content="# Architecture: {project}/{component}\n{findings}", collection="knowledge", title="architecture-{project}-{component}", tags="architecture,analysis"
- **T2 memory**: Subtask findings promoted via scratch_manage tool: action="promote", entry_id="<id>", project="{project}", title="analysis-{component}.md"
- **T1 scratch**: Per-subtask findings via scratch tool: action="put", content="Subtask {N} findings: {summary}", tags="analysis,subtask-{N}" (flagged for T2 at phase end)

**Session Scratch (T1)**: Agent uses scratch tool for ephemeral working notes during the session. Flagged items auto-promote to T2 at session end.
