# Code Search

> Fast codebase searches using grep/glob. Triggers on "find", "search", "where is", "grep for".

- Skill: `dtsong/code-search` (Agent Skill)
- Install (CLI): `npx skillmds@latest add dtsong/code-search`
- Raw SKILL.md: https://api.skillmd.com/api/skills/dtsong/code-search/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: dtsong (https://skillmd.com/u/dtsong)
- Updated: 2026-09-10
- Page: https://skillmd.com/skills/dtsong/code-search

---


# Code Search

## Scope Constraints

- Read-only file search operations using Grep and Glob
- Does not modify, create, or delete files
- Does not execute found code or run tests

## Input Sanitization

- Search patterns: reject null bytes, validate regex syntax before passing to Grep
- File glob patterns: reject `..` traversal, null bytes, and shell metacharacters

Use Grep for content searches, Glob for file pattern matching.

## Output Format

```
Found 5 matches for "handleAuth" in 3 files:

  src/lib/auth.ts:23      export function handleAuth(req: Request) {
  src/lib/auth.ts:45      return handleAuth(nextReq);
  src/middleware.ts:12     import { handleAuth } from "@/lib/auth";
```

## Gotchas

- Using `grep` or `rg` via Bash instead of the Grep tool — the Grep tool has optimized permissions and better output formatting
- Forgetting `--glob` or `--type` filtering returns matches from `node_modules`, `.git`, and vendored code — always scope searches
- Glob patterns are for file names only, not content — use Grep for content, Glob for finding files by path pattern
- `Grep` uses ripgrep regex, not grep regex — literal braces need escaping (`interface\{\}` not `interface{}`)
- Reading an entire large file when you only need a section — use `offset` and `limit` parameters on Read

## Examples
- "find all usages of X" → Grep for X
- "where is the config file" → Glob for config patterns
- "search for error handling" → Grep for try/catch, .catch, error patterns

