tdd-refactor-guard
Pre-refactor safety checklist. Verifies test coverage exists before AI modifies existing code. Use before asking AI to refactor anything.
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.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# 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
- When This Skill Activates
- Why This Guard Exists
- Process
- Step 1: Identify Scope
- Step 2: Check Existing Test Coverage
- Step 3: Evaluate Test Quality
- Step 4: Generate Missing Tests
- Step 5: Green Light / Red Light
- Step 6: Post-Refactor Verification
- Refactoring Safeguards
- Safe Refactorings (Low Risk)
- Risky Refactorings (Need Good Coverage)
- Migration Refactorings (Need Comprehensive Coverage)
- Output Format
Run all tests xcodebuild test -scheme YourApp Check specifically for regressions xcodebuild test -scheme YourApp \
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.
