Agent skill
osgrep
Semantic code search using natural language queries. Use when users ask "where is X implemented", "how does Y work", "find the logic for Z", or need to locate code by concept rather than exact text. Returns file paths with line numbers and code snippets.
Install this agent skill to your Project
npx add-skill https://github.com/iamhenry/ai-project-starter-kit/tree/main/.opencode/skills/osgrep
SKILL.md
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.
Hybrid Search Strategy (Semantic + Grep)
Combining semantic search with grep is 31% more effective than either alone.
Decision Heuristic:
- osgrep: Exploration. You don't know exact names/patterns.
- rg (ripgrep): Precision. You know the symbol/pattern to find.
Two-Stage Workflow:
-
Discover with osgrep: Find the right files conceptually
osgrep "authentication validation logic"- → Returns
src/auth/middleware.ts:45,src/utils/jwt.ts:12
-
Pinpoint with ripgrep: Find exact matches in those files
rg "verifyToken|validateJWT" src/auth/ src/utils/- → Returns exact line numbers with context
Example: Finding rate limiting implementation
# Step 1: Conceptual discovery
osgrep "rate limiting throttling"
# → src/middleware/rateLimit.ts:23, src/api/limiter.ts:8
# Step 2: Exact symbols/patterns
rg "RateLimiter|throttle" src/middleware/ src/api/
Why this works: Semantic search narrows to the right files. Grep pinpoints exact locations within those files. Together = faster, more accurate results.
Output Format
Returns: path/to/file:line [Tags] Code Snippet
Example:
ORCHESTRATION src/auth/handler.ts:45
Defines: handleAuth | Calls: validate, checkRole, respond | Score: .94
export async function handleAuth(req: Request) {
const token = req.headers.get("Authorization");
...
Tags:
ORCHESTRATION: Contains logic, coordinates other code. Prioritize these.DEFINITION: Types, interfaces, classes.
Metadata:
Defines: What this code definesCalls: What this code calls (helps trace flow)Score: Relevance (1 = best match)
Markers:
...: Truncation marker. Snippet is incomplete—useReadfor full context.
Other Commands
# Trace call graph (who calls X, what X calls)
osgrep trace handleAuth
# Skeleton of a huge file (find which ranges to read)
osgrep skeleton src/giant-2000-line-file.ts
# Just file paths when you only need locations
osgrep "authentication" --compact
Tips
- More Words = Better: "auth" is vague. "where does the server validate JWT tokens" is specific.
- Prioritize ORCH Results: ORCHESTRATION results contain the logic—start there.
- 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/ - Use Line Ranges: Don't read entire files. Use the line ranges osgrep gives you.
- Rephrase If Needed: If results seem off, rephrase your query like you'd ask a teammate.
If Index is Building
If you see "Indexing", "Building", or "Syncing": STOP. Alert the user that the index is building. Ask if they want to wait or proceed with partial results.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
verification-gate
Reusable verification gate for completed work before commit or merge. Use when implementation is done and Claude must prove the task works, verify the main user flow, choose between browser-flow, browser-static, or non-browser validation, and return a PASS/FAIL/BLOCKED verdict with evidence. When browser verification is needed, rely on the agent-browser skill for browser actions, screenshots, and recordings.
napkin
Maintain a per-repo napkin file that tracks mistakes, corrections, and what works. Activates EVERY session, unconditionally. Read the napkin before doing anything. Write to it continuously as you work — not just at session boundaries. Log your own mistakes, not just user corrections. The napkin lives in the repo at `.opencode/napkin.md`.
dogfood
Systematically explore and test a web application to find bugs, UX issues, and other problems. Use when asked to "dogfood", "QA", "exploratory test", "find issues", "bug hunt", "test this app/site/platform", or review the quality of a web application. Produces a structured report with full reproduction evidence -- step-by-step screenshots, repro videos, and detailed repro steps for every issue -- so findings can be handed directly to the responsible teams.
tmux
Manage concurrent background processes using tmux. Use when spawning dev servers, running long-running tasks, monitoring multiple processes, or capturing output from background commands without blocking the main session.
viral-research
Viral content research and DNA extraction for Instagram Reels. Use this skill whenever you need to research what's performing in a niche on Instagram, find viral faceless Reels, download and analyze them frame-by-frame, identify patterns, and produce a structured research brief. Trigger whenever the user mentions viral content research, Instagram research, Reel analysis, content DNA, swipe file building, niche research, competitor analysis for social content, or wants to understand why certain content performs. Also trigger when the user wants to find content formats to adapt, study what's working in a niche, or build a research-backed content strategy. This skill is research-only — it does not generate or publish content.
import-github-dirs
Import specific directories from external GitHub repos without cloning. Uses tarball extraction to pull only what you need. TRIGGER when user wants to copy files/folders from another repo.
Didn't find tool you were looking for?