project-initializer
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseProject Initializer
项目初始化工具
A skill for scaffolding new projects with consistent README.md, AGENTS.md, and CI/CD pipelines — all wired together with an SDD (Spec-Driven Development) framework.
一款用于快速搭建新项目的技能,可生成格式统一的README.md、AGENTS.md文件及CI/CD流水线,并与SDD(规范驱动开发)框架深度集成。
Overview
概述
The skill does five things:
- Interview — Understand the project's goals, tech stack, coding standards, quality requirements, CI platform(s), and preferred SDD workflow.
- Generate — Create README.md, AGENTS.md, and CI pipeline file(s) from templates.
- Integrate — Install SDD framework tools and initialize project structure; wire coding standards and quality checks into the CI pipeline.
- Tag — Embed a machine-readable project identity tag in AGENTS.md so server-side CI can verify the project was properly initialized.
- Verify consistency — Make sure all generated files agree with each other (same tech stack, same quality gates, same SDD expectations).
本技能主要完成五项核心工作:
- 需求访谈 — 了解项目目标、技术栈、编码规范、质量要求、CI平台偏好及SDD工作流。
- 文件生成 — 基于模板创建README.md、AGENTS.md及CI流水线配置文件。
- 框架集成 — 安装SDD框架工具并初始化项目结构,将编码规范与质量检查逻辑接入CI流水线。
- 身份标记 — 在AGENTS.md中嵌入机器可读的项目身份标签,供服务端CI验证项目是否完成合规初始化。
- 一致性校验 — 确保所有生成文件的信息一致(如技术栈、质量门槛、SDD预期等)。
Phase 1: Interview
第一阶段:需求访谈
使用 与用户进行访谈,了解项目情况。逐个问题与用户交互 — 不要跳过问题或代表用户做出决定。在进入第2阶段(文件生成)前,总结他们的答案并确认理解。
AskUserQuestion根据已有的上下文信息,可以一次性提出所有问题,也可以在自然对话中分散提问 — 根据情况自行判断。
必需信息:
对于以下每个问题,使用 与用户交互式提问。不要跳过问题,不要代替用户做决定。当提供建议或默认值时,请通过 确认用户同意后再继续。
AskUserQuestionAskUserQuestion-
项目名称和一句话描述 — 使用。这个项目是什么?它解决了什么问题?
AskUserQuestion -
项目类型 — 使用确认项目属于哪一类,以便在 Phase 2 执行对应的初始化流程(见下方「按项目类型生成」):
AskUserQuestion- 通用 — 仅生成 README、AGENTS.md、CI 与 SDD,不生成框架骨架
- Flask 后端 — 在本技能内直接生成 Flask API 项目骨架(应用工厂、Blueprint、Service/Model 分层、uv、测试等),参考 与
references/flask-backend.mdassets/flask-backend/ - React 前端 — 在本技能内直接生成 React 前端骨架(Vite + Rolldown、React + TypeScript、Ant Design、Vitest、目录与配置等),见下方「React 前端初始化」
- Taro 小程序 — 在本技能内按 Taro 官方 CLI 初始化、目录、代理、README/AGENTS,见下方「Taro 小程序初始化」
- 其他 — 仅通用文件 选择后,Phase 2 在生成通用文件之外,按类型执行对应骨架生成,不引用、不调用任何独立 init-* 技能。
-
技术栈 — 编程语言、框架、包管理工具、数据库、部署目标等。使用提示用户。用户表示不确定或要求建议时,根据问题领域提供合理的默认值 — 但通过
AskUserQuestion获得用户确认后再继续。AskUserQuestion -
质量等级 — 使用提问:这是演示/原型项目还是生产项目?
AskUserQuestion- 演示:最小化CI、无覆盖率门槛、无安全扫描、轻量级SDD
- 生产:完整CI、覆盖率门槛、安全扫描、严格的SDD对齐检查
-
SDD框架 — 使用展示所有三个选项,询问团队将使用哪一个。包括下面的描述以帮助他们做出决定。
AskUserQuestion框架 风格 适用于 OpenSpec 流畅、棕地优先、增量规范 现有代码库、个人开发者、迭代工作 SpecKit 宪法强制、分阶段 团队、企业、严格的质量标准 GSD 基于阶段的路线图、上下文工程 想让AI做主力工作的个人开发者 选择后,阅读相应的参考文件了解更多细节:- OpenSpec →
references/openspec.md - SpecKit →
references/speckit.md - GSD →
references/gsd.md
- OpenSpec →
-
CI平台 — 使用提问:应该配置哪些CI系统?
AskUserQuestion- GitLab CI — 生成
.gitlab-ci.yml - GitHub Actions — 生成
.github/workflows/ci.yml - 两者 — 生成两个文件,保持一致
- GitLab CI — 生成
-
主分支名称 — 使用提问哪个分支会触发发布流程。建议用
AskUserQuestion作为默认值,但要向用户确认。main -
编码规范 — 使用提问:团队是否有现有的编码规范、风格指南或代码检查配置?
AskUserQuestion- 直接粘贴内容 — 用户将规范粘贴到对话中
- 文件路径 — 用户提供现有文件的路径(如 、
docs/coding-standards.md).eslintrc.json - 无 — 如果没有,使用技术栈的合理默认值
如果提供了规范,请阅读并总结。规范将被注入到AGENTS.md中,并用于配置CI代码检查命令。 -
额外质量要求(生产项目)— 使用提问:
AskUserQuestion- 最小测试覆盖率百分比(如 80%)
- 静态分析工具(如 ESLint、Pylint、SonarQube)— 可能已被编码规范涵盖
- 安全扫描(Trivy、Semgrep、Bandit等)
-
文档语言 — 使用提问:README.md和AGENTS.md应该用什么语言编写?默认为中文(中文),除非用户指定其他语言。
AskUserQuestion -
Python + GitLab CI 规范(仅当技术栈含 Python 且选择了 GitLab CI 时)— 使用询问:是否采用 backend-python-cicd 规范?若选是,则生成/校验
AskUserQuestion、Dockerfile、部署脚本时须遵循本技能.gitlab-ci.yml与references/backend-python-cicd.md(私有镜像源、多阶段构建、分支 develop/bugfix/hotfix/master、dev→prod K8s 部署、先本地 Docker 构建再 Git 推送)。assets/backend-python-cicd/ -
QA/测试规范 — 使用询问:是否在 AGENTS.md 中引用 QA/测试规范(测试计划、用例、自动化与报告、缺陷根因分析)?若选是,在 AGENTS 中增加「测试与根因分析」说明或引用本技能
AskUserQuestion。references/qa-testing.md -
多角色/子代理 — 使用询问:是否需要 多角色规划与子代理(.cursor/agents/*.md)?若选是,在 Phase 2 后按本技能
AskUserQuestion与references/agent-roles.md执行角色规划与子代理文件生成。assets/agent-roles/
使用 与用户进行访谈,了解项目情况。逐个问题与用户交互 — 不要跳过问题或代表用户做出决定。在进入第2阶段(文件生成)前,总结他们的答案并确认理解。
AskUserQuestion根据已有的上下文信息,可以一次性提出所有问题,也可以在自然对话中分散提问 — 根据情况自行判断。
必需信息:
对于以下每个问题,使用 与用户交互式提问。不要跳过问题,不要代替用户做决定。当提供建议或默认值时,请通过 确认用户同意后再继续。
AskUserQuestionAskUserQuestion-
项目名称和一句话描述 — 使用。这个项目是什么?它解决了什么问题?
AskUserQuestion -
项目类型 — 使用确认项目属于哪一类,以便在第二阶段执行对应的初始化流程(见下方「按项目类型生成」):
AskUserQuestion- 通用 — 仅生成 README、AGENTS.md、CI 与 SDD 相关文件,不生成框架骨架
- Flask 后端 — 在本技能内直接生成 Flask API 项目骨架(应用工厂、Blueprint、Service/Model 分层、uv、测试等),参考 与
references/flask-backend.mdassets/flask-backend/ - React 前端 — 在本技能内直接生成 React 前端骨架(Vite + Rolldown、React + TypeScript、Ant Design、Vitest、目录与配置等),见下方「React 前端初始化」
- Taro 小程序 — 在本技能内按 Taro 官方 CLI 初始化、目录、代理、README/AGENTS,见下方「Taro 小程序初始化」
- 其他 — 仅生成通用文件 选择后,第二阶段在生成通用文件之外,按类型执行对应骨架生成,不引用、不调用任何独立 init-* 技能。
-
技术栈 — 编程语言、框架、包管理工具、数据库、部署目标等。使用提示用户。用户表示不确定或要求建议时,根据问题领域提供合理的默认值 — 但通过
AskUserQuestion获得用户确认后再继续。AskUserQuestion -
质量等级 — 使用提问:这是演示/原型项目还是生产项目?
AskUserQuestion- 演示:最小化CI配置、无覆盖率门槛、无安全扫描、轻量级SDD
- 生产:完整CI流程、覆盖率门槛、安全扫描、严格的SDD对齐检查
-
SDD框架 — 使用展示所有三个选项,询问团队将使用哪一个。包括下面的描述以帮助他们做出决定。
AskUserQuestion框架 风格 适用于 OpenSpec 流畅、棕地优先、增量规范 现有代码库、个人开发者、迭代工作 SpecKit 强制约束、分阶段推进 团队、企业、严格的质量标准 GSD 基于阶段的路线图、上下文工程 希望让AI主导开发工作的个人开发者 选择后,阅读相应的参考文件了解更多细节:- OpenSpec →
references/openspec.md - SpecKit →
references/speckit.md - GSD →
references/gsd.md
- OpenSpec →
-
CI平台 — 使用提问:应该配置哪些CI系统?
AskUserQuestion- GitLab CI — 生成
.gitlab-ci.yml - GitHub Actions — 生成
.github/workflows/ci.yml - 两者 — 生成两个文件,保持配置一致
- GitLab CI — 生成
-
主分支名称 — 使用提问哪个分支会触发发布流程。建议用
AskUserQuestion作为默认值,但要向用户确认。main -
编码规范 — 使用提问:团队是否有现有的编码规范、风格指南或代码检查配置?
AskUserQuestion- 直接粘贴内容 — 用户将规范粘贴到对话中
- 文件路径 — 用户提供现有文件的路径(如 、
docs/coding-standards.md).eslintrc.json - 无 — 如果没有,使用技术栈的合理默认值
如果提供了规范,请阅读并总结。规范将被注入到AGENTS.md中,并用于配置CI代码检查命令。 -
额外质量要求(生产项目)— 使用提问:
AskUserQuestion- 最小测试覆盖率百分比(如 80%)
- 静态分析工具(如 ESLint、Pylint、SonarQube)— 可能已被编码规范涵盖
- 安全扫描(Trivy、Semgrep、Bandit等)
-
文档语言 — 使用提问:README.md和AGENTS.md应该用什么语言编写?默认为中文,除非用户指定其他语言。
AskUserQuestion -
Python + GitLab CI 规范(仅当技术栈含 Python 且选择了 GitLab CI 时)— 使用询问:是否采用 backend-python-cicd 规范?若选是,则生成/校验
AskUserQuestion、Dockerfile、部署脚本时须遵循本技能.gitlab-ci.yml与references/backend-python-cicd.md(私有镜像源、多阶段构建、分支 develop/bugfix/hotfix/master、dev→prod K8s 部署、先本地 Docker 构建再 Git 推送)。assets/backend-python-cicd/ -
QA/测试规范 — 使用询问:是否在 AGENTS.md 中引用 QA/测试规范(测试计划、用例、自动化与报告、缺陷根因分析)?若选是,在 AGENTS 中增加「测试与根因分析」说明或引用本技能
AskUserQuestion。references/qa-testing.md -
多角色/子代理 — 使用询问:是否需要 多角色规划与子代理(.cursor/agents/*.md)?若选是,在第二阶段后按本技能
AskUserQuestion与references/agent-roles.md执行角色规划与子代理文件生成。assets/agent-roles/
Phase 2: File Generation
第二阶段:文件生成
CRITICAL — Template Fidelity: Reproduce every CI pipeline template verbatim. Substitute only thetokens. Do not remove, merge, rename, or omit any stages, jobs, or comment blocks. The complete job set in each template is the minimum viable pipeline; dropping any job will break SDD checks, project-tag validation, or coverage gates. For demo projects, dial down strictness through placeholder values (e.g., set{{PLACEHOLDER}}to{{COVERAGE_THRESHOLD}},0to{{SECURITY_SCAN_CMD}}) — never by removing jobs.echo "skipped"
After gathering information, generate files. Use the templates in as starting points and fill in the placeholders.
assets/templates/Path resolution — read this before running any script:
= the directory that contains this SKILL.md file (e.g.<skill_dir>). All script paths below are relative to.agents/skills/project-initializer.<skill_dir> = the root of the project being initialized — pass<project_root>if you are already inside it, or the absolute path if not. Never pass a path outside the project the user is working on..
File locations:
- — project root
README.md - — project root
AGENTS.md - — project root (if GitLab CI selected)
.gitlab-ci.yml - — project root (if GitHub Actions selected)
.github/workflows/ci.yml
Placeholder convention used in templates:
{{VARIABLE_NAME}}After creating all files, do a consistency pass:
- The tech stack in README.md must match AGENTS.md and the CI environment images
- Quality gates in CI files must reflect what's specified in AGENTS.md
- The SDD check script path must match the framework chosen
- Both CI files (if both selected) must use the same quality thresholds, check scripts, and branch names
关键要求 — 模板保真度: 严格完整地复现每个CI流水线模板,仅替换标记。禁止删除、合并、重命名或省略任何阶段、任务或注释块。每个模板中的完整任务集是最小可行流水线;删除任何任务都会破坏SDD检查、项目标记验证或覆盖率门槛。对于演示项目,可通过占位符值降低严格性(例如将{{PLACEHOLDER}}设置为{{COVERAGE_THRESHOLD}},0设置为{{SECURITY_SCAN_CMD}})—— 绝不要通过删除任务来实现。echo "skipped"
收集完信息后,生成文件。以 中的模板为起点,填充占位符。
assets/templates/路径解析 — 运行脚本前请阅读:
= 包含本SKILL.md文件的目录(例如<skill_dir>)。以下所有脚本路径均相对于.agents/skills/project-initializer。<skill_dir> = 待初始化项目的根目录 — 若已在项目目录内则传入<project_root>,否则传入绝对路径。绝不要传入用户当前工作项目之外的路径。.
文件位置:
- — 项目根目录
README.md - — 项目根目录
AGENTS.md - — 项目根目录(若选择GitLab CI)
.gitlab-ci.yml - — 项目根目录(若选择GitHub Actions)
.github/workflows/ci.yml
模板中使用的占位符约定:
{{VARIABLE_NAME}}创建所有文件后،执行一致性检查:
- README.md中的技术栈必须与AGENTS.md和CI环境镜像一致
- CI文件中的质量门槛必须与AGENTS.md中指定的一致
- SDD检查脚本路径必须与所选框架匹配
- 若同时生成了两个CI文件,必须使用相同的质量阈值、检查脚本和分支名称
README.md
README.md
Read . Fill in:
assets/templates/README.template.md- — project name
{{PROJECT_NAME}} - — one-paragraph description
{{PROJECT_DESCRIPTION}} - — bulleted list of stack components
{{TECH_STACK_LIST}} - — name of chosen SDD framework
{{SDD_FRAMEWORK}} - — where SDD documents live (see framework reference)
{{SDD_DOCS_PATH}} - — installation and run steps appropriate for the tech stack
{{GETTING_STARTED_STEPS}}
Language: Generate this file in the language chosen in Phase 1 (default: Chinese/中文).
读取 ,填充以下内容:
assets/templates/README.template.md- — 项目名称
{{PROJECT_NAME}} - — 一段描述文字
{{PROJECT_DESCRIPTION}} - — 技术栈组件的无序列表
{{TECH_STACK_LIST}} - — 所选SDD框架的名称
{{SDD_FRAMEWORK}} - — SDD文档的存放位置(见框架参考文件)
{{SDD_DOCS_PATH}} - — 适合该技术栈的安装与运行步骤
{{GETTING_STARTED_STEPS}}
语言:按第一阶段选择的语言生成(默认:中文)。
AGENTS.md
AGENTS.md
Read . Fill in:
assets/templates/AGENTS.template.md- — project name
{{PROJECT_NAME}} - — concise single-sentence summary
{{PROJECT_DESCRIPTION}} - — structured tech stack list with versions if known
{{TECH_STACK_DETAILS}} - — framework display name (e.g., "OpenSpec")
{{SDD_FRAMEWORK}} - — framework lowercase id:
{{SDD_FRAMEWORK_ID}},openspec, orspeckitgsd - — 3-5 bullet points describing the team's SDD workflow from the reference doc
{{SDD_WORKFLOW_SUMMARY}} - — "demo" or "production" (display)
{{QUALITY_LEVEL}} - — "demo" or "production" (machine-readable, same as display)
{{QUALITY_LEVEL_ID}} - —
{{CI_PLATFORMS_ID}},gitlab, orgithub(no spaces)gitlab,github - — number (e.g., "80") or "N/A" for demo
{{COVERAGE_THRESHOLD}} - — linter/formatter names (from coding standards or tech stack defaults)
{{LINT_TOOL}} - — security scan tools or "N/A"
{{SECURITY_TOOLS}} - — the git commit ignore tag reference for the chosen framework (see reference docs)
{{IGNORE_TAG_DOCS}} - — see Coding Standards Composition section above
{{CODING_STANDARDS_SUMMARY}} - — today's date in
{{INITIALIZED_DATE}}formatYYYY-MM-DD - — release branch name
{{MAIN_BRANCH}}
Language: Generate this file in the language chosen in Phase 1 (default: Chinese/中文).
Important: AGENTS.md is a living document. Keep it minimal at creation time. Agents should append to it during development but never remove existing entries. The initial version is just the skeleton — it will grow.
读取 ,填充以下内容:
assets/templates/AGENTS.template.md- — 项目名称
{{PROJECT_NAME}} - — 简洁的一句话摘要
{{PROJECT_DESCRIPTION}} - — 结构化的技术栈列表(若已知版本则包含版本信息)
{{TECH_STACK_DETAILS}} - — 框架显示名称(例如 "OpenSpec")
{{SDD_FRAMEWORK}} - — 框架小写ID:
{{SDD_FRAMEWORK_ID}}、openspec或speckitgsd - — 3-5个要点,描述团队的SDD工作流(来自参考文档)
{{SDD_WORKFLOW_SUMMARY}} - — "demo" 或 "production"(显示用)
{{QUALITY_LEVEL}} - — "demo" 或 "production"(机器可读,与显示值相同)
{{QUALITY_LEVEL_ID}} - —
{{CI_PLATFORMS_ID}}、gitlab或github(无空格)gitlab,github - — 数字(例如 "80"),演示项目填 "N/A"
{{COVERAGE_THRESHOLD}} - — 代码检查/格式化工具名称(来自编码规范或技术栈默认值)
{{LINT_TOOL}} - — 安全扫描工具或 "N/A"
{{SECURITY_TOOLS}} - — 所选框架的Git提交忽略标签参考(见参考文档)
{{IGNORE_TAG_DOCS}} - — 见上方「编码规范整合」部分
{{CODING_STANDARDS_SUMMARY}} - — 当前日期,格式为
{{INITIALIZED_DATE}}YYYY-MM-DD - — 发布分支名称
{{MAIN_BRANCH}}
语言:按第一阶段选择的语言生成(默认:中文)。
重要提示:AGENTS.md是一份动态文档。创建时保持简洁即可,开发过程中Agent可向其中追加内容,但绝不要删除现有条目。初始版本仅为骨架 — 后续会逐步完善。
Coding Standards Composition
编码规范整合
If the user provided coding standards:
- Read the content (from the pasted text or the file path).
- Extract the key rules relevant to: naming conventions, file structure, formatting, forbidden patterns, and required patterns.
- Summarize them into the section of AGENTS.md (concise bullet-point form — the full doc lives separately).
## Coding Standards - If the standards specify a linter/formatter config, reference it in the for CI (e.g.,
{{LINT_CMD}},eslint --config .eslintrc.json).ruff check --config pyproject.toml - If the user provided a file path, also add a reference to that file in AGENTS.md so agents know where the canonical source is.
If no standards were provided, write a minimal placeholder in the Coding Standards section appropriate for the tech stack (e.g., "Follow PEP 8" for Python, "Follow Airbnb JavaScript Style Guide" for JS).
若用户提供了编码规范:
- 读取内容(来自粘贴文本或文件路径)。
- 提取与命名约定、文件结构、格式要求、禁用模式、强制模式相关的关键规则。
- 将其总结为AGENTS.md中「## 编码规范」部分的简洁要点列表 — 完整文档存放在别处。
- 若规范指定了代码检查/格式化工具配置,在CI的中引用(例如
{{LINT_CMD}}、eslint --config .eslintrc.json)。ruff check --config pyproject.toml - 若用户提供了文件路径,在AGENTS.md中添加该文件的引用,以便Agent知道规范的权威来源。
若未提供规范,则为该技术栈编写最小化的占位内容(例如Python项目写「遵循PEP 8规范」,JS项目写「遵循Airbnb JavaScript风格指南」)。
按项目类型生成(Flask 后端 / React 前端 / Taro 小程序)
按项目类型生成(Flask 后端 / React 前端 / Taro 小程序)
以下流程内置于本技能,不调用、不引用任何独立 init-* 技能。
以下流程内置于本技能,不调用、不引用任何独立 init-* 技能。
当项目类型 = Flask 后端
当项目类型 = Flask 后端
在生成 README、AGENTS、CI 等通用文件之后,在 下按本技能 与 生成完整 Flask API 骨架。
<project_root>references/flask-backend.mdassets/flask-backend/-
目录结构
按创建目录树:assets/flask-backend/project-structure.txt(含app/、__init__.py、config.py)、extensions.py(app/routes/及至少一个业务模块如main_api.py)、user_api.py、app/models/、app/service/、app/schemas/(含app/utils/)、可选api_util.py、app/permission/(含tests/)、conftest.py、scripts/或docs/,根目录context/、.env.example。pyproject.toml -
核心文件要点
- app/init.py:应用工厂;初始化扩展、加载配置、注册 Blueprint(可调用
create_app(config_name));注册register_all_blueprints(app)/before_request/after_request/teardown_request及全局teardown_appcontext。可参考errorhandler。assets/flask-backend/create_app_snippet.py - app/config.py:按环境(development/test/production)加载配置,敏感项从环境变量读取。
- app/extensions.py:集中定义 Flask-SQLAlchemy、Redis、JWT、Casbin 等扩展实例(在 create_app 中 init_app)。
- app/utils/api_util.py:统一响应格式(如 、
AppResponse)、自定义 Api、统一异常处理。{code, message, data} - app/routes/main_api.py:健康检查等通用接口;Blueprint 命名与 约定一致,导出
*_api.py(如*_app)供自动注册。main_app - 业务路由:至少一个示例模块(如 ),Blueprint + Api,Resource 仅做「解析参数 → 调 Service → 返回 AppResponse/字典」。
user_api.py - register_all_blueprints:扫描 下
app/routes,导出变量名为文件名去*_api.py加_api,实现见_app。create_app_snippet.py
- app/init.py:
-
依赖与配置
- 使用 uv:以 +
pyproject.toml为准;参考uv.lock填写依赖(flask、flask-restful、flask-sqlalchemy、python-dotenv、pytest 等)。assets/flask-backend/pyproject-uv.example.toml - 参考
.env.example。assets/flask-backend/env-example.txt - README 中可纳入或引用「用户如何使用 uv」:见 。
assets/flask-backend/uv-usage.md
- 使用 uv:以
-
交付物
完整目录与占位;__init__.py(create_app + register_all_blueprints + 钩子);app/__init__.py、app/config.py;app/extensions.py;app/utils/api_util.py及至少一个业务模块示例;占位或示例的app/routes/main_api.py、app/models/、app/service/;app/schemas/、.env.example;pyproject.toml及至少一个 API 测试示例。可选:tests/conftest.py可从本技能复制为scripts/validate_flask_structure.py供用户校验结构。scripts/validate_flask_structure.py -
与通用 Phase 2 的衔接
若选择了 CI,/ GitHub Actions 中的.gitlab-ci.yml、{{DOCKER_IMAGE}}等按 Python/Flask 填写(如{{INSTALL_CMD}}、uv sync)。README 的uv run pytest写入 uv 安装与{{GETTING_STARTED_STEPS}}、uv sync等步骤。uv run flask run
后续开发:在 AGENTS 或开发约定中注明「新增 API/资源时按本技能与references/flask-backend-codegen.md(路由、Service、Model、Schema、权限、测试、.env.example)」。assets/flask-backend-codegen/
在生成 README、AGENTS、CI 等通用文件之后,在 下按本技能 与 生成完整 Flask API 骨架。
<project_root>references/flask-backend.mdassets/flask-backend/-
目录结构
按创建目录树:assets/flask-backend/project-structure.txt(含app/、__init__.py、config.py)、extensions.py(app/routes/及至少一个业务模块如main_api.py)、user_api.py、app/models/、app/service/、app/schemas/(含app/utils/)、可选api_util.py、app/permission/(含tests/)、conftest.py、scripts/或docs/,根目录context/、.env.example。pyproject.toml -
核心文件要点
- app/init.py:应用工厂;初始化扩展、加载配置、注册 Blueprint(可调用
create_app(config_name));注册register_all_blueprints(app)/before_request/after_request/teardown_request及全局teardown_appcontext。可参考errorhandler。assets/flask-backend/create_app_snippet.py - app/config.py:按环境(development/test/production)加载配置,敏感项从环境变量读取。
- app/extensions.py:集中定义 Flask-SQLAlchemy、Redis、JWT、Casbin 等扩展实例(在 create_app 中 init_app)。
- app/utils/api_util.py:统一响应格式(如 、
AppResponse)、自定义 Api、统一异常处理。{code, message, data} - app/routes/main_api.py:健康检查等通用接口;Blueprint 命名与 约定一致,导出
*_api.py(如*_app)供自动注册。main_app - 业务路由:至少一个示例模块(如 ),Blueprint + Api,Resource 仅做「解析参数 → 调 Service → 返回 AppResponse/字典」。
user_api.py - register_all_blueprints:扫描 下
app/routes,导出变量名为文件名去*_api.py加_api,实现见_app。create_app_snippet.py
- app/init.py:
-
依赖与配置
- 使用 uv:以 +
pyproject.toml为准;参考uv.lock填写依赖(flask、flask-restful、flask-sqlalchemy、python-dotenv、pytest 等)。assets/flask-backend/pyproject-uv.example.toml - 参考
.env.example。assets/flask-backend/env-example.txt - README 中可纳入或引用「用户如何使用 uv」:见 。
assets/flask-backend/uv-usage.md
- 使用 uv:以
-
交付物
完整目录与占位;__init__.py(create_app + register_all_blueprints + 钩子);app/__init__.py、app/config.py;app/extensions.py;app/utils/api_util.py及至少一个业务模块示例;占位或示例的app/routes/main_api.py、app/models/、app/service/;app/schemas/、.env.example;pyproject.toml及至少一个 API 测试示例。可选:tests/conftest.py可从本技能复制为scripts/validate_flask_structure.py供用户校验结构。scripts/validate_flask_structure.py -
与通用第二阶段的衔接
若选择了 CI,/ GitHub Actions 中的.gitlab-ci.yml、{{DOCKER_IMAGE}}等按 Python/Flask 填写(如{{INSTALL_CMD}}、uv sync)。README 的uv run pytest写入 uv 安装与{{GETTING_STARTED_STEPS}}、uv sync等步骤。uv run flask run
后续开发:在 AGENTS 或开发约定中注明「新增 API/资源时按本技能与references/flask-backend-codegen.md(路由、Service、Model、Schema、权限、测试、.env.example)」。assets/flask-backend-codegen/
当项目类型 = React 前端
当项目类型 = React 前端
在生成通用文件之后,在 下生成 React 前端骨架;不调用外部 init-react-frontend 技能。
<project_root>-
脚手架
使用官方 Vite 创建项目:在目标目录执行(或当前 create-vite 支持时选择 Rolldown、React、TypeScript)。若未提供 Rolldown 选项,则在生成npm create vite@latest <project-name> -- --template react-ts时在 devDependencies 中设置package.json,并在 Vite 配置中启用 React Compiler。"vite": "npm:rolldown-vite@<resolved-latest-version>" -
默认技术栈
React、React Compiler(在 Vite 中启用)、TypeScript、Ant Design、react-router-dom、Zustand、Vitest + jsdom、Tailwind CSS、Axios、Vite(Rolldown)。依赖版本在生成时解析为当时最新稳定版,并写入精确版本(不用package.json/^)。~ -
目录结构
在下创建:src/、src/utils/、src/consts/(路由配置,与 consts 分离)、src/route/、src/components/、src/pages/、src/store/或src/api/;以及src/services/或test/(Vitest 全局 setup、fixtures、mocks)。单元测试可放在源码旁src/test/。**/*.test.{ts,tsx} -
文件清单
- :scripts(dev、build、preview、test);依赖为解析后的精确版本;Vite 使用 Rolldown 时 devDependencies 中
package.json。"vite": "npm:rolldown-vite@<version>" - :React 插件、React Compiler、path alias(如
vite.config.ts→@/)、build 输出;dev proxy:src/将server.proxy等转发到后端,默认 target 端口 5000。/api - /
tsconfig.json、tsconfig.node.json+tailwind.config.js、postcss.config.js(入口为index.html)。src/main.tsx - :React 根入口、Ant Design 样式、mount。
src/main.tsx - :BrowserRouter 与最小路由列表。
src/App.tsx - 、
src/utils/、src/consts/、src/route/、src/components/、src/pages/、src/store/或src/api/的占位或示例。src/services/ - :Vitest + jsdom,匹配
vitest.config.ts。**/*.test.{ts,tsx} - 至少一个示例测试 。
src/**/*.test.tsx - (Node、dist、env、IDE)。
.gitignore - AGENTS.md:使用本技能模板 填充
assets/templates/AGENTS.react.template.md、{{PROJECT_NAME}}、{{PROJECT_DESCRIPTION}}、{{TECH_STACK_TABLE}}、{{DIR_STRUCTURE}}、{{SCRIPTS}};语言与项目约定一致(默认中文)。{{INITIALIZED_DATE}}
-
与通用 Phase 2 的衔接
若选择了 CI,CI 中的为{{INSTALL_CMD}},npm ci为{{TEST_CMD}}等。README 的npm run test写入{{GETTING_STARTED_STEPS}}、npm install、后端端口与 dev proxy 说明。npm run dev
生成完成后提示用户执行(或所选包管理器),并可选择执行npm install、npm run build做验证。npm run test
后续开发:在 AGENTS 或开发规范中注明「功能/页面/组件开发按本技能(复用优先、UI/业务分层、数据化路由、测试先行、函数组件)」。references/frontend-codegen.md
在生成通用文件之后,在 下生成 React 前端骨架;不调用外部 init-react-frontend 技能。
<project_root>-
脚手架创建
使用官方 Vite 创建项目:在目标目录执行(或当前 create-vite 支持时选择 Rolldown、React、TypeScript)。若未提供 Rolldown 选项,则在生成npm create vite@latest <project-name> -- --template react-ts时在 devDependencies 中设置package.json,并在 Vite 配置中启用 React Compiler。"vite": "npm:rolldown-vite@<resolved-latest-version>" -
默认技术栈
React、React Compiler(在 Vite 中启用)、TypeScript、Ant Design、react-router-dom、Zustand、Vitest + jsdom、Tailwind CSS、Axios、Vite(Rolldown)。依赖版本在生成时解析为当时最新稳定版,并写入精确版本(不用package.json/^)。~ -
目录结构
在下创建:src/、src/utils/、src/consts/(路由配置,与 consts 分离)、src/route/、src/components/、src/pages/、src/store/或src/api/;以及src/services/或test/(Vitest 全局 setup、fixtures、mocks)。单元测试可放在源码旁src/test/。**/*.test.{ts,tsx} -
文件清单
- :scripts(dev、build、preview、test);依赖为解析后的精确版本;Vite 使用 Rolldown 时 devDependencies 中
package.json。"vite": "npm:rolldown-vite@<version>" - :React 插件、React Compiler、path alias(如
vite.config.ts→@/)、build 输出;dev proxy:src/将server.proxy等转发到后端,默认 target 端口 5000。/api - /
tsconfig.json、tsconfig.node.json+tailwind.config.js、postcss.config.js(入口为index.html)。src/main.tsx - :React 根入口、Ant Design 样式、mount。
src/main.tsx - :BrowserRouter 与最小路由列表。
src/App.tsx - 、
src/utils/、src/consts/、src/route/、src/components/、src/pages/、src/store/或src/api/的占位或示例。src/services/ - :Vitest + jsdom,匹配
vitest.config.ts。**/*.test.{ts,tsx} - 至少一个示例测试 。
src/**/*.test.tsx - (Node、dist、env、IDE)。
.gitignore - AGENTS.md:使用本技能模板 填充
assets/templates/AGENTS.react.template.md、{{PROJECT_NAME}}、{{PROJECT_DESCRIPTION}}、{{TECH_STACK_TABLE}}、{{DIR_STRUCTURE}}、{{SCRIPTS}};语言与项目约定一致(默认中文)。{{INITIALIZED_DATE}}
-
与通用第二阶段的衔接
若选择了 CI,CI 中的为{{INSTALL_CMD}},npm ci为{{TEST_CMD}}等。README 的npm run test写入{{GETTING_STARTED_STEPS}}、npm install、后端端口与 dev proxy 说明。npm run dev
生成完成后提示用户执行(或所选包管理器),并可选择执行npm install、npm run build做验证。npm run test
后续开发:在 AGENTS 或开发规范中注明「功能/页面/组件开发按本技能(复用优先、UI/业务分层、数据化路由、测试先行、函数组件)」。references/frontend-codegen.md
当项目类型 = Taro 小程序
当项目类型 = Taro 小程序
在生成通用文件之后,在 下按 Taro 官方方式初始化并做仅允许的后续操作;不调用外部 init-taro-miniapp 技能。
<project_root>-
初始化(必须)
在项目所在父目录执行:。仅用此命令创建项目;交互中可选择框架(React/Vue3)、TypeScript、CSS 预处理器、打包工具、包管理器。不得用其他脚手架替代。npx @tarojs/cli init <projectName> -
安装依赖(必须)
进入项目根目录执行(若 init 时选了 pnpm/yarn 则用npm install或pnpm install)。不可省略。yarn -
在 src 下创建目录
仅新增以下目录(缺失则创建,不修改已有文件):(API 封装)、src/apis、src/utils、src/components;可选src/consts、src/hooks。目录可为空,不强制添加文件。src/services -
配置 H5 开发代理
仅修改项目配置中的 H5 dev proxy,使前端能请求后端。配置文件一般为或config/index.js。在 h5 → devServer 下增加或合并 proxy,例如将config/dev.js转发到后端(默认端口 5000):/apijavascripth5: { devServer: { proxy: { '/api': { target: 'http://localhost:5000', changeOrigin: true, pathRewrite: { '^/api': '/api' } } } } }后端端口非 5000 时修改;除 proxy 外不修改配置其他项。target -
README 与 AGENTS.md
使用本技能模板在项目根目录生成或覆盖assets/templates/AGENTS.taro.template.md,填充AGENTS.md、{{PROJECT_NAME}}、{{PROJECT_DESCRIPTION}}、{{TECH_STACK_TABLE}}(含 src/apis、utils、components、consts 及 config/、dist/)、{{DIR_STRUCTURE}}、{{SCRIPTS}}。可酌情新增或更新 README(项目名、运行方式、代理/端口说明),保持简洁。{{INITIALIZED_DATE}} -
禁止
不修改、依赖或脚本(仅允许执行上述 install);不修改已有源码、应用入口或其他配置(如package.json、app.config.ts),仅允许上述 proxy 配置块。babel.config.js
在生成通用文件之后,在 下按 Taro 官方方式初始化并做仅允许的后续操作;不调用外部 init-taro-miniapp 技能。
<project_root>-
初始化(必须)
在项目所在父目录执行:。仅用此命令创建项目;交互中可选择框架(React/Vue3)、TypeScript、CSS 预处理器、打包工具、包管理器。不得用其他脚手架替代。npx @tarojs/cli init <projectName> -
安装依赖(必须)
进入项目根目录执行(若 init 时选了 pnpm/yarn 则用npm install或pnpm install)。不可省略。yarn -
在 src 下创建目录
仅新增以下目录(缺失则创建,不修改已有文件):(API 封装)、src/apis、src/utils、src/components;可选src/consts、src/hooks。目录可为空,不强制添加文件。src/services -
配置 H5 开发代理
仅修改项目配置中的 H5 dev proxy,使前端能请求后端。配置文件一般为或config/index.js。在 h5 → devServer 下增加或合并 proxy,例如将config/dev.js转发到后端(默认端口 5000):/apijavascripth5: { devServer: { proxy: { '/api': { target: 'http://localhost:5000', changeOrigin: true, pathRewrite: { '^/api': '/api' } } } } }后端端口非 5000 时修改;除 proxy 外不修改配置其他项。target -
README 与 AGENTS.md
使用本技能模板在项目根目录生成或覆盖assets/templates/AGENTS.taro.template.md,填充AGENTS.md、{{PROJECT_NAME}}、{{PROJECT_DESCRIPTION}}、{{TECH_STACK_TABLE}}(含 src/apis、utils、components、consts 及 config/、dist/)、{{DIR_STRUCTURE}}、{{SCRIPTS}}。可酌情新增或更新 README(项目名、运行方式、代理/端口说明),保持简洁。{{INITIALIZED_DATE}} -
禁止操作
不修改、依赖或脚本(仅允许执行上述 install);不修改已有源码、应用入口或其他配置(如package.json、app.config.ts),仅允许上述 proxy 配置块。babel.config.js
.gitlab-ci.yml
.gitlab-ci.yml
Read . Fill in:
assets/templates/gitlab-ci.template.yml- — appropriate base image for the tech stack
{{DOCKER_IMAGE}} - — dependency install command (e.g.,
{{INSTALL_CMD}},npm ci)pip install -r requirements.txt - — lint/format check command
{{LINT_CMD}} - — test run command
{{TEST_CMD}} - — coverage report command
{{COVERAGE_CMD}} - — minimum coverage (skip/set to 0 for demo)
{{COVERAGE_THRESHOLD}} - — security scan command or
{{SECURITY_SCAN_CMD}}for demoecho "skipped" - — path to framework check script: one of:
{{SDD_CHECK_SCRIPT}}scripts/check_sdd_openspec.shscripts/check_sdd_speckit.shscripts/check_sdd_gsd.sh
- — release branch name (default:
{{MAIN_BRANCH}})main
当用户选择 Python + GitLab CI + backend-python-cicd 规范时:生成或校验 、Dockerfile、部署脚本与分支文档时,须遵循本技能 与 。要点:先本地 Docker 构建测试再 Git 推送;私有镜像 与 pip/uv 镜像源(见 );多阶段构建(requirement + project);分支 develop/bugfix/hotfix/master;dev→prod K8s 部署(dev_deploy.sh、prod_deploy.sh);私有镜像仓库 registry.dic.hillstonenet.com;Runner tags 。可生成 Dockerfile、、、、 及 Git 操作说明(见 )。
.gitlab-ci.ymlreferences/backend-python-cicd.mdassets/backend-python-cicd/docker.dic.hillstonenet.com/library/python:3.12-slimassets/backend-python-cicd/dockerfile-python-base.mdgrunnerscripts/dev_deploy.shscripts/prod_deploy.shk8s/dev_deployment.yaml.tpldocs/GITLAB-CICD.mdassets/backend-python-cicd/git-operations.mdRun the install script to copy all required check scripts into the project:
python <skill_dir>/scripts/install_scripts.py <project_root> --framework <fw>This installs the appropriate runtime variant ( on Linux/macOS, as fallback, on Windows) of and into . Do not manually recreate or copy-paste script files — the install script guarantees the exact asset versions are used without modification. Pass first to verify what will be copied.
.sh.js.ps1check_project_tagcheck_sdd_<framework><project_root>/scripts/--dry-run读取 ,填充以下内容:
assets/templates/gitlab-ci.template.yml- — 适合该技术栈的基础镜像
{{DOCKER_IMAGE}} - — 依赖安装命令(例如
{{INSTALL_CMD}}、npm ci)pip install -r requirements.txt - — 代码检查/格式校验命令
{{LINT_CMD}} - — 测试运行命令
{{TEST_CMD}} - — 覆盖率报告命令
{{COVERAGE_CMD}} - — 最小覆盖率要求(演示项目可跳过/设为0)
{{COVERAGE_THRESHOLD}} - — 安全扫描命令,演示项目填
{{SECURITY_SCAN_CMD}}echo "skipped" - — 框架检查脚本路径:以下之一:
{{SDD_CHECK_SCRIPT}}scripts/check_sdd_openspec.shscripts/check_sdd_speckit.shscripts/check_sdd_gsd.sh
- — 发布分支名称(默认:
{{MAIN_BRANCH}})main
当用户选择 Python + GitLab CI + backend-python-cicd 规范时:生成/校验 、Dockerfile、部署脚本与分支文档时,须遵循本技能 与 。要点:先本地 Docker 构建测试再 Git 推送;私有镜像 与 pip/uv 镜像源(见 );多阶段构建(依赖安装 + 项目构建);分支 develop/bugfix/hotfix/master;dev→prod K8s 部署(dev_deploy.sh、prod_deploy.sh);私有镜像仓库 registry.dic.hillstonenet.com;Runner tags 。可生成 Dockerfile、、、、 及 Git 操作说明(见 )。
.gitlab-ci.ymlreferences/backend-python-cicd.mdassets/backend-python-cicd/docker.dic.hillstonenet.com/library/python:3.12-slimassets/backend-python-cicd/dockerfile-python-base.mdgrunnerscripts/dev_deploy.shscripts/prod_deploy.shk8s/dev_deployment.yaml.tpldocs/GITLAB-CICD.mdassets/backend-python-cicd/git-operations.md运行安装脚本,将所有必要的检查脚本复制到项目中:
python <skill_dir>/scripts/install_scripts.py <project_root> --framework <fw>此脚本会将 和 的对应运行时版本(Linux/macOS 用 , fallback 用 ,Windows 用 )安装到 。请勿手动创建或复制粘贴脚本文件 — 安装脚本可确保使用的是精确的资产版本且未被修改。先传入 预览将复制的内容。
check_project_tagcheck_sdd_<framework>.sh.js.ps1<project_root>/scripts/--dry-run.github/workflows/ci.yml (if GitHub Actions selected)
.github/workflows/ci.yml(若选择GitHub Actions)
Read . Fill in the same placeholders as the GitLab template — the values must be identical to ensure both pipelines enforce the same standards.
assets/templates/github-actions.template.yml读取 ,填充与GitLab模板相同的占位符 — 值必须完全一致,以确保两个流水线执行相同的标准。
assets/templates/github-actions.template.yml当用户选择 QA/测试规范(Phase 1 问题 12)
当用户选择 QA/测试规范(第一阶段问题12)
在 AGENTS.md 中增加「测试与根因分析」小节,或引用本技能 :测试计划、用例格式、自动化约定、测试报告;缺陷与测试失败时采用系统性排错与根因分析(先根因、后修复,禁止只治标)。可摘录要点或写「详见项目所用 project-initializer 技能之 references/qa-testing.md」。
references/qa-testing.md在 AGENTS.md 中增加「测试与根因分析」小节,或引用本技能 :测试计划、用例格式、自动化约定、测试报告;缺陷与测试失败时采用系统性排错与根因分析(先找根因、再修复,禁止只治标)。可摘录要点或写「详见项目所用 project-initializer 技能之 references/qa-testing.md」。
references/qa-testing.md当用户选择多角色/子代理(Phase 1 问题 13)
当用户选择多角色/子代理(第一阶段问题13)
在 Phase 2 生成与 Phase 3 SDD 之后,按本技能 与 执行:(1) 确认场景与约束(系统开发、数据分析、运维等;串行/并行;规模与规定);(2) 规划角色清单(从 常见场景与角色映射选取并裁剪);(3) 为每个角色填规范(使用 结构,产出 或 );(4) 若用户要求创建子代理,从角色定义生成 (YAML frontmatter:name、description、model 等;正文:scope、inputExpectation、constraints、outputSpec、handoff),格式参考 。子代理目录默认项目级 。可选:将 复制到项目中用于校验角色 JSON。
references/agent-roles.mdassets/agent-roles/references/agent-roles.mdassets/agent-roles/role-template.jsonroles/<role-id>.mdroles/<role-id>.json.cursor/agents/<name>.mdassets/agent-roles/subagent-cursor-template.md.cursor/agents/scripts/validate_roles.py在第二阶段文件生成与第三阶段SDD初始化之后,按本技能 与 执行:(1) 确认场景与约束(系统开发、数据分析、运维等;串行/并行;规模与规定);(2) 规划角色清单(从 常见场景与角色映射选取并裁剪);(3) 为每个角色填充规范(使用 结构,产出 或 );(4) 若用户要求创建子代理,从角色定义生成 (YAML frontmatter:name、description、model 等;正文:scope、inputExpectation、constraints、outputSpec、handoff),格式参考 。子代理目录默认项目级 。可选:将 复制到项目中用于校验角色 JSON。
references/agent-roles.mdassets/agent-roles/references/agent-roles.mdassets/agent-roles/role-template.jsonroles/<role-id>.mdroles/<role-id>.json.cursor/agents/<name>.mdassets/agent-roles/subagent-cursor-template.md.cursor/agents/scripts/validate_roles.pyPhase 3: SDD Framework Installation
第三阶段:SDD框架安装
MANDATORY — do not skip or substitute manually. You MUST run the script below. Do NOT create SDD framework directories or documents by hand. Manually created files will be incomplete, wrongly structured, and will fail CI checks. If the script encounters an error, report it to the user — do not work around it by creating files yourself.
Resolve (the directory containing this SKILL.md) and run:
<skill_dir>python <skill_dir>/scripts/initialize_sdd.py <project_root> --framework <fw> --ai-provider <agent> [--script-shell sh|ps]If you are already inside the project directory, is .
<project_root>.Determining the value: Use the name of the AI agent currently running this skill (e.g. , , , , ). You know this from your own identity — pass it as-is.
--ai-providerclaudecopilotgeminiopencodecodexFor SpecKit only — parameter: Choose the shell for generated scripts:
--script-shell- (default): Unix/shell scripts — use for Linux/macOS CI runners
sh - : PowerShell scripts — use for Windows CI runners
ps
This script runs all frameworks non-interactively:
- OpenSpec: —
openspec init --tools <tool_id>mapped to OpenSpec's tool ID:--ai-provider,claude,opencode,codex,gemini,windsurf,qwen,codebuddyuse the same name;kilocode→copilot;github-copilot→cursor-agent;cursor→roo; all others→roocodeall - SpecKit: — passes the provider name and shell choice directly
specify init . --ai <provider> --here --force --script <shell> - GSD: —
npx -y get-shit-done-cc@latest --<runtime> --localis mapped to a runtime flag:--ai-provider→claude,--claude→opencode,--opencode→codex, all others→--codex--claude
The script also:
- Installs the framework CLI tool (,
npm, oruvas appropriate) if not foundnpx - Initializes framework-specific directories
- For OpenSpec: initializes and
openspec/specs/openspec/changes/ - For SpecKit: initializes (auto-numbered) and
specs/memory/constitution.md - For GSD: initializes with PROJECT.md, REQUIREMENTS.md, ROADMAP.md, STATE.md, config.json
.planning/
SpecKit supported values: claude, gemini, copilot, cursor-agent, windsurf, opencode, codex, qwen, amp, shai, agy, bob, qodercli, roo, codebuddy, jules, kilocode, generic.
--ai-providerPass to preview without installing.
--dry-run强制要求 — 请勿跳过或手动替代 必须运行以下脚本。请勿手动创建SDD框架目录或文档。手动创建的文件会不完整、结构错误,并导致CI检查失败。若脚本执行出错,请向用户报告 — 不要自行创建文件绕过错误。
确定 (包含本SKILL.md文件的目录)并运行:
<skill_dir>python <skill_dir>/scripts/initialize_sdd.py <project_root> --framework <fw> --ai-provider <agent> [--script-shell sh|ps]若已在项目目录内, 为 。
<project_root>.确定 的值:使用当前运行本技能的AI Agent名称(例如 、、、、)。根据自身身份传入即可。
--ai-providerclaudecopilotgeminiopencodecodex仅针对SpecKit — 参数:选择生成脚本的shell类型:
--script-shell- (默认):Unix/shell脚本 — 用于Linux/macOS CI运行器
sh - :PowerShell脚本 — 用于Windows CI运行器
ps
此脚本以非交互式方式运行所有框架:
- OpenSpec:—
openspec init --tools <tool_id>映射为OpenSpec的工具ID:--ai-provider、claude、opencode、codex、gemini、windsurf、qwen、codebuddy使用原名;kilocode→copilot;github-copilot→cursor-agent;cursor→roo;其他→roocodeall - SpecKit:— 直接传入provider名称和shell选择
specify init . --ai <provider> --here --force --script <shell> - GSD:—
npx -y get-shit-done-cc@latest --<runtime> --local映射为运行时标志:--ai-provider→claude,--claude→opencode,--opencode→codex,其他→--codex--claude
此脚本还会:
- 若未找到框架CLI工具,则安装(根据情况使用 、
npm或uv)npx - 初始化框架特定的目录
- OpenSpec:初始化 和
openspec/specs/openspec/changes/ - SpecKit:初始化 (自动编号)和
specs/memory/constitution.md - GSD:初始化 ,包含PROJECT.md、REQUIREMENTS.md、ROADMAP.md、STATE.md、config.json
.planning/
SpecKit支持的值:claude, gemini, copilot, cursor-agent, windsurf, opencode, codex, qwen, amp, shai, agy, bob, qodercli, roo, codebuddy, jules, kilocode, generic.
--ai-provider传入 预览安装内容而不实际安装。
--dry-runPrerequisites
前置依赖
| Framework | Requires |
|---|---|
| OpenSpec | |
| SpecKit | |
| GSD | |
If a required tool is not installed, the script will exit with an error message indicating what needs to be installed.
| 框架 | 所需依赖 |
|---|---|
| OpenSpec | |
| SpecKit | |
| GSD | |
若缺少必需工具,脚本会退出并显示错误消息,说明需要安装的内容。
Phase 4: SDD Check Script
第四阶段:SDD检查脚本
The check script reads the latest git commit message and the project's SDD documents. It enforces documentation consistency.
检查脚本读取最新的Git提交消息和项目的SDD文档,强制确保文档一致性。
Ignore Tag System
忽略标签系统
Agents and developers can place structured tags in commit messages to suppress specific checks:
feat: implement user login [ignore:spec_sync]
fix: typo in variable name [ignore:all_sdd]Universal tags (all frameworks):
| Tag | What it suppresses |
|---|---|
| All SDD process checks |
Framework-specific tags — see the relevant reference file for the complete list. They follow the pattern .
[ignore:<check_name>]Agent和开发者可在提交消息中添加结构化标签,以跳过特定检查:
feat: 实现用户登录 [ignore:spec_sync]
fix: 修复变量名拼写错误 [ignore:all_sdd]通用标签(所有框架):
| 标签 | 跳过的检查 |
|---|---|
| 所有SDD流程检查 |
框架特定标签 — 详见相关参考文件。格式为 。
[ignore:<check_name>]When checks fail
检查失败时的处理
The script exits non-zero and prints a message explaining:
- What was found (e.g., "3 tasks incomplete in openspec/changes/add-auth/tasks.md")
- What the developer should do (e.g., )
Run /opsx:sync add-auth to sync delta specs - How to suppress the check if appropriate (e.g., )
Add [ignore:spec_sync] to commit message if this is a bug fix not tied to a feature
脚本会返回非零退出码并打印说明消息:
- 发现的问题(例如 "openspec/changes/add-auth/tasks.md 中有3项任务未完成")
- 开发者应采取的行动(例如 )
Run /opsx:sync add-auth 以同步增量规范 - 如何跳过检查(例如 )
若此为与功能无关的bug修复,可在提交消息中添加 [ignore:spec_sync]
Phase 5: Project Identity Tag
第五阶段:项目身份标记
Every project initialized by this skill must have a machine-readable identity tag embedded at the top of . This tag allows server-side CI to:
AGENTS.md- Confirm the project was properly initialized (not just a hand-crafted AGENTS.md)
- Know which SDD framework and CI platforms are in use
- Enforce version-specific checks appropriate for the project's configuration
The tag takes the form of a structured HTML comment block (the first thing in the file, before any Markdown):
<!-- @project-initializer
version: 1
initialized_at: YYYY-MM-DD
sdd_framework: openspec|speckit|gsd
quality_level: demo|production
ci_platforms: gitlab|github|gitlab,github
project_initializer_version: 1.0.0
-->Rules:
- Always place it as the very first content in (before the
AGENTS.mdheading)# - Use the actual initialization date (today)
- — lowercase identifier:
sdd_framework,openspec, orspeckitgsd - — comma-separated, no spaces:
ci_platforms,gitlab, orgithubgitlab,github - Do not modify this block after creation except through a deliberate re-initialization
The CI check script () reads this tag and exits non-zero if it is missing or malformed. It is installed automatically by the step described in Phase 2 — is always included regardless of the chosen SDD framework. The framework's initialize script (Phase 3) must complete successfully before this tag is validated.
assets/scripts/check_project_tag.shinstall_scripts.pycheck_project_tag所有通过本技能初始化的项目,必须在AGENTS.md顶部嵌入机器可读的身份标记。此标记供服务端CI使用,以:
- 确认项目已完成合规初始化(而非手动编写的AGENTS.md)
- 了解项目使用的SDD框架和CI平台
- 执行与项目配置匹配的版本特定检查
标记采用结构化HTML注释块的形式(位于文件最开头,在任何Markdown内容之前):
<!-- @project-initializer
version: 1
initialized_at: YYYY-MM-DD
sdd_framework: openspec|speckit|gsd
quality_level: demo|production
ci_platforms: gitlab|github|gitlab,github
project_initializer_version: 1.0.0
-->规则:
- 必须始终放在AGENTS.md的最开头(在标题之前)
# - 使用实际初始化日期(当前日期)
- — 小写标识符:
sdd_framework、openspec或speckitgsd - — 逗号分隔,无空格:
ci_platforms、gitlab或githubgitlab,github - 创建后除非刻意重新初始化,否则不要修改此块
CI检查脚本()会读取此标记,若标记缺失或格式错误则返回非零退出码。此脚本会在第二阶段的步骤中自动安装 — 无论选择哪种SDD框架,都会被包含。第三阶段的框架初始化脚本必须执行成功,此标记才会被验证。
assets/scripts/check_project_tag.shinstall_scripts.pycheck_project_tagPhase 6: Consistency Verification
第六阶段:一致性验证
After generating all files, perform this checklist:
- starts with a valid
AGENTS.mdtag<!-- @project-initializer - in tag matches chosen framework
sdd_framework - in tag matches files actually generated
ci_platforms - Docker/runner image in CI file(s) matches tech stack
- tech stack section matches
AGENTS.mdREADME.md - Coverage threshold in CI file(s) matches → Quality Standards
AGENTS.md - SDD framework name consistent across all generated files
- The correct SDD check script is referenced (OpenSpec/SpecKit/GSD)
- Both CI platform files (if both generated) use identical quality thresholds
- Branch name in CI rules matches the stated main branch
- SDD framework initialized successfully (Phase 3)
- OpenSpec: and
openspec/specs/existopenspec/changes/ - SpecKit: and
specs/existmemory/constitution.md - GSD: contains PROJECT.md, REQUIREMENTS.md, ROADMAP.md, STATE.md, config.json
.planning/
- OpenSpec:
- directory was populated by running
scripts/(not manually recreated or copy-pasted)install_scripts.py - The correct single variant (on Linux/macOS,
.shon Windows,.ps1as fallback) is present in.jsscripts/ - (if generated) contains all required jobs:
.gitlab-ci.yml,lint,unit-tests,commit-format,full-test-suite,coverage-gate,security-scan,project-tag-check,sdd-process-checkdeploy - (if generated) contains all required jobs:
.github/workflows/ci.yml,lint,unit-tests,commit-format,full-test-suite,security-scan,project-tag-checksdd-process-check - No jobs were removed or merged compared to the template; only tokens were substituted
{{PLACEHOLDER}} - starts with a valid
AGENTS.mdtag<!-- @project-initializer - First commit includes: README.md, AGENTS.md, CI files, scripts/, and framework directories
Report any inconsistencies to the user before finishing.
生成所有文件后,执行以下检查清单:
- 开头包含有效的
AGENTS.md标记<!-- @project-initializer - 标记中的 与所选框架一致
sdd_framework - 标记中的 与实际生成的文件一致
ci_platforms - CI文件中的Docker/运行器镜像与技术栈匹配
- 中的技术栈部分与
AGENTS.md一致README.md - CI文件中的覆盖率阈值与 → 质量标准一致
AGENTS.md - SDD框架名称在所有生成文件中保持一致
- 引用了正确的SDD检查脚本(OpenSpec/SpecKit/GSD)
- 若同时生成了两个CI平台文件,使用完全相同的质量阈值
- CI规则中的分支名称与指定的主分支一致
- SDD框架初始化成功(第三阶段)
- OpenSpec:和
openspec/specs/存在openspec/changes/ - SpecKit:和
specs/存在memory/constitution.md - GSD:包含PROJECT.md、REQUIREMENTS.md、ROADMAP.md、STATE.md、config.json
.planning/
- OpenSpec:
- 目录是通过运行
scripts/填充的(而非手动创建或复制粘贴)install_scripts.py - 中存在正确的单一版本(Linux/macOS用
scripts/,Windows用.sh, fallback用.ps1).js - (若生成)包含所有必需任务:
.gitlab-ci.yml、lint、unit-tests、commit-format、full-test-suite、coverage-gate、security-scan、project-tag-check、sdd-process-checkdeploy - (若生成)包含所有必需任务:
.github/workflows/ci.yml、lint、unit-tests、commit-format、full-test-suite、security-scan、project-tag-checksdd-process-check - 与模板相比,未删除或合并任何任务;仅替换了 标记
{{PLACEHOLDER}} - 开头包含有效的
AGENTS.md标记<!-- @project-initializer - 首次提交包含:README.md、AGENTS.md、CI文件、scripts/ 及框架目录
完成检查后,若发现不一致,向用户报告。
Reference files
参考文件
- — OpenSpec document structure, sync workflow, ignore tags
references/openspec.md - — SpecKit spec lifecycle, constitution, phase gates, ignore tags
references/speckit.md - — GSD phase workflow, document set, planning structure, ignore tags
references/gsd.md - — Flask 后端目录结构、分层、Blueprint、UV、钩子(项目类型 = Flask 后端时使用)
references/flask-backend.md - — Python + GitLab CI:多阶段 Docker、分支、K8s、私有镜像(用户选择该规范时使用)
references/backend-python-cicd.md - — React 功能/页面/组件开发:复用优先、UI/业务分层、数据化路由、测试先行(React 项目后续开发)
references/frontend-codegen.md - — Flask 新增 API/资源:路由、Service、Model、Schema、权限、测试(Flask 项目后续开发)
references/flask-backend-codegen.md - — 测试计划、用例、自动化、报告与系统性根因分析(用户选择引用 QA 时使用)
references/qa-testing.md - — 多角色规划与 Cursor 子代理(.cursor/agents/*.md)(用户选择多角色/子代理时使用)
references/agent-roles.md
- — OpenSpec文档结构、同步工作流、忽略标签
references/openspec.md - — SpecKit规范生命周期、约束规则、阶段门槛、忽略标签
references/speckit.md - — GSD阶段工作流、文档集、规划结构、忽略标签
references/gsd.md - — Flask后端目录结构、分层、Blueprint、UV、钩子(项目类型=Flask后端时使用)
references/flask-backend.md - — Python + GitLab CI:多阶段Docker构建、分支策略、K8s部署、私有镜像(用户选择该规范时使用)
references/backend-python-cicd.md - — React功能/页面/组件开发:复用优先、UI/业务分层、数据化路由、测试先行(React项目后续开发)
references/frontend-codegen.md - — Flask新增API/资源:路由、Service、Model、Schema、权限、测试(Flask项目后续开发)
references/flask-backend-codegen.md - — 测试计划、用例、自动化、报告与系统性根因分析(用户选择引用QA时使用)
references/qa-testing.md - — 多角色规划与Cursor子代理(.cursor/agents/*.md)(用户选择多角色/子代理时使用)
references/agent-roles.md
Installation scripts
安装脚本
All script paths are relative to (the directory containing this SKILL.md). is the project's root — use if already inside it.
<skill_dir><project_root>.-
— copies check scripts into
scripts/install_scripts.py<project_root>/scripts/Usage:python <skill_dir>/scripts/install_scripts.py <project_root> --framework <openspec|speckit|gsd>Always run this instead of manually copying scripts. Addto preview.--dry-run -
— installs SDD framework tools and initializes project structure
scripts/initialize_sdd.pyUsage:python <skill_dir>/scripts/initialize_sdd.py <project_root> --framework <openspec|speckit|gsd> --ai-provider <agent>Must be run — do not manually create SDD directories. Installs the framework CLI non-interactively, sets up directories. Addto preview.--dry-run
所有脚本路径均相对于 (包含本SKILL.md文件的目录)。 是项目根目录 — 若已在项目目录内则用 。
<skill_dir><project_root>.-
— 将检查脚本复制到
scripts/install_scripts.py<project_root>/scripts/使用方式:python <skill_dir>/scripts/install_scripts.py <project_root> --framework <openspec|speckit|gsd>请始终运行此脚本,而非手动复制脚本。添加预览操作。--dry-run -
— 安装SDD框架工具并初始化项目结构
scripts/initialize_sdd.py使用方式:python <skill_dir>/scripts/initialize_sdd.py <project_root> --framework <openspec|speckit|gsd> --ai-provider <agent>必须运行 — 请勿手动创建SDD目录。以非交互式方式安装框架CLI,设置目录。添加预览操作。--dry-run
Template files
模板文件
assets/templates/README.template.md- — 通用项目;项目类型 = React 前端时改用
assets/templates/AGENTS.template.mdassets/templates/AGENTS.react.template.md - — React 前端项目 AGENTS 模板
assets/templates/AGENTS.react.template.md - — Taro 小程序项目 AGENTS 模板
assets/templates/AGENTS.taro.template.md assets/templates/gitlab-ci.template.ymlassets/templates/github-actions.template.yml- Flask 后端:(project-structure.txt、create_app_snippet.py、env-example.txt、pyproject-uv.example.toml、uv-usage.md)
assets/flask-backend/ - Python GitLab CI/K8s:(dockerfile-python-base.md、docker-build-commands.md、git-operations.md、k8s/、scripts/、gitlab-ci-example.yml、pipeline-overview.md)
assets/backend-python-cicd/ - Flask 代码生成:(response-format.json、code-snippets.md);可选
assets/flask-backend-codegen/scripts/check_route_layer.py - 角色与子代理:(role-template.json、scenario-roles-example.json、subagent-cursor-template.md、config-template.json);可选
assets/agent-roles/scripts/validate_roles.py
assets/templates/README.template.md- — 通用项目;项目类型=React前端时改用
assets/templates/AGENTS.template.mdassets/templates/AGENTS.react.template.md - — React前端项目AGENTS模板
assets/templates/AGENTS.react.template.md - — Taro小程序项目AGENTS模板
assets/templates/AGENTS.taro.template.md assets/templates/gitlab-ci.template.ymlassets/templates/github-actions.template.yml- Flask后端:(project-structure.txt、create_app_snippet.py、env-example.txt、pyproject-uv.example.toml、uv-usage.md)
assets/flask-backend/ - Python GitLab CI/K8s:(dockerfile-python-base.md、docker-build-commands.md、git-operations.md、k8s/、scripts/、gitlab-ci-example.yml、pipeline-overview.md)
assets/backend-python-cicd/ - Flask代码生成:(response-format.json、code-snippets.md);可选
assets/flask-backend-codegen/scripts/check_route_layer.py - 角色与子代理:(role-template.json、scenario-roles-example.json、subagent-cursor-template.md、config-template.json);可选
assets/agent-roles/scripts/validate_roles.py
Check scripts
检查脚本
Each check is available in three runtime variants, stored in the skill's directory. The install_scripts.py command copies these into the target project's directory — which variant gets invoked in CI depends on the runner OS and what's available.
assets/scripts/scripts/| Script | Shell (Linux/macOS) | PowerShell (Windows/cross-platform) | Node.js (any platform) |
|---|---|---|---|
| Project tag | | | |
| OpenSpec | | | |
| SpecKit | | | |
| GSD | | | |
每个检查都有三种运行时版本,存储在技能的 目录中。install_scripts.py命令会将这些脚本复制到目标项目的 目录 — CI中使用哪个版本取决于运行器OS和可用环境。
assets/scripts/scripts/| 脚本 | Shell(Linux/macOS) | PowerShell(Windows/跨平台) | Node.js(任意平台) |
|---|---|---|---|
| 项目标记检查 | | | |
| OpenSpec检查 | | | |
| SpecKit检查 | | | |
| GSD检查 | | | |
Selecting which variant to use in CI
在CI中选择使用的版本
When generating CI pipeline files, choose the invocation command based on the project's runner environment:
| Runner environment | CI invocation |
|---|---|
| Linux / macOS (bash available) | |
| Windows (PowerShell 7+ available) | |
| Any (Node.js ≥ 18 available) | |
| Unknown / mixed | Use Node.js — it works everywhere Node.js is installed |
The Node.js variants are the most portable choice if the runner environment is uncertain. They require no npm dependencies — only the Node.js built-in modules (, , ).
fspathchild_processThe GitLab CI and GitHub Actions templates default to the shell variant. If the user's CI runners are Windows-based or they prefer Node.js, update the / lines accordingly. All three variants implement identical logic and exit codes.
script:run:undefined生成CI流水线文件时,根据项目的运行器环境选择调用命令:
| 运行器环境 | CI调用命令 |
|---|---|
| Linux / macOS(bash可用) | |
| Windows(PowerShell 7+可用) | |
| 任意(Node.js ≥18可用) | |
| 未知/混合环境 | 使用Node.js版本 — 只要安装了Node.js,在任何环境都能运行 |
若不确定运行器环境,Node.js版本是最便携的选择。它们不需要npm依赖 — 仅使用Node.js内置模块(、、)。
fspathchild_processGitLab CI和GitHub Actions模板默认使用Shell版本。若用户的CI运行器是Windows系统或偏好Node.js,请相应更新 / 行。三个版本实现的逻辑和退出码完全相同。
script:run: