marketingjuliancongdanh79-pixel/skill-generator
skill-creator-ultra
VerifiedTạo AI Skill mới từ ý tưởng hoặc quy trình công việc. Kết hợp phỏng vấn thông minh, pattern detection, và quantitative evaluation để tạo skill chất lượng production. Dùng khi user nói "tạo skill", "biến quy trình thành skill", "make a new skill", "tự động hóa công việc này", hoặc mô tả quy trình lặp lại mà họ muốn AI tự làm. Cũng dùng khi user muốn cải thiện, test, hoặc optimize skill hiện có.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 14.4 KB |
| agents/analyzer.md | markdown | 10.1 KB |
| agents/comparator.md | markdown | 7.1 KB |
| agents/grader.md | markdown | 8.8 KB |
| assets/eval_review.html | other | 6.9 KB |
| examples/example_anthropic_frontend.md | markdown | 4.9 KB |
| examples/example_anthropic_pdf.md | markdown | 4.5 KB |
| examples/example_api_docs.md | markdown | 5.3 KB |
| examples/example_db_migration.md | markdown | 8.8 KB |
| examples/example_git_commit.md | markdown | 4.1 KB |
| scripts/ci_eval.py | script | 6.4 KB |
| scripts/package_skill.py | script | 4.9 KB |
| scripts/simulate_skill.py | script | 14.2 KB |
| scripts/skill_audit.py | script | 22.7 KB |
| scripts/skill_compare.py | script | 9.3 KB |
| scripts/skill_export.py | script | 9.6 KB |
| scripts/skill_scaffold.py | script | 11.7 KB |
| scripts/skill_stats.py | script | 11.6 KB |
| scripts/validate_skill.py | script | 15.0 KB |
examples/example_db_migration.md
View on GitHub# Example: db-migration-checker (🟠 Phức tạp — Complexity 16)
> **Nguồn cảm hứng:** Real-world DB migration risks + Anthropic's pdf skill (scripts + resources).
> **Mức độ:** Phức tạp — SKILL.md + resources/ + examples/ + scripts/.
> **Tham khảo:** Anthropic's `pdf` skill có SKILL.md 315 dòng + reference.md + forms.md + scripts/.
## 📂 Cấu trúc
```
skills/db-migration-checker/
├── SKILL.md ← Logic chính (~100 dòng)
├── README.md
├── resources/
│ ├── dangerous_patterns.md ← Danh sách patterns nguy hiểm
│ └── rollback_strategies.md ← Chiến thuật rollback theo DB type
├── examples/
│ ├── example_safe_migration.md ← Case an toàn
│ └── example_risky_migration.md ← Case nguy hiểm
└── scripts/
└── analyze_migration.py ← Script parse SQL file
```
---
## 📄 File 1: SKILL.md
```markdown
---
name: db-migration-checker
description: |
Review và đánh giá độ an toàn của file migration SQL/ORM trước khi chạy
trên production. Phát hiện breaking changes, data loss risks, locking issues.
Dùng khi user nói "review migration", "check migration", "migration safe
không", "database migration", "alter table", "schema change", hoặc khi
thấy file migration (*.sql, *_migration.py, *.up.sql). KHÔNG dùng cho:
viết migration mới, backup database, schema design.
---
# Goal
Phát hiện 100% migration nguy hiểm TRƯỚC KHI deploy — tránh downtime
và data loss trên production.
# Mindset
Bạn là **DBA nghiêm khắc** với kinh nghiệm xử lý 50+ production incidents.
Mặc định mọi migration đều nguy hiểm cho đến khi chứng minh an toàn.
# Instructions
1. Nhận file migration (.sql, .py, .ts, hoặc paste text).
2. Xác định DB type: PostgreSQL / MySQL / SQLite / MongoDB.
- Nếu không rõ → hỏi user
3. Parse migration → liệt kê operations:
- CREATE TABLE, ALTER TABLE, DROP TABLE
- ADD COLUMN, DROP COLUMN, RENAME COLUMN
- CREATE INDEX, DROP INDEX
- INSERT, UPDATE, DELETE (data migration)
4. Với MỖI operation, check `resources/dangerous_patterns.md`:
- 🔴 **CRITICAL**: Data loss, table drop, column rename không backward-compatible
- 🟡 **WARNING**: Lock nguy hiểm (ALTER TABLE trên bảng >1M rows)
- 🟢 **SAFE**: Additive changes (thêm column nullable, thêm index)
5. Ước tính lock time:
- Table size nếu biết → lock time ≈ f(rows, operation type)
- Nếu không biết table size → hỏi user: "Bảng X có bao nhiêu rows?"
6. Sinh báo cáo theo format:
## Migration Review Report
| # | Operation | Risk | Lock? | Ghi chú |
|---|-----------|------|-------|---------|
**Overall Risk: 🔴/🟡/🟢**
### Đề xuất:
- [Rollback strategy]
- [Safe deployment order]
7. ✅ VERIFY: Mọi DROP/DELETE có rollback strategy?
- Nếu thiếu → thêm từ `resources/rollback_strategies.md`
📚 Tham khảo: `resources/dangerous_patterns.md`, `resources/rollback_strategies.md`
# Examples
## Ví dụ 1: Migration an toàn
**Input:**
ALTER TABLE users ADD COLUMN avatar_url VARCHAR(255) DEFAULT NULL;
CREATE INDEX idx_users_email ON users(email);
**Output:**
| # | Operation | Risk | Lock? | Ghi chú |
|---|-----------|------|-------|---------|
| 1 | ADD COLUMN nullable | 🟢 SAFE | ~0s | Additive, không lock |
| 2 | CREATE INDEX | 🟡 WARN | ~5s (1M rows) | Dùng CONCURRENTLY |
**Overall Risk: 🟢 SAFE** — Chạy được, nhưng nên dùng `CREATE INDEX CONCURRENTLY`.
## Ví dụ 2: Migration nguy hiểm
**Input:**
ALTER TABLE orders DROP COLUMN customer_email;
ALTER TABLE orders RENAME COLUMN total TO amount;
**Output:**
| # | Operation | Risk | Lock? | Ghi chú |
|---|-----------|------|-------|---------|
| 1 | DROP COLUMN | 🔴 CRITICAL | ~10s | DATA LOSS — không thể undo |
| 2 | RENAME COLUMN | 🔴 CRITICAL | ~10s | App code đang dùng "total" sẽ crash |
**Overall Risk: 🔴 CRITICAL** — KHÔNG CHẠY. Cần 3-phase deployment.
# Constraints
- Mặc định mọi migration = nguy hiểm — "innocent until proven safe" ngược lại
- DROP/DELETE PHẢI có rollback strategy — vì production không có undo
- Luôn hỏi table size khi ALTER TABLE — vì lock time phụ thuộc rows
- Không tự chạy migration — chỉ review, KHÔNG execute
<!-- Generated by Skill Creator Ultra v1.0 -->
```
---
## 📄 File 2: resources/dangerous_patterns.md
```markdown
# ⚠️ Dangerous Migration Patterns
## 🔴 CRITICAL — Ngừng ngay, cần redesign
| Pattern | Vì sao nguy hiểm | Giải pháp |
|---|---|---|
| `DROP TABLE` | Mất toàn bộ data | Rename → archive → drop sau 30 ngày |
| `DROP COLUMN` | Mất data column đó | Backup column data trước |
| `RENAME COLUMN` | App code đang reference tên cũ | 3-phase: add new → migrate → drop old |
| `ALTER COLUMN type` | Implicit cast có thể fail | Test trên staging trước |
| `TRUNCATE TABLE` | Mất toàn bộ data, không log | Dùng DELETE + WHERE nếu cần |
## 🟡 WARNING — Xem xét kỹ
| Pattern | Vì sao nguy hiểm | Giải pháp |
|---|---|---|
| `ALTER TABLE` on >1M rows | Table lock, downtime | Dùng pt-online-schema-change |
| `ADD COLUMN NOT NULL` without default | Lock + rewrite toàn bộ table | Thêm DEFAULT hoặc nullable first |
| `CREATE INDEX` | Lock table (MyISAM) hoặc slow (InnoDB) | Dùng CONCURRENTLY (PostgreSQL) |
| `UPDATE` toàn bộ table | Lock rows, slow | Batch update 1000 rows/lần |
## 🟢 SAFE — Thường an toàn
| Pattern | Ghi chú |
|---|---|
| `ADD COLUMN nullable` | Nhanh, không lock |
| `CREATE INDEX CONCURRENTLY` | Non-blocking (PostgreSQL only) |
| `CREATE TABLE` | Bảng mới, không ảnh hưởng existing |
| `INSERT` vào bảng trống | Không conflict |
```
---
## 📄 File 3: resources/rollback_strategies.md
```markdown
# 🔄 Rollback Strategies theo DB Type
## PostgreSQL
| Operation | Rollback | Command |
|---|---|---|
| ADD COLUMN | DROP COLUMN | `ALTER TABLE x DROP COLUMN y;` |
| CREATE INDEX | DROP INDEX | `DROP INDEX IF EXISTS idx;` |
| DROP TABLE | Restore from backup | `pg_restore -d db -t table backup.dump` |
## MySQL
| Operation | Rollback | Command |
|---|---|---|
| ADD COLUMN | DROP COLUMN | `ALTER TABLE x DROP COLUMN y;` |
| CREATE INDEX | DROP INDEX | `DROP INDEX idx ON table;` |
| DROP TABLE | Restore from backup | `mysqlimport` hoặc point-in-time recovery |
## Quy tắc chung
1. LUÔN backup trước migration
2. Chạy migration trong transaction (nếu DB hỗ trợ)
3. Test trên staging TRƯỚC production
4. Deploy off-peak hours
```
---
## 📄 File 4: scripts/analyze_migration.py
```python
#!/usr/bin/env python3
"""
analyze_migration.py — Parse SQL migration file và phát hiện patterns nguy hiểm.
Usage:
python analyze_migration.py migration.sql
python analyze_migration.py migration.sql --verbose
python analyze_migration.py --help
"""
import sys
import re
import argparse
CRITICAL = ["DROP TABLE", "DROP COLUMN", "RENAME COLUMN", "TRUNCATE"]
WARNING = ["ALTER TABLE", "CREATE INDEX", "UPDATE", "ADD COLUMN .* NOT NULL"]
SAFE = ["ADD COLUMN .* NULL", "CREATE TABLE", "CREATE INDEX CONCURRENTLY"]
def analyze(sql_content):
results = []
for line in sql_content.split(";"):
line = line.strip().upper()
if not line: continue
risk = "🟢 SAFE"
for p in CRITICAL:
if re.search(p, line): risk = "🔴 CRITICAL"; break
if risk == "🟢 SAFE":
for p in WARNING:
if re.search(p, line): risk = "🟡 WARNING"; break
results.append({"operation": line[:60], "risk": risk})
return results
def main():
parser = argparse.ArgumentParser(description="Analyze SQL migration safety")
parser.add_argument("file", help="SQL migration file")
parser.add_argument("--verbose", "-v", action="store_true")
args = parser.parse_args()
with open(args.file) as f:
results = analyze(f.read())
for r in results:
print(f"{r['risk']} | {r['operation']}")
if __name__ == '__main__':
main()
```
---
## 🔍 Phân tích: Tại sao skill này tốt?
| Tiêu chí | Đánh giá | Ghi chú |
|---|---|---|
| **Progressive Disclosure** | ✅ | SKILL.md ~100 dòng, details in resources/ |
| **Explain The Why** | ✅ | "vì production không có undo" |
| **Role Priming** | ✅ | "DBA nghiêm khắc, 50+ incidents" |
| **Domain resources** | ✅ | dangerous_patterns.md + rollback_strategies.md |
| **Script hỗ trợ** | ✅ | analyze_migration.py có --help + --verbose |
| **Black Box Script** | ✅ | AI dùng --help, không cần đọc source |
| **Verification Step** | ✅ | "Mọi DROP có rollback strategy?" |
| **Output Format Anchoring** | ✅ | Table format rõ ràng |
| **3 mức risk** | ✅ | 🔴 CRITICAL / 🟡 WARNING / 🟢 SAFE |
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |