How to Let Claude Code Explore Without Losing Control
Why your 50-line slash commands keep breaking (and what to do instead).
This is post 3 of 4 in my Claude Code series. Catch up on The Mental Model and Skills vs Slash Commands if you missed them.
My first instinct with Claude Code was to script everything. Every task got a slash command. Every command tried to handle every edge case. Fifty lines of instructions. Nested conditionals. Error handling for scenarios that would never happen. It was beautiful. It was comprehensive. It was also completely fragile and broke constantly.
I was basically writing enterprise Java in prompt form. Nobody should have to live like that.
Then I discovered agents. Now my slash commands are thin — they set up context and spawn an agent to do the actual work. The agent figures out the details. My blood pressure dropped significantly.
(Quick terminology note: Claude Code calls these “subagents” because they run as subprocesses of your main session. Everyone just says “agents.” I’ll use “agent” throughout because life is short.)
The mistake: treating Claude like a very slow bash script
I had a /research-topic command that tried to:
Search the codebase for relevant files
Read documentation
Check external sources
Synthesize findings
Format the output in exactly the right way
Handle seventeen different edge cases I imagined at 2 AM
It was a mess. Too many conditionals. Too many assumptions about what files exist and where. It broke every time the codebase changed, which was constantly, because that’s what codebases do.
The fundamental problem: I was trying to script exploration. But exploration is inherently unpredictable. You don’t know what you’ll find until you look. That’s literally the definition of exploration. Trying to pre-script it is like writing detailed driving directions before knowing where you’re going.
“Turn left at the third building. Unless there isn’t a third building. Then turn right. Unless you’re already facing north. Check the position of the sun...”
This is madness. Don’t do this to yourself.
What agents actually do (and why it’s better)
Agents have their own context. They’re decoupled from your main conversation. They go off, do their thing, and come back with answers.
You describe the goal. The agent figures out the path.
“How does authentication work in this codebase?” I have no idea which files to look at. I could spend ten minutes finding them myself. Or I could let Claude spawn an Explore agent — one that’s already built into Claude Code — and get an answer in two minutes.
Here’s what that actually looks like:
Me: "How does authentication work in this codebase?"
Claude spawns Explore agent → searches → reads 8 files → returns:
"Authentication uses JWT tokens stored in httpOnly cookies.
The flow: login request → /api/auth/login → validates credentials
→ creates token → sets cookie. Token validation happens in
middleware at src/middleware/auth.ts:42. Refresh logic is in
src/lib/auth/refresh.ts."
The agent checked 8 files. Maybe it checked 15. I don’t know, and I don’t care. I care about the answer.
This is fundamentally different from scripting. You’re not specifying steps. You’re specifying outcomes. It’s like hiring a contractor versus writing assembly instructions. One of these is dramatically less exhausting.
What’s inside an agent (dissecting Explore)
Claude Code ships with a built-in Explore agent. Let’s look under the hood:
AspectWhat Explore UsesModelHaiku (fast, cheap)ToolsGlob, Grep, Read, limited Bash (ls, git log, etc.)Can modify files?No — strictly read-onlyContextIsolated from your main conversation
The Explore agent has three thoroughness levels:
Quick — targeted lookup, minimal file traversal. Use when you know roughly what you’re looking for.
Medium — searches multiple related locations. The default for most queries.
Very thorough — comprehensive search across unusual places and naming conventions. Slower, but finds things hidden in unexpected corners.
Here’s the part nobody emphasizes enough: the agent runs in its own context window. It can read 20 files, search through thousands of lines, and when it’s done, you get a summary. Your main conversation stays clean. Your token budget stays intact.
This is huge. Before I understood this, I was reading files directly in my main session and watching my context fill up with code I’d already reviewed. Now the agent does the heavy reading. I get the conclusions.
When to use agents (a guide for control freaks learning to let go)
Use agents when the task requires exploration:
“Find all API endpoints and document them”
“Investigate why this test is flaky”
“Research how other projects handle rate limiting”
“What files would I need to change to add feature X?”
Use agents when you’d be guessing at the steps:
If you find yourself writing a slash command with lots of “if this exists, then...” logic, stop. Step away from the keyboard. That’s agent territory. You’re trying to pre-solve a problem you don’t understand yet.
Use agents for heavy reading:
Agents have their own context window. They can read 20 files without bloating your main session. When they’re done, they return a summary. Your conversation stays clean.
Creating your own agents
You don’t have to use the built-in agents. You can create your own.
An agent is just a skill (markdown file in .claude/commands/) that spawns a subagent using the Task tool. Here’s a simple one:
# /research-topic
Research this topic in the codebase: $ARGUMENTS
Use the Task tool with subagent_type="Explore" to:
- Search for relevant files and patterns
- Read key implementation files
- Understand how it currently works
Return a structured summary:
- Key files involved (with line numbers)
- How the feature currently works
- Any gaps, issues, or technical debt found
That’s it. No fifty lines of conditionals. No edge case handling. The Explore agent figures out what to search, what to read, how deep to go. You describe the outcome. The agent handles the process.
The pattern: thin skill that spawns an agent. The skill is just a trigger with context. The agent does the thinking.
Agents vs slash commands (the actual difference)
Slash commands / Skills:
Fixed steps
Predictable output
You know exactly what will happen
Good for: formatting, templating, repetitive tasks with known structure
Agents:
Dynamic exploration
Variable output
Figures out the path autonomously
Good for: research, investigation, multi-file analysis, anything where you don’t know what you’ll find
Here’s the mental model: slash commands are for when you know the answer and just need to execute it. Agents are for when you don’t know the answer and need someone to go find it.
If you’re using slash commands for exploration, you’re making your life unnecessarily difficult. I did this for months. Learn from my suffering.
The real unlock (it’s embarrassingly simple)
Once I stopped trying to script everything, my workflow got simpler. Not more complex. Simpler.
Skills handle the predictable stuff: commit messages, content formatting, code reviews with a checklist.
Agents handle the unpredictable stuff: understanding codebases, investigating issues, researching approaches.
I stopped fighting the tool. I let agents explore. I let skills execute. Everything got easier. I felt slightly foolish for not figuring this out sooner, but that’s the tax you pay for learning things the hard way.
Next up: MCP servers — the things that let Claude actually interact with the real world instead of just imagining what websites might contain.

