constitution
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseInstructions
操作说明
- Identify the operation from or user intent:
$ARGUMENTS,create,update, orcheck.show - For create: ask which files to create (architecture.md, ontology.md, or both), gather required information via , then write the files using the templates below.
AskUserQuestion - For update: identify the target file and section, apply the change surgically, update the date.
Last Updated - For check: read both constitution files, read the target file, validate against architectural rules and ontology terms, output a Constitution Check Report.
- For show: read and display both files formatted for readability.
- Always confirm with the user before writing or overwriting files.
- 从或用户意图中识别操作类型:
$ARGUMENTS(创建)、create(更新)、update(检查)或check(展示)。show - 若为create:询问要创建哪些文件(architecture.md、ontology.md或两者都创建),通过收集必要信息,然后使用下方模板生成文件。
AskUserQuestion - 若为update:确定目标文件和章节,精准应用更改,更新日期。
Last Updated - 若为check:读取两份架构文档,读取目标文件,验证其是否符合架构规则和Ontology术语,输出架构合规检查报告(Constitution Check Report)。
- 若为show:读取两份文件并以易读格式展示。
- 在写入或覆盖文件前,务必先与用户确认。
Examples
示例
Create constitution before first brainstorm:
/developer-kit-specs:constitution createValidate a spec against architecture and ontology:
/developer-kit-specs:constitution check --target=docs/specs/001/2024-01-15--user-auth.mdUpdate the security constraints section:
/developer-kit-specs:constitution update --file=architecture --section=securityShow current constitution:
/developer-kit-specs:constitution show首次头脑风暴前创建架构文档:
/developer-kit-specs:constitution create验证规格说明是否符合架构和Ontology:
/developer-kit-specs:constitution check --target=docs/specs/001/2024-01-15--user-auth.md更新安全约束章节:
/developer-kit-specs:constitution update --file=architecture --section=security展示当前架构文档:
/developer-kit-specs:constitution showConstitution Skill
Constitution Skill
Overview
概述
The Constitution is the architectural DNA of a project, expressed through two shared documents:
| File | Purpose |
|---|---|
| Technology stack, infrastructure choices, architectural rules, security constraints, AI guardrails |
| Domain glossary (Ubiquitous Language) — terms, definitions, bounded contexts |
These files live at the level and are shared across all specifications.
docs/specs/Key difference from the old constitution.md approach: instead of a single monolithic file, the constitution is split into two focused documents that are also created and enriched by (Phase 6.8.6) and (Phase 1.5). This skill lets you create or manage them before brainstorm, as a project setup step.
brainstormspec-to-tasksConstitution是项目的架构DNA,通过两份共享文档体现:
| 文件 | 用途 |
|---|---|
| 技术栈、基础设施选择、架构规则、安全约束、AI guardrails |
| 领域术语表(Ubiquitous Language)——术语、定义、限界上下文 |
这些文件位于目录下,所有规格说明共享使用。
docs/specs/与旧版constitution.md方式的主要区别:不再是单一的庞大文件,架构文档被拆分为两份聚焦的文档,且可通过(第6.8.6阶段)和(第1.5阶段)进行创建和补充。本技能允许你在头脑风暴前作为项目设置步骤创建或管理这些文档。
brainstormspec-to-tasksWhen to Use
使用场景
| Scenario | Operation |
|---|---|
| New project — define stack and domain language before first brainstorm | |
| Stack or security rules changed | |
| Validate a spec, task, or file against architecture and ontology | |
| Review current architecture and ontology | |
Trigger phrases:
- "Create constitution", "Setup project architecture", "Define ontology"
- "Update constitution", "Update architecture", "Update ontology"
- "Constitution check", "Validate against constitution"
- "Show constitution", "Project principles", "Architectural guardrails"
| 场景 | 操作 |
|---|---|
| 新项目——在首次头脑风暴前定义技术栈和领域语言 | |
| 技术栈或安全规则变更 | |
| 验证规格说明、任务或文件是否符合架构和Ontology | |
| 查看当前架构和Ontology | |
触发短语:
- "Create constitution"、"Setup project architecture"、"Define ontology"
- "Update constitution"、"Update architecture"、"Update ontology"
- "Constitution check"、"Validate against constitution"
- "Show constitution"、"Project principles"、"Architectural guardrails"
Available Operations
可用操作
1. create — Create one or both files interactively
2. update — Update a specific section of one file
3. check — Validate a spec/task/file against both documents
4. show — Display the current state of both documents
1. create —— 交互式创建一个或两个文件
2. update —— 更新单个文件的特定章节
3. check —— 验证规格说明/任务/文件是否符合两份文档的要求
4. show —— 展示两份文档的当前状态
Operation: create
操作:create
-
Ask the user which files to create (if not specified in):
$ARGUMENTS- Options: "Both architecture.md and ontology.md" (recommended), "architecture.md only", "ontology.md only"
-
For each file to create, check if it already exists. If yes, ask: overwrite or skip.
-
For, gather via
docs/specs/architecture.md:AskUserQuestionQ1 — Software Stack:- Options: "Java / Spring Boot", "TypeScript / NestJS", "TypeScript / React", "Python / Django or FastAPI", "PHP / Laravel or Symfony", or freeform
Q2 — Data Architecture:- Options: "PostgreSQL", "MySQL", "MongoDB", "Multiple databases", or freeform
Q3 — Infrastructure:- Options: "AWS", "Docker / Docker Compose", "Kubernetes", "Serverless", "Not yet decided", or freeform
Q4 — Architectural Rules (optional, freeform):- Forbidden patterns, required patterns, security constraints, AI guardrails
Then createusing the Architecture Template below.docs/specs/architecture.md -
For, gather via
docs/specs/ontology.md:AskUserQuestionAsk the user to list the main domain terms and their definitions. Explain:"The ontology captures the Ubiquitous Language of your project. It is normally enriched during brainstorming when terms emerge from the idea. You can seed it now with known terms, or create an empty scaffold to fill later."- Options: "Seed with known terms (I'll provide them)", "Create empty scaffold", "Skip for now"
Then createusing the Ontology Template below.docs/specs/ontology.md -
Confirm with the user before writing each file.
-
询问用户要创建哪些文件(若中未指定):
$ARGUMENTS- 选项:"同时创建architecture.md和ontology.md"(推荐)、"仅创建architecture.md"、"仅创建ontology.md"
-
对于每个要创建的文件,检查是否已存在。若已存在,询问:覆盖还是跳过。
-
创建时,通过
docs/specs/architecture.md收集以下信息:AskUserQuestion问题1 —— 软件栈:- 选项:"Java / Spring Boot"、"TypeScript / NestJS"、"TypeScript / React"、"Python / Django 或 FastAPI"、"PHP / Laravel 或 Symfony",或自定义输入
问题2 —— 数据架构:- 选项:"PostgreSQL"、"MySQL"、"MongoDB"、"多数据库",或自定义输入
问题3 —— 基础设施:- 选项:"AWS"、"Docker / Docker Compose"、"Kubernetes"、"Serverless"、"尚未确定",或自定义输入
问题4 —— 架构规则(可选,自定义输入):- 禁用模式、必填模式、安全约束、AI guardrails
然后使用下方的架构模板创建。docs/specs/architecture.md -
创建时,通过
docs/specs/ontology.md收集以下信息:AskUserQuestion请用户列出主要领域术语及其定义,并说明:"Ontology记录了项目的Ubiquitous Language。通常在头脑风暴期间,随着想法中出现新术语时进行补充。你可以现在用已知术语初始化,或者创建一个空框架后续再填充。"- 选项:"用已知术语初始化(我会提供)"、"创建空框架"、"暂时跳过"
然后使用下方的Ontology模板创建。docs/specs/ontology.md -
在写入每个文件前,与用户确认。
Operation: update
操作:update
- Identify the target file and section from :
$ARGUMENTS- or
--file=architecture--file=ontology - (e.g.,
--section=<section-name>,--section=security)--section=glossary
- Read the target file.
- Apply the update surgically — do not touch other sections.
- Update the date.
Last Updated - Write the updated file.
- 从中确定目标文件和章节:
$ARGUMENTS- 或
--file=architecture--file=ontology - (例如:
--section=<章节名称>、--section=security)--section=glossary
- 读取目标文件。
- 精准应用更新——不要修改其他章节。
- 更新日期。
Last Updated - 写入更新后的文件。
Operation: check
操作:check
- Read both and
docs/specs/architecture.md. If either is missing, warn the user but continue with the available file(s).docs/specs/ontology.md - Read the target file from (
$ARGUMENTS).--target=<path> - Check against architecture.md:
- Forbidden libraries/imports present?
- Unapproved patterns used?
- Security constraints violated (raw SQL, hardcoded secrets, etc.)?
- AI guardrails violated?
- Check against ontology.md:
- Are domain terms used consistently (no synonyms for defined terms)?
- Are new domain concepts introduced without being added to the glossary?
- Output a Constitution Check Report (see format below).
- 读取和
docs/specs/architecture.md。若其中任一文件缺失,向用户发出警告,但继续使用可用文件进行检查。docs/specs/ontology.md - 从中读取目标文件(
$ARGUMENTS)。--target=<路径> - 对照architecture.md检查:
- 是否存在禁用的库/导入?
- 是否使用了未批准的模式?
- 是否违反安全约束(如原生SQL拼接、硬编码密钥等)?
- 是否违反AI guardrails?
- 对照ontology.md检查:
- 领域术语是否使用一致(已定义术语无同义词)?
- 是否引入了未添加到术语表的新领域概念?
- 输出架构合规检查报告(格式见下方)。
Operation: show
操作:show
- Read and
docs/specs/architecture.md.docs/specs/ontology.md - Print both files formatted for readability, with a header indicating which file is which.
- 读取和
docs/specs/architecture.md。docs/specs/ontology.md - 以易读格式打印两份文件,每个文件前添加标题标识。
Architecture Template
架构模板
markdown
undefinedmarkdown
undefinedProject Architecture
项目架构
Created: YYYY-MM-DD
Last Updated: YYYY-MM-DD
创建时间:YYYY-MM-DD
最后更新:YYYY-MM-DD
Software Stack
软件栈
| Component | Technology | Notes |
|---|---|---|
| Language | [e.g., TypeScript] | [version if known] |
| Framework | [e.g., NestJS] | [version if known] |
| Key Libraries | [e.g., Drizzle ORM, Passport] |
| 组件 | 技术 | 备注 |
|---|---|---|
| 编程语言 | [例如:TypeScript] | [已知版本] |
| 框架 | [例如:NestJS] | [已知版本] |
| 核心库 | [例如:Drizzle ORM、Passport] |
Data Architecture
数据架构
| Component | Technology | Notes |
|---|---|---|
| Primary Database | [e.g., PostgreSQL] | |
| Caching | [e.g., Redis, none] | |
| ORM / Data Access | [e.g., Drizzle, Hibernate] | |
| Migrations | [e.g., Flyway, Drizzle Kit] |
| 组件 | 技术 | 备注 |
|---|---|---|
| 主数据库 | [例如:PostgreSQL] | |
| 缓存 | [例如:Redis、无] | |
| ORM / 数据访问 | [例如:Drizzle、Hibernate] | |
| 迁移工具 | [例如:Flyway、Drizzle Kit] |
Infrastructure
基础设施
| Component | Technology | Notes |
|---|---|---|
| Hosting | [e.g., AWS ECS] | |
| CI/CD | [e.g., GitHub Actions] | |
| Containerization | [e.g., Docker] | |
| Orchestration | [e.g., Kubernetes, none] |
| 组件 | 技术 | 备注 |
|---|---|---|
| 托管服务 | [例如:AWS ECS] | |
| CI/CD | [例如:GitHub Actions] | |
| 容器化 | [例如:Docker] | |
| 编排工具 | [例如:Kubernetes、无] |
Architectural Rules
架构规则
- [Rule 1, e.g., "Use constructor injection. Never use @Autowired on fields."]
- [Rule 2, e.g., "Domain entities must not depend on framework annotations."]
- [规则1,例如:"使用构造函数注入。禁止在字段上使用@Autowired。"]
- [规则2,例如:"领域实体不得依赖框架注解。"]
Security Constraints
安全约束
- Forbidden patterns:
- No raw SQL string concatenation (SQL injection — CWE-89)
- No hardcoded secrets or credentials (CWE-798)
- No deserialization of untrusted data (CWE-502)
- Required patterns:
- [e.g., All inputs validated with Bean Validation]
- [e.g., All secrets via environment variables or Secrets Manager]
- 禁用模式:
- 禁止原生SQL字符串拼接(SQL注入——CWE-89)
- 禁止硬编码密钥或凭证(CWE-798)
- 禁止反序列化不可信数据(CWE-502)
- 必填模式:
- [例如:所有输入需通过Bean Validation验证]
- [例如:所有密钥通过环境变量或Secrets Manager管理]
AI Guardrails
AI Guardrails
Rules that AI agents MUST follow when generating code for this project:
- [Guardrail 1, e.g., "Never generate @Transactional on repository methods."]
- [Guardrail 2, e.g., "Always generate tests alongside implementation code."]
- [Guardrail 3, e.g., "Do not introduce new dependencies without explicit approval."]
AI Agent为该项目生成代码时必须遵循的规则:
- [规则1,例如:"禁止在仓库方法上生成@Transactional。"]
- [规则2,例如:"生成实现代码时必须同时生成测试代码。"]
- [规则3,例如:"未经明确批准不得引入新依赖。"]
Architecture Decisions
架构决策记录
Significant modifications to this architecture document must be tracked via ADR (Architecture Decision Records) using theskill.adr-draftingADR location:docs/architecture/adr/
---对本架构文档的重大修改必须通过技能以**ADR(Architecture Decision Records)**形式追踪记录。adr-draftingADR存储位置:docs/architecture/adr/
---Ontology Template
Ontology模板
markdown
undefinedmarkdown
undefinedProject Ontology — Ubiquitous Language
项目Ontology——Ubiquitous Language
Created: YYYY-MM-DD
Last Updated: YYYY-MM-DD
创建时间:YYYY-MM-DD
最后更新:YYYY-MM-DD
Domain Glossary
领域术语表
| Term | Definition | Bounded Context |
|---|---|---|
| [Term 1] | [Definition] | [Context where this term applies] |
| [Term 2] | [Definition] | [Context where this term applies] |
| 术语 | 定义 | 限界上下文 |
|---|---|---|
| [术语1] | [定义] | [该术语适用的上下文] |
| [术语2] | [定义] | [该术语适用的上下文] |
Bounded Contexts
限界上下文
| Context | Description | Key Terms |
|---|---|---|
| [Context 1] | [Description] | [Key terms] |
| 上下文 | 描述 | 核心术语 |
|---|---|---|
| [上下文1] | [描述] | [核心术语] |
Conceptual Mapping
概念映射
[Relationships between key domain entities — to be refined during brainstorming and task generation]
---[核心领域实体之间的关系——将在头脑风暴和任务生成阶段细化]
---Constitution Check Report Format
架构合规检查报告格式
undefinedundefinedConstitution Check Report
架构合规检查报告
Target: <file or spec path>
Date: YYYY-MM-DD
目标:<文件或规格说明路径>
日期:YYYY-MM-DD
Architecture Check
架构检查
| Rule | Status | Detail |
|---|---|---|
| Constructor injection required | ✅ OK | No field injection found |
| No hardcoded secrets | ❌ CRITICAL | Line 42: hardcoded password string |
| JWT authentication | ⚠️ WARNING | Missing @PreAuthorize on endpoint |
| 规则 | 状态 | 详情 |
|---|---|---|
| 必须使用构造函数注入 | ✅ 合规 | 未发现字段注入 |
| 禁止硬编码密钥 | ❌ 严重违规 | 第42行:存在硬编码密码字符串 |
| JWT认证 | ⚠️ 警告 | 端点缺少@PreAuthorize注解 |
Ontology Check
Ontology检查
| Term | Status | Detail |
|---|---|---|
| "Reservation" used consistently | ✅ OK | No synonym "Booking" found |
| New term "Voucher" introduced | ⚠️ WARNING | Not defined in ontology.md |
| 术语 | 状态 | 详情 |
|---|---|---|
| "Reservation"使用一致 | ✅ 合规 | 未发现同义词"Booking" |
| 引入新术语"Voucher" | ⚠️ 警告 | 未在ontology.md中定义 |
Summary
总结
- CRITICAL violations: 1 (must fix before proceeding)
- WARNING violations: 2 (should fix)
- Compliant rules: 2
---- 严重违规:1项(必须修复后才能继续)
- 警告:2项(建议修复)
- 合规规则:2项
---Relationship with brainstorm and spec-to-tasks
与brainstorm和spec-to-tasks的关系
This skill is the pre-brainstorm setup entry point. The same files are also created/enriched by:
| Command | When | What it does |
|---|---|---|
| Before brainstorm (this skill) | Creates architecture.md and/or ontology.md from scratch |
| During brainstorming | Creates/enriches ontology.md with terms extracted from the idea |
| After brainstorm | Creates architecture.md if missing; enriches ontology.md with new terms from the spec |
If you run before brainstorm, the brainstorm and spec-to-tasks commands will detect the existing files and load them instead of creating new ones — no duplication.
constitution createNote on ontology.md: The ontology is normally most naturally created during brainstorming, because domain terms emerge from the idea description. Using to seed it beforehand is useful when the team already has a well-defined domain language.
constitution create本技能是头脑风暴前的设置入口点。同一批文件也会通过以下命令创建/补充:
| 命令 | 时机 | 功能 |
|---|---|---|
| 头脑风暴前(本技能) | 从头创建architecture.md和/或ontology.md |
| 头脑风暴期间 | 从想法中提取术语,创建/补充ontology.md |
| 头脑风暴后 | 若缺失则创建architecture.md;从规格说明中提取新术语,补充ontology.md |
若你在头脑风暴前运行,brainstorm和spec-to-tasks命令会检测到已存在的文件并加载使用,而非创建新文件——不会重复生成。
constitution create关于ontology.md的说明:Ontology通常在头脑风暴期间自然创建,因为领域术语会从想法描述中浮现。当团队已有明确的领域语言时,使用提前初始化会很有用。
constitution createIntegration with SDD Workflow
与SDD工作流的集成
[Optional] constitution create ← this skill (pre-brainstorm setup)
↓
brainstorm ← enriches ontology.md (Phase 6.8.6)
↓
spec-to-tasks ← loads/creates architecture.md, enriches ontology.md (Phase 1.5)
↓
task-implementation ← AI guardrails from architecture.md prevent unapproved patterns
↓
task-review / ralph-loop ← constitution check validates implementation[可选] constitution create ← 本技能(头脑风暴前设置)
↓
brainstorm ← 补充ontology.md(第6.8.6阶段)
↓
spec-to-tasks ← 加载/创建architecture.md,补充ontology.md(第1.5阶段)
↓
task-implementation ← architecture.md中的AI guardrails防止使用未批准模式
↓
task-review / ralph-loop ← 架构合规检查验证实现是否符合要求Constraints
约束条件
- Does NOT modify source code — only creates/updates and
docs/specs/architecture.mddocs/specs/ontology.md - Constitution Check is advisory for WARNINGs — CRITICAL violations must be resolved
- One architecture.md and one ontology.md per project — shared across all specs
- Version the architecture — update date on every change; use ADRs for significant decisions
Last Updated
- 不会修改源代码——仅创建/更新和
docs/specs/architecture.mddocs/specs/ontology.md - 架构合规检查中的警告为建议性——严重违规必须解决
- 每个项目仅一份architecture.md和ontology.md——所有规格说明共享使用
- 版本化架构——每次更改时更新日期;重大决策使用ADR记录
Last Updated