Knowledge about writing effective project constitution files for LLM/coding agents. Use this skill when creating, editing, or reviewing constitution.md files.
From constitutionnpx claudepluginhub thlandgraf/cc-marketplace --plugin constitutionThis skill uses the workspace's default tool permissions.
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Searches prompts.chat for AI prompt templates by keyword or category, retrieves by ID with variable handling, and improves prompts via AI. Use for discovering or enhancing prompts.
Guides agent creation for Claude Code plugins with file templates, frontmatter specs (name, description, model), triggering examples, system prompts, and best practices.
A constitution file defines rules, best practices, patterns, and guardrails for LLM and coding agents working in a project. Unlike human documentation, constitutions are optimized for token efficiency and machine parsing.
Standard locations (checked in order):
constitution.md (project root)doc/constitution.mdHard limit: 25,000 tokens
Approximate conversion: 1 token ≈ 4 characters
Monitor size when adding rules. A well-written constitution for a medium project typically uses 5,000-15,000 tokens.
# Project Constitution
Brief one-line project description.
## <Category 1>
- Rule 1
- Rule 2 (rationale)
## <Category 2>
- Rule 3
- Prefer X over Y
- Avoid Z
| Category | Contents |
|---|---|
| Stack | Languages, frameworks, versions |
| Patterns | Required architectural patterns |
| Anti-patterns | What to avoid |
| Conventions | Naming, structure, organization |
| Testing | Testing requirements and approaches |
| Security | Security requirements |
| Performance | Performance constraints |
| Dependencies | Dependency rules |
const by default" not "Prefer immutability"Simple rule:
- Use TypeScript strict mode
Rule with rationale:
- Use TypeScript strict mode (catches null errors early)
Preference:
- Prefer composition over inheritance
Prohibition:
- Avoid `any` type
Conditional:
- Use server components by default; client components only for interactivity
Exception:
- Use strict mode (except legacy/ directory)
Quantified:
- Max 300 lines per file
- Min 80% test coverage for business logic
# Project Constitution
TypeScript monorepo for e-commerce platform.
## Stack
- TypeScript 5.3+ strict mode
- React 18 with Server Components
- Next.js 14 App Router
- PostgreSQL with Drizzle ORM
- Vitest for testing
## Patterns
- Feature-based directory structure
- Repository pattern for data access
- Use server components by default
- Client components only for interactivity
- Collocate tests with source files
## Anti-patterns
- Avoid `any` type (use `unknown` if needed)
- No barrel exports in feature modules
- No circular dependencies
- Avoid prop drilling beyond 2 levels
## Conventions
- camelCase for functions/variables
- PascalCase for components/types
- kebab-case for files and directories
- Prefix interfaces with I (IUser, IProduct)
- Suffix types with Type only if needed for clarity
## Testing
- Unit tests for business logic (min 80% coverage)
- Integration tests for API routes
- E2E tests for critical user flows
- Use Testing Library, avoid implementation details
## Security
- Validate all user input at API boundary
- Use parameterized queries only
- No secrets in code or logs
- HTTPS only, secure cookies