본문으로 건너뛰기
cccskills
무료GitHub에 공개

tidy

TDD Production Code Refactoring Process. Triggers on 'tidy up', 'tidy this', 'clean up code'. Use for refactoring production code with test coverage.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(2)

  • SKILL.md4.7 KB
  • workflow.js6.5 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

TDD Production Code Refactoring Process

STARTER_CHARACTER = 🟣

NEVER make changes to Test code in this process.

This process is for refactoring production code with test coverage.

Initial Setup

  1. Locate Test File Proactively

    • If user provides a file path, search for its test file using common patterns:
      • filename.test.ext, filename.spec.ext
      • __tests__/filename.ext
      • tests/filename.ext
      • Mirror path with /test/ instead of /src/
    • Use Glob and Grep to search multiple patterns in parallel
    • If multiple test files found, show options and ask which one
    • If no test file found, inform user and ask them to provide the test file path
    • Only ask user if ambiguous or not found - otherwise proceed automatically
  2. Verify Tests Pass

    • Run the test suite to establish baseline
    • If tests fail initially, stop and report to user
  3. Scan for Refactoring Opportunities

    • Read the production code file thoroughly
    • Identify ALL refactoring opportunities by priority:
      1. Dead code (commented code, unused variables)
      2. Poor names (unclear variables/methods)
      3. Long methods (> 25 lines)
      4. Duplication (repeated code blocks)
      5. Complex conditionals (nested ifs, no guard clauses)
      6. Unnecessary locals (single-use variables)
      7. Unused imports
    • Present numbered list of all findings to user
    • Ask user which ones to proceed with (e.g., "all", "1-5", "2,4,7")
    • Wait for user confirmation before starting refactoring

Refactoring Loop

The approval is interactive and stays here (Initial Setup step 3): you present the numbered findings, ask which to proceed with, and wait for user confirmation. Only the deterministic apply → green-gate → commit/revert loop is encoded as a Workflow, so the strike cap, green gate, and exact commit-message format run reliably instead of by prose.

Once the user has confirmed the subset, invoke the Workflow tool with the bundled script, passing the human-approved refactor list (in priority order):

Workflow({
  scriptPath: "${CLAUDE_PLUGIN_ROOT}/skills/tidy/workflow.js",
  args: {
    refactors: ["<approved refactor 1>", "<approved refactor 2>", ...],  // priority order
    testCommand: "<how to run the suite>",   // optional; agent infers if omitted
    productionFile: "<path>",                 // optional; the file being tidied
    testFile: "<path>"                        // optional; NEVER modified
  }
})

For each approved refactor the workflow runs:

  1. An agent applies only that one refactoring (one at a time, in priority order) to production code — it NEVER touches test code — and returns the diff.
  2. A gate agent (Haiku) runs the test suite and returns { passed, output }.
  3. If passed === true: commit with message format "- r <refactoring>" (quotes must include the - r). The loop does not commit until the gate reports passed === true.
  4. If tests fail: revert this attempt's changes and retry — up to three attempts.

It returns { total, attempted, committed, halted, outcomes }, where each outcome carries { index, refactor, committed, commitMessage, attempts, halted }. Give a brief status update after each refactor from the returned outcomes.

Stop conditions:

  • If a refactor fails three times (the workflow halts and returns halted: true)
  • If no further refactoring opportunities found
  • Pause and check with user

When the workflow returns halted: true, pause and check with the user before doing anything else — report which refactor failed and its attempt output; do not continue to the next refactor on your own.

Code Style Guidelines

  • Prefer self-explanatory, readable code over comments
  • Use functional helper methods for clarity
  • Remove comments and dead code
  • Extract paragraphs into methods
  • Use better variable names
  • Remove unused imports
  • Remove unhelpful local variables
  • Methods should be small and focused (ideally < 25 lines)

Common Refactorings (in priority order)

  1. Remove dead code - commented code, unused variables
  2. Better names - rename unclear variables/methods
  3. Extract methods - break up long methods
  4. Remove duplication - DRY principle
  5. Simplify conditionals - reduce nesting, use guard clauses
  6. Remove unnecessary locals - inline single-use variables
  7. Clean imports - remove unused imports

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Automates browser interactions for web testing, form filling, screenshots, and data extraction. Use when the user needs to navigate websites, interact with web pages, fill forms, take screenshots, test web applications, or extract information from web pages.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

SDiamante13/dotfiles112026년 10월 2일 업데이트

catchup

무료

Rebuilds session context after a clear by reading git history, plans, and beads state. Triggers on 'catch up'.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

SDiamante13/dotfiles112026년 10월 2일 업데이트

changelog

무료

Generate a bullet-point summary of branch changes for a PR description. Triggers on "changelog", "pr summary", "summarize branch", or "/changelog".

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

SDiamante13/dotfiles112026년 10월 2일 업데이트

commit

무료

Commit the current changes with quality checks, status review, staged diff inspection, appropriate tests, and a clear commit message. Use when the user says "commit", "c", asks to make a commit, or wants changes saved in git.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

SDiamante13/dotfiles112026년 10월 2일 업데이트

declutter

무료

Refactor code to remove dead code, useless comments, unused variables, and unused imports. Use when asked to declutter a class, clean up noisy code, remove cruft, or run `/refactor:declutter`.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

SDiamante13/dotfiles112026년 10월 2일 업데이트

dry

무료

Refactor duplicated code by extracting helpers, shared abstractions, or clearer reusable structure. Use when asked to apply DRY, remove duplication, consolidate repeated logic, or run `/refactor:dry`.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

SDiamante13/dotfiles112026년 10월 2일 업데이트

SDiamante13의 스킬 모두 보기

이 스킬의 문제 신고