Agent skill · Testing & QA

fitness-functions

Write architecture fitness functions — deterministic tests that enforce a project's hard rules (module boundaries, offline guarantees, content contracts) from inside its own test target. Use when a constraint lives only in prose (CLAUDE.md, code review) and should become un-arguable.

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

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

Facts
Files in the skill folder: 4
SKILL.md size: 8 KB
Bundled scripts: none
Allowed tools: ReadWriteEditGlobGrepBash
Path: skills/testing/fitness-functions/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

# Architecture Fitness Functions A fitness function is an ordinary test that enforces an architectural rule instead of a behavior. It lives in the app's own test target, runs under every existing test gate forever, and turns "the agent said it's fine" into an exit code. This is the gauntlet's answer for invariants no unit test of behavior can see: a file quietly importing a framework it must not touch, a registry drifting from its documented size, user-facing copy breaking its format contract. ## When This Skill Activates Use this skill when: - A project hard rule exists only in prose — CLAUDE.md constraints, file-header comments, review checklists ("deck games must run fully offline", "only the sync layer may import CloudKit") - A code review keeps re-checking the same structural rule by hand - An `/apple:review` structural finding is being graduated into permanent enforcement - A count, boundary, or content format was broken silently once already ## Why a Test, Not a Lint Rule A per-line regex (SwiftLint `custom_rules`) can flag a *line*. A fitness function can assert a *set*: "the files importing MusicKit are exactly these four", "the mode registry has exactly 21 entries", "ever

What's inside
Steps it walks through
  1. When This Skill Activates
  2. Why a Test, Not a Lint Rule
  3. The Three Patterns
  4. Pattern 1: Import-Boundary Allowlist Scan
  5. Pattern 2: Runtime Sentinel
  6. Pattern 3: Contract Pins
  7. Process
  8. Phase 1: Identify the Invariant
  9. Phase 2: Pick the Pattern
  10. Phase 3: Write the Suite
  11. Phase 4: Prove It Red (Deliberate-Break Drill)
  12. Phase 5: Commit
  13. Output Format
  14. Common Pitfalls
Ships with 3 files
  • templates/ContractPinTests.swift
  • templates/ImportBoundaryTests.swift
  • templates/NetworkSentinelTests.swift
More from claude-code-apple-skills
All skills →
About this skill
What does the fitness-functions skill do?

Write architecture fitness functions — deterministic tests that enforce a project's hard rules (module boundaries, offline guarantees, content contracts) from inside its own test target. Use when a constraint lives only in prose (CLAUDE.md, code review) and should become un-arguable.

How do I install it?

Run `npx skills add rshankras/claude-code-apple-skills --skill fitness-functions --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