Sourcerer
Ask the source. Sourcerer is a code research agent for understanding complex
versioned software deployments. It indexes git repos over time, searches them,
and grounds its answers in the source, scaling to hundreds of repos and billions
of lines of code. See the research blog.
- Quickstart
- Configuration
- Integrations
- Upgrades
- Benchmarks
- Development
Why Sourcerer
Get trusted answers from the source. Sourcerer indexes snapshots of git repos
so that AI agents can search the code, generate authoritative answers, and provide
inline citations for verification. It ships with configurations for Elastic Agent Builder,
which searches your code in Elasticsearch the way a coding agent would search it
on a filesystem. Its value shines for questions that span multiple repos or
versions: Sourcerer will find the right snapshot and grep a billion lines of
code in seconds.
Search like a coding agent at scale. Sourcerer is statistically tied with frontier coding agents for code retrieval based on its results from SWE-Explore-Bench (see chart below). You can expect Sourcerer to search your code as well as any coding agent, while scaling across many historical repository snapshots as if it was a single repo.

Code is the source of truth for its own behavior. Always authoriative,
never outdated. While documentation and tribal knowledge offers context, they
can never be the primary source of truth for its implementation.
Go with the grain on how model are trained. LLMs used by coding agents are
trained to use terminal commands, and grep has worked exceptionally well.
Sourcerer searches code with the same semantics (e.g. grep, ls, cat, head, tail)
over multiple code repositories indexed in Elasticsearch for greater speed,
scale, relevance, security, collaboration, and customization.
Quickstart
Prerequisites
Setup
- Install the
sourcerer CLI:
uv tool install "git+https://github.com/elastic/[email protected]"
- Add connection details. Create a
.env in your working directory, then fill it in:
cat > .env <<'EOF'
ELASTICSEARCH_URL=
KIBANA_URL=
# Authentication (use either API Key or both of Username and Password)
ELASTICSEARCH_API_KEY=
#ELASTICSEARCH_USERNAME=
#ELASTICSEARCH_PASSWORD=
EOF
- Define the sources to index. Create
sourcerer.yml, then edit it according to the sourcerer.yml specification:
cat > sourcerer.yml <<'EOF'
sources:
# Example: Index and retain only the latest snapshot of the "main" branch
- git: { host: "github", org: "elastic", repo: "docs-content", ref_type: "branch" }
match: "main"
retain.count: 1
# Example: Index and retain only the latest patch release snapshot of every minor release for the last two major releases
- git: { host: "github", org: "elastic", repo: "elasticsearch", ref_type: "tag" }
match: "v{major}.{minor}.{patch}"
since.ref: "v8.17.0"
retain.version: { majors: 2, patches: 1 }
EOF
Each source is scoped to a git.host, git.org, git.repo, and git.ref_type (can be tag, branch, or commit). match defines the names of tags, branches, or commit hashes to index based on a pattern like v{major}.{minor}.{patch} or a fixed string like main. since defines where to begin indexing in the commit history. retain defines how long to keep indexed refs before they qualify for pruning.
- Set up the indices and agent:
sourcerer setup --config sourcerer.yml
- Index the repos:
sourcerer index --config sourcerer.yml
- Chat about your software with the Sourcerer agent in Kibana under "Agents".
Configuration
The sourcerer.yml specification has the full reference of fields supported by the configuration file.
Snapshot vs. delta indexing (mode)