sdd-init
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSDD Init Skill
SDD 初始化 Skill
Initialize Spec-Driven Development (SDD) in the current project. Detects tech stack, conventions, architecture patterns, and bootstraps all persistence backends (Constitution + Knowledge Graph).
在当前项目中初始化规范驱动开发(Spec-Driven Development,SDD)。检测技术栈、开发约定、架构模式,并引导所有持久化后端启动(Constitution + 知识图谱)。
When to Use
使用场景
Trigger phrases:
- "sdd-init", "init sdd", "setup sdd"
- "initialize sdd", "setup project", "initialize project context"
- "bootstrap sdd", "start sdd"
- "detect project stack", "detect tech stack"
触发短语:
- "sdd-init"、"init sdd"、"setup sdd"
- "initialize sdd"、"setup project"、"initialize project context"
- "bootstrap sdd"、"start sdd"
- "detect project stack"、"detect tech stack"
Workflow
工作流程
1. Detect Project Context
├── Scan tech stack (languages, frameworks, tools)
├── Identify conventions (folder structure, patterns, configs)
└── Detect architecture (monolith, microservices, serverless)
2. Bootstrap Constitution
├── Check if docs/specs/architecture.md exists
├── If missing → ask user to create with constitution skill
└── If exists → show current state
3. Bootstrap Knowledge Graph
├── Check if docs/specs/knowledge-graph.json exists
├── Create with initial discoveries (stack, patterns, conventions)
└── Link to Constitution
4. Return Structured Result
└── status, executive_summary, artifacts, next_recommended1. 检测项目上下文
├── 扫描技术栈(语言、框架、工具)
├── 识别开发约定(目录结构、设计模式、配置文件)
└── 检测架构类型(单体应用、微服务、无服务器)
2. 引导 Constitution 生成
├── 检查docs/specs/architecture.md是否存在
├── 若缺失 → 询问用户是否使用constitution skill创建
└── 若已存在 → 展示当前状态
3. 引导知识图谱生成
├── 检查docs/specs/knowledge-graph.json是否存在
├── 结合初始发现内容(技术栈、设计模式、开发约定)创建文件
└── 关联至Constitution
4. 返回结构化结果
└── status、executive_summary、artifacts、next_recommendedPhase 1: Detect Project Context
阶段1:检测项目上下文
1.1 Scan Tech Stack
1.1 扫描技术栈
Detect the primary language and framework:
bash
undefined检测主语言与框架:
bash
undefinedDetect language (priority order)
Detect language (priority order)
ls *.go *.rs *.ts *.js *.py *.java *.cs *.rb *.php *.cpp *.c 2>/dev/null | head -1
ls *.go *.rs *.ts *.js *.py *.java *.cs *.rb *.php *.cpp *.c 2>/dev/null | head -1
Detect framework/type
Detect framework/type
ls package.json pyproject.toml Cargo.toml go.mod pom.xml *.csproj Gemfile composer.json 2>/dev/null
ls package.json pyproject.toml Cargo.toml go.mod pom.xml *.csproj Gemfile composer.json 2>/dev/null
Detect project type
Detect project type
ls -la src/ lib/ app/ cmd/ internal/ pkg/ services/ 2>/dev/null
undefinedls -la src/ lib/ app/ cmd/ internal/ pkg/ services/ 2>/dev/null
undefined1.2 Identify Conventions
1.2 识别开发约定
Scan for existing patterns:
bash
undefined扫描现有设计模式:
bash
undefinedFolder structure
Folder structure
find . -maxdepth 2 -type d -name "src" -o -name "lib" -o -name "app" -o -name "cmd" | head -10
find . -maxdepth 2 -type d -name "src" -o -name "lib" -o -name "app" -o -name "cmd" | head -10
Config files
Config files
ls -la *.yaml *.yml *.toml *.json .env Makefile 2>/dev/null
ls -la *.yaml *.yml *.toml *.json .env Makefile 2>/dev/null
Testing patterns
Testing patterns
find . -name "_test." -o -name "test_.py" -o -name "_test.go" -o -name "*.spec.ts" 2>/dev/null | head -10
find . -name "_test." -o -name "test_.py" -o -name "_test.go" -o -name "*.spec.ts" 2>/dev/null | head -10
Build system
Build system
ls Makefile Dockerfile docker-compose*.yml *.mk 2>/dev/null
ls Makefile Dockerfile docker-compose*.yml *.mk 2>/dev/null
CI/CD
CI/CD
ls .github/workflows/ .gitlab-ci.yml .circleci/ 2>/dev/null
undefinedls .github/workflows/ .gitlab-ci.yml .circleci/ 2>/dev/null
undefined1.3 Detect Architecture Style
1.3 检测架构风格
Analyze project structure for architectural patterns:
bash
undefined分析项目结构以识别架构模式:
bash
undefinedMicroservices vs Monolith
Microservices vs Monolith
ls services/ microservices/ cmd/ api/ internal/ 2>/dev/null
ls services/ microservices/ cmd/ api/ internal/ 2>/dev/null
Serverless
Serverless
ls functions/ lambda/ handlers/ 2>/dev/null
ls functions/ lambda/ handlers/ 2>/dev/null
Layered architecture
Layered architecture
ls controllers/ services/ repositories/ models/ 2>/dev/null
ls controllers/ services/ repositories/ models/ 2>/dev/null
Hexagonal/Ports & Adapters
Hexagonal/Ports & Adapters
ls ports/ adapters/ domain/ infrastructure/ 2>/dev/null
undefinedls ports/ adapters/ domain/ infrastructure/ 2>/dev/null
undefinedPhase 2: Bootstrap Constitution
阶段2:引导 Constitution 生成
2.1 Check Existence
2.1 检查文件存在性
bash
undefinedbash
undefinedCheck if Constitution files exist
Check if Constitution files exist
[ -f docs/specs/architecture.md ] && echo "architecture:exists" || echo "architecture:missing"
[ -f docs/specs/ontology.md ] && echo "ontology:exists" || echo "ontology:missing"
undefined[ -f docs/specs/architecture.md ] && echo "architecture:exists" || echo "architecture:missing"
[ -f docs/specs/ontology.md ] && echo "ontology:exists" || echo "ontology:missing"
undefined2.2 If Missing → Ask User
2.2 若缺失 → 询问用户
Use to prompt:
AskUserQuestionThe Constitution files (architecture.md, ontology.md) don't exist yet.Option 1: Create both (Recommended) - Sets up architectural DNA and domain language Option 2: Create architecture.md only Option 3: Create ontology.md only
Option 4: Skip for now - I'll detect context but skip Constitution
If user chooses option 1-3, delegate to with the detected context.
/developer-kit-specs:constitution create使用提示:
AskUserQuestionConstitution文件(architecture.md、ontology.md)尚未存在。选项1:同时创建两者(推荐)- 搭建架构核心与领域语言规范 选项2:仅创建architecture.md 选项3:仅创建ontology.md 选项4:暂时跳过 - 仅检测上下文,不生成Constitution
若用户选择选项1-3,将任务委托给并传入检测到的上下文。
/developer-kit-specs:constitution create2.3 If Exists → Show Current State
2.3 若已存在 → 展示当前状态
Read and display current Constitution files with detected context as comparison.
读取并展示现有Constitution文件,同时对比检测到的上下文内容。
Phase 3: Bootstrap Knowledge Graph
阶段3:引导知识图谱生成
3.1 Check Existence
3.1 检查文件存在性
bash
undefinedbash
undefinedCheck if KG exists
Check if KG exists
ls docs/specs/knowledge-graph.json 2>/dev/null
undefinedls docs/specs/knowledge-graph.json 2>/dev/null
undefined3.2 Create/Update KG
3.2 创建/更新知识图谱
Create or update with initial discoveries:
docs/specs/knowledge-graph.jsonjson
{
"metadata": {
"spec_id": "project-init",
"version": "1.0.0",
"created": "{{ISO_DATE}}",
"project": "{{PROJECT_NAME}}",
"type": "initial-discovery"
},
"context": {
"workingDirectory": "{{PWD}}",
"projectName": "{{PROJECT_NAME}}"
},
"stack": {
"primaryLanguage": "{{DETECTED_LANGUAGE}}",
"framework": "{{DETECTED_FRAMEWORK}}",
"buildSystem": "{{DETECTED_BUILD_SYSTEM}}"
},
"conventions": {
"folderStructure": ["{{FOLDERS}}"],
"namingPatterns": ["{{PATTERNS}}"],
"configFiles": ["{{CONFIGS}}"],
"testingPattern": "{{TESTING_PATTERN}}"
},
"architecture": {
"style": "{{MONOLITH|MICROSERVICE|SERVERLESS|LAYERED|HEXAGONAL}}",
"layers": ["{{LAYERS}}"],
"patterns": ["{{ARCHITECTURAL_PATTERNS}}"]
},
"references": {
"constitution": "docs/specs/architecture.md",
"ontology": "docs/specs/ontology.md"
},
"source": "sdd-init"
}结合初始发现内容创建或更新:
docs/specs/knowledge-graph.jsonjson
{
"metadata": {
"spec_id": "project-init",
"version": "1.0.0",
"created": "{{ISO_DATE}}",
"project": "{{PROJECT_NAME}}",
"type": "initial-discovery"
},
"context": {
"workingDirectory": "{{PWD}}",
"projectName": "{{PROJECT_NAME}}"
},
"stack": {
"primaryLanguage": "{{DETECTED_LANGUAGE}}",
"framework": "{{DETECTED_FRAMEWORK}}",
"buildSystem": "{{DETECTED_BUILD_SYSTEM}}"
},
"conventions": {
"folderStructure": ["{{FOLDERS}}"],
"namingPatterns": ["{{PATTERNS}}"],
"configFiles": ["{{CONFIGS}}"],
"testingPattern": "{{TESTING_PATTERN}}"
},
"architecture": {
"style": "{{MONOLITH|MICROSERVICE|SERVERLESS|LAYERED|HEXAGONAL}}",
"layers": ["{{LAYERS}}"],
"patterns": ["{{ARCHITECTURAL_PATTERNS}}"]
},
"references": {
"constitution": "docs/specs/architecture.md",
"ontology": "docs/specs/ontology.md"
},
"source": "sdd-init"
}3.3 Validation
3.3 验证
After creating KG, validate it exists and has valid JSON:
bash
undefined创建知识图谱后,验证文件是否存在且JSON格式有效:
bash
undefinedValidate KG
Validate KG
cat docs/specs/knowledge-graph.json | python3 -m json.tool > /dev/null && echo "KG:valid" || echo "KG:invalid"
undefinedcat docs/specs/knowledge-graph.json | python3 -m json.tool > /dev/null && echo "KG:valid" || echo "KG:invalid"
undefinedPhase 4: Return Structured Result
阶段4:返回结构化结果
Return a JSON object with:
json
{
"status": "success|partial|skipped",
"executive_summary": "Brief description of what was detected and initialized",
"artifacts": [
{
"path": "docs/specs/architecture.md",
"action": "created|existing|skipped",
"summary": "What this file contains"
},
{
"path": "docs/specs/ontology.md",
"action": "created|existing|skipped",
"summary": "What this file contains"
},
{
"path": "docs/specs/knowledge-graph.json",
"action": "created|updated",
"summary": "What was discovered and stored"
}
],
"next_recommended": [
"Review Constitution if just created",
"Run brainstorm to start first spec",
"Check knowledge-graph.json for detected patterns"
]
}返回如下JSON对象:
json
{
"status": "success|partial|skipped",
"executive_summary": "Brief description of what was detected and initialized",
"artifacts": [
{
"path": "docs/specs/architecture.md",
"action": "created|existing|skipped",
"summary": "What this file contains"
},
{
"path": "docs/specs/ontology.md",
"action": "created|existing|skipped",
"summary": "What this file contains"
},
{
"path": "docs/specs/knowledge-graph.json",
"action": "created|updated",
"summary": "What was discovered and stored"
}
],
"next_recommended": [
"Review Constitution if just created",
"Run brainstorm to start first spec",
"Check knowledge-graph.json for detected patterns"
]
}Output Format
输出格式
Display result in a structured format:
══════════════════════════════════════════════════
SDD Init — {{PROJECT_NAME}}
══════════════════════════════════════════════════
STATUS: {{status}}
TECH STACK DETECTED:
Language: {{language}}
Framework: {{framework}}
Build: {{build_system}}
ARCHITECTURE:
Style: {{architecture_style}}
Patterns: {{patterns}}
ARTIFACTS:
✓ Constitution (architecture.md) — {{status}}
✓ Constitution (ontology.md) — {{status}}
✓ Knowledge Graph — {{status}}
NEXT STEPS:
{{next_recommended}}
══════════════════════════════════════════════════以结构化格式展示结果:
══════════════════════════════════════════════════
SDD Init — {{PROJECT_NAME}}
══════════════════════════════════════════════════
STATUS: {{status}}
TECH STACK DETECTED:
Language: {{language}}
Framework: {{framework}}
Build: {{build_system}}
ARCHITECTURE:
Style: {{architecture_style}}
Patterns: {{patterns}}
ARTIFACTS:
✓ Constitution (architecture.md) — {{status}}
✓ Constitution (ontology.md) — {{status}}
✓ Knowledge Graph — {{status}}
NEXT STEPS:
{{next_recommended}}
══════════════════════════════════════════════════Integration with Other Skills
与其他Skill的集成
| Skill | Integration Point |
|---|---|
| Created/updated by sdd-init if missing |
| Populated by sdd-init with initial discoveries |
| Should read Constitution before starting |
| Should validate against KG and Constitution |
| Should check KG for existing patterns |
| Skill | 集成点 |
|---|---|
| 若文件缺失,由sdd-init创建/更新 |
| 由sdd-init填充初始发现内容 |
| 启动前应读取Constitution |
| 应基于KG与Constitution进行验证 |
| 应检查KG中的现有设计模式 |
Constraints and Warnings
约束与警告
- Read-only detection — Does NOT modify source code
- Non-destructive — Only creates new files, never overwrites existing content
- Permission check — Warn if docs/specs/ cannot be created
- Backup KG — If updating existing KG, preserve existing data
- 只读检测 — 不会修改源代码
- 非破坏性 — 仅创建新文件,绝不覆盖现有内容
- 权限检查 — 若无法创建docs/specs/目录则发出警告
- 备份KG — 若更新现有KG,需保留原有数据
Error Handling
错误处理
| Error | Recovery |
|---|---|
| Cannot create docs/specs/ | Ask user to create directory manually |
| KG JSON invalid | Show error, keep raw file, suggest validation |
| Constitution delegate fails | Fall back to inline creation with template |
| 错误 | 恢复方案 |
|---|---|
| 无法创建docs/specs/目录 | 提示用户手动创建目录 |
| KG的JSON格式无效 | 显示错误信息,保留原始文件,建议进行验证 |
| Constitution委托任务失败 | 回退至使用模板进行内联创建 |