MCP HubMCP Hub
SKILL·30C594

go-refactoring

eduardo-sl
업데이트됨 22 days ago
3 조회
68
9
68
GitHub에서 보기
테스팅testingautomation

정보

이 Claude Skill은 Go 코드베이스에 대해 안전하고 동작을 보존하는 리팩토링 워크플로우를 제공하며, 모든 변경 사항이 컴파일러 검사를 거치고 통과된 테스트로 뒷받침되도록 보장합니다. 코드베이스 전반의 이름 변경, 패키지 추출, 순환 의존성 해결, 그리고 점진적 마이그레이션 관리와 같은 작업을 처리합니다. 기능 변경 없이 구조적 정리를 수행할 때 사용하되, 아키텍처 결정, 새로운 언어 기능 도입, 성능 재작성에는 사용하지 마십시오.

빠른 설치

Claude Code

추천
기본
npx skills add eduardo-sl/go-agent-skills -a claude-code
플러그인 명령대체
/plugin add https://github.com/eduardo-sl/go-agent-skills
Git 클론대체
git clone https://github.com/eduardo-sl/go-agent-skills.git ~/.claude/skills/go-refactoring

Claude Code에서 이 명령을 복사하여 붙여넣어 스킬을 설치하세요

문서

Go Refactoring Workflow

A refactor changes structure, never behavior. The definition of done is mechanical: same tests pass before and after every step, and every step is small enough to revert alone.

1. The Loop

  1. Baseline: go build ./... && go test ./... must be green before touching anything. If tests are missing around the target code, write characterization tests FIRST — they pin current behavior, even if that behavior looks wrong.
  2. One transformation from the catalog below.
  3. Verify: build + tests + go vet ./....
  4. Commit. Never mix a refactor commit with a behavior change — reviewers can skim a refactor: commit; they must scrutinize a mixed one.
  5. Repeat.

If step 3 fails and the fix isn't obvious in a minute, revert the step rather than debugging a half-applied transformation.

2. Renames — Let Tools Do Them

# Preferred: gopls (understands types, interfaces, embedding)
gopls rename -w internal/service/user.go:#offset newName

# Module path or package import path changes:
# update go.mod, then rewrite imports mechanically
find . -name '*.go' -exec sed -i 's|github.com/acme/old|github.com/acme/new|g' {} +
go build ./...   # the compiler is the reviewer

Never rename an exported identifier of a published library without a deprecation cycle: add the new name, mark the old one // Deprecated: use NewName., delete in the next major version.

3. Extract Package

Moving code out of a god package, in compiler-checked steps:

  1. Create the new package; move one type and its methods (gopls or cut/paste), leaving everything else.
  2. In the old package, add type aliases so nothing breaks: type User = user.User (aliases, =, not definitions).
  3. Build. Migrate importers to the new path in batches; build each batch.
  4. Delete the aliases when no importer remains.

This keeps every commit green with an arbitrarily large caller base.

4. Break a Circular Dependency

Packages a → b and b → a won't compile; near-cycles show up as god packages. Three escapes, in order of preference:

  1. Extract the shared core: both a and b actually depend on a type — move it to a third package c that imports nothing.
  2. Invert with an interface: if store calls back into service, define the callback interface IN store (consumer side) and let service implement it. The arrow flips at compile time.
  3. Merge: if two packages can't be described without each other, they were one package all along.

5. Change a Function Signature Safely

For exported functions with many callers:

// Step 1 — add the new form alongside the old
func (s *Service) ProcessCtx(ctx context.Context, id string) error { ... }

// Step 2 — old form delegates; mark deprecated
// Deprecated: use ProcessCtx.
func (s *Service) Process(id string) error {
    return s.ProcessCtx(context.Background(), id)
}

// Step 3 — migrate callers batch by batch, building each batch
// Step 4 — delete the old form (same module) or keep until next major (library)

Inside a single module, prefer atomic signature changes when the compiler can find every caller for you: change it, then chase the build errors — that's the compiler enumerating your TODO list.

6. Strangler Migration for Subsystems

Replacing a subsystem (old store, legacy client) too big for one PR:

  1. Define the consumer-side interface the callers actually need.
  2. Make the OLD implementation satisfy it; wire callers to the interface.
  3. Build the new implementation behind the same interface; test both implementations against one shared conformance test suite.
  4. Switch the wiring in the composition root (one line, one commit, trivially revertible). Feature-flag it if risk warrants.
  5. Delete the old implementation in its own commit.

7. What Is NOT a Refactor

  • "While I'm here" bug fixes — separate commit before or after.
  • Reordering struct fields used with positional literals, changing exported error strings callers match on, changing JSON tags — these are behavior changes wearing refactor clothes.
  • Rewrites without tests. If you can't pin behavior first, you're not refactoring; you're gambling.

Verification Checklist

  1. Baseline build + tests green before the first change
  2. Characterization tests added where coverage was missing
  3. Each commit is one transformation; refactor: commits contain no behavior change
  4. Renames done via gopls/compiler, not find-and-replace on identifiers
  5. Package extractions used type aliases to stay green mid-flight
  6. No new dependency cycles (go build ./... proves it)
  7. Public API changes follow the deprecation cycle
  8. go vet ./... and the full test suite pass at every commit, not just the last
  9. git log reads as a sequence of safe, revertible steps

GitHub 저장소

eduardo-sl/go-agent-skills
경로: skills/(workflow)/go-refactoring
0
FAQ

자주 묻는 질문

go-refactoring Skill이란 무엇인가요?

go-refactoring은(는) eduardo-sl이(가) 만든 Claude Skill입니다. Skill은 Claude가 필요할 때 불러오는 지침과 리소스를 묶어 추가 프롬프트 없이 go-refactoring 관련 작업을 수행할 수 있게 합니다.

go-refactoring은(는) 어떻게 설치하나요?

이 페이지의 설치 명령을 사용하세요. go-refactoring을(를) Claude Code 플러그인으로 추가하거나 저장소를 skills 디렉터리에 복제한 다음 Claude를 다시 시작해 Skill을 불러옵니다.

go-refactoring은(는) 어떤 카테고리에 속하나요?

go-refactoring은(는) 테스팅 카테고리에 속합니다.

go-refactoring은(는) 무료로 사용할 수 있나요?

네. go-refactoring은(는) AIMCP에 등록되어 있으며 무료로 설치할 수 있습니다.

연관 스킬

evaluating-llms-harness
테스팅

이 Claude Skill은 MMLU, GSM8K를 포함한 60개 이상의 표준화된 학술 과제에서 LLM 성능을 벤치마크하기 위해 lm-evaluation-harness를 실행합니다. 개발자들이 모델 품질을 비교하고, 학습 진행 상황을 추적하거나 학술 결과를 보고할 수 있도록 설계되었습니다. 이 도구는 HuggingFace와 vLLM 모델을 포함한 다양한 백엔드를 지원합니다.

스킬 보기
cloudflare-cron-triggers
테스팅

이 스킬은 cron 표현식을 사용하여 Worker를 스케줄링하기 위한 Cloudflare Cron Triggers 구현에 관한 포괄적인 지식을 제공합니다. 주기적 작업, 유지보수 작업, 자동화된 워크플로우 설정 방법을 다루며, 잘못된 cron 표현식이나 시간대 문제 같은 일반적인 이슈들을 해결하는 방법을 포함합니다. 개발자들은 이를 통해 스케줄된 핸들러 구성, cron 트리거 테스트, Workflows 및 Green Compute와의 연동 작업을 수행할 수 있습니다.

스킬 보기
webapp-testing
테스팅

이 Claude Skill은 Python 스크립트를 통해 로컬 웹 애플리케이션을 테스트하기 위한 Playwright 기반 툴킷을 제공합니다. 프론트엔드 검증, UI 디버깅, 스크린샷 캡처, 로그 확인 기능을 지원하며 서버 라이프사이클을 관리합니다. 브라우저 자동화 작업에 사용하되 컨텍스트 오염을 방지하기 위해 소스 코드를 읽지 않고 스크립트를 직접 실행하세요.

스킬 보기
finishing-a-development-branch
테스팅

이 스킬은 테스트 통과를 확인한 후 체계적인 통합 옵션을 제시하여 개발자가 완성된 작업을 마무리하도록 돕습니다. 구현이 완료된 후 머지, PR 생성, 브랜치 정리와 같은 워크플로우를 안내합니다. 코드가 준비되고 테스트가 완료되었을 때 개발 프로세스를 체계적으로 마무리하기 위해 사용하세요.

스킬 보기