contract-first-design
Design and manage API contracts before implementation using OpenAPI and AsyncAPI specifications for contract-first development
What this skill does
# Contract-First Design Skill
## When to Use This Skill
Use this skill when:
- **Contract First Design tasks** - Working on design and manage api contracts before implementation using openapi and asyncapi specifications for contract-first development
- **Planning or design** - Need guidance on Contract First Design approaches
- **Best practices** - Want to follow established patterns and standards
## Overview
Apply contract-first development methodology for APIs, ensuring specifications drive implementation.
## Contract-First Methodology
### Core Principles
```yaml
contract_first_principles:
design_before_code:
description: "API specification comes before implementation"
benefits:
- "Early feedback from consumers"
- "Parallel development enabled"
- "Clear contract for testing"
- "Documentation from day one"
specification_as_source_of_truth:
description: "Spec is authoritative, code conforms to it"
enforcement:
- "Generate code from spec"
- "Validate implementation against spec"
- "CI/CD gates on spec compliance"
consumer_centric:
description: "Design for consumer needs, not provider convenience"
practices:
- "Involve consumers in design reviews"
- "Consumer-driven contract testing"
- "Gather real-world usage patterns"
evolution_over_revolution:
description: "Evolve contracts without breaking consumers"
practices:
- "Semantic versioning"
- "Backward compatibility by default"
- "Deprecation before removal"
```
### Development Workflow
```yaml
contract_first_workflow:
phases:
1_design:
activities:
- "Identify API consumers and use cases"
- "Define resources and operations"
- "Draft specification (OpenAPI/AsyncAPI)"
- "Review with stakeholders"
artifacts:
- "Draft API specification"
- "Use case documentation"
gate: "Specification approved by consumers"
2_validate:
activities:
- "Lint specification for style/standards"
- "Check backward compatibility"
- "Generate mock server"
- "Consumer acceptance testing with mocks"
artifacts:
- "Lint report"
- "Compatibility report"
- "Mock server configuration"
gate: "Consumers validated against mocks"
3_implement:
activities:
- "Generate server stubs"
- "Implement business logic"
- "Contract testing against spec"
- "Integration testing"
artifacts:
- "Generated code"
- "Contract test results"
gate: "Implementation passes contract tests"
4_publish:
activities:
- "Publish specification to catalog"
- "Generate documentation"
- "Update changelog"
- "Notify consumers"
artifacts:
- "Published specification"
- "API documentation portal"
- "Changelog entry"
gate: "Documentation live, consumers notified"
5_operate:
activities:
- "Monitor API usage"
- "Collect consumer feedback"
- "Track breaking change requests"
- "Plan next version"
artifacts:
- "Usage metrics"
- "Feedback log"
- "Deprecation schedule"
```
## Contract Management
### Specification Organization
```yaml
specification_organization:
directory_structure:
recommended:
specs/
openapi/
order-service.yaml
customer-service.yaml
inventory-service.yaml
asyncapi/
order-events.yaml
inventory-events.yaml
shared/
schemas/
common-types.yaml
error-responses.yaml
parameters/
pagination.yaml
security/
auth-schemes.yaml
file_naming:
pattern: "{service-name}.yaml"
versioned: "{service-name}-v{major}.yaml"
modular_specs:
description: "Split large specs into components"
approach:
main_file: "Defines paths, references components"
components_dir: "Reusable schemas, parameters, responses"
shared_dir: "Cross-API shared definitions"
example_main:
openapi: "3.1.0"
info:
title: "Order Service API"
version: "1.0.0"
paths:
$ref: "./paths/orders.yaml"
components:
schemas:
$ref: "./schemas/_index.yaml"
```
### Version Management
```yaml
version_management:
semantic_versioning:
major: "Breaking changes"
minor: "Backward-compatible additions"
patch: "Backward-compatible fixes"
version_in_spec:
location: "info.version"
format: "MAJOR.MINOR.PATCH"
api_versioning_strategies:
url_path:
spec_example:
servers:
- url: "https://api.example.com/v1"
change_approach: "New spec file for major versions"
header:
spec_example:
parameters:
API-Version:
in: header
required: false
schema:
type: string
default: "2025-01-01"
changelog_requirements:
location: "CHANGELOG.md alongside spec"
format: "Keep a Changelog"
content:
- "Version number and date"
- "Added: new endpoints/fields"
- "Changed: modified behavior"
- "Deprecated: marked for removal"
- "Removed: breaking deletions"
- "Fixed: bug fixes"
- "Security: vulnerability patches"
```
### Breaking Change Detection
```yaml
breaking_changes:
definition: "Changes that can break existing consumers"
openapi_breaking:
removals:
- "Remove endpoint"
- "Remove required response field"
- "Remove enum value"
- "Remove supported content type"
modifications:
- "Change field type"
- "Add required request field"
- "Narrow validation (smaller max, larger min)"
- "Change authentication requirements"
renames:
- "Rename field (equivalent to remove + add)"
- "Change endpoint path"
asyncapi_breaking:
removals:
- "Remove channel"
- "Remove message type"
- "Remove required payload field"
modifications:
- "Change payload schema incompatibly"
- "Change channel address format"
- "Modify required headers"
detection_tools:
openapi:
- "openapi-diff"
- "oasdiff"
- "speccy"
asyncapi:
- "asyncapi/diff"
ci_integration:
script: |
# Compare current spec against main branch
oasdiff breaking main.yaml current.yaml
if [ $? -ne 0 ]; then
echo "Breaking changes detected!"
exit 1
fi
```
## C# Models for Contract Management
```csharp
namespace SpecDrivenDevelopment.ContractFirst;
/// <summary>
/// Represents an API contract lifecycle state
/// </summary>
public enum ContractStatus
{
Draft,
InReview,
Approved,
Implementing,
Published,
Deprecated,
Retired
}
/// <summary>
/// API contract metadata
/// </summary>
public record ApiContract
{
public required string Id { get; init; }
public required string Name { get; init; }
public required string Version { get; init; }
public required ContractType Type { get; init; }
public required ContractStatus Status { get; init; }
public required string SpecificationPath { get; init; }
public string? Description { get; init; }
public List<string> Owners { get; init; } = [];
public List<string> Consumers { get; init; } = [];
public DateTimeOffset CreatedAt { get; init; }
public DateTimeOffset? PublishedAt { get; init; }
public DateTimeOffset? DeprecatedAt { get; init; }
public DateTimeOffset? SunsetAt { get; init; }
}
public enum ContractType
{
OpenApi,
AsyncApi,
GraphQL,
gRPC
}
/// <summary>
/// Tracks changes between contract versions
/// </summary>
public record ContractChange
{
public required string ContractId { get; init; }
public required string FromVersion { get; init;Related in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.