ai-developer-skill-os 7.0.2 β 7.5.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.
- package/.agents/AGENTS.md +44 -88
- package/.agents/CHANGELOG.md +69 -0
- package/.agents/LICENSE +21 -0
- package/.agents/README.md +59 -0
- package/.agents/_template/BEHAVIOR_SPEC.md +96 -0
- package/.agents/_template/examples/example-en.md +49 -0
- package/.agents/_template/examples/example-vi.md +49 -0
- package/.agents/docs/CHI_TIET_SKILLS.md +125 -0
- package/.agents/docs/GOVERNANCE.md +40 -0
- package/.agents/docs/HUONG_DAN_SU_DUNG.md +120 -0
- package/.agents/docs/SPEC.md +87 -0
- package/.agents/docs/adr/0001-intent-based-architecture.md +19 -0
- package/.agents/docs/adr/0002-kernel-freeze.md +21 -0
- package/.agents/docs/adr/0003-risk-based-verification.md +20 -0
- package/.agents/docs/adr/0004-progressive-evidence.md +19 -0
- package/.agents/docs/skill-classification.md +25 -0
- package/.agents/skills/qk-access-policy/SKILL.md +179 -0
- package/.agents/skills/qk-ai-builder/SKILL.md +215 -0
- package/.agents/skills/qk-api-lifecycle/SKILL.md +176 -0
- package/.agents/skills/qk-bug-resolution/SKILL.md +307 -0
- package/.agents/skills/qk-context-loader/SKILL.md +218 -0
- package/.agents/skills/qk-data-lifecycle/SKILL.md +192 -0
- package/.agents/skills/qk-db-optimizer/SKILL.md +196 -0
- package/.agents/skills/qk-design-to-code/SKILL.md +285 -0
- package/.agents/skills/qk-docs/SKILL.md +198 -0
- package/.agents/skills/qk-engineering-standard/SKILL.md +351 -0
- package/.agents/skills/qk-engineering-standard/rules/backend.md +122 -0
- package/.agents/skills/qk-engineering-standard/rules/database.md +3 -0
- package/.agents/skills/qk-engineering-standard/rules/frontend.md +152 -0
- package/.agents/skills/qk-engineering-standard/rules/security.md +3 -0
- package/.agents/skills/qk-engineering-standard/rules/testing.md +3 -0
- package/.agents/skills/qk-fe-api-integration/SKILL.md +326 -0
- package/.agents/skills/qk-feature-delivery/SKILL.md +305 -0
- package/.agents/skills/qk-help/SKILL.md +193 -0
- package/.agents/skills/qk-orchestrator/SKILL.md +277 -0
- package/.agents/skills/qk-orchestrator/references/routing-table.md +77 -0
- package/.agents/skills/qk-production-release/SKILL.md +284 -0
- package/.agents/skills/qk-project-bootstrap/SKILL.md +234 -0
- package/.agents/skills/qk-project-health/SKILL.md +199 -0
- package/.agents/skills/qk-project-memory/SKILL.md +172 -0
- package/.agents/skills/qk-system-evolution/SKILL.md +281 -0
- package/.agents/skills/qk-ui-audit/SKILL.md +314 -0
- package/.agents/skills/qk-ui-audit/references/anti-slop-checklist.md +136 -0
- package/.agents/skills/qk-ui-system-builder/SKILL.md +221 -0
- package/.agents/skills/qk-validation-gate/SKILL.md +359 -0
- package/.agents/skills.json +819 -0
- package/.github/workflows/ci.yml +1 -1
- package/.qk-ai-skill-os/CHANGELOG.md +69 -0
- package/.qk-ai-skill-os/LICENSE +21 -0
- package/.qk-ai-skill-os/README.md +59 -0
- package/.qk-ai-skill-os/_template/BEHAVIOR_SPEC.md +96 -0
- package/.qk-ai-skill-os/_template/examples/example-en.md +49 -0
- package/.qk-ai-skill-os/_template/examples/example-vi.md +49 -0
- package/.qk-ai-skill-os/docs/CHI_TIET_SKILLS.md +125 -0
- package/.qk-ai-skill-os/docs/GOVERNANCE.md +40 -0
- package/.qk-ai-skill-os/docs/HUONG_DAN_SU_DUNG.md +120 -0
- package/.qk-ai-skill-os/docs/SPEC.md +87 -0
- package/.qk-ai-skill-os/docs/adr/0001-intent-based-architecture.md +19 -0
- package/.qk-ai-skill-os/docs/adr/0002-kernel-freeze.md +21 -0
- package/.qk-ai-skill-os/docs/adr/0003-risk-based-verification.md +20 -0
- package/.qk-ai-skill-os/docs/adr/0004-progressive-evidence.md +19 -0
- package/.qk-ai-skill-os/docs/skill-classification.md +25 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-accessibility-audit/SKILL.md +121 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-agent-orchestrator/SKILL.md +179 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-api-integration/SKILL.md +389 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-auth-security/SKILL.md +96 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-backend-architecture/SKILL.md +125 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-bug-fix/SKILL.md +213 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-component-generator/SKILL.md +136 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-context-manager/SKILL.md +175 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-database-engineer/SKILL.md +104 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-deployment/SKILL.md +96 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-design-system/SKILL.md +137 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-form-builder/SKILL.md +140 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-frontend-architecture/SKILL.md +155 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-frontend-debug/SKILL.md +133 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-frontend-performance/SKILL.md +129 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-frontend-testing/SKILL.md +146 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-git-engineer/SKILL.md +304 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-help/SKILL.md +68 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-migration/SKILL.md +284 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-project-audit/SKILL.md +280 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-refactor/SKILL.md +222 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-state-management/SKILL.md +140 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-table-crud-generator/SKILL.md +127 -0
- package/.qk-ai-skill-os/skills/_archive_old_skills/qk-ui-builder/SKILL.md +152 -0
- package/.qk-ai-skill-os/skills/_template/SKILL.md +238 -0
- package/.qk-ai-skill-os/skills/qk-access-policy/SKILL.md +179 -0
- package/.qk-ai-skill-os/skills/qk-ai-builder/SKILL.md +221 -0
- package/.qk-ai-skill-os/skills/qk-api-lifecycle/SKILL.md +176 -0
- package/.qk-ai-skill-os/skills/qk-bug-resolution/SKILL.md +307 -0
- package/.qk-ai-skill-os/skills/qk-context-loader/SKILL.md +218 -0
- package/.qk-ai-skill-os/skills/qk-data-lifecycle/SKILL.md +192 -0
- package/.qk-ai-skill-os/skills/qk-db-optimizer/SKILL.md +196 -0
- package/.qk-ai-skill-os/skills/qk-design-to-code/SKILL.md +291 -0
- package/.qk-ai-skill-os/skills/qk-docs/SKILL.md +198 -0
- package/.qk-ai-skill-os/skills/qk-engineering-standard/SKILL.md +351 -0
- package/.qk-ai-skill-os/skills/qk-engineering-standard/rules/backend.md +122 -0
- package/.qk-ai-skill-os/skills/qk-engineering-standard/rules/database.md +3 -0
- package/.qk-ai-skill-os/skills/qk-engineering-standard/rules/frontend.md +152 -0
- package/.qk-ai-skill-os/skills/qk-engineering-standard/rules/security.md +3 -0
- package/.qk-ai-skill-os/skills/qk-engineering-standard/rules/testing.md +3 -0
- package/.qk-ai-skill-os/skills/qk-fe-api-integration/SKILL.md +326 -0
- package/.qk-ai-skill-os/skills/qk-feature-delivery/SKILL.md +305 -0
- package/.qk-ai-skill-os/skills/qk-help/SKILL.md +193 -0
- package/.qk-ai-skill-os/skills/qk-orchestrator/SKILL.md +277 -0
- package/.qk-ai-skill-os/skills/qk-orchestrator/references/routing-table.md +77 -0
- package/.qk-ai-skill-os/skills/qk-production-release/SKILL.md +290 -0
- package/.qk-ai-skill-os/skills/qk-project-bootstrap/SKILL.md +240 -0
- package/.qk-ai-skill-os/skills/qk-project-health/SKILL.md +199 -0
- package/.qk-ai-skill-os/skills/qk-project-memory/SKILL.md +172 -0
- package/.qk-ai-skill-os/skills/qk-system-evolution/SKILL.md +285 -0
- package/.qk-ai-skill-os/skills/qk-ui-audit/SKILL.md +314 -0
- package/.qk-ai-skill-os/skills/qk-ui-audit/references/anti-slop-checklist.md +136 -0
- package/.qk-ai-skill-os/skills/qk-ui-system-builder/SKILL.md +225 -0
- package/.qk-ai-skill-os/skills/qk-validation-gate/SKILL.md +361 -0
- package/.qk-ai-skill-os/skills.json +819 -0
- package/CLAUDE.md +110 -0
- package/README.md +25 -3
- package/add_lang.js +21 -0
- package/add_lang.py +25 -0
- package/add_sections.py +53 -0
- package/bin/install.js +225 -170
- package/bin/lint.js +122 -0
- package/docs/CHI_TIET_SKILLS.md +26 -26
- package/docs/HUONG_DAN_SU_DUNG.md +3 -3
- package/docs/SPEC.md +70 -20
- package/framework/skill-schema.md +310 -0
- package/package.json +15 -4
- package/patch.js +15 -0
- package/patch.py +89 -0
- package/patch2.py +83 -0
- package/skills/_archive_old_skills/qk-accessibility-audit/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-agent-orchestrator/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-api-integration/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-auth-security/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-backend-architecture/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-bug-fix/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-component-generator/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-context-manager/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-database-engineer/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-deployment/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-design-system/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-form-builder/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-frontend-architecture/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-frontend-debug/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-frontend-performance/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-frontend-testing/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-git-engineer/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-help/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-migration/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-project-audit/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-refactor/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-state-management/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-table-crud-generator/SKILL.md +1 -0
- package/skills/_archive_old_skills/qk-ui-builder/SKILL.md +1 -0
- package/skills/_template/SKILL.md +238 -0
- package/skills/qk-access-policy/SKILL.md +179 -39
- package/skills/qk-ai-builder/SKILL.md +215 -40
- package/skills/qk-api-lifecycle/SKILL.md +176 -46
- package/skills/qk-bug-resolution/SKILL.md +307 -46
- package/skills/qk-context-loader/SKILL.md +218 -43
- package/skills/qk-data-lifecycle/SKILL.md +192 -44
- package/skills/qk-db-optimizer/SKILL.md +196 -41
- package/skills/qk-design-to-code/SKILL.md +285 -46
- package/skills/qk-docs/SKILL.md +198 -40
- package/skills/qk-engineering-standard/SKILL.md +351 -42
- package/skills/qk-fe-api-integration/SKILL.md +326 -55
- package/skills/qk-feature-delivery/SKILL.md +305 -48
- package/skills/qk-help/SKILL.md +178 -23
- package/skills/qk-orchestrator/SKILL.md +277 -42
- package/skills/qk-orchestrator/references/routing-table.md +77 -0
- package/skills/qk-production-release/SKILL.md +284 -41
- package/skills/qk-project-bootstrap/SKILL.md +234 -38
- package/skills/qk-project-health/SKILL.md +199 -40
- package/skills/qk-project-memory/SKILL.md +172 -40
- package/skills/qk-system-evolution/SKILL.md +281 -40
- package/skills/qk-ui-audit/SKILL.md +314 -42
- package/skills/qk-ui-audit/references/anti-slop-checklist.md +136 -0
- package/skills/qk-ui-system-builder/SKILL.md +221 -43
- package/skills/qk-validation-gate/SKILL.md +359 -40
- package/skills.json +813 -824
- package/specs/fixtures/user-payload.json +12 -0
- package/specs/regressions/api-integration-null-fields.yaml +19 -0
- package/temp_fix.js +61 -0
- package/tests/registry.test.js +1 -1
- package/update_template.js +28 -0
- package/skills/qk-policy-engine/SKILL.md +0 -39
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: qk-api-integration
|
|
3
|
+
description: >-
|
|
4
|
+
Chuyα»n Δα»i tΓ i liα»u API (curl, swagger...) thΓ nh code tΓch hợp frontend chuαΊ©n xΓ‘c, cΓ³ type an toΓ n vΓ xα» lΓ½ lα»i.
|
|
5
|
+
version: 2.0.0
|
|
6
|
+
category: engineering
|
|
7
|
+
tags: [api, integration, rest, graphql, axios, fetch, react-query, typescript]
|
|
8
|
+
platforms: [antigravity, claude-code, kilo-code, cursor, windsurf]
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# API Integration Engineer
|
|
12
|
+
|
|
13
|
+
> **Language rule:**
|
|
14
|
+
> Use English for: code, identifiers, file names, architecture terms, technical decisions.
|
|
15
|
+
> Use the user's language for: explanations, questions, summaries, and feedback.
|
|
16
|
+
> The user may write in any language β detect and match it automatically.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Trigger
|
|
21
|
+
|
|
22
|
+
Activate this skill when the user provides any of:
|
|
23
|
+
- `curl` command
|
|
24
|
+
- Swagger 2.0 / OpenAPI 3.0 (YAML or JSON)
|
|
25
|
+
- Postman collection or HAR file
|
|
26
|
+
- API documentation (endpoint, method, request/response)
|
|
27
|
+
- Code snippet to reverse-engineer (fetch/axios/custom client)
|
|
28
|
+
- Backend controller or route handler to mirror on the frontend
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Scope
|
|
33
|
+
|
|
34
|
+
- β
Parse and understand any API input format
|
|
35
|
+
- β
Extract the full API contract (request + response + errors)
|
|
36
|
+
- β
Detect existing project patterns (HTTP client, state layer, conventions)
|
|
37
|
+
- β
Generate typed service/client, hooks/queries, and TypeScript types
|
|
38
|
+
- β
Follow and extend existing architecture β never duplicate it
|
|
39
|
+
- β
Handle special cases: file upload, file download, pagination, auth, WebSocket
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Non-goals
|
|
44
|
+
|
|
45
|
+
- β Do NOT create a new HTTP client if one already exists
|
|
46
|
+
- β Do NOT introduce a new state system if one is already in use
|
|
47
|
+
- β Do NOT hardcode URLs, tokens, or secrets
|
|
48
|
+
- β Do NOT use `any` when types can be inferred
|
|
49
|
+
- β Do NOT overwrite existing files without explicit user approval
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Severity Levels
|
|
54
|
+
|
|
55
|
+
| Level | Meaning |
|
|
56
|
+
|-------|---------|
|
|
57
|
+
| P0 | Conflict with existing endpoint or type β must resolve before generating |
|
|
58
|
+
| P1 | Missing critical info (auth, response schema) β ask before proceeding |
|
|
59
|
+
| P2 | Naming or structure inconsistency β warn and apply best guess |
|
|
60
|
+
| P3 | Missing optional fields β document assumption and proceed |
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Workflow
|
|
65
|
+
|
|
66
|
+
### Phase 1 β Input Validation
|
|
67
|
+
|
|
68
|
+
Before parsing, verify:
|
|
69
|
+
- URL is valid and method is correct (GET/POST/PUT/PATCH/DELETE)
|
|
70
|
+
- Auth format is identifiable (Bearer, API Key, OAuth2, Basic, Cookie)
|
|
71
|
+
- Request info is present (path params, query params, body)
|
|
72
|
+
- Response structure is clear (JSON, binary, stream, paginated)
|
|
73
|
+
- Error cases are documented
|
|
74
|
+
|
|
75
|
+
If critical info is missing β **stop and ask**. Do not guess.
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"validation": {
|
|
80
|
+
"status": "VALID | INVALID | INCOMPLETE",
|
|
81
|
+
"confidence": 0.95,
|
|
82
|
+
"errors": [],
|
|
83
|
+
"warnings": [],
|
|
84
|
+
"input_type": "curl | openapi | postman | docs | code"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
### Phase 2 β API Contract Extraction
|
|
92
|
+
|
|
93
|
+
Extract the full contract:
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
metadata:
|
|
97
|
+
name, domain, endpoint, method, version, description
|
|
98
|
+
|
|
99
|
+
request:
|
|
100
|
+
pathParams: { name, type, required }
|
|
101
|
+
queryParams: { name, type, required, default }
|
|
102
|
+
headers: { name, value, required }
|
|
103
|
+
body: { contentType, schema { field, type, required, nullable } }
|
|
104
|
+
auth: { type, location, name }
|
|
105
|
+
|
|
106
|
+
response:
|
|
107
|
+
success: { statusCode, contentType, schema, pagination? }
|
|
108
|
+
errors: [ { statusCode, message, businessCode? } ]
|
|
109
|
+
|
|
110
|
+
special:
|
|
111
|
+
rateLimit, timeout, retryable, streaming
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Map each field: `type`, `required`, `nullable`, `enum`, `example`.
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
### Phase 3 β Project Profile Detection
|
|
119
|
+
|
|
120
|
+
1. Check for `.api-config.json` at project root β use if present
|
|
121
|
+
2. Otherwise infer from:
|
|
122
|
+
- Framework: `package.json`, config files, imports
|
|
123
|
+
- HTTP client: existing axios instance, fetch wrapper, custom client
|
|
124
|
+
- State management: React Query, Redux, Zustand, Pinia, Apollo, Vuex
|
|
125
|
+
- Type system: `tsconfig.json`, JSDoc, plain JS
|
|
126
|
+
- Folder conventions: `services/`, `hooks/`, `api/`, `types/`, `adapters/`
|
|
127
|
+
- Naming: camelCase, PascalCase, snake_case, file patterns
|
|
128
|
+
3. Read 1-2 existing API files to capture exact patterns for imports, typing, error handling, naming
|
|
129
|
+
|
|
130
|
+
If project context is ambiguous β use conservative defaults and document all assumptions.
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
### Phase 4 β Conflict Detection
|
|
135
|
+
|
|
136
|
+
Before generating code, check for:
|
|
137
|
+
|
|
138
|
+
| Conflict | Action |
|
|
139
|
+
|----------|--------|
|
|
140
|
+
| `ENDPOINT_DUPLICATE` β endpoint already exists | Reuse if same, warn if different |
|
|
141
|
+
| `FUNCTION_DUPLICATE` β function name conflicts | Warn, propose new name |
|
|
142
|
+
| `TYPE_DUPLICATE` β type already defined | Extend or reuse existing |
|
|
143
|
+
| `LOGIC_OVERLAP` β logic exists in another service | Consolidate, don't duplicate |
|
|
144
|
+
| `IMPORT_CONFLICT` β import path conflicts | Resolve before generating |
|
|
145
|
+
|
|
146
|
+
**P0 conflict β stop, report, wait for user decision before proceeding.**
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
### Phase 5 β Code Generation
|
|
151
|
+
|
|
152
|
+
Generate the minimum necessary set for the task:
|
|
153
|
+
|
|
154
|
+
#### TypeScript Types
|
|
155
|
+
```typescript
|
|
156
|
+
// Request types
|
|
157
|
+
export interface CreateUserRequest {
|
|
158
|
+
name: string;
|
|
159
|
+
email: string;
|
|
160
|
+
role?: UserRole;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Response types
|
|
164
|
+
export interface CreateUserResponse {
|
|
165
|
+
id: string;
|
|
166
|
+
name: string;
|
|
167
|
+
email: string;
|
|
168
|
+
createdAt: string;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Error types
|
|
172
|
+
export interface ApiError {
|
|
173
|
+
code: string;
|
|
174
|
+
message: string;
|
|
175
|
+
details?: Record<string, unknown>;
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
#### Service / API Layer
|
|
180
|
+
```typescript
|
|
181
|
+
// Thin layer: HTTP + mapping only. No UI, no business logic.
|
|
182
|
+
export const createUser = async (
|
|
183
|
+
data: CreateUserRequest
|
|
184
|
+
): Promise<CreateUserResponse> => {
|
|
185
|
+
const response = await apiClient.post<CreateUserResponse>('/users', data);
|
|
186
|
+
return response.data;
|
|
187
|
+
};
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
#### Hook / Query (if project uses React Query)
|
|
191
|
+
```typescript
|
|
192
|
+
export const useCreateUser = () => {
|
|
193
|
+
return useMutation<CreateUserResponse, ApiError, CreateUserRequest>({
|
|
194
|
+
mutationFn: createUser,
|
|
195
|
+
onSuccess: () => {
|
|
196
|
+
queryClient.invalidateQueries({ queryKey: ['users'] });
|
|
197
|
+
},
|
|
198
|
+
});
|
|
199
|
+
};
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
**If project uses Redux** β follow existing slice/thunk pattern.
|
|
203
|
+
**If project uses Zustand** β follow existing store pattern.
|
|
204
|
+
**If project uses Pinia/Vuex** β follow existing composable/action pattern.
|
|
205
|
+
|
|
206
|
+
Do NOT mix patterns.
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
### Phase 6 β Special Case Handling
|
|
211
|
+
|
|
212
|
+
#### File Upload (`multipart/form-data`)
|
|
213
|
+
```typescript
|
|
214
|
+
// Always use FormData β never send File object in JSON
|
|
215
|
+
const formData = new FormData();
|
|
216
|
+
formData.append('file', file);
|
|
217
|
+
formData.append('name', name);
|
|
218
|
+
await apiClient.post('/upload', formData, {
|
|
219
|
+
headers: { 'Content-Type': 'multipart/form-data' },
|
|
220
|
+
});
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
#### File Download (binary response)
|
|
224
|
+
```typescript
|
|
225
|
+
const response = await apiClient.get('/export', { responseType: 'blob' });
|
|
226
|
+
const url = URL.createObjectURL(response.data);
|
|
227
|
+
const a = document.createElement('a');
|
|
228
|
+
a.href = url;
|
|
229
|
+
a.download = filename;
|
|
230
|
+
a.click();
|
|
231
|
+
URL.revokeObjectURL(url);
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
#### Pagination
|
|
235
|
+
```typescript
|
|
236
|
+
interface PaginatedResponse<T> {
|
|
237
|
+
items: T[];
|
|
238
|
+
total: number;
|
|
239
|
+
page: number;
|
|
240
|
+
limit: number;
|
|
241
|
+
}
|
|
242
|
+
// Implement consistently with existing project pagination pattern
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
#### Authentication
|
|
246
|
+
- Follow existing auth mechanism (interceptor, header injection, cookie)
|
|
247
|
+
- Never hardcode tokens or credentials
|
|
248
|
+
- Refresh token logic belongs in the existing interceptor
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
### Phase 7 β Quality Validation
|
|
253
|
+
|
|
254
|
+
Before marking as ready:
|
|
255
|
+
|
|
256
|
+
- [ ] TypeScript strict β compiles clean, no `any` without justification
|
|
257
|
+
- [ ] All functions/params have explicit types and return types
|
|
258
|
+
- [ ] No unused imports, no debug code
|
|
259
|
+
- [ ] Error handling complete (try/catch, `.catch`, fallback)
|
|
260
|
+
- [ ] No hardcoded URLs, tokens, or secrets β use env vars
|
|
261
|
+
- [ ] Naming matches project conventions
|
|
262
|
+
- [ ] Reuses existing HTTP client, interceptors, and query client
|
|
263
|
+
- [ ] JSDoc added for public API if project convention requires it
|
|
264
|
+
- [ ] React: dependency arrays correct, cleanup present, no race conditions
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
### Phase 8 β End-to-End UI Integration (Optional / On-Demand)
|
|
269
|
+
|
|
270
|
+
If the user explicitly requests to integrate the API directly into the UI (End-to-End):
|
|
271
|
+
1. **Find Target Component:** Identify the UI component where the API should be called.
|
|
272
|
+
2. **Wire State:** Inject the generated Hook/Query/Service into the component.
|
|
273
|
+
3. **Handle States:** Implement Loading (spinners, skeletons), Error (toast, alert), and Success (redirect, form reset, table refetch) states in the UI.
|
|
274
|
+
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.
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
## Decision Tree
|
|
279
|
+
|
|
280
|
+
```
|
|
281
|
+
Is required info complete?
|
|
282
|
+
βββ No β Ask for missing info (auth, response schema, base URL)
|
|
283
|
+
βββ Yes β Check for conflicts
|
|
284
|
+
βββ P0 conflict β Stop, report, wait for user decision
|
|
285
|
+
βββ No P0 β Generate code following project patterns
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
```
|
|
289
|
+
Does project have existing HTTP client?
|
|
290
|
+
βββ Yes β Extend it
|
|
291
|
+
βββ No β Create minimal axios/fetch wrapper following project style
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
```
|
|
295
|
+
Does project use state management?
|
|
296
|
+
βββ React Query β useMutation / useQuery pattern
|
|
297
|
+
βββ Redux β slice + thunk / RTK Query
|
|
298
|
+
βββ Zustand β store action
|
|
299
|
+
βββ Pinia β action in store
|
|
300
|
+
βββ None β Service function only
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## Output Format
|
|
306
|
+
|
|
307
|
+
```
|
|
308
|
+
π API Contract
|
|
309
|
+
βββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
310
|
+
Name: [API name]
|
|
311
|
+
Endpoint: [METHOD /path]
|
|
312
|
+
Auth: [type]
|
|
313
|
+
Input: [brief description]
|
|
314
|
+
Output: [brief description]
|
|
315
|
+
|
|
316
|
+
π Project Pattern Detected
|
|
317
|
+
βββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
318
|
+
HTTP client: [axios instance at src/lib/axios.ts]
|
|
319
|
+
State: [React Query]
|
|
320
|
+
Types path: [src/types/]
|
|
321
|
+
Service path: [src/services/]
|
|
322
|
+
Hook path: [src/hooks/]
|
|
323
|
+
|
|
324
|
+
β οΈ Assumptions
|
|
325
|
+
βββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
326
|
+
β’ [Assumption 1]
|
|
327
|
+
β’ [Assumption 2]
|
|
328
|
+
|
|
329
|
+
π Files Generated
|
|
330
|
+
βββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
331
|
+
[NEW] src/types/user.types.ts
|
|
332
|
+
[NEW] src/services/user.service.ts
|
|
333
|
+
[NEW] src/hooks/useCreateUser.ts
|
|
334
|
+
[EXTEND] src/services/index.ts
|
|
335
|
+
|
|
336
|
+
π Next steps:
|
|
337
|
+
β Import hook in your component
|
|
338
|
+
β Add env var: VITE_API_BASE_URL
|
|
339
|
+
β Test with: [example usage snippet]
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
---
|
|
343
|
+
|
|
344
|
+
## Validation Checklist
|
|
345
|
+
|
|
346
|
+
- [ ] All 7 phases completed
|
|
347
|
+
- [ ] Input validated β no missing critical fields
|
|
348
|
+
- [ ] Conflicts checked β none unresolved
|
|
349
|
+
- [ ] Types generated and strict
|
|
350
|
+
- [ ] Existing HTTP client reused
|
|
351
|
+
- [ ] Existing state pattern followed
|
|
352
|
+
- [ ] Special cases handled if applicable (upload, download, pagination, auth)
|
|
353
|
+
- [ ] No hardcoded secrets
|
|
354
|
+
- [ ] Output format produced with files listed
|
|
355
|
+
|
|
356
|
+
---
|
|
357
|
+
|
|
358
|
+
## Project Config Reference (`.api-config.json`)
|
|
359
|
+
|
|
360
|
+
```json
|
|
361
|
+
{
|
|
362
|
+
"framework": "React",
|
|
363
|
+
"httpClient": "axios",
|
|
364
|
+
"stateManagement": "react-query",
|
|
365
|
+
"typing": "typescript",
|
|
366
|
+
"conventions": {
|
|
367
|
+
"servicePath": "src/services/",
|
|
368
|
+
"typePath": "src/types/",
|
|
369
|
+
"hookPath": "src/hooks/",
|
|
370
|
+
"naming": "camelCase",
|
|
371
|
+
"fileNaming": "{name}.service.ts",
|
|
372
|
+
"typeFileNaming": "{Name}.types.ts",
|
|
373
|
+
"hookFileNaming": "use{Name}.ts"
|
|
374
|
+
},
|
|
375
|
+
"httpConfig": {
|
|
376
|
+
"baseURL": "process.env.VITE_API_URL",
|
|
377
|
+
"interceptor": "src/lib/axios.ts",
|
|
378
|
+
"authHeader": "Authorization",
|
|
379
|
+
"timeout": 30000
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
---
|
|
385
|
+
|
|
386
|
+
## Examples
|
|
387
|
+
|
|
388
|
+
See `examples/` folder.
|
|
389
|
+
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: qk-
|
|
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: code, identifiers, file names, architecture terms, technical decisions.
|
|
15
|
+
> Use the user's language for: explanations, questions, summaries, and feedback.
|
|
16
|
+
> The user may write in any language β detect and match it automatically.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Trigger
|
|
21
|
+
|
|
22
|
+
Activate this skill when:
|
|
23
|
+
- User asks to "add login", "protect this route", or "implement OAuth"
|
|
24
|
+
- Defining user roles and permissions (Admin vs User)
|
|
25
|
+
- Project audit flags security vulnerabilities (P0/P1)
|
|
26
|
+
- Handling sensitive data (passwords, PII, API keys)
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Scope
|
|
31
|
+
|
|
32
|
+
- β
**Authentication:** JWT, Session Cookies, OAuth2 (Google, GitHub, etc.), Magic Links.
|
|
33
|
+
- β
**Authorization:** Role-Based Access Control (RBAC), Middleware guards.
|
|
34
|
+
- β
**Data Protection:** Hashing passwords (bcrypt, Argon2), encrypting sensitive fields.
|
|
35
|
+
- β
**Vulnerability Prevention:** CSRF protection, Rate Limiting, CORS config, input sanitization (SQLi/XSS).
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Non-goals
|
|
40
|
+
|
|
41
|
+
- β Do NOT store passwords in plain text. Ever.
|
|
42
|
+
- β Do NOT hardcode secrets or private keys in the code (use `.env`).
|
|
43
|
+
- β Do NOT store JWTs in `localStorage` if cookies (`httpOnly`) are an option, unless explicitly requested.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Workflow
|
|
48
|
+
|
|
49
|
+
### Phase 1 β Strategy Selection
|
|
50
|
+
|
|
51
|
+
Determine the auth mechanism:
|
|
52
|
+
1. **Stateless (JWT):** Good for mobile/SPAs, distributed systems.
|
|
53
|
+
2. **Stateful (Sessions):** Good for traditional web apps, easier revocation.
|
|
54
|
+
3. **Third-party (OAuth / Auth0 / NextAuth / Supabase):** Offload auth complexity.
|
|
55
|
+
|
|
56
|
+
### Phase 2 β Implementation
|
|
57
|
+
|
|
58
|
+
**For JWT + Cookies (Recommended Web Pattern):**
|
|
59
|
+
1. Create Login endpoint: Verify password β Generate JWT β Set `httpOnly` cookie.
|
|
60
|
+
2. Create Middleware: Extract cookie β Verify JWT signature β Attach user to request.
|
|
61
|
+
3. Create Logout endpoint: Clear the cookie.
|
|
62
|
+
|
|
63
|
+
**For Authorization:**
|
|
64
|
+
1. Define roles (e.g., `enum Role { ADMIN, USER }`).
|
|
65
|
+
2. Create Role Middleware: Check `req.user.role`.
|
|
66
|
+
|
|
67
|
+
### Phase 3 β Security Audit
|
|
68
|
+
|
|
69
|
+
Verify:
|
|
70
|
+
- Passwords are hashed with a salt (e.g., `bcrypt.hash(password, 10)`).
|
|
71
|
+
- Cookies are `httpOnly`, `Secure` (in prod), and `SameSite`.
|
|
72
|
+
- CORS is configured to only allow trusted origins.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Output Format
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
π‘οΈ Auth & Security Report
|
|
80
|
+
βββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
81
|
+
Mechanism: [JWT in httpOnly Cookie / OAuth / Session]
|
|
82
|
+
Roles: [Admin, User]
|
|
83
|
+
|
|
84
|
+
Components Implemented:
|
|
85
|
+
β
Login/Logout handlers
|
|
86
|
+
β
Auth Middleware (Guard)
|
|
87
|
+
β
Password hashing (bcrypt)
|
|
88
|
+
|
|
89
|
+
Security measures enforced:
|
|
90
|
+
β’ `httpOnly`, `Secure`, `SameSite=Strict` on cookies
|
|
91
|
+
β’ CORS restricted to frontend origin
|
|
92
|
+
|
|
93
|
+
π Next Steps:
|
|
94
|
+
Remember to add `JWT_SECRET` to your production environment variables.
|
|
95
|
+
```
|
|
96
|
+
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: qk-
|
|
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, identifiers, file names, architecture terms, technical decisions.
|
|
15
|
+
> Use the user's language for: explanations, questions, summaries, and feedback.
|
|
16
|
+
> The user may write in any language β detect and match it automatically.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Trigger
|
|
21
|
+
|
|
22
|
+
Activate this skill when:
|
|
23
|
+
- Creating new backend API endpoints, services, or models
|
|
24
|
+
- User asks "where should I put this business logic?"
|
|
25
|
+
- Project audit flags mixed concerns (e.g., SQL queries inside a controller)
|
|
26
|
+
- Inheriting or setting up a Node.js, Python, or Go backend
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Scope
|
|
31
|
+
|
|
32
|
+
- β
Discover existing backend folder structure
|
|
33
|
+
- β
Enforce Layered Architecture (Controller β Service β Data Access)
|
|
34
|
+
- β
Enforce Domain/Module-based structure if applicable (`src/users/`, `src/orders/`)
|
|
35
|
+
- β
Define where validation, mapping, and error handling should live
|
|
36
|
+
- β
Validate file placement before code generation
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Non-goals
|
|
41
|
+
|
|
42
|
+
- β Do NOT rewrite the architecture unless requested
|
|
43
|
+
- β Do NOT write the actual database queries (delegate to `database-engineer`)
|
|
44
|
+
- β Do NOT configure server infrastructure (delegate to `deployment`)
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Severity Levels
|
|
49
|
+
|
|
50
|
+
| Level | Meaning |
|
|
51
|
+
|-------|---------|
|
|
52
|
+
| P0 | Circular dependency or security bypass in architecture |
|
|
53
|
+
| P1 | Mixed concerns (e.g., ORM logic in route handler) |
|
|
54
|
+
| P2 | Inconsistent folder or file naming |
|
|
55
|
+
| P3 | Minor deviation from convention |
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Workflow
|
|
60
|
+
|
|
61
|
+
### Phase 1 β Architecture Discovery
|
|
62
|
+
|
|
63
|
+
Analyze the project structure:
|
|
64
|
+
1. **Classic MVC / Layered:** `controllers/`, `services/`, `models/`, `routes/`
|
|
65
|
+
2. **Domain-Driven (Module):** `src/modules/user/{controller, service, repository}`
|
|
66
|
+
3. **Framework-specific:** NestJS (`.controller.ts`, `.service.ts`), Django apps, Express monolithic.
|
|
67
|
+
4. **Serverless:** `functions/`, `handlers/`
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
### Phase 2 β Rule Extraction
|
|
72
|
+
|
|
73
|
+
Extract conventions:
|
|
74
|
+
- **Routes/Controllers:** Should only handle HTTP req/res, params validation, and calling services. No business logic.
|
|
75
|
+
- **Services:** Pure business logic. Does not know about HTTP (`req`/`res`).
|
|
76
|
+
- **Repositories/Data Access:** Only layer that interacts with the DB.
|
|
77
|
+
- **Error Handling:** Centralized error middleware vs local try/catch.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
### Phase 3 β File Placement & Routing
|
|
82
|
+
|
|
83
|
+
Map a new requirement to the architecture:
|
|
84
|
+
|
|
85
|
+
*Request: "Add an endpoint to update user profile"*
|
|
86
|
+
- Route: `PUT /api/users/:id` mapped in `src/routes/user.routes.ts`
|
|
87
|
+
- Controller: `updateProfile(req, res)` in `src/controllers/user.controller.ts`
|
|
88
|
+
- Service: `updateUserProfile(userId, data)` in `src/services/user.service.ts`
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Decision Tree
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
Does the project group files by Layer or by Domain?
|
|
96
|
+
βββ Layer β Place in `src/controllers/` and `src/services/`
|
|
97
|
+
βββ Domain β Place in `src/modules/users/`
|
|
98
|
+
|
|
99
|
+
Where does data validation happen?
|
|
100
|
+
βββ Middleware β Add Zod/Joi validation at the router level
|
|
101
|
+
βββ Controller β Validate inside the controller function before calling service
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Output Format
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
ποΈ Backend Architecture Plan
|
|
110
|
+
βββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
111
|
+
Structure Type: [Layered / Domain-based / Framework-specific]
|
|
112
|
+
|
|
113
|
+
Layer Mapping:
|
|
114
|
+
β
Controller: [path/to/controller.ts] β handles HTTP
|
|
115
|
+
β
Service: [path/to/service.ts] β business logic
|
|
116
|
+
β
Repo/DB: [handled by database-engineer]
|
|
117
|
+
|
|
118
|
+
β οΈ Constraints enforced:
|
|
119
|
+
β’ Do not pass `req` or `res` objects into the Service layer.
|
|
120
|
+
β’ Validate all inputs at the Controller/Route level.
|
|
121
|
+
|
|
122
|
+
π Next Steps:
|
|
123
|
+
Proceeding to implement the layers.
|
|
124
|
+
```
|
|
125
|
+
|