agentleFS
ROCmROCm/rocprofiler-systems-skills/skills/exploration-explore-code/SKILL.md

exploration-explore-code

Skill5 starsChanged 16 days agoMITView on GitHub

Use when user wants to understand unfamiliar code before extracting functionality - exploring database layers, API usage, library patterns, or any code to be extracted into a reusable component

The file

Show its rules and text

We split this skill into the rules it gives an agent

13 rules. About 0 are common, 11 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈11

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Where to use it: - Call sites, contexts, triggering conditions

    line 19
  2. Very specific:

    Use the AskUserQuestion tool to understand:

    line 95
  3. Distinctive:

    After scoping, perform initial pass:

    line 112
  4. Distinctive:

    Wait for user response before continuing.

    line 135
  5. Distinctive:

    Document the patterns and conditions:

    line 159
  6. Distinctive:

    Wait for user response.

    line 221
  7. Distinctive:

    After all areas explored:

    line 225
  8. Distinctive:

    Wait for user approval before generating.

    line 247
  9. Distinctive:

    Create the final markdown file with:

    line 251
  10. Distinctive:

    Call sites and triggering contexts:

    line 271
  11. Distinctive:

    Long silence: - If you've read more than 5 files without user update, pause and report

    line 321
  12. Very specific:

    Missing what/how/where: - Every finding should answer at least one of the three questions

    line 322
  13. Distinctive:

    Generating without checkpoint: - Always present draft structure before final document

    line 323

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Explore Code

Deep exploration of unfamiliar codebases to understand usage patterns before extraction or integration.

Overview

This skill helps users understand code they don't know, specifically when preparing to extract functionality into reusable libraries or components.

MANDATORY: User must specify what usage type to explore (e.g., "database reading patterns", "authentication flow", "API client usage").

The exploration answers three questions:

  1. What is used - Which tables, APIs, components, functions
  2. How it is used - Patterns, conditions, parameters, transformations
  3. Where to use it - Call sites, contexts, triggering conditions

Key assumption: The project is unknown to the user. They're learning to extract, not verifying known behavior.

Output: A structured markdown file at planning/exploration-<topic>.md with precise usage inventory for extraction planning.

Process Flowchart

┌─────────────────────────────────────────────────────────────────┐
│                     User asks exploration question              │
└─────────────────────────────────────────────────────────────────┘
                                │
                                ▼
                    ┌───────────────────────┐
                    │  Ask scoping questions │◄────┐
                    └───────────────────────┘     │
                                │                 │
                                ▼                 │
                    ┌───────────────────────┐     │
                    │     Scope clear?      │─────┘
                    └───────────────────────┘ no
                                │ yes
                                ▼
                    ┌───────────────────────┐
                    │ Initial exploration   │
                    └───────────────────────┘
                                │
                                ▼
                    ┌───────────────────────┐
                    │ CHECKPOINT 1: Report  │
                    │ Ask: Focus areas?     │
                    └───────────────────────┘
                                │
                                ▼
                    ┌───────────────────────┐
                    │ Deep dive on areas    │◄────┐
                    └───────────────────────┘     │
                                │                 │
                                ▼                 │
                    ┌───────────────────────┐     │
                    │ CHECKPOINT 2: Report  │     │
                    │ Ask: Skip/add areas?  │     │
                    └───────────────────────┘     │
                                │                 │
                                ▼                 │
                    ┌───────────────────────┐     │
                    │   More areas?         │─────┘
                    └───────────────────────┘ yes
                                │ no
                                ▼
                    ┌───────────────────────┐
                    │ Synthesize findings   │
                    └───────────────────────┘
                                │
                                ▼
                    ┌───────────────────────┐
                    │ CHECKPOINT 3: Draft   │
                    │ Ask: Adjust format?   │
                    └───────────────────────┘
                                │
                                ▼
                    ┌───────────────────────┐
                    │ Generate final doc    │
                    └───────────────────────┘
                                │
                                ▼
                    ┌───────────────────────┐
                    │    Deliver document   │
                    └───────────────────────┘

Phase 1: Scoping Questions

MANDATORY: Ask these BEFORE any exploration.

Use the AskUserQuestion tool to understand:

  1. Usage type (REQUIRED): "What specific usage do you want to explore?"
    • Examples: "database reading layer", "REST API client", "authentication flow", "file I/O patterns"
    • This MUST be specified - do not proceed without it
  2. Extraction goal: "What are you planning to extract or create?"
    • Options: Standalone library, Internal module, API wrapper, Understanding only (no extraction)
  3. Scope boundaries: "Which parts of the codebase are relevant?"
    • Options: Specific directories, Specific file types, Everything, Not sure (I'll explore)
  4. Depth: "How detailed should the inventory be?"
    • Options: High-level patterns only, Detailed with all call sites, Exhaustive with parameters/conditions

Phase 2: Initial Exploration

After scoping, perform initial pass:

  1. Find relevant files using Glob patterns based on scope
  2. Identify key entry points - main files, exports, public APIs
  3. Map top-level structure - directories, modules, packages

CHECKPOINT 1: Present initial findings to user

## Initial Scan Results

**Files found:** N files matching criteria
**Key entry points:** [list]
**Main directories:** [list]

**Potential focus areas:**
1. [Area A] - appears to handle X
2. [Area B] - appears to handle Y
3. [Area C] - appears to handle Z

**Which areas should I focus on?** (can select multiple or suggest others)

Wait for user response before continuing.

Phase 3: Deep Exploration

For each selected area, answer the three core questions:

3.1 What Is Used

Inventory everything the code interacts with for the specified usage type:

  • Classes, structs, functions accessed
  • External libraries or APIs called
  • Resources (files, connections, handles)
  • Data structures and their members
// Example inventory for "file I/O layer"
// Classes: FileReader, BufferedStream, PathResolver
// Functions: open(), read(), seek(), close()
// Types: std::ifstream, std::filesystem::path

3.2 How It Is Used

Document the patterns and conditions:

  • Function signatures and parameter patterns
  • Return value handling (error codes, exceptions, optionals)
  • Conditional logic (when is X called vs Y?)
  • Resource lifecycle (RAII patterns, manual management)
  • Configuration and parameterization
// Example: "How is connection pooling used?"
// - Pool initialized with max_connections from config
// - get_connection() blocks if pool exhausted
// - Connections auto-returned via RAII wrapper
// - Timeout triggers reconnect logic

3.3 Where To Use It

Map call sites and triggering contexts:

  • Which functions/methods initiate the usage?
  • What's the call hierarchy? (entry point → ... → actual usage)
  • What conditions trigger each pattern?
  • Lifecycle timing (initialization, request handling, shutdown)
// Example call hierarchy for "data fetching"
// main()
//   → Application::run()
//     → RequestHandler::process()
//       → DataService::fetch()      // <-- actual usage
//         → Repository::query()

CHECKPOINT 2: Present findings for each area

## Deep Dive: [Area Name]

### What Is Used
| Component | Type | Purpose |
|-----------|------|---------|
| DataReader | class | Reads records from source |
| Config::timeout | member | Connection timeout in ms |
| fetch() | method | Retrieves data with filters |

### How It Is Used
| Pattern | Signature/Example | Conditions |
|---------|-------------------|------------|
| Filtered fetch | fetch(Filter f) | When user specifies criteria |
| Batch read | fetchBatch(size_t n) | For bulk operations |
| Retry on error | 3 retries with backoff | On connection failure |

### Where To Use It
| Call Site | Context | Trigger |
|-----------|---------|---------|
| Processor::run() | Main loop | Each iteration |
| Importer::load() | Startup | Once on init |

**Should I continue to next area, go deeper here, or adjust scope?**

Wait for user response.

Phase 4: Synthesis

After all areas explored:

CHECKPOINT 3: Present draft document structure

## Proposed Document Structure

1. **What Is Used** (Complete inventory)
   - [components to include]

2. **How It Is Used** (Patterns and conditions)
   - [patterns to document]

3. **Where To Use It** (Call sites and contexts)
   - [call hierarchies to include]

4. **Extraction Recommendations**
   - [interface suggestions, dependencies to handle]

**Adjustments needed?** (add sections, remove sections, change focus)

Wait for user approval before generating.

Phase 5: Generate Document

Create the final markdown file with:

Required Sections

1. What Is Used Complete inventory of components for the explored usage type:

ComponentTypePurposeDependencies
ClassNameclassBrief purposelib1, lib2
functionName()functionBrief purposeClassName

2. How It Is Used Patterns, signatures, and conditions:

PatternSignature/ExampleWhen UsedNotes
Pattern namefunc(param1, param2)ConditionGotchas

3. Where To Use It Call sites and triggering contexts:

Entry PointCall ChainTriggerFrequency
main()→ App::run() → Service::fetch()On requestPer-request

4. Extraction Recommendations

  • Suggested interface for extracted library
  • Dependencies to bundle or abstract
  • Breaking changes to anticipate
  • Specific answers to user's original question

Output File Location

Default: planning/exploration-<topic>.md

This integrates with the planning workflow - exploration documents feed into planning-feature or planning-refactor skills.

Subagent Usage

For large codebases, use subagents for parallel exploration:

  • Spawn separate subagents for independent areas
  • Each subagent reports back with What/How/Where for its area
  • Main agent synthesizes findings

Example: "Explore database layer" might spawn:

  • Subagent 1: Read operations
  • Subagent 2: Write operations
  • Subagent 3: Connection management
Main Agent
    │
    ├── Subagent: "Explore read operations"
    │   └── Returns: What/How/Where for reads
    │
    ├── Subagent: "Explore write operations"
    │   └── Returns: What/How/Where for writes
    │
    └── Subagent: "Explore connection management"
        └── Returns: What/How/Where for connections

Main Agent synthesizes into single document

Red Flags - STOP and Check

  • No usage type specified - User MUST specify what to explore (e.g., "database reading", "logging layer")
  • Exploring without scoping - Go back and ask questions first
  • Long silence - If you've read more than 5 files without user update, pause and report
  • Missing what/how/where - Every finding should answer at least one of the three questions
  • Generating without checkpoint - Always present draft structure before final document

Common Mistakes

MistakeFix
Starting without usage typeAsk: "What specific usage do you want to explore?"
Diving into code without asking scopeAlways run Phase 1 scoping questions first
Listing "what" without "how" or "where"Every component needs usage patterns and call sites
Producing final doc without checkpointsStop at each checkpoint, wait for user
Prose-heavy outputUse tables, lists, diagrams - scannable format
Missing call hierarchiesTrace from entry point to actual usage

Rationalizations to Reject

ExcuseReality
"User seems busy, I'll skip scoping"Scoping saves time. Ask the questions.
"Usage type is obvious from context"Confirm anyway. "Database" could mean read/write/schema/migrations.
"I found what's used, that's enough"Without how/where, user can't extract safely. Complete all three.
"Checkpoints slow things down"Checkpoints prevent wasted work. Do them.
"I'll figure out call sites later"Call sites ARE the extraction boundary. Find them now.
"The code is simple, no doc needed"User is unfamiliar with it. Document everything found.

Integration with Other Skills

After ExplorationUse This Skill
Extract as new libraryplanning-feature
Refactor existing codeplanning-refactor
Just needed understandingDone - no further action

The exploration document (planning/exploration-<topic>.md) serves as input to planning skills.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.