Agent skill · Testing & QA

tdd-refactor-guard

Pre-refactor safety checklist. Verifies test coverage exists before AI modifies existing code. Use before asking AI to refactor anything.

rshankrasgithub.com/rshankrasGitHub ↗
claude-codecan modify filesMIT
Install
npx skills add rshankras/claude-code-apple-skills --skill tdd-refactor-guard --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 1
SKILL.md size: 7 KB
Bundled scripts: none
Allowed tools: ReadWriteEditGlobGrepBashAskUserQuestion
Path: skills/testing/tdd-refactor-guard/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 589
Language: Swift

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# TDD Refactor Guard A safety gate that runs before any AI-assisted refactoring. Ensures tests exist to catch regressions. If coverage is insufficient, generates characterization tests first. ## When This Skill Activates Use this skill when the user: - Says "refactor this" or "clean this up" - Wants AI to "restructure" or "reorganize" code - Asks to "extract", "inline", "rename", or "simplify" existing code - Plans to migrate between patterns (e.g., MVC → MVVM, CoreData → SwiftData) - Wants AI to "improve" or "modernize" existing code ## Why This Guard Exists ``` Without guard: With guard: "Claude, refactor this" "Claude, refactor this" → AI rewrites code → Guard checks for tests → Something breaks → Tests missing → generate them → You don't know what → Tests pass → proceed with refactor → Debugging nightmare → Tests fail → exact regression found ``` ## Process ### Step 1: Identify Scope What code is being refactored? ``` Ask user: "Which files/classes are you planning to refactor?" ``` Or detect from context: ``` Glob: [files mentioned in conversation] Read: each file to understand scope ``` Determine: - [ ] Files involved - [ ] Public API surface (methods, properties) - [ ] Depen

What's inside
Steps it walks through
  1. When This Skill Activates
  2. Why This Guard Exists
  3. Process
  4. Step 1: Identify Scope
  5. Step 2: Check Existing Test Coverage
  6. Step 3: Evaluate Test Quality
  7. Step 4: Generate Missing Tests
  8. Step 5: Green Light / Red Light
  9. Step 6: Post-Refactor Verification
  10. Refactoring Safeguards
  11. Safe Refactorings (Low Risk)
  12. Risky Refactorings (Need Good Coverage)
  13. Migration Refactorings (Need Comprehensive Coverage)
  14. Output Format
Commands it runs
Run all tests
xcodebuild test -scheme YourApp
Check specifically for regressions
xcodebuild test -scheme YourApp \
More from claude-code-apple-skills
All skills →
About this skill
What does the tdd-refactor-guard skill do?

Pre-refactor safety checklist. Verifies test coverage exists before AI modifies existing code. Use before asking AI to refactor anything.

How do I install it?

Run `npx skills add rshankras/claude-code-apple-skills --skill tdd-refactor-guard --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From rshankras/claude-code-apple-skills, a repository with 589 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going