ai-developer-skill-os 2.1.1 → 3.1.0

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 (41) hide show
  1. package/.agents/AGENTS.md +81 -0
  2. package/CHANGELOG.md +14 -0
  3. package/README.md +84 -130
  4. package/docs/GOVERNANCE.md +40 -0
  5. package/docs/SPEC.md +37 -0
  6. package/docs/adr/0001-intent-based-architecture.md +19 -0
  7. package/docs/adr/0002-kernel-freeze.md +21 -0
  8. package/docs/adr/0003-risk-based-verification.md +20 -0
  9. package/docs/adr/0004-progressive-evidence.md +19 -0
  10. package/docs/skill-classification.md +25 -0
  11. package/knowledge/backend/nodejs.md +52 -0
  12. package/knowledge/frontend/react.md +81 -0
  13. package/package.json +1 -1
  14. package/skills/qk-access-policy/SKILL.md +40 -127
  15. package/skills/qk-ai-builder/SKILL.md +41 -33
  16. package/skills/qk-api-lifecycle/SKILL.md +62 -420
  17. package/skills/qk-bug-resolution/SKILL.md +67 -371
  18. package/skills/qk-context-loader/SKILL.md +47 -206
  19. package/skills/qk-data-lifecycle/SKILL.md +60 -135
  20. package/skills/qk-design-to-code/SKILL.md +46 -33
  21. package/skills/qk-docs/SKILL.md +52 -335
  22. package/skills/qk-documentation-system/SKILL.md +38 -33
  23. package/skills/qk-engineering-standard/SKILL.md +63 -171
  24. package/skills/qk-feature-delivery/SKILL.md +65 -432
  25. package/skills/qk-help/SKILL.md +37 -95
  26. package/skills/qk-orchestrator/SKILL.md +52 -272
  27. package/skills/qk-policy-engine/SKILL.md +52 -33
  28. package/skills/qk-production-release/SKILL.md +47 -127
  29. package/skills/qk-project-bootstrap/SKILL.md +43 -33
  30. package/skills/qk-project-health/SKILL.md +58 -650
  31. package/skills/qk-project-memory/SKILL.md +35 -33
  32. package/skills/qk-system-evolution/SKILL.md +65 -315
  33. package/skills/qk-ui-audit/SKILL.md +60 -152
  34. package/skills/qk-ui-system-builder/SKILL.md +40 -444
  35. package/skills/qk-validation-gate/SKILL.md +61 -33
  36. package/skills.json +36 -40
  37. package/templates/bug-report.md +21 -0
  38. package/templates/design-report.md +21 -0
  39. package/templates/feature-report.md +20 -0
  40. package/templates/review-report.md +21 -0
  41. package/templates/skill-template.md +38 -0
@@ -1,420 +1,62 @@
1
- ---
2
- name: qk-api-lifecycle
3
- description: Thiết kế Spec, Code Service, Types, Test, Docs cho API.
4
- mode_supported: [standard]
5
- input: [API requirement]
6
- output: [API Service, Routes, Docs]
7
- workflow: [1. Spec -> 2. Type -> 3. Service -> 4. Test -> 5. Docs]
8
- allowed_tools: [write_to_file, run_command]
9
- handoff_to: [qk-validation-gate]
10
- ---
11
-
12
- # 🛠️ qk-api-lifecycle - Quy Trình Vận Hành Chuẩn (SOP)
13
-
14
- > **Mô tả:** Thiết kế Spec, Code Service, Types, Test, Docs cho API.
15
-
16
- ## 🎯 1. Mục Tiêu (Goal)
17
- - Hoàn thành thành công tác vụ được giao liên quan đến nhiệm vụ của skill.
18
- - Đảm bảo chất lượng mã nguồn và tính nhất quán của hệ thống.
19
-
20
- ## 🔄 2. Chuỗi Hành Động (Chain of Thought / SOP)
21
- *(Bắt buộc AI phải suy nghĩ và làm theo đúng thứ tự)*
22
- 1. **Phân tích (Analyze):** Thu thập ngữ cảnh và hiểu rõ yêu cầu đầu vào.
23
- 2. **Lên kế hoạch (Plan):** Xác định các bước cần thay đổi/tạo mới dựa trên bộ luật (rules).
24
- 3. **Thực thi (Execute):** Tiến hành sửa đổi nguồn hoặc tạo tài liệu.
25
- 4. **Xác thực (Verify):** Đảm bảo đầu ra đáp ứng đúng yêu cầu và không vi phạm quy định.
26
-
27
- ## 🛡️ 3. Ràng Buộc & Quy Tắc (Constraints)
28
- - CẤM bỏ qua việc kiểm tra `qk-engineering-standard` trước khi viết code.
29
- - Mọi quyết định kỹ thuật phải dựa trên nội dung tại phần Deep Knowledge (nếu có).
30
-
31
- ## 🤝 4. Giao Thức Bàn Giao (Handoff Protocol)
32
- - Đích đến: `qk-validation-gate`
33
- - Nội dung bàn giao: Chuyển toàn bộ ngữ cảnh và kết quả đã thực thi cho bước tiếp theo.
34
-
35
- ## 📚 5. Kiến Thức Chuyên Sâu (Deep Knowledge)
36
-
37
- *(Nền tảng kiến thức quy tắc chi tiết kế thừa từ kỹ )*
38
-
39
- ---
40
-
41
-
42
-
43
- # API Integration Engineer
44
-
45
- > **Language rule:**
46
- > Use English for: code, identifiers, file names, architecture terms, technical decisions.
47
- > Use the user's language for: explanations, questions, summaries, and feedback.
48
- > The user may write in any language — detect and match it automatically.
49
-
50
- ---
51
-
52
- ## Trigger
53
-
54
- Activate this skill when the user provides any of:
55
- - `curl` command
56
- - Swagger 2.0 / OpenAPI 3.0 (YAML or JSON)
57
- - Postman collection or HAR file
58
- - API documentation (endpoint, method, request/response)
59
- - Code snippet to reverse-engineer (fetch/axios/custom client)
60
- - Backend controller or route handler to mirror on the frontend
61
-
62
- ---
63
-
64
- ## Scope
65
-
66
- - ✅ Parse and understand any API input format
67
- - ✅ Extract the full API contract (request + response + errors)
68
- - ✅ Detect existing project patterns (HTTP client, state layer, conventions)
69
- - ✅ Generate typed service/client, hooks/queries, and TypeScript types
70
- - ✅ Follow and extend existing architecture — never duplicate it
71
- - ✅ Handle special cases: file upload, file download, pagination, auth, WebSocket
72
-
73
- ---
74
-
75
- ## Non-goals
76
-
77
- - ❌ Do NOT create a new HTTP client if one already exists
78
- - ❌ Do NOT introduce a new state system if one is already in use
79
- - ❌ Do NOT hardcode URLs, tokens, or secrets
80
- - ❌ Do NOT use `any` when types can be inferred
81
- - ❌ Do NOT overwrite existing files without explicit user approval
82
-
83
- ---
84
-
85
- ## Severity Levels
86
-
87
- | Level | Meaning |
88
- |-------|---------|
89
- | P0 | Conflict with existing endpoint or type — must resolve before generating |
90
- | P1 | Missing critical info (auth, response schema) — ask before proceeding |
91
- | P2 | Naming or structure inconsistency — warn and apply best guess |
92
- | P3 | Missing optional fields — document assumption and proceed |
93
-
94
- ---
95
-
96
- ## Workflow
97
-
98
- ### Phase 1 — Input Validation
99
-
100
- Before parsing, verify:
101
- - URL is valid and method is correct (GET/POST/PUT/PATCH/DELETE)
102
- - Auth format is identifiable (Bearer, API Key, OAuth2, Basic, Cookie)
103
- - Request info is present (path params, query params, body)
104
- - Response structure is clear (JSON, binary, stream, paginated)
105
- - Error cases are documented
106
-
107
- If critical info is missing → **stop and ask**. Do not guess.
108
-
109
- ```json
110
- {
111
- "validation": {
112
- "status": "VALID | INVALID | INCOMPLETE",
113
- "confidence": 0.95,
114
- "errors": [],
115
- "warnings": [],
116
- "input_type": "curl | openapi | postman | docs | code"
117
- }
118
- }
119
- ```
120
-
121
- ---
122
-
123
- ### Phase 2 — API Contract Extraction
124
-
125
- Extract the full contract:
126
-
127
- ```
128
- metadata:
129
- name, domain, endpoint, method, version, description
130
-
131
- request:
132
- pathParams: { name, type, required }
133
- queryParams: { name, type, required, default }
134
- headers: { name, value, required }
135
- body: { contentType, schema { field, type, required, nullable } }
136
- auth: { type, location, name }
137
-
138
- response:
139
- success: { statusCode, contentType, schema, pagination? }
140
- errors: [ { statusCode, message, businessCode? } ]
141
-
142
- special:
143
- rateLimit, timeout, retryable, streaming
144
- ```
145
-
146
- Map each field: `type`, `required`, `nullable`, `enum`, `example`.
147
-
148
- ---
149
-
150
- ### Phase 3 — Project Profile Detection
151
-
152
- 1. Check for `.api-config.json` at project root → use if present
153
- 2. Otherwise infer from:
154
- - Framework: `package.json`, config files, imports
155
- - HTTP client: existing axios instance, fetch wrapper, custom client
156
- - State management: React Query, Redux, Zustand, Pinia, Apollo, Vuex
157
- - Type system: `tsconfig.json`, JSDoc, plain JS
158
- - Folder conventions: `services/`, `hooks/`, `api/`, `types/`, `adapters/`
159
- - Naming: camelCase, PascalCase, snake_case, file patterns
160
- 3. Read 1-2 existing API files to capture exact patterns for imports, typing, error handling, naming
161
-
162
- If project context is ambiguous → use conservative defaults and document all assumptions.
163
-
164
- ---
165
-
166
- ### Phase 4 — Conflict Detection
167
-
168
- Before generating code, check for:
169
-
170
- | Conflict | Action |
171
- |----------|--------|
172
- | `ENDPOINT_DUPLICATE` — endpoint already exists | Reuse if same, warn if different |
173
- | `FUNCTION_DUPLICATE` — function name conflicts | Warn, propose new name |
174
- | `TYPE_DUPLICATE` — type already defined | Extend or reuse existing |
175
- | `LOGIC_OVERLAP` — logic exists in another service | Consolidate, don't duplicate |
176
- | `IMPORT_CONFLICT` — import path conflicts | Resolve before generating |
177
-
178
- **P0 conflict → stop, report, wait for user decision before proceeding.**
179
-
180
- ---
181
-
182
- ### Phase 5 — Code Generation
183
-
184
- Generate the minimum necessary set for the task:
185
-
186
- #### TypeScript Types
187
- ```typescript
188
- // Request types
189
- export interface CreateUserRequest {
190
- name: string;
191
- email: string;
192
- role?: UserRole;
193
- }
194
-
195
- // Response types
196
- export interface CreateUserResponse {
197
- id: string;
198
- name: string;
199
- email: string;
200
- createdAt: string;
201
- }
202
-
203
- // Error types
204
- export interface ApiError {
205
- code: string;
206
- message: string;
207
- details?: Record<string, unknown>;
208
- }
209
- ```
210
-
211
- #### Service / API Layer
212
- ```typescript
213
- // Thin layer: HTTP + mapping only. No UI, no business logic.
214
- export const createUser = async (
215
- data: CreateUserRequest
216
- ): Promise<CreateUserResponse> => {
217
- const response = await apiClient.post<CreateUserResponse>('/users', data);
218
- return response.data;
219
- };
220
- ```
221
-
222
- #### Hook / Query (if project uses React Query)
223
- ```typescript
224
- export const useCreateUser = () => {
225
- return useMutation<CreateUserResponse, ApiError, CreateUserRequest>({
226
- mutationFn: createUser,
227
- onSuccess: () => {
228
- queryClient.invalidateQueries({ queryKey: ['users'] });
229
- },
230
- });
231
- };
232
- ```
233
-
234
- **If project uses Redux** → follow existing slice/thunk pattern.
235
- **If project uses Zustand** → follow existing store pattern.
236
- **If project uses Pinia/Vuex** → follow existing composable/action pattern.
237
-
238
- Do NOT mix patterns.
239
-
240
- ---
241
-
242
- ### Phase 6 — Special Case Handling
243
-
244
- #### File Upload (`multipart/form-data`)
245
- ```typescript
246
- // Always use FormData — never send File object in JSON
247
- const formData = new FormData();
248
- formData.append('file', file);
249
- formData.append('name', name);
250
- await apiClient.post('/upload', formData, {
251
- headers: { 'Content-Type': 'multipart/form-data' },
252
- });
253
- ```
254
-
255
- #### File Download (binary response)
256
- ```typescript
257
- const response = await apiClient.get('/export', { responseType: 'blob' });
258
- const url = URL.createObjectURL(response.data);
259
- const a = document.createElement('a');
260
- a.href = url;
261
- a.download = filename;
262
- a.click();
263
- URL.revokeObjectURL(url);
264
- ```
265
-
266
- #### Pagination
267
- ```typescript
268
- interface PaginatedResponse<T> {
269
- items: T[];
270
- total: number;
271
- page: number;
272
- limit: number;
273
- }
274
- // Implement consistently with existing project pagination pattern
275
- ```
276
-
277
- #### Authentication
278
- - Follow existing auth mechanism (interceptor, header injection, cookie)
279
- - Never hardcode tokens or credentials
280
- - Refresh token logic belongs in the existing interceptor
281
-
282
- ---
283
-
284
- ### Phase 7 — Quality Validation
285
-
286
- Before marking as ready:
287
-
288
- - [ ] TypeScript strict — compiles clean, no `any` without justification
289
- - [ ] All functions/params have explicit types and return types
290
- - [ ] No unused imports, no debug code
291
- - [ ] Error handling complete (try/catch, `.catch`, fallback)
292
- - [ ] No hardcoded URLs, tokens, or secrets — use env vars
293
- - [ ] Naming matches project conventions
294
- - [ ] Reuses existing HTTP client, interceptors, and query client
295
- - [ ] JSDoc added for public API if project convention requires it
296
- - [ ] React: dependency arrays correct, cleanup present, no race conditions
297
-
298
- ---
299
-
300
- ### Phase 8 — End-to-End UI Integration (Optional / On-Demand)
301
-
302
- If the user explicitly requests to integrate the API directly into the UI (End-to-End):
303
- 1. **Find Target Component:** Identify the UI component where the API should be called.
304
- 2. **Wire State:** Inject the generated Hook/Query/Service into the component.
305
- 3. **Handle States:** Implement Loading (spinners, skeletons), Error (toast, alert), and Success (redirect, form reset, table refetch) states in the UI.
306
- 4. **Data Binding:** Bind the API response data to the UI elements (Table rows, Dropdowns, etc.) and bind UI inputs to the API request payload.
307
-
308
- ---
309
-
310
- ## Decision Tree
311
-
312
- ```
313
- Is required info complete?
314
- ├── No → Ask for missing info (auth, response schema, base URL)
315
- └── Yes → Check for conflicts
316
- ├── P0 conflict → Stop, report, wait for user decision
317
- └── No P0 → Generate code following project patterns
318
- ```
319
-
320
- ```
321
- Does project have existing HTTP client?
322
- ├── Yes → Extend it
323
- └── No → Create minimal axios/fetch wrapper following project style
324
- ```
325
-
326
- ```
327
- Does project use state management?
328
- ├── React Query → useMutation / useQuery pattern
329
- ├── Redux → slice + thunk / RTK Query
330
- ├── Zustand → store action
331
- ├── Pinia → action in store
332
- └── None → Service function only
333
- ```
334
-
335
- ---
336
-
337
- ## Output Format
338
-
339
- ```
340
- 📋 API Contract
341
- ─────────────────────────────────────────────────
342
- Name: [API name]
343
- Endpoint: [METHOD /path]
344
- Auth: [type]
345
- Input: [brief description]
346
- Output: [brief description]
347
-
348
- 🔍 Project Pattern Detected
349
- ─────────────────────────────────────────────────
350
- HTTP client: [axios instance at src/lib/axios.ts]
351
- State: [React Query]
352
- Types path: [src/types/]
353
- Service path: [src/services/]
354
- Hook path: [src/hooks/]
355
-
356
- ⚠️ Assumptions
357
- ─────────────────────────────────────────────────
358
- • [Assumption 1]
359
- • [Assumption 2]
360
-
361
- 📁 Files Generated
362
- ─────────────────────────────────────────────────
363
- [NEW] src/types/user.types.ts
364
- [NEW] src/services/user.service.ts
365
- [NEW] src/hooks/useCreateUser.ts
366
- [EXTEND] src/services/index.ts
367
-
368
- 🔗 Next steps:
369
- → Import hook in your component
370
- → Add env var: VITE_API_BASE_URL
371
- → Test with: [example usage snippet]
372
- ```
373
-
374
- ---
375
-
376
- ## Validation Checklist
377
-
378
- - [ ] All 7 phases completed
379
- - [ ] Input validated — no missing critical fields
380
- - [ ] Conflicts checked — none unresolved
381
- - [ ] Types generated and strict
382
- - [ ] Existing HTTP client reused
383
- - [ ] Existing state pattern followed
384
- - [ ] Special cases handled if applicable (upload, download, pagination, auth)
385
- - [ ] No hardcoded secrets
386
- - [ ] Output format produced with files listed
387
-
388
- ---
389
-
390
- ## Project Config Reference (`.api-config.json`)
391
-
392
- ```json
393
- {
394
- "framework": "React",
395
- "httpClient": "axios",
396
- "stateManagement": "react-query",
397
- "typing": "typescript",
398
- "conventions": {
399
- "servicePath": "src/services/",
400
- "typePath": "src/types/",
401
- "hookPath": "src/hooks/",
402
- "naming": "camelCase",
403
- "fileNaming": "{name}.service.ts",
404
- "typeFileNaming": "{Name}.types.ts",
405
- "hookFileNaming": "use{Name}.ts"
406
- },
407
- "httpConfig": {
408
- "baseURL": "process.env.VITE_API_URL",
409
- "interceptor": "src/lib/axios.ts",
410
- "authHeader": "Authorization",
411
- "timeout": 30000
412
- }
413
- }
414
- ```
415
-
416
- ---
417
-
418
- ## Examples
419
-
420
- See `examples/` folder.
1
+ ---
2
+ name: qk-api-lifecycle
3
+ version: 3.0.0
4
+ updated: 2026-07-02
5
+ description: Design, implement, and integrate API endpoints.
6
+ category: engineering
7
+ priority: high
8
+ tags: [api, backend, frontend-integration, endpoints]
9
+ platforms: [claude-code, cursor, windsurf, gemini-cli]
10
+ trigger: User wants to create a new API, fix an API, or integrate frontend with backend API.
11
+ inputs: [API requirements, JSON schema, or Backend URL]
12
+ outputs: [API routes, Service classes, API Hooks]
13
+ allowed_tools: [run_command, read_file, write_to_file, grep_search]
14
+ pipeline: [analyze, implement, engineering-standard, validate, complete]
15
+ ---
16
+
17
+ # 🛠️ qk-api-lifecycle - Standard Operating Procedure
18
+
19
+ > **Goal:** Quản lý toàn bộ vòng đời của một API, từ việc thiết kế Spec (Swagger/Types) cho đến khi Backend code xong và Frontend gọi thành công.
20
+
21
+ ## 🔄 1. Chain of Thought (SOP)
22
+ 1. **Analyze (Contract Definition):**
23
+ - Read the user requirements.
24
+ - Define the exact API contract (Request Body, Query Params, Response DTO) in TypeScript interfaces or OpenAPI spec.
25
+ 2. **Plan (Architecture Selection):**
26
+ - Determine if the task is Backend (creating the endpoint) or Frontend (consuming the endpoint).
27
+ - If Frontend: Load `knowledge/frontend/react.md` to decide between React Query vs raw fetch.
28
+ - If Backend: Choose the appropriate layer (Controller -> Service -> Repository).
29
+ 3. **Execute (Implementation):**
30
+ - Write the backend handler/controller with strict validation (e.g., Zod, Class Validator).
31
+ - Write the frontend API client (e.g., Axios instance wrapper).
32
+ 4. **Verify (Validation):**
33
+ - Handle Error Status Codes (400, 401, 403, 404, 500) gracefully.
34
+ - Ensure loading states are managed on the frontend.
35
+
36
+ ## 🛡️ 2. Constraints & Rules
37
+ - **No Hardcoded URLs:** Never hardcode `http://localhost:3000` inside frontend components. Always use environment variables (`process.env.API_URL`).
38
+ - **Separation of Concerns:** Do NOT write `fetch` or `axios.get` directly inside a React UI component. Extract it to a custom hook or an API service file.
39
+
40
+ ## 🌳 3. Decision Tree
41
+ ```text
42
+ Is this a Backend or Frontend task?
43
+ ├── BACKEND → Does the API need Database access?
44
+ │ ├── YES → Handoff to `qk-data-lifecycle` to create models first.
45
+ │ └── NO → Write Controller and Service.
46
+ └── FRONTEND Are we fetching data to display or mutating data?
47
+ ├── FETCH Use React Query `useQuery` or equivalent.
48
+ └── MUTATE Use React Query `useMutation` or equivalent.
49
+ ```
50
+
51
+ ## 🤝 4. Handoff Pipeline
52
+ 1. `engineering-standard`: Verify API naming conventions (e.g., `GET /users` instead of `POST /getUsers`).
53
+ 2. `validate`: Run API tests and Type-checks.
54
+ 3. `complete`: Generate the final report.
55
+
56
+ ## 📝 5. Output Format
57
+ Vui lòng trả kết quả bằng Tiếng Việt. Sử dụng template chuẩn của hệ thống:
58
+ - **Tóm tắt (Summary):** Các endpoint đã tạo hoặc tích hợp.
59
+ - **Chi tiết (Changes):** File nào chứa logic API.
60
+ - **Kiến trúc (Reasoning):** do chọn thư viện hoặc cách bắt lỗi (Error handling).
61
+ - **Xác thực (Verification):** Cách gọi thử API.
62
+ - **Rủi ro (Risks):** Vấn đề bảo mật CORS hoặc Rate Limit (nếu có).