Building a Constitution for Spec-Kit
Discover how to create a foundational governance document that guides all development decisions in your spec-driven projects. Learn the structure, best practices, and real-world examples of effective project constitutions.
Download Complete Guide
Get the full constitution guide as a Markdown file
A constitution is the foundational governance document for a spec-driven development project. It establishes non-negotiable principles that guide all subsequent development decisions—from specification writing to implementation.
Core Philosophy
AI agents reference your constitution in:
/speckit.specify- Writing specs/speckit.plan- Creating plans/speckit.tasks- Breaking down work/speckit.implement- Generating code1. Core Principles (5 recommended)
Each principle must have four key elements:
### I. API-First Architecture
**Description**: All features must expose a
documented API before building UI
**Rationale**: Ensures modularity and enables
multiple clients
**Enforcement**: Code review must verify OpenAPI
spec exists before merge2. Technology Constraints
Required stack and architectural decisions:
- Framework choices (e.g., Next.js 14+, Ruby on Rails 8)
- Database requirements (e.g., PostgreSQL, Supabase)
- Authentication patterns (e.g., Magic links, OAuth)
- Third-party integrations (e.g., Stripe, Twilio)
3. Development Standards
Team conventions and workflows:
- Git branching strategy (e.g., feature branches with ticket IDs)
- Code review requirements (e.g., minimum 1 approval)
- Testing gates (e.g., 80% coverage for business logic)
- Documentation standards (e.g., inline comments, README updates)
4. Performance & Quality Requirements
Measurable targets:
- Response time SLAs (e.g., < 2 seconds at p95)
- Availability targets (e.g., 99.9% uptime)
- Error budgets and monitoring thresholds
- Data validation standards (e.g., Zod schemas for all inputs)
5. Governance
How the constitution evolves:
- Amendment procedures (who can propose changes)
- Version control (semantic versioning)
- Compliance verification (PR checks, CI/CD gates)
Command Syntax
/speckit.constitution/speckit.constitution <natural language description of principles>How It Works
Updates existing template at .specify/memory/constitution.md
Accepts natural language - describe principles in plain English
Fills placeholder tokens like [PROJECT_NAME], [PRINCIPLE_1_NAME]
Applies semantic versioning (MAJOR.MINOR.PATCH)
Propagates changes to dependent templates
Generates sync report documenting what changed
Next.js + Supabase
Core Principles: 1. Server Components First: Default to React Server Components for all data fetching. Use Client Components only for interactivity. 2. Direct Database Access: Query Supabase directly in Server Components. API routes only for webhooks and external integrations. 3. Type Safety Throughout: Always use generated TypeScript types from database schema. Never use 'any' type. 4. Migration-Driven Schema: All database changes through timestamped migrations. Never modify schema directly. 5. Validation at Boundaries: Validate all external inputs with Zod schemas.
Ruby on Rails API
Core Principles: 1. The Rails-Way: Follow idiomatic Rails patterns and conventions 2. API-First: Document all endpoints with rswag before implementation 3. Background Jobs: All async work via Sidekiq, no inline processing 4. Database as Source of Truth: PostgreSQL handles data integrity 5. Test Coverage: Maintain >80% coverage, TDD for business logic
Microservices Architecture
Core Principles: 1. Service Autonomy: No shared databases between services 2. Event-Driven Communication: Async messaging preferred over sync calls 3. API Contracts: OpenAPI specs required for all service endpoints 4. Circuit Breakers: All external calls must fail gracefully 5. Observability First: Structured logging and distributed tracing mandatory
DO:
- ✓Start with 3-5 core principles
- ✓Make principles verifiable and enforceable
- ✓Include rationale for each principle
- ✓Version your constitution properly
- ✓Update as project evolves
- ✓Reference in code reviews
DON'T:
- ✗Create aspirational principles you won't follow
- ✗Make it so rigid it blocks productivity
- ✗Skip the "why" for each principle
- ✗Forget to update when practices change
- ✗Add principles without team consensus
Specificity over Vagueness
Enforceability
Measurability
Initial Creation
- Start with 3-5 core principles
- Add technology constraints
- Document existing practices
- Get team consensus
Evolution Process
Amendment Workflow
- Propose change via
/speckit.constitution - Review sync impact report
- Update dependent templates if needed
- Commit with semantic version message
The constitution influences every stage of development, ensuring consistency across the entire lifecycle:
Identify Your Principles
Ask yourself: What patterns do we consistently use? What mistakes do we want to prevent? What makes our codebase unique?
Draft Your Constitution
Use natural language to describe 3-5 core architectural principles, technology stack requirements, development workflow standards, and performance targets.
Run the Command
Execute /speckit.constitution with your project details and principles described in plain English.
Verify and Commit
Check .specify/memory/constitution.md, review version number, examine sync report, and commit to version control.
Reference in Development
Use in code reviews, cite when making architectural decisions, update as you learn, and enforce in CI/CD where possible.
Consistency
All features follow the same patterns
AI Alignment
Spec-kit agents reference principles automatically
Faster Onboarding
New developers understand rules immediately
Better Decisions
Constitution serves as tiebreaker in debates
Quality Gates
Clear enforcement mechanisms
Living Document
Versioned and evolvable
Over-Engineering
Aspirational Thinking
Lack of Enforcement
Forgetting to Update
The constitution becomes your project's "north star" - ensuring every feature, every spec, and every line of code aligns with your core architectural vision. Start with 3-5 principles and evolve from there.