Cette page est affichée en anglais. Une traduction française est en cours.
CLI ToolsMay 12, 2026·2 min de lecture

GritQL — Declarative Code Rewrite CLI

GritQL is a declarative language + CLI for searching and rewriting codebases with snippet-like patterns, making large refactors repeatable and reviewable.

Prêt pour agents

Cet actif peut être lu et installé directement par les agents

TokRepo expose une commande CLI universelle, un contrat d'installation, le metadata JSON, un plan selon l'adaptateur et le contenu raw pour aider les agents à juger l'adaptation, le risque et les prochaines actions.

Native · 94/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Cli
Installation
Single
Confiance
Confiance : Established
Point d'entrée
README.md
Commande CLI universelle
npx tokrepo install df1ae063-451e-4b1f-9061-4867afc21ce4
Introduction

GritQL is a declarative language + CLI for searching and rewriting codebases with snippet-like patterns, making large refactors repeatable and reviewable.

  • Best for: teams doing recurring migrations (logging, API renames, lint fixes) across 10k–10M+ LOC repos
  • Works with: polyglot repos (TS/Python/Go/etc.), CI-driven codemods, branch-based review workflows
  • Setup time: 5 minutes

Practical Notes

  • Designed for scale: README claims it can handle 10M+ line repositories
  • Reuse library patterns: supports 200+ shared patterns via a built-in module system (README)

A Practical Refactor Loop for Agents

If you’re using coding agents, the bottleneck is often “how do we apply the same change consistently across many files?”

GritQL helps by making the change declarative:

  1. Start with a search-only pattern to learn the surface area.
  2. Add a rewrite (=>) once you’re confident the match is precise.
  3. Run on a small folder first, then the whole repo.
  4. Review the diff like any other migration (tests + lint + code review).

Example rewrite from the README:

grit apply '`console.log($msg)` => `winston.log($msg)`'

If the repo is large, treat the migration as a batch job: run it once in CI, then keep it as a reusable “codemod” command for future consistency.

FAQ

Q: Do I need to learn ASTs? A: No. The README emphasizes snippet-like patterns as valid queries without deep AST knowledge.

Q: Is it only for JavaScript? A: No. It supports many target languages (TS/Python/Go/etc.) via its language support matrix.

Q: How do I keep it safe? A: Run in a branch, start small, and use CI tests + code review like any refactor.

🙏

Source et remerciements

Source: https://github.com/biomejs/gritql > License: MIT > GitHub stars: 4,493 · forks: 121

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires