search_code
Search across all GitHub repositories to find code examples, usage patterns, or library imports using advanced queries with regex, boolean operators, and qualifiers.
Instructions
Search for code across all of GitHub (200M+ repos), or narrowed to one repo/org/path. Supports regex (/pattern/), tree-sitter symbol search (symbol:name), boolean operators (AND/OR/NOT), exact phrases, and code-search qualifiers: repo:, org:, user:, path:, language:, content:, symbol:, is:archived, is:fork, is:vendored, is:generated, size:, in:file, in:path, filename:, extension:. Convenience params repo, language, path are appended as qualifiers automatically. Use this to find real-world usage patterns (how do projects actually import and call library X?), discover who uses a library (search for its import/crate name across GitHub), or locate example code for a framework you're evaluating. NOT for finding where a symbol is defined (use find_symbol). IMPORTANT: GitHub's code-search endpoint does NOT support repository-level qualifiers like stars:, pushed:, forks:, created:, topic:, license:, archived: — GitHub silently matches them as literal file content, giving wrong results with no error. For popularity-filtered discovery, use search_repos instead.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | GitHub code search query. Supports regex (/pattern/), symbol:name, boolean (AND/OR/NOT), exact phrases. Code-search qualifiers: repo:, org:, user:, path:, language:, content:, symbol:, is:archived, is:fork, is:vendored, is:generated, size:, in:, filename:, extension:. Repository-level filters (stars:, pushed:, forks:, created:, topic:, license:, archived:) are NOT supported by code search — use `search_repos` for those. | |
| repo | No | Scope to one repository (owner/repo). | |
| language | No | Filter by programming language. | |
| path | No | Filter by file path pattern (e.g. src/). | |
| page | No | Page number for paginated results. | |
| per_page | No | Results per page (max 100). | |
| context_lines | No | Max lines of code context per match (default 10). |