constitution.md is the governance document of a spec bundle: the project vision, its core principles, and the MUST / MUST NOT constraints on technology, architecture, testing, coding standards, security, performance, and integrations. It rarely changes, and every later spec file - and every AI coding agent - must comply with it.
Ordinary laws (requirements, solutions, tasks) get written and rewritten all the time, but each one has to be constitutional. A judge does not re-argue free speech in every case; they check the case against the constitution. Likewise an agent should not re-decide the ORM, the test coverage floor, or "no raw SQL" on every prompt - it reads constitution.md and applies it. Amending the constitution is rare, deliberate, and visible.
Why the constitution comes first
Architectural drift is the signature failure of AI-assisted engineering: as a chat grows, the model forgets earlier decisions, introduces a second HTTP client, bypasses the repository layer, or quietly relaxes a security rule. Prompt-level hints such as .cursorrules are transient; the constitution is the permanent, version-controlled sandbox that survives every prompt, commit, and branch.
- It resolves conflicts. When two requirements pull in different directions, the Core Principles say which wins.
- It bounds the solution. solution.md may only use technologies the constitution approves.
- It is the reviewer's checklist. MySpec's independent reviewer rejects a draft requirement, solution, or task that contradicts it.
Where it lives and when it is written
| Workflow | Path | Scope | Written at |
|---|---|---|---|
| MySpec (greenfield) | specs/<bundle>/constitution.md | One per bundle | Stage 2, right after the interview; collect → generate → review |
| Spec Kit | specs/memory/constitution.md | One per project, shared by every feature | Stage 2 of the first feature; later features read it and only edit it if it needs amending |
| OpenSpec | - | Not part of the change layout | Constraints are captured in the proposal and design.md instead |
The interview that precedes it deliberately asks nothing technical - product, users, journeys, MVP scope only. Technology, architecture, testing, and security questions belong to the constitution's own collect substage, which is why the constitution ends up traceable to your answers rather than to the model's defaults.
The nine sections (MySpec)
All nine must be present, in this order. A section with nothing to say gets an explicit N/A, never a silent omission.
# Project Constitution: [Project Name]
## Project Vision
## Core Principles
## Technology Constraints
## Architecture Constraints
## Testing Approaches
## Coding Standards
## Security Constraints (may be "N/A")
## Performance Targets (may be "N/A")
## Integration Points (may be "N/A") | Section | What goes in it |
|---|---|
| Project Vision | The problem, the target users, the long-term outcome. Sets direction and bounds scope. |
| Core Principles | Non-negotiable values used to resolve ambiguity when requirements conflict. |
| Technology Constraints | Approved and disallowed languages, platforms, tools - "MUST use X for Y". |
| Architecture Constraints | Required patterns, boundaries, structural rules that control coupling. |
| Testing Approaches | Mandatory strategies and coverage - what "done" means. |
| Coding Standards | Enforced style, structure, and maintainability rules. |
| Security Constraints | Required practices and risk controls, or N/A. |
| Performance Targets | Measurable responsiveness / throughput goals, or N/A. |
| Integration Points | External systems, APIs, services to integrate with, or N/A. |
A complete example
Short on purpose: three to five items per section is the sweet spot. Every line is traceable to something the user said.
# Project Constitution: A Generic Product
## Project Vision
Build a product that solves a real user problem with minimal friction, remains easy
to evolve over time, and can be confidently operated by a small team. Favor clarity
over cleverness and long-term maintainability over short-term velocity.
## Core Principles
- MVP scope only - focus on essential features first
- User-centric design - prioritize user experience in all decisions
- Performance first - optimize for speed and responsiveness
## Technology Constraints
- MUST use TypeScript for all frontend and backend code
- MUST use PostgreSQL as the primary database
- MUST use AWS services for cloud infrastructure
## Architecture Constraints
- Microservices architecture with clear service boundaries
- Stateless services for horizontal scalability
- Event-driven communication between services
## Testing Approaches
- Minimum 80% unit test coverage required
- Integration tests for all API endpoints
- E2E tests for critical user flows
## Coding Standards
- Functional programming style preferred
- Dependency injection required for testability
- ESLint and Prettier for code formatting
## Security Constraints
- OWASP Top 10 compliance required
- No secrets or credentials in code repositories
- All data encrypted at rest and in transit
## Performance Targets
N/A
## Integration Points
N/A Need a production-grade starting point for a specific stack? The constitution.md templates page has Next.js 15 and FastAPI constitutions with prohibited-pattern lists, verification gates, and a decision-precedence hierarchy.
The Spec Kit constitution
The Spec Kit workflow mirrors GitHub Spec Kit's constitution-template.md: principles become numbered Articles (Roman numerals, three to seven of them, more than nine is over-prescriptive), genuinely non-negotiable ones are marked (NON-NEGOTIABLE), and the file carries its own version history.
<!--
SYNC IMPACT REPORT (constitution rev)
- Version: (initial) → 1.0.0
- Changed Articles: all new
- Downstream artifacts that may need re-sync: none (first ratification)
-->
# Photo Albums Constitution
## Core Principles
### I. Library-First
Every feature is implemented in a self-contained library first; the app is a thin
shell that wires libraries together.
### II. Test-First (NON-NEGOTIABLE)
TDD: tests written → user-approved → tests fail → implement. Red-Green-Refactor
strictly enforced.
### III. Integration-First Contracts
Integration tests define a feature's contract before any implementation detail.
## Additional Constraints
- Storage MUST default to SQLite for local dev; production may swap to PostgreSQL.
- All public APIs are versioned MAJOR.MINOR; breaking changes require a MAJOR bump.
## Development Workflow
PRs must pass the spec quality review; the Constitution Check gates in plan.md must
be re-evaluated for any new feature.
## Governance
Constitution supersedes all other practices. Amendments require an explicit PR, the
Sync Impact Report block updated, and approval from a code owner.
**Version**: 1.0.0 | **Ratified**: 2026-06-13 | **Last Amended**: 2026-06-13 - Sync Impact Report - an HTML comment at the top of every revision recording the SemVer bump and which downstream files (spec.md, plan.md, tasks.md) may need re-syncing.
- Governance - who can amend it, how, and the rule that added complexity must be justified.
- Footer -
**Version** | **Ratified** | **Last Amended**, all three required. - Constitution Check - plan.md re-evaluates Simplicity, Anti-Abstraction, and Integration-First gates against it for every feature.
Authoring and review rules
These are the rules MySpec's generator follows and its reviewer enforces. They are just as useful when you write one by hand.
- Has all nine sections, in order (MySpec) or Articles + Governance + footer (Spec Kit).
- Keeps each section to roughly three to five well-defined items.
- Traces every constraint to at least one user answer and contradicts none of them.
- Focuses on high-impact, essential constraints; leaves room for the downstream files.
- Uses clear MUST / MUST NOT language that is enforceable, not aspirational.
- Invents speculative constraints for requirements the user never expressed.
- Adds new sections, exhaustive lists, or a metadata footer (version / date / status) on the MySpec variant.
- Silently drops Security, Performance, or Integration Points instead of writing N/A.
- Buries the technology sandbox in prose instead of explicit MUST lines.
How AI coding agents should use it
- Read it first, every session. With the MySpec MCP server connected, the agent calls
read_spec_fileon the constitution before touching code; or download the bundle to.specs/and reference the file fromCLAUDE.md/.cursorrules. - Treat it as a gate, not a suggestion. A diff that adds an unapproved dependency, skips a verification command, or violates an architecture boundary is wrong even if it works.
- Escalate instead of amending. If a task cannot be completed inside the constitution, the agent should say so; changing the constitution is a human decision (and, in Spec Kit, a versioned one).
You are an autonomous senior engineer. Before proposing any change, read and strictly
adhere to every invariant, prohibition, and verification gate in .specs/<bundle>/constitution.md. Related spec files
Project vision, core principles, and the MUST / MUST NOT constraints every later file has to obey.
User roles, FR-/NFR- requirements with EARS+ acceptance criteria; a coded AR-/BR-/CR- delta for brownfield changes.
Architecture, modules, data model, and API design with Mermaid flowchart, ER and sequence diagrams - plus C4 diagrams when your organisation enables them.
Ordered, sized implementation tasks grouped into milestones, traced back to requirement IDs.
Why a brownfield change is needed, what changes, the technical solution, and its impact on existing code.
Spec Kit's prioritised user stories and success criteria, or OpenSpec's ADDED / MODIFIED / REMOVED / RENAMED requirement deltas.
Spec Kit's technical plan: technical context, constitution gates, architecture, data model, and key decisions.
OpenSpec's optional context, goals / non-goals, decisions, and risks for a change.
Workflows that write it
The default four-file bundle: interview → constitution → requirements → solution → tasks.
GitHub Spec Kit's feature-scoped flow: interview → constitution → specify → plan → tasks.
OpenSpec's change-proposal flow: explore → proposal → delta specs → design → tasks.
Let the AI Architect write it for you
MySpec interviews you, then drafts every spec file with collect → generate → review gates. Free during Open Beta.