characterization-test-generator
Generates tests that capture current behavior of existing code before refactoring. Use when you need a safety net before AI-assisted refactoring or modifying legacy code.
npx skills add rshankras/claude-code-apple-skills --skill characterization-test-generator --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.
# Characterization Test Generator Generate tests that document what existing code **actually does** — not what it should do. These tests capture current behavior so you can refactor with confidence, especially when using AI to modify code. ## When This Skill Activates Use this skill when the user: - Says "I need to refactor this" or "help me refactor" - Wants to "add tests before changing code" - Asks for "characterization tests" or "golden master tests" - Says "I want to safely modify this class/module" - Mentions "legacy code" or "untested code" - Wants AI to refactor but is worried about breaking things ## Why This Matters for AI-Generated Code AI refactoring is powerful but risky: - AI doesn't remember **why** code works a certain way - AI may "improve" code and break subtle behavior - Characterization tests freeze current behavior as a regression suite - If any test fails after refactoring, you know something changed ## Process ### Phase 1: Discover Code Under Test ``` Glob: **/*.swift (in the target module) Grep: "class |struct |enum |protocol |func " (public API surface) ``` Identify: - [ ] Public types and their public methods - [ ] Input types and return types - [ ] Side e
- When This Skill Activates
- Why This Matters for AI-Generated Code
- Process
- Phase 1: Discover Code Under Test
- Phase 2: Classify Behavior
- Phase 3: Generate Tests
- Phase 4: Fill in Actual Values
- Phase 5: Verify and Lock
- Output Format
- When NOT to Use This
- References
Run only characterization tests xcodebuild test -scheme YourApp \
What does the characterization-test-generator skill do?
Generates tests that capture current behavior of existing code before refactoring. Use when you need a safety net before AI-assisted refactoring or modifying legacy code.
How do I install it?
Run `npx skills add rshankras/claude-code-apple-skills --skill characterization-test-generator --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.
