ast-refactoring-scripts
Installation
SKILL.md
AST-Delegated Local Refactoring (Scripts over Token Rewrites)
Overview
When tasked with a repository-wide codebase migration ("Rename method getUserById to fetchUserRecord across all 45 microservice files"), naive AI agents attempt to open, edit, and rewrite all 45 files sequentially through LLM tool calls.
This naive approach consumes 100,000+ tokens, takes 5 minutes of streaming latency, and frequently introduces subtle hallucinated syntax regressions.
The AST-Delegated Refactoring Protocol directs the agent to write a single 20-line local AST transformer script (using Python libcst, TypeScript ts-morph, or jscodeshift) and execute it locally via run_command. The entire codebase is refactored deterministically in 200 milliseconds using only 350 tokens.