osgrep
When to Use
Use this to find code by concept or behavior (e.g., "where is auth validated", "how are plugins loaded"). Note: This tool prioritizes finding the right files and locations in the code. Snippets are truncated (max 16 lines) and are often just previews.
Example:
osgrep "how are plugins loaded"
osgrep "how are plugins loaded" packages/transformers.js/src
Strategy for Different Query Types
For Architectural/System-Level Questions (auth, LSP integration, file watching)
- Search Broadly First: Use a conceptual query to map the landscape.
osgrep "authentication authorization checks"
- Survey the Results: Look for patterns across multiple files:
- Are checks in middleware? Decorators? Multiple services?
- Do file paths suggest different layers (gateway, handlers, utils)?
- Read Strategically: Pick 2-4 files that represent different aspects:
- Read the main entry point
- Read representative middleware/util files
- Follow imports if architecture is unclear
- Refine with Specific Searches: If one aspect is unclear:
osgrep "session validation logic"osgrep "API authentication middleware"
For Targeted Implementation Details (specific function, algorithm)
- Search Specifically: Ask about the precise logic.
osgrep "logic for merging user and default configuration"
- Evaluate the Semantic Match:
- Does the snippet look relevant?
- Crucial: If it ends in
...or cuts off mid-logic, read the file.
- One Search, One Read: Use osgrep to pinpoint the best file, then read it fully.
Output Format
Returns: path/to/file:line [Tags] Code Snippet
[Definition]: Semantic search detected a class/function here. High relevance....: Truncation Marker. Snippet is incomplete—useread_filefor full context.
Tips
- Trust the Semantics: You don't need exact names.
osgrep "how does the server start"works better than guessingosgrep "server.init". - Watch for Distributed Patterns: If results span 5+ files in different directories, the feature is likely architectural—survey before diving deep.
- Scope When Possible: Use path constraints to focus:
osgrep "auth" src/server/ - Don't Over-Rely on Snippets: For architectural questions, snippets are signposts, not answers. Read the key files.
- "Still Indexing...": If you see this, please stop, alert the user that the index is ongoing and ask them if they wish to proceed. Results will be partial until the index is complete.
More from pr-pm/prpm
human-writing
Write content that sounds natural, conversational, and authentically human - avoiding AI-generated patterns, corporate speak, and generic phrasing
168creating-opencode-agents
Use when creating OpenCode agents - provides markdown format with YAML frontmatter, mode/tools/permission configuration, and best practices for specialized AI assistants
25creating-agents-md
Use when creating agents.md files - provides plain markdown format with NO frontmatter, free-form structure, and project context guidelines for AI coding assistants
20self-improving
Use when starting infrastructure, testing, deployment, or framework-specific tasks - automatically searches PRPM registry for relevant expertise packages and suggests installation to enhance capabilities for the current task
19creating-opencode-plugins
Use when creating OpenCode plugins that hook into command, file, LSP, message, permission, server, session, todo, tool, or TUI events - provides plugin structure, event API specifications, and implementation patterns for JavaScript/TypeScript event-driven modules
18typescript-type-safety
Use when encountering TypeScript any types, type errors, or lax type checking - eliminates type holes and enforces strict type safety through proper interfaces, type guards, and module augmentation
16