Analyzes existing codebases by mapping structure, architecture, conventions, and concerns using parallel subagents. Checks for prior scans and supports refresh options.
From pbrnpx claudepluginhub sienklogic/plan-build-run --plugin pbrThis skill is limited to using the following tools:
templates/mapper-prompt.md.tmplSearches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Searches prompts.chat for AI prompt templates by keyword or category, retrieves by ID with variable handling, and improves prompts via AI. Use for discovering or enhancing prompts.
Enables AI agents to execute x402 payments with per-task budgets, spending controls, and non-custodial wallets via MCP tools. Use when agents pay for APIs, services, or other agents.
STOP — DO NOT READ THIS FILE. You are already reading it. This prompt was injected into your context by Claude Code's plugin system. Using the Read tool on this SKILL.md file wastes ~7,600 tokens. Begin executing Step 1 immediately.
Before ANY tool calls, display this banner:
╔══════════════════════════════════════════════════════════════╗
║ PLAN-BUILD-RUN ► SCANNING CODEBASE ║
╚══════════════════════════════════════════════════════════════╝
Then proceed to Step 1.
You are running the scan skill. Your job is to analyze an existing codebase and produce a comprehensive map of its structure, architecture, conventions, and concerns. This is the entry point for brownfield projects — codebases that already have code before Plan-Build-Run is introduced.
This skill spawns 4 parallel Task(subagent_type: "pbr:codebase-mapper") agents for analysis.
Reference: skills/shared/context-budget.md for the universal orchestrator rules.
Additionally for this skill:
Understand before you change. Scanning a codebase is about building a mental model of what exists. Every file produced by this skill becomes context that the planner and executor use to make informed decisions. Accuracy matters more than speed.
Check if .planning/codebase/ directory exists:
If it exists and has files:
First, resolve the depth profile so you know which areas are available:
node ${CLAUDE_PLUGIN_ROOT}/scripts/pbr-tools.js config resolve-depth
Read profile["scan.mapper_areas"] to determine available areas (quick: tech, arch; standard/comprehensive: tech, arch, quality, concerns).
Then present to user via AskUserQuestion:
A codebase analysis already exists (from {date based on file modification}).
Files found:
- {list of .md files in the directory}
Options:
1. Refresh the full analysis (overwrites existing)
2. Refresh a specific area ({list available areas from depth profile})
3. Keep existing analysis
If it doesn't exist:
.planning/codebase/ directory.planning/ if it doesn't exist (scan can be run before begin)Reference: skills/shared/context-loader-task.md (Scan Reconnaissance variation) for the underlying pattern.
Before spawning agents, do a quick scan to identify what we're working with. This gives agents better context.
.planning/codebase/RECON.md with project type, scale, key directories, entry points, and quick statsRefer to the "Reconnaissance Detection Reference" section of ${CLAUDE_SKILL_DIR}/templates/mapper-prompt.md.tmpl for the full detection checklists.
Resolve mapper configuration: Before spawning, resolve the depth profile:
node ${CLAUDE_PLUGIN_ROOT}/scripts/pbr-tools.js config resolve-depth
Read profile["scan.mapper_count"] and profile["scan.mapper_areas"] to determine how many mappers to spawn and which focus areas to cover.
Default mappings by depth:
quick (budget): 2 mappers -- tech and arch only. Produces STACK.md, INTEGRATIONS.md, ARCHITECTURE.md, STRUCTURE.md. Skips quality and concerns analysis.standard (balanced): 4 mappers -- all areas. Full analysis.comprehensive (thorough): 4 mappers -- all areas. Full analysis.Display to the user:
◐ Spawning {mapper_count} codebase mapper(s) in parallel...
→ Technology stack analysis
→ Architecture patterns
→ Code quality assessment
→ Concerns & risks
(Only list the focus areas that will actually be spawned based on the depth profile.)
Spawn {mapper_count} parallel Task(subagent_type: "pbr:codebase-mapper") agents, one for each area in scan.mapper_areas. All should be spawned in a single response for maximum parallelism.
For each agent, read ${CLAUDE_SKILL_DIR}/templates/mapper-prompt.md.tmpl and fill in the placeholders:
{focus_area}: one of tech, arch, quality, concerns{project_path}: the working directory{recon_data}: contents of RECON.md{scale}: detected scale from Step 2{output_path}: .planning/codebase/Prepend this block to each mapper prompt before sending:
<files_to_read>
CRITICAL: Read these files BEFORE any other action:
1. .planning/codebase/RECON.md — baseline reconnaissance data (if exists)
</files_to_read>
| Agent | Focus | Output Files | When |
|---|---|---|---|
| 1 | tech | STACK.md, INTEGRATIONS.md | Always |
| 2 | arch | ARCHITECTURE.md, STRUCTURE.md | Always |
| 3 | quality | CONVENTIONS.md, TESTING.md | standard + comprehensive |
| 4 | concerns | CONCERNS.md | standard + comprehensive |
All agents run in parallel. As each completes, display:
✓ Technology stack analysis complete
✓ Architecture patterns complete
✓ Code quality assessment complete
✓ Concerns & risks complete
(Only display lines for the focus areas that were actually spawned.)
After each codebase-mapper Task() completes, check the Task() output for the ## MAPPING COMPLETE marker:
## MAPPING COMPLETE is present: the mapper finished successfully, proceed normally⚠ Codebase mapper ({focus_area}) did not report MAPPING COMPLETE.
Output may be incomplete — check .planning/codebase/ for partial results.
Continue to Step 5 verification regardless (the file existence checks will catch truly missing output).After all agents complete, verify the expected files exist:
Required files (always):
.planning/codebase/RECON.md (created in Step 2).planning/codebase/STACK.md (tech mapper).planning/codebase/INTEGRATIONS.md (tech mapper).planning/codebase/ARCHITECTURE.md (arch mapper).planning/codebase/STRUCTURE.md (arch mapper)Required files (standard + comprehensive only):
.planning/codebase/CONVENTIONS.md (quality mapper).planning/codebase/TESTING.md (quality mapper).planning/codebase/CONCERNS.md (concerns mapper)Check only the files that correspond to the mapper areas that were actually spawned.
For any missing files, display:
╔══════════════════════════════════════════════════════════════╗
║ ERROR ║
╚══════════════════════════════════════════════════════════════╝
Missing analysis output: {filename}
Agent that failed: {focus_area} mapper
**To fix:** Re-run with `/pbr:scan` and select "Refresh a specific area" → {focus_area}.
Read key findings from each file (frontmatter or first section) and display using the branded stage banner from references/ui-formatting.md:
╔══════════════════════════════════════════════════════════════╗
║ PLAN-BUILD-RUN ► SCAN COMPLETE ✓ ║
╚══════════════════════════════════════════════════════════════╝
Project: {type} ({scale})
Stack: {primary language} + {framework}
Architecture: {style}
Key Stats:
- {file count} source files, {test count} test files
- {dependency count} dependencies
- {integration count} external integrations
Full analysis: .planning/codebase/
Concerns section (only display if ALL of these conditions are true: (1) the concerns mapper was included in scan.mapper_areas for the resolved depth profile, (2) the concerns mapper was actually spawned, AND (3) .planning/codebase/CONCERNS.md exists and contains at least one concern entry). If any condition is false, skip this entire section silently — do NOT display an empty concerns block or a "no concerns" message:
Concerns: {critical} critical, {high} high, {medium} medium
Top concerns:
1. {most critical concern}
2. {second concern}
3. {third concern}
Then use the "Next Up" routing block:
╔══════════════════════════════════════════════════════════════╗
║ ▶ NEXT UP ║
╚══════════════════════════════════════════════════════════════╝
**Start a project** — use the scan results to plan your work
`/pbr:begin`
<sub>`/clear` first → fresh context window</sub>
**Also available:**
- `/pbr:milestone new` — create a milestone to address concerns
- `/pbr:status` — see project status
Reference: skills/shared/commit-planning-docs.md for the standard commit pattern.
If .planning/config.json exists and planning.commit_docs: true:
git add .planning/codebase/
git commit -m "docs(planning): map existing codebase"
If no config exists yet (scan before begin), use AskUserQuestion (pattern: yes-no from skills/shared/gate-prompts.md):
question: "Commit the codebase analysis to git?"
header: "Commit?"
options:
- label: "Yes" description: "Stage and commit .planning/codebase/ files"
- label: "No" description: "Skip commit — files are saved but not committed"
git add .planning/codebase/ && git commit -m "docs(planning): map existing codebase".planning/ and .planning/codebase/ if neededReference: skills/shared/universal-anti-patterns.md for rules that apply to ALL skills.
Additionally for this skill:
npm start, python app.py, etc.) — analyze statically