ワンクリックで
explore-repo
Deep-scan a repository to understand its structure, functionality, and documentation gaps.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Deep-scan a repository to understand its structure, functionality, and documentation gaps.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Capture session learnings and save to skills, guidelines, or reference docs under ~/.claude/.
Orchestrate parallel claude -p sessions — bootstrap, launch, monitor, and converge. Works with any skill that produces manifest.json, item directories, and a runner script.
Create a request (pull request or merge request) or update an existing one following project conventions.
Resolve merge or rebase conflicts between branches.
Assess open PRs with unaddressed review comments and generate a parallel addressing script — produces manifest.json and let-it-rip.sh for address-request-comments execution.
Assess open work items and generate a parallel execution script — produces manifest.json and let-it-rip.sh for implement/clarify execution.
| name | explore-repo |
| description | Deep-scan a repository to understand its structure, functionality, and documentation gaps. |
| argument-hint | [repo-path] |
| allowed-tools | ["Read","Glob","Grep","Bash","Task","WebFetch","AskUserQuestion"] |
git rev-parse --show-toplevel 2>/dev/nullgit branch --show-current 2>/dev/nullgit rev-parse --short HEAD 2>/dev/nullgit rev-parse --abbrev-ref origin/HEAD 2>/dev/nullgit rev-parse --short origin/HEAD 2>/dev/nullDeep-scan a repository using parallel exploration agents to produce comprehensive documentation, identify documentation gaps, and flag inconsistencies between code and existing docs.
Operates in two modes based on file state — scan mode writes domain-specific docs, synthesis mode reads them to produce cross-domain outputs. Each invocation runs one mode only.
/explore-repo - Auto-detect mode based on file state/explore-repo <focus-areas> - Scan specific dimensions only (comma-separated: structure, api, data-model, integrations, flows, config, testing)~/.claude/skill-references/subagent-patterns.md — Universal patterns for launching and orchestrating subagentsThe skill scans the working tree as-is. Default expectation is the canonical baseline (latest upstream default branch) so the docs match what new readers see in main; pick the operator's current branch only when scanning in-flight work that isn't merged yet.
git fetch origin --prune (silent on success). If it fails (offline / no origin), skip step 2–3 and use the current branch as SCAN_REF.git rev-parse --abbrev-ref origin/HEAD — typically origin/main. If unset, try origin/main, then origin/master. If none exist, fall back to the current branch as SCAN_REF.<DEFAULT_REF> as the metadata stamp.
<DEFAULT_REF>. Working tree is the baseline. Proceed in place.<DEFAULT_REF> with doc-only changes. This is the common case where a dev runs /explore-repo repeatedly on a branch off main and accumulates artifact commits. Detect it like this:
git rev-list --count <DEFAULT_REF>..HEAD. If 0 → Case A. If >5 → fall through to step 4.git merge-base --is-ancestor <DEFAULT_REF> HEAD (must succeed; otherwise fall through — HEAD diverged).git diff --name-only <DEFAULT_REF>..HEAD. Every changed path must match the doc-artifact allowlist:
docs/** (any docs subdirectory, including docs/explore-repo/, docs/learnings/, docs/features/, etc.)CLAUDE.md, **/CLAUDE.md (root and subdirectory CLAUDE.md files — these are the skill's own outputs)README.md.claude/** (skill/settings tooling)📚 HEAD is N commit(s) ahead of <DEFAULT_REF> with doc-only changes — scanning at baseline (<DEFAULT_REF> @ <sha>).AskUserQuestion if available; otherwise output the question and stop for input). Reached only when neither fast path in step 3 applied — HEAD diverged from the baseline by source-code changes, or by more than 5 commits, or it isn't a descendant of <DEFAULT_REF> at all:
Scan target?<DEFAULT_REF> @ <short-sha> — "Latest upstream — recommended."<current-branch> @ <short-sha> — "Current working-tree HEAD."The chosen scan target (<DEFAULT_REF> @ <sha>) doesn't match working-tree HEAD (<current-branch> @ <sha>).
Check it out and re-run:
git fetch origin && git checkout <DEFAULT_REF>
/explore-repo
Do NOT auto-checkout, stash, or create a worktree — leave it to the operator.SCAN_REF = the chosen branch ref (in fast paths, this is <DEFAULT_REF>).SCAN_COMMIT = the short SHA at that ref. In Case A this equals current HEAD; in Case B this is the SHA of <DEFAULT_REF>, even though working-tree HEAD is a few commits ahead — source code is identical, so the stamp reflects the baseline readers will see.commit: and branch:) of every domain file and synthesis output. All references to "current HEAD" in the rest of this file mean SCAN_COMMIT.📚 Scan target: <SCAN_REF> @ <SCAN_COMMIT>.Determine what work needs to be done by checking existing output files.
Check for domain scan files and synthesis files (run in parallel):
docs/explore-repo/structure.mddocs/explore-repo/api-surface.mddocs/explore-repo/data-model.mddocs/explore-repo/integrations.mddocs/explore-repo/processing-flows.mddocs/explore-repo/config-ops.mddocs/explore-repo/testing.mddocs/explore-repo/SYSTEM_OVERVIEW.mddocs/explore-repo/inconsistencies.mdDetermine which files exist and check staleness:
SCAN_COMMIT and SCAN_REF from Phase 0 (already resolved).commit from the scan metadata header.SCAN_COMMIT.Smart staleness — identify affected domains:
If any scan files are stale, run git diff --stat <stale-commit>..<SCAN_COMMIT> to see which files changed, excluding the skill's own output files from the diff using git pathspec exclusions:
git diff --stat <stale-commit>..<SCAN_COMMIT> \
':!docs/explore-repo/structure.md' \
':!docs/explore-repo/api-surface.md' \
':!docs/explore-repo/data-model.md' \
':!docs/explore-repo/integrations.md' \
':!docs/explore-repo/processing-flows.md' \
':!docs/explore-repo/config-ops.md' \
':!docs/explore-repo/testing.md' \
':!docs/explore-repo/SYSTEM_OVERVIEW.md' \
':!docs/explore-repo/inconsistencies.md' \
':!.claude/'
This prevents the synthesis phase's own writes and .claude/ tooling changes (skill files, settings) from triggering re-scans.
Check branch topology before mapping domains. Run git log --oneline <stale-commit>..<SCAN_COMMIT> to understand what the commits are. If the diff is entirely from branch switches or .claude/ tooling work (no source code changes), skip re-scanning entirely — just stamp-update the metadata headers to SCAN_COMMIT. Only proceed with domain mapping if the log shows commits that touched actual source code.
Map changed file paths to affected domains using this table:
| Changed path pattern | Affected domain(s) |
|---|---|
pom.xml, build.gradle, Makefile, Dockerfile, docker-compose*, .gitlab-ci.yml, *.sh (root/scripts) | Structure |
**/openapi*.yml, **/*Controller*, **/*Filter*, **/*Interceptor*, **/middleware/** | API Surface |
**/*Entity*, **/*Repository*, **/migration/**, **/schema*, **/*Converter* | Data Model |
**/integration/**, **/integrations/**, **/*Client*, **/*client/** | Integrations |
**/*Service* (non-client), **/*Activity*, **/*Processor*, **/*Handler* (non-controller), **/*Workflow* | Processing Flows |
**/application*.properties, **/application*.yml, **/*Config*, **/*Properties*, **/logback* | Config & Ops |
**/test/**, **/tests/**, **/*Test*, **/*IT*, **/testdata/**, **/fixtures/** | Testing |
Only re-scan domains whose files were materially affected by the changes. Apply judgment: a 2-line property addition won't change a 350-line config scan, and adding test cases to an existing test file won't change the testing infrastructure scan. Re-scan when the changes would meaningfully alter the domain file's content (new integrations, new entities, new test patterns), not when they're incremental additions to existing patterns. When in doubt, stamp-update rather than re-scan.
If the diff is too large (100+ files changed) or the mapping is ambiguous, fall back to re-scanning all stale domains
If <stale-commit> is unreachable (e.g., scan was run on a deleted feature branch like claude/create-feature-branch-*), git diff and git log against it will fail. Detect via git rev-parse <stale-commit> returning non-zero, then fall back to re-scanning all stale domains. Don't try to find a nearest-ancestor — it's not worth the heuristic complexity.
Important: If CLAUDE.md or README.md changed, mark ALL domains for re-scan (project-level docs affect all agents' context)
Clean up stale synthesis files:
SYSTEM_OVERVIEW.md and inconsistencies.md — they were produced from older scan data and will be regenerated in a subsequent synthesis runDetermine mode:
| Condition | Mode | Action |
|---|---|---|
| Any scan files missing (not all 7 present) | Scan | Scan missing domains |
All 7 present, stale (commit differs from SCAN_COMMIT) | Scan | Re-scan only domains affected by changes (from step 3) |
| All 7 present, current, no SYSTEM_OVERVIEW.md | Synthesize | Produce synthesized outputs |
| All 7 present, current, SYSTEM_OVERVIEW.md exists but stale | Synthesize | Re-synthesize |
| All 7 present, current, SYSTEM_OVERVIEW.md current | Up-to-date | Nothing to do |
$ARGUMENTS override: If focus areas are specified, always scan those domains regardless of file state.
Announce mode:
Before launching exploration agents, gather essential project context.
Read existing documentation (run in parallel):
Glob for top-level files to understand the repo layoutIf no CLAUDE.md or README.md exists, detect the project type:
pom.xml, build.gradle, package.json, Cargo.toml, go.mod, requirements.txt, pyproject.toml, Makefile, CMakeLists.txtapplication.properties (Spring Boot), next.config.js (Next.js), angular.json, etc.Assemble PROJECT_CONTEXT — a concise summary containing:
This context will be injected into every agent prompt.
Launch exploration agents in parallel using the Task tool. Use subagent_type: "general-purpose" for all agents — this allows them to spawn sub-agents if they encounter too many files.
For each agent:
The 7 agents:
| # | Agent | Domain | Output File |
|---|---|---|---|
| 1 | Structure | Module layout, build system, dependencies, CI/CD | docs/explore-repo/structure.md |
| 2 | API Surface | REST/gRPC/CLI endpoints, request/response shapes | docs/explore-repo/api-surface.md |
| 3 | Data Model | Entities, schema, relationships, migrations, state machines | docs/explore-repo/data-model.md |
| 4 | Integrations | External services, clients, authentication, error handling | docs/explore-repo/integrations.md |
| 5 | Processing Flows | Core business logic, workflows, scheduled tasks, events | docs/explore-repo/processing-flows.md |
| 6 | Config & Ops | Configuration, profiles, monitoring, secrets, deployment | docs/explore-repo/config-ops.md |
| 7 | Testing | Test structure, patterns, utilities, how to run tests | docs/explore-repo/testing.md |
Only launch agents for domains that need scanning (missing or stale files, or explicitly requested via $ARGUMENTS).
If $ARGUMENTS specifies focus areas, only launch agents for those dimensions. Map argument names to agents:
structure → Agent 1api → Agent 2data-model → Agent 3integrations → Agent 4flows → Agent 5config → Agent 6testing → Agent 7Launch all selected agents in a single message to maximize parallelism.
Each agent will:
Wait for all agents to complete. If any agent fails, note the failure — the missing file will be picked up on the next run.
Post-scan validation: After all agents complete, read the first 6 lines of each output file and verify:
commit field matches SCAN_COMMIT and the branch field matches SCAN_REFAfter all agents complete, print a brief summary:
Scan Complete
Target: <SCAN_REF> @ <SCAN_COMMIT>
Domains scanned: [list]
Domains skipped: [list, if any — already current]
Domains failed: [list, if any]
Output files:
- docs/explore-repo/structure.md
- docs/explore-repo/api-surface.md
- ...
Run /explore-repo again to synthesize into SYSTEM_OVERVIEW.md
Stop here. Do not proceed to synthesis in the same invocation.
This phase runs in a fresh invocation with a clean context. Read domain files from disk — do NOT rely on any cached or in-memory results.
Read all 7 domain files from docs/explore-repo/:
structure.md, api-surface.md, data-model.md, integrations.md, processing-flows.md, config-ops.md, testing.mdRead existing documentation for comparison:
Cross-check domain files for contradictions:
Before synthesizing, scan all 7 domain files' ## Gotchas sections for claims about the same code or behavior. Independent agents can report contradictory findings (e.g., one says a bug exists, another says it was fixed). When two files make conflicting claims:
inconsistencies.md under a "Cross-agent contradictions" sectionSynthesize SYSTEM_OVERVIEW.md:
Write a cross-domain overview — this is the unique value that individual domain files cannot provide on their own. Do NOT simply concatenate the domain files.
Concision mandate (same standard as the domain agents):
Structure:
┌─────────────┐ ┌──────────────┐
│ API Layer │────▶│ Service Layer│
└─────────────┘ └──────┬───────┘
│
┌───────────┼───────────┐
▼ ▼ ▼
┌──────────┐ ┌─────────┐ ┌──────────┐
│ Adapters │ │ DB │ │ Events │
└──────────┘ └─────────┘ └──────────┘
| Pattern | Domains | Mechanism | Notes |
|---|---|---|---|
| (auth, error handling, naming conventions, transactions, retries, etc.) |
| # | Step | Layer | File:line | Notes |processing-flows.md" — no prose narration of the steps| Order | File | What it teaches |
|---|---|---|
| Answers "If I only have 30 minutes, what should I read?" |
| Service | Retry | Timeout | Circuit breaker | Idempotency |
|---|---|---|---|---|
| Cells show mechanism if present, blank if absent. Below the table: one-line overall posture (e.g., "0 of 7 integrations have retry logic") and call out outliers. Don't repeat the per-service detail in prose. |
| Module | Test file? | Risk | Notes |
|---|---|---|---|
| Structural coverage only (test file exists), not line-level. One bullet beneath summarizing posture. |
| Severity | What's missing | Where it should go | Suggested content |
|---|---|---|---|
| Severities: Critical (blocks productivity) · Medium (inferable from code) · Low (nice-to-have). |
Synthesize inconsistencies.md:
Compare existing CLAUDE.md and README.md against what the scan actually found. Only write this file if existing docs were found — if there are no docs, skip it. Same format rules as SYSTEM_OVERVIEW.md: tables-first, prose only when needed.
Doc-vs-code inconsistencies — table:
| Severity | Doc source (file § section) | Claim | Reality (file:line) | Suggested fix | Status |
|---|
Severities:
Status column carries the auto-fix outcome (see step 7): [FIXED] or [UNFIXED — reason].
Config artifact drift — separate table with the same columns. Cross-reference configuration templates and declarations against their canonical code sources:
.env.template / .env.example vs canonical env var definitions in code (e.g., env_vars.py, config.ts, application.properties) — flag variables present in template but absent in code (dead), and variables in code but missing from template (undocumented)npm test but package.json defines yarn test)python:3.11 in Dockerfile vs 3.12 in pyproject.toml)Skip silently if no templates or CI config exist.
Add cross-references between domain files:
After synthesizing, go back and add a ## Cross-references section at the bottom of each domain file (before ## Scan Limitations) with links to related content in other domain files. The goal is to make each domain file navigable to its neighbors. Example:
## Cross-references
- Entity details: `docs/explore-repo/data-model.md` (full entity field listings)
- Integration clients: `docs/explore-repo/integrations.md` (HTTP client configuration)
- Workflow orchestration: `docs/explore-repo/processing-flows.md` (step function activities)
Only add cross-references where there's a genuine relationship — don't cross-reference everything to everything.
Auto-fix outdated documentation:
Using the inconsistencies found in step 5, automatically apply fixes to CLAUDE.md and README.md:
[FIXED] or [UNFIXED] with reason)Update CLAUDE.md files:
Based on the synthesized understanding, update documentation for better agent traversal:
Root CLAUDE.md: Be opinionated. Don't just add new sections — actively improve existing content based on what the scan revealed. If the scan found that a section is misleading, incomplete, or poorly organized, fix it. Add counts, correct inaccuracies, add missing cross-references. Don't clobber the operator's structure, but do make it more accurate and useful.
Subdirectory CLAUDE.md files — Evaluate candidates and create where valuable:
Checklist — you MUST explicitly evaluate each candidate and report which you created vs. skipped (with reasons).
Scan the codebase for directories that meet one or more of these criteria:
For each candidate, create a focused CLAUDE.md that covers:
docs/explore-repo/Root CLAUDE.md cross-references: Add a "Context-Specific Guides" section to root CLAUDE.md with conditional @ references pointing to subdirectory CLAUDE.md files. This enables agent discovery from root context while keeping token cost low. Format:
@path/to/CLAUDE.md - Brief description of what context it provides
Keep CLAUDE.md content concise and navigational — deep detail belongs in the domain files under docs/explore-repo/.
Write output files:
mkdir -p docs/explore-repo
docs/explore-repo/SYSTEM_OVERVIEW.mddocs/explore-repo/inconsistencies.md (skip if no existing docs)After writing files, validate and then print a summary.
Validation — verify counts from structured sections:
Before printing the summary, scan the domain files and SYSTEM_OVERVIEW.md to extract actual counts from their structured sections:
## Modules in structure.md## Core Entities in data-model.md## External Services in integrations.md## Core Workflows in processing-flows.mdUse these actual counts in the summary below — do not estimate or approximate. If the SYSTEM_OVERVIEW.md says "15+ partner adapters" but structure.md lists 21 modules, flag the mismatch and fix it.
Summary:
Synthesis Complete
Project: [name] ([language/framework])
Scan: <SCAN_REF> @ <SCAN_COMMIT> at [date]
Codebase:
- [N] modules | [N] REST endpoints | [N] entities | [N] external integrations | [N] core workflows
Key Findings:
- [1-2 sentence architectural summary]
- [N] cross-cutting patterns identified
- [N] end-to-end workflows traced
Resilience: [N]/[N] integrations with retries | [N]/[N] with timeouts | [N]/[N] with circuit breakers
Test Coverage: [N] source modules without test files ([list high-risk ones])
Documentation Health:
- [N] critical / [N] medium / [N] low gaps
- [N] doc inconsistencies ([N] auto-fixed, [N] unfixed)
- [N] config artifact drift items
Output:
- docs/explore-repo/SYSTEM_OVERVIEW.md
- docs/explore-repo/inconsistencies.md
- CLAUDE.md ([NEW — created from scratch] or [updated]). If new, add a 1-2 line synopsis: "Covers: [what sections were included, e.g., architecture, commands, patterns, gotchas, API surface]"
- [list any subdirectory CLAUDE.md files created]
- [list any auto-fixed files: CLAUDE.md, README.md]
Domain docs (for deeper context):
- docs/explore-repo/structure.md
- docs/explore-repo/api-surface.md
- docs/explore-repo/data-model.md
- docs/explore-repo/integrations.md
- docs/explore-repo/processing-flows.md
- docs/explore-repo/config-ops.md
- docs/explore-repo/testing.md
data-model.md directly without needing the overview.@ references in CLAUDE.md over dumping everything inline — optimize for token efficiency.