{"slug":"pdlc-db-design","title":"pdlc-db-design","summary":"数据库设计","platform":"Claude","tags":[],"authorName":"LLM Mart","authorSlug":"llm-mart","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-09-23T18:54:22.552424Z","repo":{"url":"https://github.com/kanfu-panda/pdlc-skills","stars":15,"forks":2,"license":"MIT","updatedAt":"2026-09-23T15:59:31Z"},"bodyHtml":"<hr>\n<p>name: pdlc-db-design\ndescription: 数据库设计\nargument-hint: &lt;功能ID | 数据模型描述&gt;\nallowed-tools: Read, Write, Edit, Glob, Grep, Bash\nlayer: 3\nstage: design\nproduces:</p>\n<ul>\n<li>docs/02_design/database/**\nrequires: []\nnext_step: null\nterminal_state: null</li>\n</ul>\n<hr>\n<h1>数据库设计</h1>\n\n<p>⛔ <strong>IRON LAW · 不可违反的硬门禁</strong></p>\n<p>以下规则为<strong>不可协商</strong>的执行约束：</p>\n<ol>\n<li><strong>文件必须落盘</strong>：所有带编号（功能ID / 缺陷ID）的文档，必须作为实际文件写入磁盘，不可仅在对话中输出。</li>\n<li><strong>阶段必须落章</strong>：每个阶段完成后必须在状态机 <code>docs/.pdlc-state/&lt;feature-id&gt;.json</code> 追加 history，不可跳过。</li>\n<li><strong>测试必须存在</strong>：进入 <code>/pdlc-implement</code> 前，对应测试必须存在且处于红灯状态。违反则中止。</li>\n<li><strong>自检必须执行</strong>：段二自检为强制步骤，不得以\"已经很好了\"为由跳过。</li>\n<li><strong>防循环</strong>：段三修复为单次，不递归。无法自动修复的问题记录到报告，继续往下走。</li>\n<li><strong>状态必推进</strong>：成功执行某 phase 后 <code>current_stage</code> 必须变更。收尾时若发现 <code>current_stage</code> 未推进，视为失败并报错，<strong>不得静默返回</strong>（防止外层循环拿滞后的状态空转烧额度）。唯一例外：命中人工点主动 block 时，<code>current_stage</code> 保持不变但必须写 <code>last_phase_result.ok=false</code> + <code>blocked_reason</code>。</li>\n</ol>\n<p><strong>违反任一条 = 立即中止当前命令，输出违规详情，等待人工介入。</strong></p>\n\n<p>根据需求和 API 设计文档，创建数据库设计方案。</p>\n<h2>PDLC 前置检查（必须执行，不可跳过）</h2>\n<ol>\n<li>从用户输入中提取功能名称关键词</li>\n<li>在 <code>docs/01_requirements/prd/</code> 目录下搜索包含该关键词的 PRD 文档\n<ul>\n<li>匹配新格式：<code>F&lt;日期&gt;-&lt;编号&gt;-*&lt;关键词&gt;*-prd.md</code></li>\n<li>匹配旧格式：<code>YYYYMMDD-*&lt;关键词&gt;*-prd.md</code></li>\n<li>同时检查文件内容中是否包含该关键词</li>\n</ul>\n</li>\n<li><strong>未找到</strong> → 输出以下信息后<strong>立即停止，不继续执行</strong>：\n<pre><code>⛔ PDLC 守卫：未找到与「&lt;功能名&gt;」相关的 PRD 文档。\n数据库设计必须基于已有的 PRD。请先运行：\n\uD83D\uDC49 /pdlc-prd &lt;需求描述&gt;\n</code></pre>\n</li>\n<li><strong>找到</strong> → 提取功能ID（如 <code>F20260326-090000</code>），读取该 PRD 内容，继续执行</li>\n</ol>\n<h2>工作流程</h2>\n<ol>\n<li><strong>阅读需求</strong>: 阅读找到的 PRD 文档</li>\n<li><strong>阅读 API 设计</strong>: 阅读 <code>docs/02_design/api/</code> 下同功能ID的 API 设计文档（如有）</li>\n<li><strong>梳理数据模型</strong>: 识别实体、属性、关系</li>\n<li><strong>ER 图</strong>: 用文本方式描绘实体关系图</li>\n<li><strong>表结构定义</strong>: 逐表定义字段、类型、约束</li>\n<li><strong>索引设计</strong>: 根据查询场景设计索引</li>\n<li><strong>输出设计文档</strong>: 在 <code>docs/02_design/database/</code> 下创建数据库设计文档</li>\n</ol>\n<h2>文档内容</h2>\n<ul>\n<li><strong>文件名格式</strong>: <code>&lt;功能ID&gt;-&lt;功能名&gt;-db.md</code>（如 <code>F20260326-090000-user-auth-db.md</code>）\n<ul>\n<li>若 PRD 为旧格式无功能ID，则使用旧格式 <code>YYYYMMDD-&lt;模块名&gt;-db.md</code></li>\n</ul>\n</li>\n<li><strong>文档顶部必须包含 PDLC 追溯头</strong>：\n<pre><code>&lt;!-- PDLC-TRACE --&gt;\n&lt;!-- 功能ID: F20260326-090000 --&gt;\n&lt;!-- 功能名称: user-auth --&gt;\n&lt;!-- 阶段: 设计 --&gt;\n&lt;!-- 前置文档: docs/01_requirements/prd/F20260326-090000-user-auth-prd.md --&gt;\n</code></pre>\n</li>\n</ul>\n<h3>ER 图格式</h3>\n<pre><code>[用户] 1──N [订单] N──N [商品]\n  │                       │\n  └───N [地址]    [库存] 1─┘\n</code></pre>\n<h3>表结构格式</h3>\n<table>\n<thead>\n<tr>\n<th>字段</th>\n<th>类型</th>\n<th>可空</th>\n<th>默认值</th>\n<th>索引</th>\n<th>描述</th>\n</tr>\n</thead>\n</table>\n<h3>必须包含</h3>\n<ul>\n<li>公共字段约定（id、created_at、updated_at、deleted_at 等）</li>\n<li>主键策略（自增/UUID/雪花ID）</li>\n<li>软删除策略</li>\n<li>分表分库策略（如数据量大）</li>\n<li>数据迁移方案（DDL 变更脚本）</li>\n</ul>\n<h2>要求</h2>\n\n<p>\uD83C\uDF10 <strong>Output language for generated artifacts</strong></p>\n<p>All generated artifacts (PRDs, design docs, code comments, review reports,\ntest plans, deployment manuals, changelog entries, etc.) follow this policy:</p>\n<ol>\n<li><p><strong>Default — match the conversation language exactly</strong>:</p>\n<ul>\n<li>用户用中文与 Claude 对话 → 产中文文档、中文代码注释、中文报告</li>\n<li>User talks to Claude in English → produce English artifacts</li>\n<li>User talks in another language → produce artifacts in that language</li>\n<li><strong>Never silently default to a fixed language regardless of the user's input.</strong></li>\n</ul>\n</li>\n<li><p><strong>Explicit override always wins</strong>: when the user specifies a language for\nan artifact (e.g. \"write the PRD in English\", \"用英文写 API 设计文档\",\n\"output the deploy doc in Japanese\"), use that language for that artifact,\nregardless of conversation language.</p>\n</li>\n<li><p><strong>Mixed-language requirements</strong>: if the user wants some artifacts in one\nlanguage and others in a different language (common: Chinese PRD + English\nAPI docs for partners), honour each per-artifact instruction.</p>\n</li>\n<li><p><strong>Uncertain</strong>: if you cannot reliably detect the conversation language,\nask once before producing the first artifact.</p>\n</li>\n</ol>\n<p>This policy applies to <strong>content</strong> (prose, comments, headings). It does\n<strong>not</strong> override technical conventions like English variable names, English\ngit commit subjects, or English error codes when the project's conventions\nrequire them.</p>\n\n<ul>\n<li>字段命名使用 snake_case</li>\n<li>枚举值必须有中文说明</li>\n<li>考虑数据量增长后的性能影响</li>\n</ul>\n<p>设计目标: $ARGUMENTS</p>\n\n<h2>段四：交接（Handoff）</h2>\n<p>命令完成后必须输出以下格式的最终消息：</p>\n<pre><code>✅ &lt;阶段名&gt; 完成：&lt;主要产出物路径&gt;\n\uD83D\uDCCA 自检：&lt;通过数&gt;/&lt;总数&gt; 通过（若有未通过，附要点）\n\uD83D\uDCE6 状态快照：docs/.pdlc-state/&lt;feature-id&gt;.json\n\uD83D\uDC49 下一步：/pdlc-&lt;next_step&gt;\n   （如果有分叉）或 /pdlc-&lt;alt&gt;（条件：&lt;选择依据&gt;）\n</code></pre>\n<p><strong>规则：</strong></p>\n<ul>\n<li>主流程命令（写状态机的命令；下一跳见正文里「本命令的状态机取值」）必须显式输出\"下一步\"，不可省略</li>\n<li>工具型命令（Layer 3）可以没有 <code>next_step</code>，此时输出 <code>\uD83D\uDC49 下一步：（本次流程结束，无后续）</code></li>\n<li>分叉场景必须说明<strong>选择条件</strong>，例如\"若需补充测试用例 → <code>/pdlc-tdd</code>；若测试已齐 → <code>/pdlc-review</code>\"</li>\n</ul>\n\n<p><strong>本命令的 handoff 输出：</strong></p>\n<pre><code>✅ 数据库设计文档 完成\n\uD83D\uDCE6 产出：docs/02_design/database/&lt;功能ID&gt;-&lt;功能名&gt;-db.md\n\uD83D\uDC49 下一步：（本次流程结束，无后续）\n</code></pre>\n","files":[{"path":"SKILL.md","sizeBytes":6758,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"clean","suspicious":0,"notes":0,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-09-23T18:54:28.417245Z","sha256":"EFAFDFBFB6E0A232E2FA6F3169744722FE6223122CB11572B58E4DA739C6B4D4","sizeBytes":3740},"review":null,"source":{"repositoryUrl":"https://github.com/kanfu-panda/pdlc-skills","path":"skills/pdlc-db-design","license":"MIT","commit":"3cd2f02ab45cb1cd48962e0f298ae4dad9fb442f","subtreeSha":"CD1DBF1D21BB09FE9E431E510199FB2DF202CEE98151C7C30F34D27E98D1D788","lastSyncedAt":"2026-09-23T18:54:21.123477Z"},"reviewedAt":"2026-09-23T18:55:10.101766Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/kanfu-panda/pdlc-skills/tree/main/skills/pdlc-db-design"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install kanfu-panda-pdlc-skills@llmmart"},{"target":"git","command":"git clone https://github.com/kanfu-panda/pdlc-skills.git"}]}