GrepAI Advanced Search Options
This skill covers advanced search options including JSON output, compact mode, and integration with AI agents.
When to Use This Skill
- Integrating GrepAI with scripts or tools
- Using GrepAI with AI agents (Claude, GPT)
- Processing search results programmatically
- Reducing token usage in AI contexts
Command-Line Options
Note:
--jsonand--toonare mutually exclusive.
JSON Output
Standard JSON
Output:
Compact JSON (AI Optimized)
Output:
Key differences:
- Abbreviated keys (
svsscore,fvsfile) - No content (just file locations)
- ~80% fewer tokens for AI agents
TOON Output (v0.26.0+)
TOON (Token-Oriented Object Notation) is an even more compact format, optimized for AI agents.
Standard TOON
Output:
Compact TOON (Best for AI)
Output:
TOON vs JSON Comparison
When to Use TOON
- Use TOON when integrating with AI agents that support it
- Use TOON compact for maximum token efficiency (~50% smaller than JSON compact)
- Stick with JSON for traditional scripting (jq, programming languages)
Compact Format Reference
Combining Options
AI Agent Integration
For Claude/GPT Prompts
Use compact mode to minimize tokens:
Then provide results to the AI with file read tool for details.
Workflow Example
- Search for relevant code:
- Get response:
- Read specific files:
AI reads
src/auth/middleware.go:15-45for full context.
Scripting with JSON
Bash + jq
Python
Node.js
MCP Integration
GrepAI provides MCP tools with format selection (v0.26.0+):
MCP tools support JSON (default) or TOON format:
Format Parameter
Valid values: "json" (default) or "toon"
Token Optimization
Token Comparison
For a typical search with 5 results:
When to Use Each Format
Piping Results
To File
To Another Tool
Batch Searches
Run multiple searches:
Error Handling
JSON Error Response
When search fails:
Checking for Errors in Scripts
Best Practices
- Use compact for AI agents: 80% token savings
- Use full JSON for scripts: When you need content
- Use human-readable for debugging: Easier to read
- Limit results appropriately: Don't fetch more than needed
- Check for errors: Parse JSON response properly
Output Format
Advanced search output (JSON compact):
Token estimate: ~80 tokens (vs ~800 for full content)


