Skip to content

CLI Search

The code-search search command lets you search across all indexed repositories.

Terminal window
# Simple text search
code-search search "foo"
# Search for a phrase
code-search search "func main"
# Regex search
code-search search "func\s+\w+\(" --regex
Terminal window
code-search search <query> [flags]

Treat the search query as a regular expression.

Terminal window
# Match function definitions
code-search search "func\s+\w+\(" --regex
# Match version numbers
code-search search "v\d+\.\d+\.\d+" --regex

Filter results to specific repositories (can be used multiple times or comma-separated).

Terminal window
# Single repo
code-search search "foo" --repos myorg/myrepo
# Multiple repos
code-search search "foo" --repos myorg/frontend,myorg/backend
# Or specify multiple times
code-search search "foo" -R myorg/frontend -R myorg/backend

Filter by programming languages (can be specified multiple times).

Terminal window
code-search search "class" --langs python
code-search search "interface" --langs typescript,javascript

Supported languages: go, python, javascript, typescript, java, ruby, rust, c, cpp, csharp, php, swift, kotlin, and more.

Filter by file path patterns (can be specified multiple times).

Terminal window
# By extension
code-search search "import" --files "*.py"
# By directory
code-search search "config" --files "src/**"
# By filename
code-search search "main" --files "main.go,main.ts"

Enable case-sensitive search (default is case-insensitive).

Terminal window
code-search search "foo" --case-sensitive
code-search search "foo" --case-sensitive # Different results

Number of lines to show before and after each match.

Terminal window
code-search search "error" --context 5

Stream results as they arrive for faster time-to-first-result. Useful for interactive searches with large result sets.

Terminal window
# Stream results as they're found
code-search search "TODO" --stream
# Combine with other filters
code-search search "deprecated" --repos myorg/backend --stream

Maximum number of results to return.

Terminal window
code-search search "foo" --limit 50

These options are available on all commands:

OptionDescription
--configPath to config file
--api-urlAPI server URL (default: localhost:8080)
--outputOutput format: text, json, table
Terminal window
# Find function definitions
code-search search "func Create" --lang go
# Find class definitions
code-search search "class User" --lang python
Terminal window
# Find where a package is imported
code-search search 'import "github.com/pkg/errors"' --lang go
code-search search "from flask import" --lang python
Terminal window
# Find hardcoded secrets (be careful!)
code-search search 'password\s*=' --regex
code-search search 'api_key\s*=' --regex
  1. Use filters - Narrow results with --repo, --lang, --file
  2. Limit results - Use --limit for large result sets
  3. Be specific - More specific queries are faster