Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add alivirgo/Major-AI-Skills --skill ast-refactoring-scriptsgit clone --depth 1 https://github.com/alivirgo/Major-AI-SkillsWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/alivirgo/major-ai-skills/ast-refactoring-scripts)<a href="https://agentmods.dev/skills/alivirgo/major-ai-skills/ast-refactoring-scripts"><img src="https://agentmods.dev/badge/skills/alivirgo/major-ai-skills/ast-refactoring-scripts/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/alivirgo/major-ai-skills/ast-refactoring-scripts"><img src="https://agentmods.dev/badge/skills/alivirgo/major-ai-skills/ast-refactoring-scripts.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00033 | $0.01384 |
| Opus 5 | $0.00016 | $0.00692 |
| Sonnet 5 | $0.00007 | $0.00277 |
| Haiku 4.5 | $0.00003 | $0.00138 |
Grade A, and why
ast-refactoring-scripts scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 146 lines — stays where its author put it; the contents beside it link to each section on GitHub.
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.
LLM Multi-File Rewriting vs. AST Local Delegation
┌─────────────────────────────────────────────────────────────┐
│ Refactoring Architecture Comparison │
│ │
│ Naive LLM File-by-File Rewrite (45 Files): │
│ • 45 sequential `replace_file_content` tool calls │
│ • ~120,000 tokens billed │
│ • 4-6 minutes execution latency │
│ • High risk of missed edge cases or broken imports │
│ │
│ AST-Delegated Local Execution: │
│ 1. Agent writes 1 local Python / TS AST script (350 tokens)│
│ 2. Agent runs: `python scratch/refactor.py` (Local CPU) │
│ ↳ 45 files mutated in 180ms with 100% syntactic precision │
│ ↳ 99.7% Token Reduction ($1.80 $\rightarrow$ $0.005) │
└─────────────────────────────────────────────────────────────┘
Production AST Transformer Recipes
1. Python libcst Argument Renaming Script
Use when renaming function arguments or decorators across multiple Python modules while preserving exact comments and formatting:
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- yesterday Changed · -15 tokens per session 8b635135fe1b
- 7d ago First seen · 146 lines · 48 tokens per session scan A e86ed3271dca
ast-refactoring-scripts is a skill published in the GitHub repository alivirgo/Major-AI-Skills (1 stars, last pushed today), licensed MIT. It adds 33 tokens to every session and 1,384 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-05.
Other skills, from other repositories
agent-framework-azure-ai-py
Build persistent agents on Azure AI Foundry using the Microsoft Agent Framework Python SDK.
build-fullstack-backend
MANDATORY reading before writing ANY backend, API, server, or fullstack application code (createartifact types fullstack-stateless-app / fullstack-stateful-app, or anything that will be launched with launchbackend). Contains the complete hard contract: the canonical FastAPI+Mangum backend.py template, SECRETS…
detecting-languages
Use when the user wants to know which programming language a file or snippet is. Covers implicit detection in ts-pack parse/process, confirming support with ts-pack list/info, and the SDK detection functions for path, extension, and raw content.
gograph
Go repository intelligence for Claude Code. Use when reading, navigating, editing, reviewing, or refactoring a Go codebase. Exposes 64 query, analysis, and workflow capabilities through the local gograph MCP server, including bounded first-call exploration, AST-aware call graphs, blast-radius analysis, impact, and…
windows-compat
Audit and harden this Rust repo (code-graph-mcp) for Windows correctness: path-spelling drift between producers, the 32,767-char command-line cap, index-key mismatches, and path predicates that assume one ecosystem's layout. Use whenever touching code that builds, compares, prints, or stores a filesystem path; that…
1c-cfe-init
A command that creates the starter XML files for a 1C configuration extension, which changes or adds to an existing 1C business application.