Esta página se muestra en inglés. Una traducción al español está en curso.
ScriptsJul 23, 2026·3 min de lectura

The Silver Searcher (ag) — Lightning-Fast Code Search from the Terminal

A code-searching tool similar to ack but optimized for speed. ag recursively searches directories for a regex pattern while respecting .gitignore rules, delivering results 5-10x faster than ack and on par with ripgrep.

Listo para agents

Instalación lista para agent

Este activo puede instalarse después de elegir el runtime, revisar el plan y ejecutar el comando correspondiente.

Native · 98/100Política: permitir
Superficie agent
Cualquier agent MCP/CLI
Tipo
Skill
Instalación
Single
Confianza
Confianza: Established
Entrada
The Silver Searcher
Comando de instalación directa
npx -y tokrepo@latest install d77daba2-8658-11f1-9bc6-00163e2b0d79 --target codex

Ejecutar después de confirmar el plan con dry-run.

Introduction

The Silver Searcher (ag) is a code-searching tool originally inspired by ack but rewritten in C for raw speed. It automatically skips files listed in .gitignore and .hgignore, making it ideal for searching large codebases without wading through build artifacts or vendor directories.

What The Silver Searcher Does

  • Recursively searches directories for regex or literal patterns at high speed
  • Honors .gitignore, .hgignore, and custom ignore files out of the box
  • Prints results with filenames, line numbers, and color highlighting
  • Supports PCRE-style regular expressions for complex pattern matching
  • Searches compressed files and allows file-type filtering with flags

Architecture Overview

ag is written in C and uses POSIX threads to parallelize directory traversal and file searching. It memory-maps files for fast I/O, builds an ignore-rule tree from .gitignore and similar files at startup, and applies those rules during traversal so excluded paths are never opened. Pattern matching is handled by the PCRE library.

Self-Hosting & Configuration

  • Ships as a single binary with no runtime dependencies beyond libc and PCRE
  • Available in all major package managers (brew, apt, yum, pacman, choco)
  • Configure default flags in a ~/.agrc file (e.g., --hidden, --depth)
  • Override ignore rules per-project with a .ignore or .agignore file
  • Integrates with editors via plugins for Vim (ag.vim), Emacs (ag.el), and VS Code

Key Features

  • Typically 5-10x faster than ack on large repositories
  • Automatic .gitignore awareness removes the need for manual exclude lists
  • Colored, grouped output is easy to scan in a terminal
  • Pager support pipes long results through less automatically
  • Broad platform support across Linux, macOS, FreeBSD, and Windows

Comparison with Similar Tools

  • ripgrep (rg) — newer Rust-based successor, generally faster on modern hardware but ag remains well-established
  • ack — the Perl-based predecessor; ag is a performance-oriented reimplementation
  • grep -r — universal but slower and requires manual ignore configuration
  • git grep — fast inside git repos but limited to tracked files only
  • ugrep — newer C++ grep alternative with ag-compatible output

FAQ

Q: How does ag compare to ripgrep? A: ripgrep is generally faster in benchmarks, especially on very large repos. ag is still fast and widely installed, making it a solid choice when rg is unavailable.

Q: Can ag search binary files? A: By default ag skips binary files. Use the --search-binary flag to include them.

Q: Does ag support multiline search? A: ag does not natively support multiline patterns. Use ripgrep with the -U flag or pcregrep -M for that.

Q: How do I search only specific file types? A: Use file-type flags like ag --python "pattern" or provide a glob with -G "*.ts".

Sources

Discusión

Inicia sesión para unirte a la discusión.
Aún no hay comentarios. Sé el primero en compartir tus ideas.

Activos relacionados