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.
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.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# 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
- When This Skill Activates
- Why a Test, Not a Lint Rule
- The Three Patterns
- Pattern 1: Import-Boundary Allowlist Scan
- Pattern 2: Runtime Sentinel
- Pattern 3: Contract Pins
- Process
- Phase 1: Identify the Invariant
- Phase 2: Pick the Pattern
- Phase 3: Write the Suite
- Phase 4: Prove It Red (Deliberate-Break Drill)
- Phase 5: Commit
- Output Format
- Common Pitfalls
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.
