A grep-like tool that understands source code syntax for precise search and manipulation across multiple languages.
srgn is a command-line tool that performs syntax-aware search and manipulation of source code across multiple programming languages. It combines regex patterns with tree-sitter's language grammars to target specific code constructs, enabling precise refactoring, linting, and bulk edits that traditional text tools like grep or sed cannot achieve.
Developers and engineers working on codebases who need to perform safe, precise refactoring, automate code cleanup, or enforce coding standards across multiple files and languages.
Unlike grep or sed, srgn understands source code syntax, allowing operations like 'rename all function calls within Python classes' or 'find unsafe blocks in Rust' with high precision. It's fast, composable, and designed to complement existing IDE tooling.
A grep-like tool which understands source code syntax and allows for manipulation in addition to search
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses tree-sitter to scope operations to specific language constructs, enabling precise edits like targeting only Python class bodies or Rust unsafe blocks, as demonstrated in the README examples.
Processes files recursively with glob patterns, leveraging all CPU cores; benchmarks show handling 450k lines of Python in about a second, with parallel file processing.
Supports combining multiple actions (replacement, casing, deletion) and scopes in a single command, such as --titlecase --python 'doc-strings' with regex patterns for complex workflows.
Includes dry-run mode, explicit failure flags (--fail-any/--fail-none), and requires scopes for destructive actions to prevent accidental data loss, as highlighted in the warning sections.
Only supports seven languages (C, C#, Go, HCL, Python, Rust, TypeScript), excluding many common ones like Java or JavaScript, which restricts its utility in polyglot projects.
Custom tree-sitter queries require understanding of complex query syntax, which the README admits can be unwieldy and is best for users familiar with tree-sitter's pattern matching.
As a version 0.x tool, the README warns of potential breaking changes and recommends only processing files that can be safely restored, making it risky for production without backups.