Building Project Constitutions

Introduction to the Project Constitution

In software development, consistency is key. If three different developers work on a project without rules, the code will quickly become a mess. The same is true when working with Claude Code.

In Lesson 1, you learned WHY specifications matter for AI-assisted development. Before you write your first feature spec, you need to establish your project's foundation. A Project Constitution is a Markdown file that serves as the "source of truth" for your project. It defines the tools, the coding style, and the workflow that Claude must follow. By setting these rules at the start, you prevent Claude from making guesses about your tech stack or using outdated coding patterns. This lesson will show you how to write a constitution that ensures Claude acts like a senior engineer on your team.

What is CLAUDE.md?

CLAUDE.md is a special file that Claude Code automatically reads at the start of every session. It acts as your project's persistent memory and governance layer.

What Goes in CLAUDE.md?

The first part of a Constitution is defining the Tech Stack. This tells Claude exactly which languages and libraries to use. We also define Architectural Principles, which act as the blueprint for how the code should be organized.

Markdown
# Project Constitution: TaskMaster API

## Tech Stack (Non-Negotiable)
- Python 3.11+ with type hints (mypy strict mode)
- FastAPI 0.100+ (latest stable)
- Pytest with >90% coverage requirement
- PostgreSQL 15+ (primary data store)
- Redis 7+ (caching, pub/sub)

By listing specific versions (such as Python 3.11+ or PostgreSQL 15+), you ensure Claude doesn't use old features or incompatible libraries. In your CodeSignal environment, most of these tools, such as FastAPI and Pytest, are already pre-installed, so you can start using them immediately.

Next, we add the Architectural Principles:

Markdown
## Architectural Principles
1. Repository Pattern: All database access through repositories
2. Dependency Injection: Use FastAPI's DI system
3. API-First: API schema drives implementation
4. Stateless: No session state on server

These rules tell Claude how to write the code. For example, the Repository Pattern is a rule stating that all code dealing with the database must be kept in a specific place. This makes the code easier to test and change later.

Sign up

Join the 1M+ learners on CodeSignal

Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal