Agent skill
codebase-exploration
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/codebase-exploration
SKILL.md
Codebase Exploration Skill
Version: 1.0.0 Compiler: skill-compiler/1.0.0 Last Updated: 2026-01-23
Systematically survey unfamiliar codebases to build understanding before implementation work.
When to Activate
Use this skill when:
- Exploring a new repository for the first time
- Surveying an unfamiliar codebase
- Conducting pre-implementation reconnaissance
- Performing architecture review or audit
- Onboarding to a project
Core Principles
1. Documentation First
Read README, AGENTS.md, and existing docs before exploring code.
Existing documentation captures intent and context that code alone cannot convey; saves exploration time when docs exist.
2. Outside-In Discovery
Start with project boundaries (deps, config, structure) before diving into implementation.
Understanding the shape of the system prevents getting lost in details; dependencies reveal technology choices and constraints.
3. Parallel Exploration for Breadth
Explore multiple orthogonal aspects simultaneously using sub-agents when appropriate.
Large codebases have independent concerns; parallel exploration covers more ground within context limits.
4. Follow the References
When a file references another file or concept, trace that reference.
Codebases are graphs of related concepts; following edges reveals the full picture.
5. Capture Before Context Loss
Write observations and findings immediately; don't rely on memory across exploration.
Context windows are finite; explicit capture preserves knowledge for later phases.
6. Map the Territory
Build explicit maps (directory structure, component relationships) not just notes.
Maps are reusable orientation tools; prose notes are harder to navigate.
Workflow
Phase 1: Pre-Flight Check
Gather immediate context before exploration begins.
- Identify exploration goal (audit, pre-implementation, onboarding, debugging)
- Set scope boundaries (which directories, file types, depth limit, time budget)
- Check for existing documentation that answers questions (README, AGENTS.md, docs/)
- Note any specific questions to answer
Outputs: Exploration scope definition, known documentation inventory, question list
Phase 2: Structural Survey
Map the shape of the codebase without reading implementation.
- List top-level directory structure
- Identify workspace/monorepo patterns (Cargo workspace, npm workspaces, etc.)
- Locate entry points (main files, index files, CLI entry)
- Identify test locations and patterns
- Note documentation locations
Outputs: Directory tree (annotated), entry point map, test location summary
# Directory structure
tree -L 2 -d
# File type distribution
find . -type f -name "*.rs" | wc -l
find . -type f -name "*.ts" | wc -l
# Entry points
ls **/main.* **/index.* **/mod.* 2>/dev/null
Phase 3: Dependency Analysis
Understand external dependencies and technology choices.
- Read package manifests (Cargo.toml, package.json, go.mod, etc.)
- Identify major frameworks and their versions
- Note dev vs runtime dependencies
- Look for lock files indicating version pinning
- Check for workspace/monorepo configuration
Outputs: Dependency inventory with purposes, technology stack summary
Files to check:
- Cargo.toml, Cargo.lock
- package.json, package-lock.json, yarn.lock
- go.mod, go.sum
- pyproject.toml, requirements.txt
- Makefile, justfile
Phase 4: Configuration Discovery
Find and understand configuration patterns.
- Locate config files (.env, config/, settings)
- Identify environment-specific configs
- Note configuration formats (YAML, TOML, JSON, etc.)
- Check for CI/CD configuration (.github/, .gitlab-ci.yml)
- Look for editor/tooling configs (.vscode/, .editorconfig)
Outputs: Configuration file inventory, environment handling summary, CI/CD overview
Phase 5: Documentation Deep-Read
Read existing documentation thoroughly.
- Read README.md completely (not skimming)
- Check for AGENTS.md or similar agent instructions
- Read any architecture docs (docs/architecture.md, ADRs)
- Check for API documentation
- Look for contribution guides (CONTRIBUTING.md)
Outputs: Documentation quality assessment, key concepts extracted, gaps identified
Priority order:
- README.md
- AGENTS.md
- docs/codebase-overview.md
- docs/adr/*.md
- CONTRIBUTING.md
Phase 6: Code Pattern Recognition
Sample implementation files to understand conventions.
- Read 2-3 representative source files in detail
- Identify naming conventions (files, functions, types)
- Note error handling patterns
- Look for common abstractions and utilities
- Check comment and documentation style
Outputs: Convention summary, common patterns catalog, code style notes
Sampling strategy: Don't read everything; sample strategically:
- One entry point file (main.rs, index.ts)
- One "core" module (often largest or most imported)
- One test file (reveals testing patterns)
- One utility/helper file (reveals abstractions)
Phase 7: Integration Points
Identify how components connect and external boundaries.
- Find module boundaries and exports
- Identify external service integrations
- Note CLI/API surface areas
- Map internal dependencies between modules
- Check for plugin/extension points
Outputs: Integration point inventory, external service dependencies, module graph
Phase 8: Synthesis and Output
Consolidate findings into usable artifacts.
- Write structured findings (tables, lists)
- Create or update codebase map
- Document open questions
- Note technical debt or red flags observed
- Recommend next exploration areas if incomplete
Outputs: Codebase overview document, open questions list, observations dump
Patterns
| Pattern | When | Do | Why |
|---|---|---|---|
| Parallel Sub-Agent Exploration | Codebase has separable concerns | Spawn Task agents for each concern; merge findings | Covers more ground within context limits |
| Documentation-Existence Check | Starting any repo exploration | ls README.md AGENTS.md docs/*.md 2>/dev/null |
Existing docs may answer questions |
| Dependency Purpose Annotation | Reading package manifest | Note each dependency's purpose | Dependency lists without context are hard to interpret |
| Progressive Depth | Limited time budget | Complete each phase shallow before going deep | Broad coverage reveals structure |
| Reference Chasing | File mentions another file/concept | Note reference; trace if relevant | References reveal actual relationships |
| Sampling Not Exhaustive | Many files of similar type (50+) | Read 3-5 samples; infer patterns | Exhaustive reading exhausts context |
Anti-Patterns to Avoid
| Anti-Pattern | Why It Fails | Instead |
|---|---|---|
| Diving Into Implementation First | Get lost in details; miss architecture | Complete structural survey first |
| Exhaustive Reading | Context exhaustion; diminishing returns | Sample representative files |
| Ignoring Documentation | Miss intent and context code can't convey | Read docs first; verify against code |
| Sequential Single-Threaded | Covers less ground; misses connections | Use sub-agents for orthogonal concerns |
| Mental-Only Notes | Knowledge lost at context exhaustion | Write findings immediately |
| Skipping Test Structure | Miss usage patterns and expected behaviors | Always check test organization |
Quality Checklist
Before completing exploration:
- README.md and AGENTS.md read (if they exist)
- Directory structure mapped
- Entry points identified
- Dependencies inventoried with purposes
- Configuration files located
- 2-3 source files sampled for conventions
- Test structure understood
- Integration points noted
- Findings written (not just remembered)
- Open questions documented
Examples
Survey unfamiliar Rust CLI project (beadsmith)
# 1. Pre-flight: Goal is understanding for implementation work
# Scope: Full repo, focus on skill system
# 2. Check for docs first
ls README.md docs/ AGENTS.md
# Found: README.md, docs/ with ADRs
# 3. Structural survey
tree -L 2 -d
# Identified: crates/beadsmith (CLI), skills/ (bundled skills), planning/
# 4. Dependencies
cat Cargo.toml # workspace config
cat crates/beadsmith/Cargo.toml # clap, anyhow, colored, dirs
# 5. Read docs
# README.md - project overview, skill list
# docs/codebase-overview.md - comprehensive bootstrap guide
# 6. Sample source files
# main.rs - CLI entry, command dispatch
# skills.rs - include_str!() pattern for bundling
# commands/init.rs - skill extraction logic
# 7. Findings
# - Compile-time skill bundling via include_str!()
# - Skills have input.yaml (source) + SKILL.md (compiled)
# - Planning integration with external org-mode and beads
# - Well-documented with ADRs
Quick audit under time pressure (15 minutes)
# Use progressive depth - broad shallow first
# Phase 1: Immediate orientation (3 min)
cat README.md | head -100
tree -L 1
ls -la
# Phase 2: Dependencies (3 min)
cat package.json 2>/dev/null || cat Cargo.toml 2>/dev/null
# Phase 3: Entry points (3 min)
find . -name "main.*" -o -name "index.*" | head -5
# Phase 4: Quick doc scan (3 min)
ls docs/ 2>/dev/null
cat CONTRIBUTING.md 2>/dev/null | head -50
# Phase 5: Write findings (3 min)
# Even under time pressure, write what you learned
Related Skills
| Skill | Relationship |
|---|---|
research |
Use after exploration for deep investigation |
skill-compiler |
Understanding skill structure aids beadsmith exploration |
References
researchskill - for deep investigation after initial surveyskill-compilerskill - for understanding skill structure in beadsmith- Anthropic: "Building Effective Agents" - context management patterns
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?