ai-developer-skill-os 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/bin/install.js +19 -4
  2. package/docs/HUONG_DAN_SU_DUNG.md +37 -47
  3. package/package.json +1 -1
  4. package/rules-skill/CHANGELOG.md +0 -31
  5. package/rules-skill/LICENSE +0 -21
  6. package/rules-skill/README.md +0 -142
  7. package/rules-skill/_template/SKILL.md +0 -154
  8. package/rules-skill/_template/examples/example-en.md +0 -49
  9. package/rules-skill/_template/examples/example-vi.md +0 -49
  10. package/rules-skill/docs/CHI_TIET_SKILLS.md +0 -117
  11. package/rules-skill/docs/HUONG_DAN_SU_DUNG.md +0 -102
  12. package/rules-skill/skills/backend/auth-security/SKILL.md +0 -94
  13. package/rules-skill/skills/backend/backend-architecture/SKILL.md +0 -123
  14. package/rules-skill/skills/backend/database-engineer/SKILL.md +0 -102
  15. package/rules-skill/skills/backend/deployment/SKILL.md +0 -94
  16. package/rules-skill/skills/engineering/agent-orchestrator/SKILL.md +0 -177
  17. package/rules-skill/skills/engineering/api-integration/SKILL.md +0 -378
  18. package/rules-skill/skills/engineering/bug-fix/SKILL.md +0 -211
  19. package/rules-skill/skills/engineering/context-manager/SKILL.md +0 -174
  20. package/rules-skill/skills/engineering/git-engineer/SKILL.md +0 -302
  21. package/rules-skill/skills/engineering/migration/SKILL.md +0 -282
  22. package/rules-skill/skills/engineering/project-audit/SKILL.md +0 -278
  23. package/rules-skill/skills/engineering/refactor/SKILL.md +0 -220
  24. package/rules-skill/skills/frontend/accessibility-audit/SKILL.md +0 -119
  25. package/rules-skill/skills/frontend/component-generator/SKILL.md +0 -134
  26. package/rules-skill/skills/frontend/design-system/SKILL.md +0 -135
  27. package/rules-skill/skills/frontend/form-builder/SKILL.md +0 -138
  28. package/rules-skill/skills/frontend/frontend-architecture/SKILL.md +0 -153
  29. package/rules-skill/skills/frontend/frontend-debug/SKILL.md +0 -131
  30. package/rules-skill/skills/frontend/frontend-performance/SKILL.md +0 -127
  31. package/rules-skill/skills/frontend/frontend-testing/SKILL.md +0 -144
  32. package/rules-skill/skills/frontend/state-management/SKILL.md +0 -138
  33. package/rules-skill/skills/frontend/table-crud-generator/SKILL.md +0 -125
  34. package/rules-skill/skills/frontend/ui-builder/SKILL.md +0 -150
  35. package/rules-skill/skills.json +0 -667
@@ -1,117 +0,0 @@
1
- # Chi Tiết 23 Skills — AI Developer Skill OS
2
-
3
- **Tác giả:** Quang Khánh
4
- **Phiên bản:** v1.0.0
5
-
6
- Tài liệu này giải thích chi tiết chức năng của từng Skill trong bộ Skill OS.
7
- AI sẽ đọc mô tả (description) bằng tiếng Anh để nhận diện, nhưng bạn có thể đọc tài liệu tiếng Việt này để hiểu AI có thể làm được gì.
8
-
9
- ---
10
-
11
- ## 🛠️ Nhóm 1: Engineering Core (Kỹ thuật Cốt lõi)
12
-
13
- Đây là các kỹ năng chung quản lý toàn bộ dự án, kiến trúc và mã nguồn.
14
-
15
- ### 1. `agent-orchestrator` (Người Điều Phối)
16
- - **Mô tả:** AI không tự viết code mà đóng vai trò như một Project Manager. Phân tích yêu cầu phức tạp của bạn, chia nhỏ thành các tác vụ (Task) và quyết định gọi các Skill nào theo thứ tự nào.
17
- - **Khi nào dùng:** Khi bạn giao một việc lớn ("Làm cho tôi tính năng thanh toán") mà không biết bắt đầu từ đâu.
18
-
19
- ### 2. `context-manager` (Quản Lý Ngữ Cảnh)
20
- - **Mô tả:** Xác định file nào cần đọc, đọc cấu trúc thư mục, ghi nhớ kiến trúc hệ thống để AI không bị "quên" hoặc đọc tràn ngập các file không cần thiết.
21
- - **Khi nào dùng:** Khi bắt đầu một dự án mới tinh, hoặc khi AI cần nắm bắt bức tranh tổng thể.
22
-
23
- ### 3. `project-audit` (Kiểm Toán Dự Án)
24
- - **Mô tả:** Quét toàn bộ mã nguồn hoặc các file bạn vừa thay đổi để tìm kiếm bug tiềm ẩn, code smell, lỗ hổng bảo mật hoặc nợ kỹ thuật. AI sẽ xuất ra một báo cáo khám bệnh chi tiết.
25
- - **Khi nào dùng:** Trước khi refactor lớn, trước khi release, hoặc muốn kiểm tra code mình viết có sạch không.
26
-
27
- ### 4. `bug-fix` (Chuyên Gia Sửa Lỗi)
28
- - **Mô tả:** Dò tìm nguyên nhân gốc rễ (root cause) của một lỗi dựa trên stack trace hoặc mô tả của bạn. Không chữa cháy tạm thời, cung cấp bản fix tối thiểu và an toàn nhất.
29
- - **Khi nào dùng:** Khi app bị crash, test fail, màn hình trắng.
30
-
31
- ### 5. `refactor` (Tái Cấu Trúc Code)
32
- - **Mô tả:** Làm sạch code, tách hàm, tách component, xóa code thừa, dọn dẹp biến mà **không làm thay đổi logic hoạt động**.
33
- - **Khi nào dùng:** Khi code quá rối rắm (spaghetti code), cần dọn dẹp cho dễ bảo trì.
34
-
35
- ### 6. `api-integration` (Kỹ Sư Tích Hợp API)
36
- - **Mô tả:** Nhận bất kỳ input nào (curl, swagger, postman, backend controller) và sinh ra một lớp gọi API hoàn chỉnh cho Frontend (Type chuẩn, xử lý lỗi, call Axios/Fetch/React Query).
37
- - **Khi nào dùng:** Khi Backend vừa làm xong API và bạn cần nối nó vào Frontend.
38
-
39
- ### 7. `migration` (Nâng Cấp Hệ Thống)
40
- - **Mô tả:** Nâng cấp an toàn các thư viện cũ (như React 17 lên 19), chuyển đổi thư viện (Moment sang Date-fns) theo mô hình tăng dần, có kế hoạch Rollback.
41
- - **Khi nào dùng:** Khi cần update package có lỗ hổng bảo mật hoặc chuyển framework.
42
-
43
- ### 8. `git-engineer` (Quản Lý Git & Release)
44
- - **Mô tả:** Viết commit message cực chuẩn theo Conventional Commits, viết mô tả Pull Request, sinh Changelog và Release Notes cho sếp/khách hàng đọc.
45
- - **Khi nào dùng:** Khi code xong và cần đẩy code lên hoặc chuẩn bị release version mới.
46
-
47
- ---
48
-
49
- ## 🎨 Nhóm 2: Frontend (Giao Diện)
50
-
51
- Nhóm chuyên biệt cho việc xây dựng giao diện người dùng (UI/UX).
52
-
53
- ### 9. `frontend-architecture` (Kiến Trúc Frontend)
54
- - **Mô tả:** Đọc hiểu và ép AI phải tuân thủ việc đặt file ở đâu cho đúng chuẩn của project (Features-based, Layer-based, DDD...).
55
- - **Khi nào dùng:** Khi không biết nên tạo file component mới ở thư mục nào.
56
-
57
- ### 10. `design-system` (Hệ Thống Thiết Kế)
58
- - **Mô tả:** Ép AI phải dùng thư viện UI có sẵn (MUI, Shadcn, Tailwind...) thay vì tự viết HTML chay hay CSS inline lộn xộn.
59
- - **Khi nào dùng:** Đi kèm khi xây dựng UI để giữ tính nhất quán.
60
-
61
- ### 11. `ui-builder` (Xây Dựng Giao Diện)
62
- - **Mô tả:** Lắp ráp các component nhỏ thành một màn hình/trang hoàn chỉnh, xử lý layout (Grid/Flexbox) và responsive (di động/máy tính).
63
- - **Khi nào dùng:** Khi bạn đưa wireframe/mockup và bảo "Làm cho tôi màn hình Dashboard".
64
-
65
- ### 12. `component-generator` (Tạo Component Đơn Lẻ)
66
- - **Mô tả:** Sinh ra các mảnh ghép UI nhỏ, tái sử dụng được (như Button, Card, Dropdown) với Props Type an toàn.
67
- - **Khi nào dùng:** Khi cần tạo một UI Component dùng chung.
68
-
69
- ### 13. `state-management` (Quản Lý Trạng Thái)
70
- - **Mô tả:** Phân tích dữ liệu và quyết định nên dùng React Query, Redux, Zustand hay chỉ là useState local. Setup các store hoàn chỉnh.
71
- - **Khi nào dùng:** Khi phải truyền Props quá sâu, hoặc cần lưu cache dữ liệu.
72
-
73
- ### 14. `form-builder` (Chuyên Gia Làm Form)
74
- - **Mô tả:** Sinh ra các Form phức tạp với validate đầu vào (Zod, Yup) kết hợp React Hook Form. Hiển thị báo lỗi chuẩn mực.
75
- - **Khi nào dùng:** Làm màn hình Đăng ký, Đăng nhập, Tạo mới dữ liệu.
76
-
77
- ### 15. `table-crud-generator` (Làm Bảng Dữ Liệu)
78
- - **Mô tả:** Sinh ra bảng Data Grid hoàn chỉnh có phân trang (pagination), lọc, sắp xếp và các nút hành động (Thêm/Sửa/Xóa).
79
- - **Khi nào dùng:** Làm trang Admin quản trị.
80
-
81
- ### 16. `frontend-debug` (Sửa Lỗi Frontend)
82
- - **Mô tả:** Chuyên trị các lỗi khó chịu của UI như: Hydration Error (Next.js), Infinite Re-render (lặp vô tận), lỗi vỡ CSS layout.
83
- - **Khi nào dùng:** Lỗi vỡ giao diện hoặc lỗi render của React.
84
-
85
- ### 17. `frontend-testing` (Kiểm Thử UI)
86
- - **Mô tả:** Viết Unit Test, Component Test (React Testing Library) hay E2E Test (Cypress/Playwright) giả lập hành vi người dùng thật.
87
- - **Khi nào dùng:** Khi sếp yêu cầu tăng Test Coverage hoặc bọc test cho tính năng quan trọng.
88
-
89
- ### 18. `accessibility-audit` (Kiểm Tra Tiếp Cận)
90
- - **Mô tả:** Đảm bảo trang web chuẩn WCAG, dùng đúng thẻ Semantic HTML, có thể dùng phím Tab để điều hướng và hỗ trợ phần mềm đọc màn hình cho người khiếm thị.
91
- - **Khi nào dùng:** Làm các project chuẩn quốc tế, nhà nước, hoặc tối ưu SEO nâng cao.
92
-
93
- ### 19. `frontend-performance` (Tối Ưu Hiệu Năng)
94
- - **Mô tả:** Chữa bệnh web chạy chậm. Tối ưu ảnh, chẻ nhỏ file JS (Code splitting, Lazy load), thêm `useMemo/useCallback` để tránh giật lag.
95
- - **Khi nào dùng:** Điểm Google Lighthouse thấp, web bị khựng khi cuộn.
96
-
97
- ---
98
-
99
- ## ⚙️ Nhóm 3: Backend (Máy Chủ)
100
-
101
- Nhóm chuyên biệt cho việc xây dựng và quản lý API, máy chủ.
102
-
103
- ### 20. `backend-architecture` (Kiến Trúc Backend)
104
- - **Mô tả:** Phân chia rạch ròi đâu là Controller (xử lý HTTP), đâu là Service (Xử lý nghiệp vụ), đâu là Repository (Gọi Database) để code không bị thành một đống bùi nhùi.
105
- - **Khi nào dùng:** Cấu trúc file cho backend mới hoặc thêm module mới.
106
-
107
- ### 21. `database-engineer` (Kỹ Sư Cơ Sở Dữ Liệu)
108
- - **Mô tả:** Thiết kế schema, vẽ quan hệ bảng, sinh script Migration, tối ưu hóa câu lệnh truy vấn (SQL, Prisma, Drizzle, MongoDB).
109
- - **Khi nào dùng:** Cần thêm bảng mới vào DB hoặc API truy vấn DB quá chậm.
110
-
111
- ### 22. `auth-security` (Bảo Mật & Phân Quyền)
112
- - **Mô tả:** Triển khai đăng nhập JWT, OAuth, thiết lập phân quyền (Admin vs User), phòng chống hacker tấn công bằng các cấu hình bảo mật chuẩn OWASP.
113
- - **Khi nào dùng:** Làm tính năng đăng nhập, bảo vệ API nhạy cảm.
114
-
115
- ### 23. `deployment` (Triển Khai DevOps)
116
- - **Mô tả:** Viết Dockerfile, cấu hình CI/CD bằng GitHub Actions, thiết lập luồng tự động build và deploy lên Vercel, AWS hoặc VPS.
117
- - **Khi nào dùng:** Lúc cần đưa code lên môi trường production cho khách hàng xem.
@@ -1,102 +0,0 @@
1
- # Hướng Dẫn Sử Dụng — AI Developer Skill OS
2
-
3
- **Tác giả:** Quang Khánh
4
- **Phiên bản:** v1.0.0
5
-
6
- Chào mừng bạn đến với **AI Developer Skill OS**, bộ khung quản lý kỹ năng (Skill Framework) biến các trợ lý AI (Claude Code, Kilo Code, Antigravity, Cursor, Windsurf) từ một "cỗ máy sinh code" thành một Senior Software Engineer thực thụ.
7
-
8
- ---
9
-
10
- ## 1. Cơ chế hoạt động (Tại sao lại cần Skin/Skill này?)
11
-
12
- Thông thường, khi bạn yêu cầu AI "Làm cho tôi tính năng X", AI sẽ nhảy ngay vào viết code. Điều này ở các dự án lớn thường dẫn đến: phá vỡ kiến trúc, tạo ra code rác, và không tuân thủ các component dùng chung.
13
-
14
- Với hệ điều hành kỹ năng (Skill OS) này:
15
- 1. Bạn đưa ra yêu cầu.
16
- 2. Skill **agent-orchestrator** sẽ tiếp nhận, phân tích và lên kế hoạch (Plan only).
17
- 3. Nó gọi **context-manager** để đọc đúng những file cần thiết (chống tràn ngữ cảnh).
18
- 4. Nó gọi các skill chuyên biệt (`ui-builder`, `api-integration`, `database-engineer`...) để thực thi từng bước.
19
- 5. AI luôn bị ép phải dùng tiếng Anh để viết code/định nghĩa biến, nhưng sẽ dùng tiếng Việt để giao tiếp và báo cáo với bạn.
20
-
21
- ---
22
-
23
- ## 2. Hướng dẫn cài đặt
24
-
25
- Bộ Skin này rất linh hoạt và có thể được tích hợp vào hầu hết các AI Agent IDE hiện đại:
26
-
27
- ### Cho Antigravity / Gemini IDE
28
- Bạn cần copy thư mục chứa các skill này vào thư mục `.agents` của dự án:
29
- ```
30
- my-project/
31
- └── .agents/
32
- └── skills/
33
- ├── engineering/
34
- ├── frontend/
35
- └── backend/
36
- ```
37
- Hoặc cấu hình Global trong máy tính của bạn tại:
38
- `C:\Users\<Tên-Máy-Bạn>\.gemini\config\skills\`
39
-
40
- ### Cho Claude Code & Kilo Code (CLI AI Agents)
41
- Claude Code và Kilo Code đọc các quy tắc (rules) từ thư mục gốc của dự án.
42
- **Cách cài đặt:**
43
- 1. Copy toàn bộ thư mục `rules-skill/` vào gốc dự án của bạn.
44
- 2. Tạo (hoặc sửa) file `CLAUDE.md` (đối với Claude) hoặc `KILO.md` (đối với Kilo) ở thư mục gốc, dán nội dung sau vào:
45
-
46
- ```md
47
- # System Instructions
48
- Bạn đang chạy bằng **AI Developer Skill OS** (Tác giả: Quang Khánh).
49
-
50
- Vui lòng tìm đọc danh sách kỹ năng tại file `./rules-skill/skills.json`.
51
- Trước khi thực hiện bất kỳ yêu cầu nào, hãy gọi file `SKILL.md` tương ứng trong thư mục `./rules-skill/skills/` để biết quy trình làm việc chuẩn.
52
- Luôn giao tiếp bằng tiếng Việt nhưng viết code, đặt tên biến, comment trong code bằng tiếng Anh.
53
- ```
54
-
55
- ### Cho Cursor / Windsurf (AI Code Editors)
56
- Cursor và Windsurf sử dụng file quy tắc riêng biệt.
57
- **Cách cài đặt:**
58
- 1. Copy toàn bộ thư mục `rules-skill/` vào gốc dự án của bạn.
59
- 2. Mở file `.cursorrules` (với Cursor) hoặc `.windsurfrules` (với Windsurf), dán nội dung sau vào:
60
-
61
- ```md
62
- # AI Developer Skill OS by Quang Khánh
63
-
64
- When answering or generating code, you MUST act as an expert engineer using the skills defined in `./rules-skill/skills.json`.
65
- Always read the relevant `SKILL.md` from `./rules-skill/skills/` before providing a solution.
66
- Speak to me in Vietnamese, but write all code in English.
67
- ```
68
-
69
- ---
70
-
71
- ## 3. Cách tương tác với AI
72
-
73
- Vì AI giờ đây đã có "nghề" (Skill), bạn không cần phải prompt quá dài dòng. Hãy ra lệnh như giao việc cho một kỹ sư.
74
-
75
- **Ví dụ 1: Nhờ AI tự lên kế hoạch (Kích hoạt `agent-orchestrator`)**
76
- > "Quang Khánh ơi, dự án này đang cần thêm tính năng Đăng nhập. Cậu lên kế hoạch giúp mình nên làm gì trước nhé."
77
-
78
- **Ví dụ 2: Sửa lỗi (Kích hoạt `bug-fix`)**
79
- > "Bị lỗi Hydration error trên Next.js rồi. Fix giúp mình."
80
-
81
- **Ví dụ 3: Review Codebase (Kích hoạt `project-audit`)**
82
- > "Audit nhanh cho tôi thư mục `src/components/`, tìm xem có bị vấn đề về hiệu năng hay code smell không."
83
-
84
- **Ví dụ 4: Frontend UI (Kích hoạt `ui-builder` + `design-system`)**
85
- > "Làm cho tôi cái giao diện màn hình Danh sách User. Chú ý dùng chuẩn components của thư mục `src/components/ui/` nhé."
86
-
87
- **Ví dụ 5: Tích hợp API (Kích hoạt `api-integration`)**
88
- > "Tích hợp cái swagger login này vào frontend giúp. Nhớ dùng React Query như chuẩn của project."
89
-
90
- ---
91
-
92
- ## 4. Tùy chỉnh Skin (Dành cho Advanced User)
93
-
94
- Nếu bạn muốn thêm kỹ năng mới cho AI, hãy sử dụng mẫu (Template) đã được tác giả chuẩn bị sẵn:
95
- 1. Copy file từ thư mục `_template/SKILL.md`.
96
- 2. Chỉnh sửa các thông số: Name, Description, Trigger, Scope, v.v.
97
- 3. Đăng ký nó vào file `skills.json` ở gốc.
98
- 4. Tận hưởng AI với kỹ năng mới của riêng bạn!
99
-
100
- ---
101
-
102
- Để xem danh sách chi tiết và công dụng của từng skill, vui lòng xem [Chi Tiết Skills](CHI_TIET_SKILLS.md).
@@ -1,94 +0,0 @@
1
- ---
2
- name: auth-security
3
- description: >-
4
- Triển khai tính năng đăng nhập (JWT, OAuth), phân quyền (RBAC) và bảo vệ app khỏi các lỗ hổng OWASP.
5
- version: 1.0.0
6
- category: backend
7
- tags: [auth, security, jwt, oauth, rbac, owasp]
8
- platforms: [antigravity, claude-code, kilo-code, cursor, windsurf]
9
- ---
10
-
11
- # Auth & Security Engineer
12
-
13
- > **Language rule:**
14
- > Use **English** for: security protocols, tokens, headers, algorithms, code.
15
- > Use **the user's language** for: explanations, summaries, and questions.
16
-
17
- ---
18
-
19
- ## Trigger
20
-
21
- Activate this skill when:
22
- - User asks to "add login", "protect this route", or "implement OAuth"
23
- - Defining user roles and permissions (Admin vs User)
24
- - Project audit flags security vulnerabilities (P0/P1)
25
- - Handling sensitive data (passwords, PII, API keys)
26
-
27
- ---
28
-
29
- ## Scope
30
-
31
- - ✅ **Authentication:** JWT, Session Cookies, OAuth2 (Google, GitHub, etc.), Magic Links.
32
- - ✅ **Authorization:** Role-Based Access Control (RBAC), Middleware guards.
33
- - ✅ **Data Protection:** Hashing passwords (bcrypt, Argon2), encrypting sensitive fields.
34
- - ✅ **Vulnerability Prevention:** CSRF protection, Rate Limiting, CORS config, input sanitization (SQLi/XSS).
35
-
36
- ---
37
-
38
- ## Non-goals
39
-
40
- - ❌ Do NOT store passwords in plain text. Ever.
41
- - ❌ Do NOT hardcode secrets or private keys in the code (use `.env`).
42
- - ❌ Do NOT store JWTs in `localStorage` if cookies (`httpOnly`) are an option, unless explicitly requested.
43
-
44
- ---
45
-
46
- ## Workflow
47
-
48
- ### Phase 1 — Strategy Selection
49
-
50
- Determine the auth mechanism:
51
- 1. **Stateless (JWT):** Good for mobile/SPAs, distributed systems.
52
- 2. **Stateful (Sessions):** Good for traditional web apps, easier revocation.
53
- 3. **Third-party (OAuth / Auth0 / NextAuth / Supabase):** Offload auth complexity.
54
-
55
- ### Phase 2 — Implementation
56
-
57
- **For JWT + Cookies (Recommended Web Pattern):**
58
- 1. Create Login endpoint: Verify password → Generate JWT → Set `httpOnly` cookie.
59
- 2. Create Middleware: Extract cookie → Verify JWT signature → Attach user to request.
60
- 3. Create Logout endpoint: Clear the cookie.
61
-
62
- **For Authorization:**
63
- 1. Define roles (e.g., `enum Role { ADMIN, USER }`).
64
- 2. Create Role Middleware: Check `req.user.role`.
65
-
66
- ### Phase 3 — Security Audit
67
-
68
- Verify:
69
- - Passwords are hashed with a salt (e.g., `bcrypt.hash(password, 10)`).
70
- - Cookies are `httpOnly`, `Secure` (in prod), and `SameSite`.
71
- - CORS is configured to only allow trusted origins.
72
-
73
- ---
74
-
75
- ## Output Format
76
-
77
- ```
78
- 🛡️ Auth & Security Report
79
- ─────────────────────────────────────────────────
80
- Mechanism: [JWT in httpOnly Cookie / OAuth / Session]
81
- Roles: [Admin, User]
82
-
83
- Components Implemented:
84
- ✅ Login/Logout handlers
85
- ✅ Auth Middleware (Guard)
86
- ✅ Password hashing (bcrypt)
87
-
88
- Security measures enforced:
89
- • `httpOnly`, `Secure`, `SameSite=Strict` on cookies
90
- • CORS restricted to frontend origin
91
-
92
- 🔗 Next Steps:
93
- Remember to add `JWT_SECRET` to your production environment variables.
94
- ```
@@ -1,123 +0,0 @@
1
- ---
2
- name: backend-architecture
3
- description: >-
4
- Kiểm soát cấu trúc backend, ép buộc tuân thủ mô hình Layer (Controller/Service/Repository) và vị trí file.
5
- version: 1.0.0
6
- category: backend
7
- tags: [architecture, backend, controller, service, repository, structure]
8
- platforms: [antigravity, claude-code, kilo-code, cursor, windsurf]
9
- ---
10
-
11
- # Backend Architecture
12
-
13
- > **Language rule:**
14
- > Use **English** for: code, folder names, pattern names, technical rules.
15
- > Use **the user's language** for: explanations, summaries, and questions.
16
-
17
- ---
18
-
19
- ## Trigger
20
-
21
- Activate this skill when:
22
- - Creating new backend API endpoints, services, or models
23
- - User asks "where should I put this business logic?"
24
- - Project audit flags mixed concerns (e.g., SQL queries inside a controller)
25
- - Inheriting or setting up a Node.js, Python, or Go backend
26
-
27
- ---
28
-
29
- ## Scope
30
-
31
- - ✅ Discover existing backend folder structure
32
- - ✅ Enforce Layered Architecture (Controller → Service → Data Access)
33
- - ✅ Enforce Domain/Module-based structure if applicable (`src/users/`, `src/orders/`)
34
- - ✅ Define where validation, mapping, and error handling should live
35
- - ✅ Validate file placement before code generation
36
-
37
- ---
38
-
39
- ## Non-goals
40
-
41
- - ❌ Do NOT rewrite the architecture unless requested
42
- - ❌ Do NOT write the actual database queries (delegate to `database-engineer`)
43
- - ❌ Do NOT configure server infrastructure (delegate to `deployment`)
44
-
45
- ---
46
-
47
- ## Severity Levels
48
-
49
- | Level | Meaning |
50
- |-------|---------|
51
- | P0 | Circular dependency or security bypass in architecture |
52
- | P1 | Mixed concerns (e.g., ORM logic in route handler) |
53
- | P2 | Inconsistent folder or file naming |
54
- | P3 | Minor deviation from convention |
55
-
56
- ---
57
-
58
- ## Workflow
59
-
60
- ### Phase 1 — Architecture Discovery
61
-
62
- Analyze the project structure:
63
- 1. **Classic MVC / Layered:** `controllers/`, `services/`, `models/`, `routes/`
64
- 2. **Domain-Driven (Module):** `src/modules/user/{controller, service, repository}`
65
- 3. **Framework-specific:** NestJS (`.controller.ts`, `.service.ts`), Django apps, Express monolithic.
66
- 4. **Serverless:** `functions/`, `handlers/`
67
-
68
- ---
69
-
70
- ### Phase 2 — Rule Extraction
71
-
72
- Extract conventions:
73
- - **Routes/Controllers:** Should only handle HTTP req/res, params validation, and calling services. No business logic.
74
- - **Services:** Pure business logic. Does not know about HTTP (`req`/`res`).
75
- - **Repositories/Data Access:** Only layer that interacts with the DB.
76
- - **Error Handling:** Centralized error middleware vs local try/catch.
77
-
78
- ---
79
-
80
- ### Phase 3 — File Placement & Routing
81
-
82
- Map a new requirement to the architecture:
83
-
84
- *Request: "Add an endpoint to update user profile"*
85
- - Route: `PUT /api/users/:id` mapped in `src/routes/user.routes.ts`
86
- - Controller: `updateProfile(req, res)` in `src/controllers/user.controller.ts`
87
- - Service: `updateUserProfile(userId, data)` in `src/services/user.service.ts`
88
-
89
- ---
90
-
91
- ## Decision Tree
92
-
93
- ```
94
- Does the project group files by Layer or by Domain?
95
- ├── Layer → Place in `src/controllers/` and `src/services/`
96
- └── Domain → Place in `src/modules/users/`
97
-
98
- Where does data validation happen?
99
- ├── Middleware → Add Zod/Joi validation at the router level
100
- └── Controller → Validate inside the controller function before calling service
101
- ```
102
-
103
- ---
104
-
105
- ## Output Format
106
-
107
- ```
108
- 🏗️ Backend Architecture Plan
109
- ─────────────────────────────────────────────────
110
- Structure Type: [Layered / Domain-based / Framework-specific]
111
-
112
- Layer Mapping:
113
- ✅ Controller: [path/to/controller.ts] — handles HTTP
114
- ✅ Service: [path/to/service.ts] — business logic
115
- ✅ Repo/DB: [handled by database-engineer]
116
-
117
- ⚠️ Constraints enforced:
118
- • Do not pass `req` or `res` objects into the Service layer.
119
- • Validate all inputs at the Controller/Route level.
120
-
121
- 🔗 Next Steps:
122
- Proceeding to implement the layers.
123
- ```
@@ -1,102 +0,0 @@
1
- ---
2
- name: database-engineer
3
- description: >-
4
- Thiết kế database schema, viết script migration và tối ưu truy vấn cho SQL/NoSQL bằng ORM (Prisma, Drizzle...).
5
- version: 1.0.0
6
- category: backend
7
- tags: [database, sql, prisma, drizzle, schema, migration, query-optimization]
8
- platforms: [antigravity, claude-code, kilo-code, cursor, windsurf]
9
- ---
10
-
11
- # Database Engineer
12
-
13
- > **Language rule:**
14
- > Use **English** for: table names, columns, queries, ORM code, technical terms.
15
- > Use **the user's language** for: explanations, summaries, and questions.
16
-
17
- ---
18
-
19
- ## Trigger
20
-
21
- Activate this skill when:
22
- - User says "create a new table", "add a column", "design the schema"
23
- - Writing complex data retrieval logic (joins, aggregations)
24
- - A query is running slowly and needs optimization (indexing)
25
- - Running or generating database migrations
26
-
27
- ---
28
-
29
- ## Scope
30
-
31
- - ✅ **Schema Design:** Model tables, relations (1:1, 1:N, N:M), and constraints (Unique, FK).
32
- - ✅ **ORM Integration:** Generate code for Prisma, Drizzle, TypeORM, Sequelize, or Mongoose.
33
- - ✅ **Migrations:** Generate SQL or ORM migration files safely.
34
- - ✅ **Query Optimization:** Prevent N+1 queries, add indexes, use efficient aggregations.
35
-
36
- ---
37
-
38
- ## Non-goals
39
-
40
- - ❌ Do NOT execute destructive migrations (DROP TABLE) on production environments without extreme warnings and approval.
41
- - ❌ Do NOT mix raw SQL into ORM logic unless necessary for performance.
42
-
43
- ---
44
-
45
- ## Workflow
46
-
47
- ### Phase 1 — Schema Design
48
-
49
- Understand the business entities and relations.
50
- - Identify primary keys (UUID vs Auto-increment ID).
51
- - Identify foreign keys and cascade rules (`ON DELETE CASCADE`).
52
- - Ensure proper normalization (usually 3NF) or denormalization (if NoSQL).
53
-
54
- ### Phase 2 — ORM / Migration Generation
55
-
56
- Map the design to the project's tool:
57
- - **Prisma:** Update `schema.prisma`.
58
- - **Drizzle:** Update `schema.ts`.
59
- - **Raw SQL:** Write `V1__create_table.sql`.
60
-
61
- ### Phase 3 — Query Implementation
62
-
63
- Write the data access methods (Repository pattern or direct ORM calls).
64
- - Avoid fetching `SELECT *` if only 2 columns are needed.
65
- - Batch queries or use joins to prevent N+1 issues.
66
-
67
- ---
68
-
69
- ## Decision Tree
70
-
71
- ```
72
- Is the project using an ORM?
73
- ├── Prisma → Modify `schema.prisma`, use `prisma.entity.findMany()`
74
- ├── Drizzle → Modify schema TS files, use Drizzle query builder
75
- └── No → Write raw SQL or use query builder (Knex)
76
-
77
- Does the schema change drop data or alter existing columns?
78
- ├── Yes → Flag as High Risk. Provide rollback strategy. Ask for approval.
79
- └── No → Standard migration (e.g., adding a nullable column).
80
- ```
81
-
82
- ---
83
-
84
- ## Output Format
85
-
86
- ```
87
- 🗄️ Database Engineering Report
88
- ─────────────────────────────────────────────────
89
- Action: [Schema Update / Query Optimization]
90
- Tooling: [Prisma / Raw SQL / etc.]
91
-
92
- Changes:
93
- ✅ Added model: `User` (1:N with `Post`)
94
- ✅ Added index on `User.email`
95
- ✅ Generated query: `getUserWithPosts`
96
-
97
- ⚠️ Risk Assessment:
98
- [Low / High — e.g., "Safe addition, no data loss"]
99
-
100
- 🔗 Next Steps:
101
- Run `npx prisma migrate dev` to apply these changes locally.
102
- ```
@@ -1,94 +0,0 @@
1
- ---
2
- name: deployment
3
- description: >-
4
- Cấu hình CI/CD pipelines, tạo Dockerfile và thiết lập môi trường để deploy lên Vercel, AWS hoặc VPS.
5
- version: 1.0.0
6
- category: backend
7
- tags: [deploy, ci-cd, docker, github-actions, devops, hosting]
8
- platforms: [antigravity, claude-code, kilo-code, cursor, windsurf]
9
- ---
10
-
11
- # Deployment & DevOps
12
-
13
- > **Language rule:**
14
- > Use **English** for: configuration files, Docker commands, YAML syntax, technical concepts.
15
- > Use **the user's language** for: explanations, summaries, and questions.
16
-
17
- ---
18
-
19
- ## Trigger
20
-
21
- Activate this skill when:
22
- - User asks "how do I deploy this?", "create a Dockerfile", or "setup CI/CD"
23
- - Configuring GitHub Actions, GitLab CI, or Jenkins
24
- - Preparing a project for Vercel, Netlify, Render, or AWS
25
- - Setting up environment variables for production
26
-
27
- ---
28
-
29
- ## Scope
30
-
31
- - ✅ **Containerization:** Write `Dockerfile` and `docker-compose.yml`.
32
- - ✅ **CI/CD Pipelines:** Write GitHub Actions YAML for testing, building, and deploying.
33
- - ✅ **Environment Setup:** Create `.env.example` and document required production variables.
34
- - ✅ **Build Scripts:** Ensure `package.json` has correct build and start commands.
35
-
36
- ---
37
-
38
- ## Non-goals
39
-
40
- - ❌ Do NOT expose real production secrets. Always use placeholders or CI secrets.
41
- - ❌ Do NOT over-complicate (e.g., don't setup Kubernetes if a simple Docker container on a VPS is enough).
42
-
43
- ---
44
-
45
- ## Workflow
46
-
47
- ### Phase 1 — Platform Selection
48
-
49
- Ask the user where they are deploying (if not specified):
50
- 1. **PaaS (Vercel, Render, Heroku):** Very easy, mostly relies on `vercel.json` or standard build scripts. No Docker needed usually.
51
- 2. **VPS/VM (DigitalOcean, AWS EC2):** Needs Docker and/or PM2 + Nginx reverse proxy.
52
- 3. **Container Service (AWS ECS, Google Cloud Run):** Needs a highly optimized Dockerfile.
53
-
54
- ### Phase 2 — Containerization (If required)
55
-
56
- Create a multi-stage Dockerfile for minimal image size:
57
- 1. `deps` stage: Install dependencies.
58
- 2. `builder` stage: Build the app.
59
- 3. `runner` stage: Copy only the built assets and prod modules, start the app.
60
-
61
- ### Phase 3 — CI/CD Pipeline
62
-
63
- Create `.github/workflows/deploy.yml`:
64
- - Trigger on `push` to `main`.
65
- - Job 1: Setup Node/Python/Go, install deps, run tests, run linter.
66
- - Job 2: Build image and push to registry, or deploy to PaaS.
67
-
68
- ### Phase 4 — Environment Variables
69
-
70
- Audit the codebase for `process.env.XYZ` and create a `.env.example` file listing every required variable.
71
-
72
- ---
73
-
74
- ## Output Format
75
-
76
- ```
77
- 🚀 Deployment Plan
78
- ─────────────────────────────────────────────────
79
- Target: [Vercel / Docker VPS / AWS]
80
- Tooling: [GitHub Actions, Docker]
81
-
82
- Files Created/Modified:
83
- ✅ `Dockerfile` (Multi-stage build)
84
- ✅ `.github/workflows/deploy.yml`
85
- ✅ `.env.example`
86
-
87
- ⚠️ Prerequisites:
88
- Before deploying, you must set these secrets in GitHub Actions:
89
- - `DOCKER_USERNAME`
90
- - `DATABASE_URL`
91
-
92
- 🔗 Next Steps:
93
- Commit these files and push to `main` to trigger the pipeline.
94
- ```