Explore

From swissarmyhammer/swissarmyhammer · View interactive version

Explore is an AI agent skill from the GitHub repository swissarmyhammer/swissarmyhammer. Understand how unfamiliar code works before planning or changing it — its structure, behavior, data flow, and the blast radius of a change. Use when the user says "explore", "investigate", "how does X work", "why does X happen", "where is X handled", "what calls X", "what would it take to change X",

How to use this skill

Skill file

Explore

Understand code well enough to explain how it works and what a change would touch.

$ARGUMENTS

Done Means

Exploration is complete when you can explain:

1. HOW IT WORKS    — what calls what, what data flows where
2. WHERE IT LIVES  — specific files and symbols
3. WHAT IT TOUCHES — blast radius: what a change would affect

Can't state all three? Not done. Guessing at any? Back to the tool — don't fill the gap with assumptions.

Process

Orient — check layers

{"op": "get status"}

Note which layers are active. Live LSP ops (get definition, get hover, search workspace_symbol) work immediately — don't wait for indexing. If LSP unavailable, results come from tree-sitter. Check lsp status to see per-language coverage.

If ARCHITECTURE.md exists at the project root, read it now (per the Architecture Awareness guidance) — it gives the system map before tracing individual symbols.

Survey — find the territory

Broad first. Use domain keywords:

{"op": "search symbol", "query": "<domain keyword>", "max_results": 15}

If the index is building and search symbol is sparse, use the live alternative:

{"op": "search workspace_symbol", "query": "<domain keyword>"}
{"op": "list symbols", "file_path": "<key file>"}

Looking for: the nouns and verbs of the problem — structs, traits, functions that participate.

Trace — follow execution

{"op": "get symbol", "query": "<specific symbol>"}

Jump to definitions and types without reading whole files:

{"op": "get definition", "file_path": "<file>", "line": <line>, "character": <col>}
{"op": "get hover", "file_path": "<file>", "line": <line>, "character": <col>}

Call relationships both directions:

{"op": "get callgraph", "symbol": "<symbol>", "direction": "both", "max_depth": 2}
{"op": "get inbound_calls", "file_path": "<file>", "line": <line>, "character": <col>}

All usages:

{"op": "get references", "file_path": "<file>", "line": <line>, "character": <col>}

Looking for: the path data takes through the system. get inbound_calls is live LSP precision for "who calls this"; get callgraph uses indexed edges for broader traversal.

Scope — measure the blast radius

{"op": "get blastradius", "file_path": "<target>", "max_hops": 3}

Supplement with get references — blast radius follows call edges, but references also catch type usage, field access, and trait impls.

Looking for: how far a change propagates. If the radius surprises you, you don't understand the code yet — back to step 3.

Check tests

Tests are the clearest executable spec — they confirm understanding and show project patterns.

Also use Glob/Grep for test files near the code:

Looking for: intended behavior, the project's test patterns, behavior with no coverage.

Conclude — explain

Exit gate. State concretely:

HOW IT WORKS: <mechanism in plain terms — what calls what, what flows where>
KEY CODE:     <files and symbols — paths>
BLAST RADIUS: <what a change touches, or "n/a — investigation only">

Then point at the next step — but don't take it. Exploration produces understanding; acting is separate:

Layered Resolution

code-context is primary. Indexed ops (tree-sitter symbols, callgraphs, blast radius) plus live LSP ops (definitions, hover, references, inbound calls, workspace symbol search). Live ops work before the index is fully built.

Results include source_layer:

Tree-sitter-only for a language that should have LSP? Suggest /lsp.

Use raw Read/Grep/Glob only for:

Don't start by reading files top to bottom. Start with search symbol (or search workspace_symbol while indexing) and get callgraph; use get definition/get hover to inspect specifics.

When to Recurse

If blast radius reveals surprises or the callgraph leads to new territory, loop back to step 2 with new keywords. Each loop should narrow focus, not widen it.

Examples

Understanding a feature: User says "explore how the kanban watcher decides which files to re-index".

  1. Orient with get status — note active layers.
  2. Survey: search symbol "watcher", search symbol "invalidate" → KanbanWatcher::on_event, invalidate_file.
  3. Trace: get symbol "KanbanWatcher::on_event", then get callgraph "invalidate_file" inbound, depth 2.
  4. Scope: get blastradius "src/watcher.rs" max_hops 3 → indexer + MCP layer only.
  5. Tests: grep code "on_event" in test → smoke test covers creation; nothing covers deletion.
  6. Conclude:

```

HOW IT WORKS: on_event receives a FileEvent, matches the EventKind, and calls

invalidate_file for created/modified files; the indexer picks up

invalidated paths on its next pass.

KEY CODE: src/watcher.rs (KanbanWatcher::on_event, invalidate_file)

BLAST RADIUS: indexer + MCP layer only. Deletion (EventKind::Remove) is not

handled — invalidate_file is never called for deleted files.

```

Exploration complete. Deletion gap → /tdd or /task.

Exploration reveals work too large: /explore what it would take to add SSO. Orient, survey auth symbols, trace login flow. Blast radius on src/auth/login.rs shows 40+ call sites. Stop — escalate to /plan rather than force a conclusion.

Constraints

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.