test-contract
Generate protocol/interface test suites that any implementation must pass. Define the contract once, test every implementation. Use when designing protocols or swapping implementations.
npx skills add rshankras/claude-code-apple-skills --skill test-contract --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.
# Test Contract Define behavioral contracts as test suites. Any class conforming to a protocol must pass the contract tests. Ensures consistent behavior across implementations — human-written, AI-generated, or mock. ## When This Skill Activates Use this skill when the user: - Designs a protocol and wants to ensure conformance quality - Has multiple implementations of the same interface (e.g., real + mock + in-memory) - Says "test the protocol" or "contract test" - Wants to swap implementations safely (e.g., CoreData → SwiftData) - Wants to ensure AI-generated implementations meet the spec ## Why Contract Tests ``` Protocol: DataStore ├── SQLiteDataStore → must pass contract tests ├── InMemoryDataStore → must pass contract tests ├── MockDataStore → must pass contract tests └── CloudDataStore → must pass contract tests ``` Write the contract once. Every implementation proves it works by passing the same tests. ## Process ### Phase 1: Identify the Protocol ``` Grep: "protocol.*\\{" to find protocols Read: protocol definition ``` Understand: - [ ] All required methods and properties - [ ] Expected behavior for each method - [ ] Error conditions and edge cases - [ ] Thread safety requir
- When This Skill Activates
- Why Contract Tests
- Process
- Phase 1: Identify the Protocol
- Phase 2: Define Contract Behaviors
- Phase 3: Generate Contract Test Suite
- Common Contract Categories
- Repository / Data Store
- Network Client
- Cache
- Authentication
- Output Format
- References
What does the test-contract skill do?
Generate protocol/interface test suites that any implementation must pass. Define the contract once, test every implementation. Use when designing protocols or swapping implementations.
How do I install it?
Run `npx skills add rshankras/claude-code-apple-skills --skill test-contract --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.
