Claude Code Subagent
Claude Code uses subagents for specialized tasks. grepai provides a ready-to-use exploration subagent that leverages semantic search and call graph tracing.
Why a Subagent?
When Claude Code spawns an “Explore” subagent:
- The subagent operates in an isolated context
- It doesn’t inherit CLAUDE.md instructions
- It uses standard Grep/Glob instead of semantic search
The grepai deep-explore subagent solves this by providing direct access to grepai tools.
Installation
grepai agent-setup --with-subagentThis creates .claude/agents/deep-explore.md in your project.
What It Does
The deep-explore subagent provides:
| Capability | Tool | Description |
|---|---|---|
| Semantic Search | grepai search | Find code by intent, not just text |
| Call Graph | grepai trace | Understand function relationships |
| Standard Tools | Grep, Glob, Read | Available as fallback |
Usage
Claude Code automatically selects the deep-explore agent when:
- Exploring unfamiliar code areas
- Understanding code architecture
- Finding implementations by intent
- Analyzing function relationships
You can also explicitly request it:
“Use the deep-explore agent to understand the authentication flow”
Subagent vs MCP
| Feature | Subagent | MCP |
|---|---|---|
| Setup | --with-subagent flag | Separate MCP config |
| Access | Bash commands | Native tools |
| Context | Isolated | Shared |
| Use case | Exploration tasks | All tasks |
Both approaches complement each other. MCP provides native tool access, while the subagent ensures exploration tasks use grepai.
Manual Setup
If you prefer manual setup, create .claude/agents/deep-explore.md:
---name: deep-exploredescription: Deep codebase exploration using grepai semantic search and call graph tracing.tools: Read, Grep, Glob, Bashmodel: inherit---
## Instructions
You are a specialized code exploration agent with access to grepai.
### Primary Tools
Use `grepai search` for semantic code search:- grepai search "authentication flow"- grepai search "error handling"
Use `grepai trace` for call graph analysis:- grepai trace callers "Login"- grepai trace callees "HandleRequest"- grepai trace graph "ProcessOrder" --depth 3
### Workflow
1. Start with grepai search to find relevant code2. Use grepai trace to understand function relationships3. Use Read to examine files in detail4. Synthesize findings into a clear summaryTroubleshooting
Subagent not appearing
- Verify the file exists:
cat .claude/agents/deep-explore.md - Restart Claude Code after creating the file
- Ensure the YAML frontmatter is valid
grepai commands failing in subagent
- Ensure grepai is in your PATH
- Verify the index is built:
grepai status - Run
grepai watchto build/update the index