Structural Refactor (GritQL)
Instructions
- •Identify Target: Clearly define the structural anti-pattern you want to fix (e.g., "nested Effect calls", "manual type assertions").
- •Pattern Discovery:
- •List existing repo patterns using
gritql listPatterns. - •Check
biome/gritql-patterns/for a matching.gritfile.
- •List existing repo patterns using
- •Dry Run:
- •Execute a dry run using
grit check --dry-runor thegritqltool withcommand: "checkPattern". - •Review the unified diff to ensure the transformation logic is sound.
- •Execute a dry run using
- •Execution:
- •Apply the transformation using
grit applyor thegritqltool withcommand: "applyPattern". - •Provide the
runIdfrom the dry run if the policy isstrict.
- •Apply the transformation using
- •Verification:
- •Run
nix develop --command grit checkto ensure no new violations were introduced. - •Run
bun testto confirm functional parity.
- •Run
Example
"Refactor all nested Effect calls to use pipe() in libs/feature-payments."
- •Use
gritqltool withpatternName: "enforce-effect-pipe". - •Review dry-run diff.
- •Apply fixes.