ast-grep vs ripgrep vs ugrep: which code search should your AI agent run?
ast-grep vs ripgrep vs ugrep: which one for an AI agent? ripgrep finds text and regex fast and respects .gitignore. ast-grep finds and rewrites code by syntax, using tree-sitter. ugrep adds Boolean and fuzzy queries and searches inside archives and PDFs. Most agents use ripgrep by default and add ast-grep for refactors.
Key number: ripgrep 16.0.0 shipped on 2026-11-22, and ripgrep has 70,142 GitHub stars. (as of 2026-11-22 · source: github.com/BurntSushi/ripgrep)
Last checked: 2026-11-22. Features come from each project's README; stars and releases from the GitHub REST API on that date.
TL;DR Use ripgrep to find text, ast-grep to find or rewrite a code shape, and ugrep when you want Boolean, fuzzy or archive search. They answer different questions, so many agents keep two of them.
Which search tool fits this job?
Pick an answer above.
ripgrep
Recursive regex search that respects .gitignore and skips hidden and binary files.
ast-grep
Structural search, lint and rewrite on tree-sitter syntax trees.
ugrep
Boolean AND, OR and NOT, fuzzy search, a query TUI, and search in archives and PDFs.
XERJ
A local index that returns a few ranked passages with file:line, over MCP.
Act as a coding agent. Read https://xerj.org/compare/ast-grep-vs-ripgrep-vs-ugrep. For each search you run in this repository, use ripgrep for names and regex, ast-grep for code shapes and rewrites, and ugrep for Boolean or fuzzy queries over mixed files. Tell me which tool you used for each search and why.
Side by side
| Question | ripgrep | ast-grep | ugrep |
|---|---|---|---|
| What it matches | text and regex | tree-sitter syntax patterns | text, regex, Boolean and fuzzy queries |
| Rewrites matches | no | yes, with --rewrite | no |
| Lint rules | no | yes, in YAML | no |
| Archives, compressed files, PDFs | no | no | yes |
| Respects .gitignore by default | yes | yes | with --ignore-files |
| Interactive mode | no | yes, --interactive | yes, query TUI with -Q |
| MCP server | no | separate ast-grep-mcp project | no |
| Licence | MIT or Unlicense | MIT | BSD-3-Clause |
| Latest release (2026-11-22) | 16.0.0 (2026-11-22) | 0.51.3 (2026-11-16) | v7.8.5 (2026-09-15) |
| GitHub stars (2026-11-22) | 70,142 | 16,661 | 3,339 |
| Install | brew install ripgrep | brew install ast-grep | brew install ugrep |
When to choose ripgrep instead
Choose ripgrep for names, strings and regular expressions in a git repository. It needs no setup, respects .gitignore and skips hidden and binary files by default, so it is the right first call for most agent searches.
When to choose ast-grep instead
Choose ast-grep when the match depends on code structure, or when the agent must rewrite every match. Its patterns follow the syntax tree, so formatting and line breaks do not change the result, and YAML rules turn a pattern into a lint check.
When to choose ugrep instead
Choose ugrep for Boolean AND, OR and NOT queries, fuzzy matches, or search inside archives, compressed files, PDFs and documents. Its query TUI (ug -Q) is handy when a person searches alongside the agent.
ast-grep vs ripgrep
ripgrep answers "where does this text appear?". ast-grep answers "where does this code shape appear?" and can rewrite each match. Ask ripgrep for a function name. Ask ast-grep for every call of that function with a given argument pattern, then rewrite them in one step.
ugrep vs ripgrep
Both search text recursively. ugrep adds Google-like Boolean queries, fuzzy matches, a query TUI, and search inside zip, 7z and tar archives, compressed files, PDFs and documents. An optional ugrep-indexer speeds up search on slow or cold file systems. ripgrep keeps to fast regex search and respects your ignore files by default.
ast-grep vs ugrep
They rarely compete. ast-grep reads code as syntax trees for refactors and lint rules. ugrep reads any file as text, including archives and PDFs. A refactor goes to ast-grep; a search across a downloaded bundle of docs goes to ugrep.
When an agent needs ranked passages
All three print every match in file order. When an agent asks one tree many questions, a ranked index returns less to read: on psf/requests one XERJ answer was 1,303 bytes where ripgrep printed 25,150 (capture). XERJ is a new way for AI to search for data, and it sits next to ripgrep rather than replacing it. XERJ is single-node, and search is lexical by default.
How this page was checked
On 2026-11-22 we read the README of each project and the GitHub REST API for stars and the latest release. No head-to-head benchmark was run for this page; ripgrep publishes its own benchmarks in its README.
Read next
- Grep AI alternatives 2026: 7 search tools for coding agents
- ast-grep vs a code index for an agent
- Is ripgrep enough for a coding agent?
- What is agentic search?
FAQ
ast-grep vs ripgrep: what is the difference?
ripgrep searches text with regular expressions and respects .gitignore by default. ast-grep matches code by its syntax tree, using tree-sitter patterns, and can rewrite every match. Many agents keep both.
ugrep vs ripgrep: what is the difference?
ugrep adds Boolean AND, OR and NOT queries, fuzzy search, a query TUI and search inside archives, compressed files, PDFs and documents. ripgrep focuses on fast recursive regex search that respects .gitignore.
Which one should a coding agent call first?
ripgrep for a literal name or regex, ast-grep for a code shape such as every call of a function with given arguments, and ugrep for Boolean or fuzzy queries over mixed files. For many questions over one tree, a ranked index such as XERJ returns fewer bytes.
Do any of them have an MCP server?
ast-grep has a separate ast-grep-mcp project (MIT). ripgrep and ugrep are command-line tools that agents call through the shell. XERJ ships xerj mcp.
Which licences do they use?
ripgrep is dual licensed MIT or Unlicense, ugrep is BSD-3-Clause and ast-grep is MIT.
Evidence
- ripgrep recursively searches the current directory for a regex pattern, respects gitignore rules and skips hidden files and directories and binary files by default. Source: https://github.com/BurntSushi/ripgrep
- ripgrep 16.0.0 was published on 2026-11-22. Source: https://github.com/BurntSushi/ripgrep/releases
- ast-grep is a CLI tool for code structural search, lint and rewriting, built on tree-sitter syntax trees, with YAML rules. Source: https://github.com/ast-grep/ast-grep
- ast-grep run has -i, --interactive for an interactive edit session, and respects .gitignore and .ignore files unless --no-ignore is passed. Source: https://ast-grep.github.io/reference/cli/run.html
- ugrep excludes files listed in .gitignore when run with --ignore-files. Source: https://github.com/Genivia/ugrep
- ast-grep-mcp is a separate MIT-licensed project. Source: https://github.com/ast-grep/ast-grep-mcp
- ugrep offers Boolean AND, OR and NOT search, fuzzy search, a query TUI with -Q, and search inside archives, compressed files, PDFs and documents. Source: https://github.com/Genivia/ugrep
- ugrep-indexer is an optional indexer for ugrep. Source: https://github.com/Genivia/ugrep-indexer
- Stars and latest releases on 2026-11-22: ripgrep 70,142 and 16.0.0; ast-grep 16,661 and 0.51.3; ugrep 3,339 and v7.8.5. Source: GitHub REST API
- On psf/requests one XERJ answer was 1,303 bytes; rg printed 25,150. Source: /answers/local-code-search-mcp-fewer-tokens-than-grep