Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add rshankras/claude-code-apple-skills --skill tdd-refactor-guardgit clone --depth 1 https://github.com/rshankras/claude-code-apple-skillsWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/rshankras/claude-code-apple-skills/tdd-refactor-guard)<a href="https://agentmods.dev/skills/rshankras/claude-code-apple-skills/tdd-refactor-guard"><img src="https://agentmods.dev/badge/skills/rshankras/claude-code-apple-skills/tdd-refactor-guard/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/rshankras/claude-code-apple-skills/tdd-refactor-guard"><img src="https://agentmods.dev/badge/skills/rshankras/claude-code-apple-skills/tdd-refactor-guard.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00033 | $0.01725 |
| Opus 5.5 | $0.00013 | $0.00690 |
| Sonnet 5.5 | $0.00007 | $0.00345 |
| Haiku 4.5 | $0.00003 | $0.00172 |
Grade A, and why
tdd-refactor-guard scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 248 lines — stays where its author put it; the contents beside it link to each section on GitHub.
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)
- Dependencies (what calls this code, what it calls)
- Side effects (network, disk, notifications, UI updates)
Step 2: Check Existing Test Coverage
Grep: "class.*Tests.*XCTestCase|@Suite.*Tests|struct.*Tests" in test targets
Grep: "@Test|func test" that reference the classes being refactored
Coverage Assessment
| Level | Criteria | Action |
|---|---|---|
| Good (> 80%) | Most public methods have tests for happy + error paths | Proceed with refactoring |
| Partial (40-80%) | Some methods tested, missing edge cases | Add characterization tests for uncovered methods |
| Minimal (< 40%) | Few or no tests | Generate full characterization test suite first |
| None (0%) | No test file exists | STOP — create characterization tests before any refactoring |
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 1mo ago First seen · 248 lines · 33 tokens per session scan A 341e4dd2aa5a
tdd-refactor-guard is a skill published in the GitHub repository rshankras/claude-code-apple-skills (927 stars, last pushed 26d ago), licensed MIT. It adds 33 tokens to every session and 1,725 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-11-05.
tdd-refactor-guard compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| tdd-refactor-guardrshankras/claude-code-apple-skills | Skill | 927 | 26d ago | MIT | A | 33 | Claude Code |
| kotlin-testingaffaan-m/ECC | Skill | 317k | 3d ago | MIT | A | 38 | Claude Code, Kiro |
| cpp-testingaffaan-m/ECC | Skill | 317k | 3d ago | MIT | A | 34 | Claude Code, Kiro |
| image-crop-rotateinstavm/coderunner | Skill | 903 | yesterday | Apache-2.0 | A | 50 | Claude Code, Codex |
| triage-issuesoftspark/ai-toolkit | Skill | 180 | 2d ago | Apache-2.0 | A | 39 | Claude Code |
| tddsoftspark/ai-toolkit | Skill | 180 | 2d ago | Apache-2.0 | A | 33 | Claude Code |
| tdd-workflowFlorianBruniaux/claude-code-ultimate-guide | Skill | 7.6k | 2d ago | CC-BY-SA-4.0 | A | 44 | Claude Code |