Engineering
file-search avatar

file-search

Search codebases efficiently using ripgrep for lightning-fast text patterns and ast-grep for precise, syntax-aware structural code analysis.

Introduction

The file-search skill empowers agents to navigate and analyze large codebases by integrating two high-performance tools: ripgrep (rg) for text-based regex searching and ast-grep (sg) for structural, syntax-aware code matching. Designed for developers and AI agents alike, this skill is essential for codebase exploration, refactoring, security auditing, and technical documentation. By leveraging these tools, users can quickly identify entry points, track down function or class usages, and detect problematic code patterns without the overhead of manual file traversal.

  • Advanced text searching: Supports multi-file regex patterns via ripgrep to quickly locate strings, variable names, comments, and configuration keys.

  • Syntax-aware structural analysis: Uses ast-grep to perform semantic code searching based on Abstract Syntax Trees, allowing for precise matching of class definitions, function signatures, and complex code blocks.

  • Performance-focused architecture: Built to handle large repositories, significantly outperforming standard grep or find commands in speed and efficiency.

  • Comprehensive language support: Facilitates targeted searches across diverse programming languages, including Python, JavaScript, TypeScript, and others.

  • Prioritize targeted searches: Always scope your queries by using directory-specific paths or file-type filters (e.g., --type py) to maintain high precision and minimize token consumption.

  • Workflow refinement: Start with broad counts to assess the scope, then use context flags (like -C for ripgrep) or increasingly specific structural patterns to drill down into the desired code logic.

  • Safety and security: Use the skill to proactively identify security vulnerabilities, such as hardcoded credentials, potential injection points, or the use of dangerous functions like eval.

  • Tool selection guide: Select ripgrep for simple text strings, comments, or general pattern matching; select ast-grep when the logic or syntax of the code structure is the primary search criteria.

  • Optimization tips: Always pipe results to head when scanning large sets to prevent overwhelming the agent context, and utilize the --glob flag to exclude test directories or irrelevant assets from your search space.

Repository Stats

Stars
968
Forks
151
Open Issues
6
Language
Python
Default Branch
main
Sync Status
Idle
Last Synced
Apr 29, 2026, 05:27 AM
View on GitHub