grepai-search-advanced
Skill22 starsChanged 10 months agoMITView on GitHub
Advanced search options in GrepAI. Use this skill for JSON output, compact mode, and AI agent integration.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- ElyzeSolutions/skillsword for word, first seen Aug 6, 2026
Other versions1 project uses a version of this.
Word for word · 1
- ElyzeSolutions/skills★ 1100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository26 other files it gives its agents.
- grepai-languagesSkill
- grepai-troubleshootingSkill
- grepai-workspacesSkill
- grepai-config-referenceSkill
- grepai-ignore-patternsSkill
- grepai-initSkill
- grepai-embeddings-lmstudioSkill
- grepai-embeddings-ollamaSkill
- grepai-embeddings-openaiSkill
- grepai-installationSkill
- grepai-ollama-setupSkill
- grepai-quickstartSkill
- grepai-chunkingSkill
- grepai-watch-daemonSkill
- grepai-mcp-claudeSkill
- grepai-mcp-cursorSkill
- grepai-mcp-toolsSkill
- grepai-search-basicsSkill
- grepai-search-boostingSkill
- grepai-search-tipsSkill
- grepai-storage-gobSkill
- grepai-storage-postgresSkill
- grepai-storage-qdrantSkill
- grepai-trace-calleesSkill
- grepai-trace-callersSkill
- grepai-trace-graphSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 5 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 88
No content (just file locations)
- Distinctive: line 132
Use TOON: when integrating with AI agents that support it
- Distinctive: line 161
Use compact mode to minimize tokens:
- Distinctive: line 351
Use full JSON for scripts: When you need content
- Distinctive: line 353
Limit results appropriately: Don't fetch more than needed
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 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.
Files
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
| Option | Description |
--limit N | Number of results (default: 10) |
--json / -j | JSON output format |
--toon / -t | TOON output format (~50% fewer tokens than JSON) |
--compact / -c | Compact output (no content, works with --json or --toon) |
Note:
--jsonand--toonare mutually exclusive.
JSON Output
Standard JSON
grepai search "authentication" --jsonOutput:
{
"query": "authentication",
"results": [
{
"score": 0.89,
"file": "src/auth/middleware.go",
"start_line": 15,
"end_line": 45,
"content": "func AuthMiddleware() gin.HandlerFunc {\n return func(c *gin.Context) {\n token := c.GetHeader(\"Authorization\")\n if token == \"\" {\n c.AbortWithStatus(401)\n return\n }\n claims, err := ValidateToken(token)\n ...\n }\n}"
},
{
"score": 0.82,
"file": "src/auth/jwt.go",
"start_line": 23,
"end_line": 55,
"content": "func ValidateToken(tokenString string) (*Claims, error) {\n ..."
}
],
"total": 2
}Compact JSON (AI Optimized)
grepai search "authentication" --json --compactOutput:
{
"q": "authentication",
"r": [
{
"s": 0.89,
"f": "src/auth/middleware.go",
"l": "15-45"
},
{
"s": 0.82,
"f": "src/auth/jwt.go",
"l": "23-55"
}
],
"t": 2
}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
grepai search "authentication" --toonOutput:
[2]{content,end_line,file_path,score,start_line}:
"func AuthMiddleware()...",45,src/auth/middleware.go,0.89,15
"func ValidateToken()...",55,src/auth/jwt.go,0.82,23Compact TOON (Best for AI)
grepai search "authentication" --toon --compactOutput:
[2]{end_line,file_path,score,start_line}:
45,src/auth/middleware.go,0.89,15
55,src/auth/jwt.go,0.82,23TOON vs JSON Comparison
| Format | Tokens (5 results) | Best For |
| JSON | ~1,500 | Scripts, parsing |
| JSON compact | ~300 | AI agents |
| TOON | ~250 | AI agents |
| TOON compact | ~150 | Token-constrained AI |
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
| Full Key | Compact Key | Description |
query | q | Search query |
results | r | Results array |
score | s | Similarity score |
file | f | File path |
start_line/end_line | l | Line range ("15-45") |
total | t | Total results |
Combining Options
# 5 results in compact JSON
grepai search "error handling" --limit 5 --json --compact
# 20 results in full JSON
grepai search "database" --limit 20 --jsonAI Agent Integration
For Claude/GPT Prompts
Use compact mode to minimize tokens:
# Agent asks for context
grepai search "payment processing" --json --compact --limit 5Then provide results to the AI with file read tool for details.
Workflow Example
- Search for relevant code:
grepai search "authentication middleware" --json --compact --limit 3- Get response:
{
"q": "authentication middleware",
"r": [
{"s": 0.92, "f": "src/auth/middleware.go", "l": "15-45"},
{"s": 0.85, "f": "src/auth/jwt.go", "l": "23-55"},
{"s": 0.78, "f": "src/handlers/auth.go", "l": "10-40"}
],
"t": 3
}- Read specific files:
AI reads
src/auth/middleware.go:15-45for full context.
Scripting with JSON
Bash + jq
# Get just file paths
grepai search "config" --json | jq -r '.results[].file'
# Filter by score
grepai search "config" --json | jq '.results[] | select(.score > 0.8)'
# Count results
grepai search "config" --json | jq '.total'Python
import subprocess
import json
result = subprocess.run(
['grepai', 'search', 'authentication', '--json'],
capture_output=True,
text=True
)
data = json.loads(result.stdout)
for r in data['results']:
print(f"{r['score']:.2f} | {r['file']}:{r['start_line']}")Node.js
const { execSync } = require('child_process');
const output = execSync('grepai search "authentication" --json');
const data = JSON.parse(output);
data.results.forEach(r => {
console.log(`${r.score.toFixed(2)} | ${r.file}:${r.start_line}`);
});MCP Integration
GrepAI provides MCP tools with format selection (v0.26.0+):
# Start MCP server
grepai mcp-serveMCP tools support JSON (default) or TOON format:
| MCP Tool | Parameters |
grepai_search | query, limit, compact, format |
grepai_trace_callers | symbol, compact, format |
grepai_trace_callees | symbol, compact, format |
grepai_trace_graph | symbol, depth, format |
grepai_index_status | format |
Format Parameter
{
"name": "grepai_search",
"arguments": {
"query": "authentication",
"format": "toon",
"compact": true
}
}Valid values: "json" (default) or "toon"
Token Optimization
Token Comparison
For a typical search with 5 results:
| Format | Approximate Tokens |
| Human-readable | ~2,000 |
| JSON full | ~1,500 |
| JSON compact | ~300 |
When to Use Each Format
| Format | Use Case |
| Human-readable | Manual inspection |
| JSON full | Scripts needing content |
| JSON compact | AI agents, token-limited contexts |
Piping Results
To File
grepai search "authentication" --json > results.jsonTo Another Tool
# Open results in VS Code
grepai search "config" --json | jq -r '.results[0].file' | xargs code
# Copy first result path to clipboard (macOS)
grepai search "config" --json | jq -r '.results[0].file' | pbcopyBatch Searches
Run multiple searches:
#!/bin/bash
queries=("authentication" "database" "logging" "error handling")
for q in "${queries[@]}"; do
echo "=== $q ==="
grepai search "$q" --json --compact --limit 3
echo
doneError Handling
JSON Error Response
When search fails:
{
"error": "Index not found. Run 'grepai watch' first.",
"code": "INDEX_NOT_FOUND"
}Checking for Errors in Scripts
result=$(grepai search "query" --json)
if echo "$result" | jq -e '.error' > /dev/null 2>&1; then
echo "Error: $(echo "$result" | jq -r '.error')"
exit 1
fiBest 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):
{
"q": "authentication middleware",
"r": [
{"s": 0.92, "f": "src/auth/middleware.go", "l": "15-45"},
{"s": 0.85, "f": "src/auth/jwt.go", "l": "23-55"},
{"s": 0.78, "f": "src/handlers/auth.go", "l": "10-40"}
],
"t": 3
}Token estimate: ~80 tokens (vs ~800 for full content)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
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.

