Comprehensive CLI reference and search strategies for osgrep semantic code search. Use for detailed CLI options, index management commands, search strategy guidance (architectural vs targeted queries), and troubleshooting. Complements the osgrep plugin which handles daemon lifecycle.
ALWAYS prefer osgrep over grep/rg for code exploration. It finds concepts, not just strings.
osgrep is a natural-language semantic code search tool that finds code by concept rather than keyword matching. Unlike grep which matches literal strings, osgrep understands code semantics using local AI embeddings.
Version 0.5.16 (Dec 2025) highlights:
skeleton command: Compress files to function/class signatures (~85% token reduction)trace command: Show who calls/what calls for any symbol (call graph)symbols command: List all indexed symbols with definitionsdoctor command: Health/integrity verificationlist command: Display all indexed repositories.osgrep/ directories (no longer global ~/.osgrep/data)--reset flag for clean re-indexingWhen to use osgrep:
When to use traditional tools:
Grep)Glob)Read)IMPORTANT: You must cd into the project directory before running osgrep commands.
osgrep uses per-project .osgrep/ indexes, so it only searches the repo you're currently in.
cd /path/to/project # REQUIRED: cd into the project first
osgrep "your query" # Now search works
osgrep "your semantic query"
osgrep search "your query" path/to/scope # Scope to subdirectory
osgrep skeleton src/file.py # Compress file to signatures
osgrep trace functionName # Show call graph
osgrep symbols # List all symbols
Examples:
osgrep "user registration flow"
osgrep "webhook signature validation"
osgrep "database transaction handling"
osgrep "how are plugins loaded" packages/src
Returns results in this format:
IMPLEMENTATION path/to/file:line
Score: 0.95
Preamble:
[code snippet or content preview]
...
Read for full contextUse for: auth, integrations, file watching, cross-cutting concerns
Search broadly first to map the landscape:
osgrep "authentication authorization checks"
Survey the results - look for patterns across multiple files:
Read strategically - pick 2-4 files that represent different aspects:
Refine with specific searches if one aspect is unclear:
osgrep "session validation logic"
osgrep "API authentication middleware"
Use for: specific function, algorithm, single feature
Search specifically about the precise logic:
osgrep "logic for merging user and default configuration"
Evaluate the semantic match:
... or cuts off mid-logic, read the fileOne search, one read: Use osgrep to pinpoint the best file, then read it fully.
Control result count:
osgrep "validation logic" -m 20 # Max 20 results total (default: 10)
osgrep "validation logic" --per-file 3 # Up to 3 matches per file (default: 1)
Output formats:
osgrep "API endpoints" --compact # File paths only
osgrep "API endpoints" --content # Full chunk content (not just snippets)
osgrep "API endpoints" --scores # Show relevance scores
osgrep "API endpoints" --plain # Disable ANSI colors
Sync before search:
osgrep "validation logic" -s # Sync files to index before searching
osgrep "validation logic" -d # Dry run (show what would sync)
osgrep index # Incremental update
osgrep index -r # Full re-index from scratch (--reset)
osgrep index -p /path/to/repo # Index a specific directory
osgrep index -d # Preview what would be indexed (--dry-run)
Skeleton - Compress files to signatures:
osgrep skeleton src/server.py # Show function/class signatures only
osgrep skeleton src/server.py --no-summary # Omit call/complexity summaries
osgrep skeleton "auth logic" -l 5 # Query mode: skeleton of top 5 matching files
Output shows: function signatures with # → calls | C:N | ORCH summaries inside bodies.
Trace - Show call graph:
osgrep trace handleRequest # Who calls this? What does it call?
Symbols - List all indexed symbols:
osgrep symbols # All symbols (default limit: 20)
osgrep symbols "Request" # Filter by pattern
osgrep symbols -p src/api/ -l 50 # Filter by path, increase limit
osgrep list # Show all indexed repositories
osgrep doctor # Check health and configuration
osgrep setup # Pre-download models (~150MB)
osgrep serve # Run background daemon (port 4444)
osgrep serve -p 8080 # Custom port (or OSGREP_PORT=8080)
osgrep serve -b # Run in background (--background)
osgrep serve status # Check if daemon is running
osgrep serve stop # Stop daemon
osgrep serve stop --all # Stop all daemons
Serve endpoints:
GET /health - Health checkPOST /search - Search with { query, limit, path, rerank }.osgrep/server.json with port/pidosgrep install-claude-code # Install as Claude Code plugin
osgrep install-opencode # Install for Opencode
Both plugins automatically manage the background server lifecycle during sessions.
# Mental processes (Open Souls / Daimonic)
osgrep "mental processes that orchestrate conversation flow"
osgrep "subprocesses that learn about the user"
osgrep "cognitive steps using structured output"
# React/Next.js
osgrep "where do we fetch data in components?"
osgrep "custom hooks for API calls"
osgrep "protected route implementation"
# Backend
osgrep "request validation middleware"
osgrep "authentication flow"
osgrep "rate limiting logic"
osgrep "payment processing"
osgrep "notification sending"
osgrep "user permission checks"
osgrep "order fulfillment workflow"
osgrep "error handling patterns"
osgrep "logging configuration"
osgrep "database migrations"
osgrep "environment variable usage"
You don't need exact names. Conceptual queries work better:
# Good - conceptual
osgrep "how does the server start"
osgrep "component state management"
# Less effective - too literal
osgrep "server.init"
osgrep "useState"
# Too vague
osgrep "code"
# Clear intent
osgrep "user registration validation logic"
osgrep "how do we handle payment failures?"
osgrep "what happens when a webhook arrives?"
osgrep "where is user input sanitized?"
If results span 5+ files in different directories, the feature is likely architectural—survey before diving deep.
For architectural questions, snippets are signposts, not answers. Read the key files.
.osgrep/ directory (v0.5+).osgrep/ in project root (was ~/.osgrep/data/ in v0.4.x)osgrep setup to pre-download)"Still Indexing..." message:
Slow first search:
osgrep setup to pre-download modelsIndex out of date:
osgrep index to refreshosgrep index --reset for a complete re-indexInstallation issues:
osgrep doctor # Diagnose problems
npm install -g osgrep # Reinstall if needed
No results found:
osgrep index)Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer