← Back to AI Engineering Blog

Building a Constitution for Spec-Kit

November 12, 2025
18 min read
Spec-Driven Development
GitHub Spec-Kit
Project Governance
AI Engineering
Best Practices

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

What is a Constitution in Spec-Kit?

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.

AI agents reference your constitution in:

/speckit.specify- Writing specs
/speckit.plan- Creating plans
/speckit.tasks- Breaking down work
/speckit.implement- Generating code
Core Components of a Constitution

1. Core Principles (5 recommended)

Each principle must have four key elements:

Name:Short, memorable identifier
Description:Clear, declarative statement of the rule
Rationale:Why this principle exists
Enforcement:How it's verified
### 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 merge

2. 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)
Using the /speckit.constitution Command

Command Syntax

# Interactive mode (asks questions)
/speckit.constitution
# Direct input mode
/speckit.constitution <natural language description of principles>

How It Works

1

Updates existing template at .specify/memory/constitution.md

2

Accepts natural language - describe principles in plain English

3

Fills placeholder tokens like [PROJECT_NAME], [PRINCIPLE_1_NAME]

4

Applies semantic versioning (MAJOR.MINOR.PATCH)

5

Propagates changes to dependent templates

6

Generates sync report documenting what changed

Real-World Examples

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
Best Practices

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
What Makes a Good Principle?

Specificity over Vagueness

✓Good: "Tests written → User approved → Tests fail → Then implement"
✗Bad: "Testing is important"

Enforceability

✓Good: "API routes only for webhooks (verified in PR review)"
✗Bad: "Minimize API routes when possible"

Measurability

✓Good: "Page load < 2 seconds at p95"
✗Bad: "Performance should be good"
Constitution Lifecycle

Initial Creation

  1. Start with 3-5 core principles
  2. Add technology constraints
  3. Document existing practices
  4. Get team consensus

Evolution Process

Patch (0.0.x)
Typos, clarifications
Minor (0.x.0)
New constraints, refined enforcement
Major (x.0.0)
New principles, fundamental shifts

Amendment Workflow

  1. Propose change via /speckit.constitution
  2. Review sync impact report
  3. Update dependent templates if needed
  4. Commit with semantic version message
Integration with Spec-Kit Workflow

The constitution influences every stage of development, ensuring consistency across the entire lifecycle:

constitution.md
Foundation
↓
/speckit.specify
References principles
↓
/speckit.plan
Follows constraints
↓
/speckit.tasks
Implements standards
↓
/speckit.implement
Honors constitution
Getting Started
1

Identify Your Principles

Ask yourself: What patterns do we consistently use? What mistakes do we want to prevent? What makes our codebase unique?

2

Draft Your Constitution

Use natural language to describe 3-5 core architectural principles, technology stack requirements, development workflow standards, and performance targets.

3

Run the Command

Execute /speckit.constitution with your project details and principles described in plain English.

4

Verify and Commit

Check .specify/memory/constitution.md, review version number, examine sync report, and commit to version control.

5

Reference in Development

Use in code reviews, cite when making architectural decisions, update as you learn, and enforce in CI/CD where possible.

Benefits of a Constitution

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

Common Pitfalls to Avoid

Over-Engineering

✗Creating 20+ principles that no one can remember
✓Start with 5 core principles, add more as needed

Aspirational Thinking

✗"We should write tests for everything"
✓"80% test coverage required for business logic"

Lack of Enforcement

✗Principles with no verification method
✓Each principle states how it's checked

Forgetting to Update

✗Constitution written once and never revised
✓Review quarterly, update when practices change
Ready to Establish Your Constitution?

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.

View GitHub Spec-Kit