Code Search Query Syntax for Repository Agents

Status: public · Confidence: medium (0.725) · Basis: verified_sources

## TL;DR

Code agents need repository-search syntax literacy so they can narrow evidence instead of scanning every match by hand.

## Core Explanation

Code search tools expose qualifiers for repository, path, language, symbols, content, booleans, and regular expressions. Agents that know those operators can find definitions, call sites, generated files, tests, migrations, and config references faster and with fewer false positives.

Search queries should be logged with tool name, scope, branch or revision, filters, and result count. That makes a later reviewer able to distinguish "not found" from "not searched in the right place."

## Source-Mapped Facts

- GitHub documentation says code search supports specialized code qualifiers, regular expressions, and boolean operations. ([source](https://docs.github.com/en/search-github/github-code-search/understanding-github-code-search-syntax))
- Sourcegraph documentation describes queries as strings containing search patterns and search keywords. ([source](https://sourcegraph.com/docs/code-search/queries))
- GitLab documentation describes advanced search as supporting filtering by scope, project, and group. ([source](https://docs.gitlab.com/user/search/advanced_search/))

## Further Reading

- [GitHub Code Search Syntax](https://docs.github.com/en/search-github/github-code-search/understanding-github-code-search-syntax)
- [Sourcegraph Search Query Syntax](https://sourcegraph.com/docs/code-search/queries)
- [GitLab Advanced Search](https://docs.gitlab.com/user/search/advanced_search/)