ast-refactoring

ast-refactoring is a skill for Claude Code, Codex from Insajin/autopus-adk. It costs 15 tokens per session (570 once invoked), scanned A, original, MIT.

A code-refactoring guide that uses an abstract syntax tree, a structured representation of source code, to make changes based on code meaning rather than text matching.

In plain words
What is it for?
Use it to safely rename symbols, move Go packages, extract functions or interfaces, update references, and check that behavior remains unchanged.
Why use it?
Text replacement can change the wrong code or miss related references; syntax-aware changes reduce those risks. It also recommends running tests before and after refactoring.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to safely rename symbols, move Go packages, extract functions or interfaces, update references, and check that behavior remains unchanged.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/insajin/autopus-adk/ast-refactoring
Install

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.

Any agent
npx skills add Insajin/autopus-adk --skill ast-refactoring
Clone the repo
git clone --depth 1 https://github.com/Insajin/autopus-adk

Made for: Claude Code, Codex.

Wrote 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.

agentmods badge for ast-refactoring

README.md
[![agentmods](https://agentmods.dev/badge/skills/insajin/autopus-adk/ast-refactoring/github.svg)](https://agentmods.dev/skills/insajin/autopus-adk/ast-refactoring)
Your own site
<a href="https://agentmods.dev/skills/insajin/autopus-adk/ast-refactoring"><img src="https://agentmods.dev/badge/skills/insajin/autopus-adk/ast-refactoring/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.

agentmods 80×15 button for ast-refactoring

Your own site · 80×15
<a href="https://agentmods.dev/skills/insajin/autopus-adk/ast-refactoring"><img src="https://agentmods.dev/badge/skills/insajin/autopus-adk/ast-refactoring.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 15 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 570 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5.1 $0.00015 $0.00570
Opus 5 $0.00008 $0.00285
Sonnet 5 $0.00003 $0.00114
Haiku 4.5 $0.00002 $0.00057

Measured 10d ago against content hash 453dc83e7738, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

ast-refactoring 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 10d ago.

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.

.omp/skills/ast-refactoring/SKILL.md · 87 lines

What it actually says

AST Refactoring Skill

Abstract Syntax Tree(AST)를 활용하여 코드를 안전하게 리팩토링하는 스킬입니다.

AST 기반 리팩토링 원칙

왜 AST인가?

  • 텍스트 기반 치환: sed, 정규식 → 오탐, 부분 매칭 위험
  • AST 기반 변환: 문법을 이해하고 변환 → 안전

Go AST 도구

# gorename: 심볼 안전 이름 변경
gorename -from "github.com/org/pkg.OldName" -to NewName

# gofmt -r: 패턴 기반 변환
gofmt -r 'a.Foo(b, c) -> a.Bar(b, c)' -w ./...

# gotools: 패키지 이동
gomv github.com/org/pkg/old github.com/org/pkg/new

리팩토링 패턴

Extract Function

// Before: 복잡한 함수
func ProcessOrder(order Order) error {
    // 유효성 검사 (30줄)
    // 가격 계산 (20줄)
    // DB 저장 (15줄)
    return nil
}

// After: 분리된 함수
func ProcessOrder(order Order) error {
    if err := validateOrder(order); err != nil {
        return err
    }
    price := calculatePrice(order)
    return saveOrder(order, price)
}

Extract Interface

// 구체 타입에 인터페이스 추출
type UserRepository interface {
    FindByID(ctx context.Context, id string) (*User, error)
    Save(ctx context.Context, user *User) error
}

Move Package

# 패키지 이동 시 모든 참조 자동 업데이트
# gopls를 통한 LSP rename 사용

안전한 리팩토링 절차

1. 기존 테스트 실행 (GREEN 확인)
2. 리팩토링 실행
3. 테스트 재실행 (GREEN 유지 확인)
4. 린터 실행
5. 커밋

원칙: 기능 변경과 리팩토링을 동일 커밋에 혼합하지 않습니다.

체크리스트

  • 리팩토링 전 테스트 GREEN 확인
  • 단일 책임 원칙 충족
  • 인터페이스 추출로 테스트 용이성 향상
  • 변수/함수 명명이 의도를 명확히 표현
  • 리팩토링 후 테스트 GREEN 확인
  • 성능 회귀 없음 (벤치마크 비교)
Changes

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.

  1. 10d ago First seen · 87 lines · 15 tokens per session scan A 453dc83e7738

Subscribe to this mod's changes

ast-refactoring is a skill published in the GitHub repository Insajin/autopus-adk (111 stars, last pushed today), licensed MIT. It adds 15 tokens to every session and 570 once invoked, about $0.0001 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-08-30.