Autonomous two-phase codebase exploration with adaptive agents
Autonomously discovers codebase structure, then explores target with adaptive agents.
/plugin marketplace add lerianstudio/ring/plugin install ring-default@ring[target]Autonomously discover codebase structure, then explore deeply with adaptive agents. The system first learns the architecture, then dispatches targeted explorers based on what it found.
/explore-codebase [target]
| Argument | Required | Description |
|---|---|---|
target | Yes | Feature, component, or system to explore (e.g., "account creation", "transaction processing", "authentication system") |
Two-Phase Autonomous Exploration:
Target: "account creation"
│
▼
┌──────────────┐
│ Phase 1: │ Launch 4 discovery agents in parallel:
│ Discovery │ • Architecture pattern?
│ │ • Components/modules?
│ │ • Layers/boundaries?
└──────┬───────┘ • Organization principle?
│
│ Discovered: 3 components, hexagonal architecture, 4 layers each
│
▼
┌──────────────┐
│ Phase 2: │ Launch 3 deep-dive agents (adapted to discoveries):
│ Deep Dive │ • Onboarding component
│ │ • Transaction component
│ │ • CRM component
└──────┬───────┘ Each explores "account creation" in their area
│
▼
┌──────────────┐
│ Synthesis │ • Integrate discoveries + deep dives
│ │ • Cross-cutting insights
│ │ • Implementation guidance
└──────────────┘
This command invokes the exploring-codebase skill which handles:
Architecture Discovery Agent:
Component Discovery Agent:
Layer Discovery Agent:
Organization Discovery Agent:
The number and focus of agents adapts to Phase 1 findings:
| What Phase 1 Found | Phase 2 Strategy |
|---|---|
| 3 components × 4 layers | Launch 3 agents (one per component) |
| Single component, clear layers | Launch 4 agents (one per layer) |
| 5 microservices | Launch 5 agents (one per service) |
| 6 features (feature-organized) | Launch 6 agents (one per feature) |
Each deep dive agent receives:
Each deep dive agent produces:
/explore-codebase account creation
Phase 1 might discover:
Phase 2 adapts with 3 agents:
Result: Comprehensive understanding of how account creation works across all components
/explore-codebase transaction processing
Phase 1 might discover:
Phase 2 adapts with 5 agents:
Result: End-to-end understanding of transactions across services
/explore-codebase authentication system
Phase 1 might discover:
Phase 2 adapts with 3 agents:
Result: Vertical slice of authentication through all layers
The command produces a comprehensive synthesis document with:
2-3 sentences about architecture + how target works
For each discovered area:
Context-aware recommendations for:
Recommendations based on your goal (implementation, debugging, or learning)
Use this command when:
Don't use when:
| Command/Skill | Relationship |
|---|---|
/brainstorm | Use explore-codebase in Phase 1 for context |
/write-plan | Use explore-codebase before planning implementation |
/execute-plan | Use if plan execution reveals gaps in understanding |
exploring-codebase | Underlying skill with full logic and prompts |
dispatching-parallel-agents | Pattern used twice (discovery + deep dive) |
systematic-debugging | Use explore-codebase before debugging |
Cause: Codebase may have inconsistent or legacy patterns Solution: Review discovery agent outputs, may need manual interpretation
Cause: Target may not exist in that area (valid finding) OR target named differently Solution: Check if agents noted "not found in this area" - may be expected
Cause: Different parts of codebase use different patterns (common in legacy code) Solution: Synthesis phase should document variations - may indicate refactoring opportunities
Cause: Phase 1 discovered many components/layers Solution: Refine target to be more specific, or use a subset scope
Cause: Target may be too broad or vague Solution: Be more specific: "account creation API endpoint" vs "accounts"
Focus discovery on specific area:
/explore-codebase transaction processing in payment service only
Request comprehensive analysis:
/explore-codebase authentication (include all integrations and edge cases)
Run twice to understand changes:
# Before refactoring
/explore-codebase user management
# After refactoring
/explore-codebase user management
# Compare the two synthesis documents
Phase 1: "Found 8 microservices with event-driven architecture" Phase 2: 8 deep-dive agents, one per service Synthesis: Event flow diagram + service responsibilities + integration points
Phase 1: "Found single app with hexagonal architecture, 4 layers" Phase 2: 4 deep-dive agents, one per layer Synthesis: Dependency inversion patterns + layer boundaries + adapter implementations
Phase 1: "Found 12 features, each self-contained with own layers" Phase 2: 12 deep-dive agents, one per feature Synthesis: Shared code patterns + feature independence + cross-feature integration
The command suggests appropriate follow-up:
If you're implementing something:
Ready to create implementation plan? Use /write-plan
If you're setting up workspace:
Ready for isolated workspace? Use /worktree
If you're debugging:
Ready to investigate? Use systematic-debugging skill
If you're designing:
Ready to refine design? Use /brainstorm
# 1. Understand the codebase
/explore-codebase payment processing
# 2. Review synthesis document (architecture + implementation)
# 3. Based on findings, plan your changes
/write-plan add-refund-support
# 4. Set up isolated workspace
/worktree feature/add-refund-support
# 5. Execute the plan
/execute-plan <plan-file>
✅ Autonomous - Discovers structure, doesn't assume it ✅ Adaptive - Deep dive agents match discovered architecture ✅ Efficient - Parallel exploration in both phases ✅ Thorough - Structural context + implementation details ✅ Actionable - Synthesis provides implementation guidance ✅ Universal - Works with any codebase architecture
This command MUST load the skill for complete workflow execution.
Use Skill tool: exploring-codebase
The skill contains the complete workflow with: