code-gritqllisted
Install: claude install-skill tstapler/dotfiles
# gritql: AST-Based Code Transformation
Use `grit` for structural code rewrites. Unlike text-based find/replace, gritql understands code syntax and rewrites safely across all occurrences.
## When to Use
**Use gritql for:**
- Renaming methods, classes, variables across many files
- API migrations (library version upgrades)
- Pattern modernization (legacy → idiomatic code)
- Any change where "find all + replace" needs syntax awareness
**Don't use for:**
- Single-file edits → use `Edit` tool
- Non-code files (YAML, JSON, MD) → use `Edit` tool
- Simple text substitution → use `MultiEdit`
- Code *searching* → use `code-ast-grep` instead
## ⚠️ Critical: Go Package Prefix Migrations
When adding package prefixes to Go types (e.g., `FooType` → `pkg.FooType`), two things WILL go wrong without guards:
**1. Double-prefix** — GritQL visits sub-nodes of already-rewritten code. Fix with `not within`:
```grit
language go
// WRONG: causes detection.detection.FooType
`FooType` => `detection.FooType`
// CORRECT: use specific not within guard
`FooType` => `detection.FooType` where {
$_ <: not within `detection.$_`
}
```
**2. Struct field types missed** — Go uses `type_identifier` AST node in struct fields; GritQL backtick patterns compile as `identifier` (different node type) and don't match. Use `gofmt -r` to cover these:
```bash
gofmt -r 'FooType -> detection.FooType' -w ./...
```
Then run `go build ./...` to catch any remaining occurrences.
## Installation
```bash
brew instal