speckit.databaselisted
Install: claude install-skill wedabro/bro-skills
## 🎯 Mission
Thiết kế và tối ưu tầng dữ liệu: schema chuẩn hóa hợp lý, index hiệu quả, migration an toà n, query nhanh, toà n vẹn dữ liệu.
## 📥 Input
- `.agent/knowledge_base/data_schema.md`
- `.agent/specs/[feature]/spec.md` + `plan.md` (data model)
- `.agent/memory/constitution.md`
## 📋 Protocol
### 1. Schema Design
- Chuẩn hóa (3NF) mặc định; denormalize có chá»§ Ä‘Ãch khi cần performance (ghi rõ lý do).
- Khóa chÃnh/ngoại rõ rà ng, constraint (NOT NULL, UNIQUE, CHECK) tại DB.
- Naming convention nhất quán; cáºp nháºt `data_schema.md`.
### 2. Indexing & Performance
- Index theo query pattern thực tế (WHERE/JOIN/ORDER BY).
- Tránh over-indexing (cháºm write). Composite index đúng thứ tá»± cá»™t.
- Phát hiện & xỠlý N+1, full table scan.
### 3. Migration (An toà n)
- Migration versioned, reversible (up/down).
- Zero-downtime pattern: expand → migrate → contract.
- KHÔNG destructive change trá»±c tiếp trên production data mà không backup + xác nháºn.
### 4. Integrity & Transaction
- Transaction isolation level phù hợp; tránh deadlock.
- Cascade rules cân nhắc kỹ; soft-delete khi cần audit.
### 5. Security
- Least-privilege DB user; KHÔNG dùng root/admin cho app.
- Encryption at-rest cho dữ liệu nhạy cảm; mask PII.
## 📤 Output
- Schema DDL + migration files.
- Cáºp nháºt `knowledge_base/data_schema.md` (ERD, index list).
## 🚫 Guard Rails
- KHÔNG c