From spec-writer
Use when designing or updating a database schema from an existing requirements/screen spec (docs/spec/) — sinh tài liệu Thiết kế Cơ sở dữ liệu (table definition + constraint/index + ER diagram Mermaid + phân loại dữ liệu) và cập nhật index truy vết để map F-NNN ↔ bảng ↔ NFR. Là Stage 3 (DB) trong pipeline spec-writer.
How this skill is triggered — by the user, by Claude, or both
Slash command
/spec-writer:db-designerThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Sinh & quản lý **tài liệu Thiết kế Cơ sở dữ liệu** từ bộ spec do `spec-writer` tạo ra (`docs/spec/`).
Sinh & quản lý tài liệu Thiết kế Cơ sở dữ liệu từ bộ spec do spec-writer tạo ra (docs/spec/).
Mục tiêu: tài liệu DB đủ căn cứ để sinh test spec và code — định nghĩa bảng/cột/kiểu, constraint, index, relation, ER diagram, phân loại dữ liệu — đồng thời giữ truy vết F-NNN ↔ bảng ↔ NFR trong 00_index.md.
Ngôn ngữ: tiếng Việt là chính; tên bảng/cột/kiểu dữ liệu/constraint để tiếng Anh (theo mẫu).
Write/Edit. KHÔNG in/dán toàn bộ nội dung tài liệu (định nghĩa bảng, ER) ra chat.db-designer là Stage 3 (DB) — chạy SAU spec (spec-writer), TRƯỚC API (api-designer).
| Stage | Việc | Skill |
|---|---|---|
| 1. Hỏi/đáp | Khai thác yêu cầu | superpowers:brainstorming |
| 2. Spec | Spec tổng + spec con màn hình | spec-writer |
| 3. DB | Thiết kế CSDL từ spec | db-designer ← đang ở đây |
| 4. API | Thiết kế API | api-designer |
| 5. Plan / 6. Code | Lập kế hoạch & code | superpowers:writing-plans / executing-plans |
Hết Stage 3 LUÔN hỏi người dùng: "Dừng ở DB, hay tiếp tục sang API (Stage 4)?"
docs/spec/00_index.md + docs/spec/01_requirements.md. Nếu chưa có → dừng, đề nghị chạy spec-writer trước.00_index.md để lấy danh sách F-NNN, NFR-X-NNN, các màn hình.01_requirements.md (Glossary, scope, NFR) và các screens/F-NNN_*.md liên quan để biết dữ liệu nào màn hình cần.DB design cần biết DBMS. Trước khi thiết kế bảng:
docs/spec/02_tech_context.md. Nếu chưa có → sinh nó theo references/tech-context-template.md, hỏi người dùng (1 câu/lần) các mục còn thiếu: DBMS + phiên bản, backend framework, phương thức xác thực (session/JWT/OAuth2), ngôn ngữ lập trình.Cần xác nhận, KHÔNG bịa.02_tech_context.md dùng chung cho cả db-designer và api-designer.conventions.md nếu có.docs/spec/database/03_database-design.md theo references/db-design-template.md (≤15 bảng: 1 file; >15 bảng: tách Master/Transaction/ER theo references/db-rules.md § file).references/db-rules.md (định nghĩa, constraint, index, relation, quy tắc nghiệp vụ, hiệu năng, bảo mật, thời hạn lưu trữ).references/db-rules.md §ER).00_index.md: thêm bảng truy vết DB (xem references/db-rules.md §truy vết).00_index.md + tài liệu DB hiện có để biết quan hệ.00_index.md.00_index.md xác định F-NNN nào đổi → bảng nào bị ảnh hưởng.00_index.md.../spec-writer/references/cross-doc-checks.md (mục B: màn ↔ DB); báo CRITICAL/WARNING.Cần xác nhận chưa giải quyết).docs/spec/
├── 00_index.md # (spec-writer) — bổ sung bảng truy vết DB ở đây
├── 02_tech_context.md # DBMS / framework / auth (dùng chung db + api)
└── database/
├── 03_database-design.md # ≤15 bảng: 1 file
│ # >15 bảng: tách ↓
├── 03_1_master-tables.md
├── 03_2_transaction-tables.md
└── 03_3_er-diagram.md
(ADR tùy chọn: docs/spec/database/adr/ADR-NNN_*.md cho quyết định lớn — xem references/db-rules.md §ADR.)
Cần xác nhận.references/db-design-template.md — khuôn tài liệu DB (9 section + per-table).references/tech-context-template.md — khuôn 02_tech_context.md.references/db-rules.md — quy tắc đặt tên, kiểu dữ liệu, ER Mermaid, phân loại dữ liệu, cập nhật truy vết 00_index.md, phase-gate, ADR.F-NNN trong 00_index.md; index hiệu năng gắn NFR-P nếu có.Cần xác nhận chưa xử lý (trừ phần cố ý chờ người dùng) + có version & Lịch sử thay đổi.npx claudepluginhub lvh149/create-document-skill --plugin spec-writerSearches MemPalace before answering questions about past work, people, projects, or prior decisions. Returns verbatim stored content instead of guessing from model memory.
Fetches up-to-date documentation from Context7 for libraries and frameworks like React, Next.js, Prisma. Use for setup questions, API references, and code examples.
Guides Payload CMS config (payload.config.ts), collections, fields, hooks, access control, APIs. Debugs validation errors, security, relationships, queries, transactions, hook behavior.