본문으로 건너뛰기
Skillpedia
테스트48k · #5937

tdd-workflows-tdd-refactor

하는 일

이 도구는 프로그래밍 코드를 더 깔끔하고 효율적으로 만드는 데 도움을 줍니다. 리팩터링 기법을 적용하면서 코드의 모든 테스트가 계속 통과하도록 합니다.

사용하는 경우

  • ✓코드를 더 체계적으로 만들고 싶을 때.
  • ✓코드의 속도를 개선하고 싶을 때.
  • ✓코드 변경이 아무것도 망가뜨리지 않도록 확인하는 경우.

스킬 링크

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/tdd-workflows-tdd-refactor/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/tdd-workflows-tdd-refactor/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“이 코드를 더 깔끔하고 빠르게 리팩터링해 주세요. 단, 모든 테스트가 계속 통과해야 합니다.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

도구는 코드를 분석하고, 반복이나 복잡성 같은 개선 영역을 찾아 알려진 기법을 적용합니다. 변경 전후에 테스트를 실행해 모든 것이 여전히 작동하는지 확인합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Use this skill when

  • Working on tdd workflows tdd refactor tasks or workflows
  • Needing guidance, best practices, or checklists for tdd workflows tdd refactor

Do not use this skill when

  • The task is unrelated to tdd workflows tdd refactor
  • You need a different domain or tool outside this scope

Instructions

  • Clarify goals, constraints, and required inputs.
  • Apply relevant best practices and validate outcomes.
  • Provide actionable steps and verification.
  • If detailed examples are required, open resources/implementation-playbook.md.

Refactor code with confidence using comprehensive test safety net:

[Extended thinking: This tool uses the tdd-orchestrator agent (opus model) for sophisticated refactoring while maintaining all tests green. It applies design patterns, improves code quality, and optimizes performance with the safety of comprehensive test coverage.]

Usage

Use Task tool with subagent_type="tdd-orchestrator" to perform safe refactoring.

Prompt: "Refactor this code while keeping all tests green: $ARGUMENTS. Apply TDD refactor phase:

Core Process

1. Pre-Assessment

  • Run tests to establish green baseline
  • Analyze code smells and test coverage
  • Document current performance metrics
  • Create incremental refactoring plan

2. Code Smell Detection

  • Duplicated code → Extract methods/classes
  • Long methods → Decompose into focused functions
  • Large classes → Split responsibilities
  • Long parameter lists → Parameter objects
  • Feature Envy → Move methods to appropriate classes
  • Primitive Obsession → Value objects
  • Switch statements → Polymorphism
  • Dead code → Remove

3. Design Patterns

  • Apply Creational (Factory, Builder, Singleton)
  • Apply Structural (Adapter, Facade, Decorator)
  • Apply Behavioral (Strategy, Observer, Command)
  • Apply Domain (Repository, Service, Value Objects)
  • Use patterns only where they add clear value

4. SOLID Principles

  • Single Responsibility: One reason to change
  • Open/Closed: Open for extension, closed for modification
  • Liskov Substitution: Subtypes substitutable
  • Interface Segregation: Small, focused interfaces
  • Dependency Inversion: Depend on abstractions

5. Refactoring Techniques

  • Extract Method/Variable/Interface
  • Inline unnecessary indirection
  • Rename for clarity
  • Move Method/Field to appropriate classes
  • Replace Magic Numbers with constants
  • Encapsulate fields
  • Replace Conditional with Polymorphism
  • Introduce Null Object

6. Performance Optimization

  • Profile to identify bottlenecks
  • Optimize algorithms and data structures
  • Implement caching where beneficial
  • Reduce database queries (N+1 elimination)
  • Lazy loading and pagination
  • Always measure before and after

7. Incremental Steps

  • Make small, atomic changes
  • Run tests after each modification
  • Commit after each successful refactoring
  • Keep refactoring separate from behavior changes
  • Use scaffolding when needed

8. Architecture Evolution

  • Layer separation and dependency management
  • Module boundaries and interface definition
  • Event-driven patterns for decoupling
  • Database access pattern optimization

9. Safety Verification

  • Run full test suite after each change
  • Performance regression testing
  • Mutation testing for test effectiveness
  • Rollback plan for major changes

10. Advanced Patterns

  • Strangler Fig: Gradual legacy replacement
  • Branch by Abstraction: Large-scale changes
  • Parallel Change: Expand-contract pattern
  • Mikado Method: Dependency graph navigation

Output Requirements

  • Refactored code with improvements applied
  • Test results (all green)
  • Before/after metrics comparison
  • Applied refactoring techniques list
  • Performance improvement measurements
  • Remaining technical debt assessment

Safety Checklist

Before committing:

  • ✓ All tests pass (100% green)
  • ✓ No functionality regression
  • ✓ Performance metrics acceptable
  • ✓ Code coverage maintained/improved
  • ✓ Documentation updated

Recovery Protocol

If tests fail:

  • Immediately revert last change
  • Identify breaking refactoring
  • Apply smaller incremental changes
  • Use version control for safe experimentation

Example: Extract Method Pattern

Before:

class OrderProcessor {
  processOrder(order: Order): ProcessResult {
    // Validation
    if (!order.customerId || order.items.length === 0) {
      return { success: false, error: "Invalid order" };
    }

    // Calculate totals
    let subtotal = 0;

…
자주 묻는 질문

리팩터링이란 무엇인가요?

외부에서 보이는 동작은 바꾸지 않고 기존 컴퓨터 코드의 구조를 재구성하는 과정입니다. 명확성을 높이고 복잡성을 줄여 유지보수를 쉽게 하는 것이 목표입니다.

테스트가 계속 통과하는 것이 왜 중요한가요?

테스트가 계속 통과하면 코드 변경으로 새 버그가 생기거나 기존 기능이 깨지지 않았다는 뜻입니다. 안전망 역할을 합니다.

코드가 어떤 개선을 얻을 수 있나요?

코드를 읽기 쉽고, 더 빠르게 실행되고, 더 체계적이며, 나중에 수정하기 쉽게 만들 수 있습니다.

상세 정보

작성자의 원본 설명

Use when working with tdd workflows tdd refactor

repo: sickn33/agentic-awesome-skills

인기도

GitHub 스타
48k
순위
#5937
라이선스
MIT
업데이트
2026. 10. 15.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬