ai-developer-skill-os 2.0.1 → 3.0.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.
@@ -1,650 +1,56 @@
1
- ---
2
- name: qk-project-health
3
- purpose: Kiểm toán Code Smell, Tech Debt, Architecture (Audit Only).
4
- mode_supported: [enterprise]
5
- input: [Codebase]
6
- output: [Health Report]
7
- workflow: [1. Scan Repo -> 2. Check Architecture -> 3. Report]
8
- allowed_tools: [run_command, grep_search]
9
- handoff_to: [qk-bug-resolution]
10
- ---
11
-
12
- # 🛠️ qk-project-health - Quy Trình Vận Hành Chuẩn (SOP)
13
-
14
- > **Mô tả:** Kiểm toán Code Smell, Tech Debt, Architecture (Audit Only).
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 mã 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-bug-resolution`
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 và quy tắc chi tiết kế thừa từ kỹ sư)*
38
-
39
- ---
40
-
41
-
42
-
43
- # Project Audit
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
- > ⚠️ **CRITICAL: Do NOT modify any code during audit.**
51
- > The audit produces a report. Changes happen only after the user reviews and approves.
52
-
53
- ---
54
-
55
- ## Trigger
56
-
57
- Activate this skill when:
58
- - User says "audit", "review", "health check", "what's wrong with my project"
59
- - Before starting a large feature or refactor
60
- - After inheriting a codebase
61
- - Before a major release
62
- - When the system behaves unexpectedly and the root cause is unknown
63
-
64
- ---
65
-
66
- ## Scope
67
-
68
- - ✅ Detect hidden bugs, race conditions, and unstable areas
69
- - ✅ Review architecture and separation of concerns
70
- - ✅ Identify security vulnerabilities
71
- - ✅ Find performance bottlenecks
72
- - ✅ Audit dependencies (outdated, risky, unused)
73
- - ✅ Produce prioritized findings with recommended fixes
74
-
75
- ---
76
-
77
- ## Non-goals
78
-
79
- - ❌ Do NOT fix anything during the audit
80
- - ❌ Do NOT refactor code
81
- - ❌ Do NOT make assumptions — document uncertainty instead
82
- - ❌ Do NOT audit `node_modules`, `dist`, `build`, `.git`
83
-
84
- ---
85
-
86
- ## Audit Modes
87
-
88
- Choose based on context:
89
-
90
- | Mode | Scope | When to use |
91
- |------|-------|-------------|
92
- | **Quick** | Changed files only (git diff / recent edits) | Fast pre-commit check, small bug scope |
93
- | **Standard** | Current feature / module being worked on | Default — before implementing changes |
94
- | **Full** | Entire repository | Onboarding, pre-release, inherited codebase |
95
-
96
- **Default: Standard mode.**
97
- Use Full mode only when explicitly requested or before a major release.
98
-
99
- ---
100
-
101
- ## Severity Levels
102
-
103
- All findings use this shared scale:
104
-
105
- | Level | Label | Meaning |
106
- |-------|-------|---------|
107
- | P0 | Critical | Security breach, data loss, production crash — fix immediately |
108
- | P1 | High | Bug affecting core functionality — fix before shipping |
109
- | P2 | Medium | Performance issue or bad pattern — schedule soon |
110
- | P3 | Low | Technical debt, code smell — fix when possible |
111
-
112
- ---
113
-
114
- ## Workflow
115
-
116
- ### Phase 1 — Project Discovery
117
-
118
- *(Use `context-manager` if project context is not yet loaded)*
119
-
120
- Analyze:
121
- - Framework, language, build system
122
- - Folder structure and architecture style
123
- - Key dependencies and their versions
124
- - Entry points, routing, data flow
125
-
126
- Output: **Project Overview** (2-5 lines)
127
-
128
- ---
129
-
130
- ### Phase 2 — Architecture Review
131
-
132
- Check:
133
-
134
- **Separation of concerns:**
135
- - Are UI components mixing API calls and business logic?
136
- - Are services doing too much?
137
- - Is there duplicated logic across modules?
138
-
139
- **Folder structure:**
140
- - Does file placement follow the declared architecture?
141
- - Are there misplaced files or responsibilities?
142
-
143
- **Patterns:**
144
- - Are patterns applied consistently? (hooks, services, stores)
145
- - Are there anti-patterns? (prop drilling, God components, circular imports)
146
-
147
- ---
148
-
149
- ### Phase 3 — Bug Detection
150
-
151
- #### Frontend
152
-
153
- Check for:
154
- - `useEffect` with missing or wrong dependency arrays
155
- - State updates after component unmount (memory leak)
156
- - Missing cleanup in subscriptions, timers, event listeners
157
- - Stale closures in async callbacks
158
- - Race conditions in data fetching
159
- - Infinite re-render loops
160
- - `key` prop issues in lists
161
-
162
- #### Backend
163
-
164
- Check for:
165
- - Unhandled promise rejections
166
- - Missing input validation
167
- - Incorrect HTTP status codes
168
- - Transaction issues (missing rollback on error)
169
- - Race conditions in concurrent operations
170
-
171
- #### API Layer
172
-
173
- Check for:
174
- - Inconsistent response handling
175
- - Missing error states
176
- - Duplicate requests without debounce/cancellation
177
- - Missing loading/error/empty states in UI
178
-
179
- ---
180
-
181
- ### Phase 4 — Security Audit
182
-
183
- Check for:
184
- - Hardcoded secrets, tokens, credentials in code
185
- - Sensitive data in `localStorage` or URL params
186
- - Missing authentication/authorization checks
187
- - SQL injection or NoSQL injection risks
188
- - XSS vulnerabilities (dangerouslySetInnerHTML, unsanitized input)
189
- - Insecure direct object references (IDOR)
190
- - CORS misconfiguration
191
-
192
- ---
193
-
194
- ### Phase 5 — Performance Audit
195
-
196
- Check for:
197
- - Large bundle size (missing code splitting, lazy loading)
198
- - Expensive computations on every render (missing `useMemo`, `useCallback`)
199
- - Unnecessary re-renders (missing `memo`, wrong dependency arrays)
200
- - N+1 query problems
201
- - Missing pagination on large datasets
202
- - Unoptimized images or assets
203
-
204
- ---
205
-
206
- ### Phase 6 — Dependency Audit
207
-
208
- Check:
209
- - Outdated packages with known CVEs
210
- - Packages with very low maintenance (abandoned)
211
- - Duplicate packages doing the same job
212
- - Unused dependencies in `package.json`
213
- - Major version gaps that indicate deferred upgrades
214
-
215
- ---
216
-
217
- ## Decision Tree
218
-
219
- ```
220
- Which audit mode?
221
- ├── Quick → Read only git diff / recently changed files
222
- ├── Standard → Read current feature/module files + related
223
- └── Full → Scan entire src/ directory systematically
224
-
225
- Issue found → Assess severity:
226
- ├── P0 → Flag immediately, recommend pausing current work
227
- ├── P1 → Include in required fixes before shipping
228
- ├── P2 → Include in scheduled improvements
229
- └── P3 → Log as technical debt
230
-
231
- No issues found in area → Mark as ✅ Clean
232
- ```
233
-
234
- ---
235
-
236
- ## Output Format
237
-
238
- ### Executive Summary
239
-
240
- ```
241
- 🏥 Project Health Report
242
- ─────────────────────────
243
- Health: [Excellent / Good / Needs Attention / Critical]
244
- Risk Level: [Low / Medium / High / Critical]
245
- Audit Mode: [Quick / Standard / Full]
246
- Files Reviewed: [N]
247
- Total Findings: [N] (P0: N · P1: N · P2: N · P3: N)
248
- ```
249
-
250
- ### Findings (one per issue)
251
-
252
- ```
253
- ───────────────────────────────
254
- ID: AUDIT-001
255
- Severity: P1 — High
256
- Location: src/hooks/useUserData.ts:47
257
- Problem: useEffect fetches data but missing cleanup — causes state update
258
- on unmounted component, triggering React warning and potential
259
- memory leak under slow networks.
260
- Impact: Console errors in production, potential memory leak.
261
- Root cause: No AbortController or isMounted flag used.
262
- Fix: Add AbortController + cleanup return in useEffect.
263
- Effort: ~15 min
264
- ```
265
-
266
- ### Priority Roadmap
267
-
268
- ```
269
- 🗺️ Fix Roadmap
270
- ──────────────────
271
- P0 — Fix immediately (before anything else):
272
- • [AUDIT-00X] [Brief description]
273
-
274
- P1 — Fix before shipping:
275
- • [AUDIT-00X] [Brief description]
276
-
277
- P2 — Schedule this sprint:
278
- • [AUDIT-00X] [Brief description]
279
-
280
- P3 — Technical debt backlog:
281
- • [AUDIT-00X] [Brief description]
282
- ```
283
-
284
- ### Next Steps
285
-
286
- ```
287
- 🔗 Recommended next skills:
288
- → bug-fix (for P0/P1 issues)
289
- → refactor (for architecture issues)
290
- → migration (for outdated dependencies)
291
- → frontend-performance (for P2 performance issues)
292
-
293
- ⏳ Awaiting your approval to proceed with fixes.
294
- ```
295
-
296
- ---
297
-
298
- ## Validation Checklist
299
-
300
- - [ ] Correct audit mode selected for the task
301
- - [ ] All 6 phases covered (or scoped ones for Quick/Standard)
302
- - [ ] Every finding has: ID, severity, location, problem, root cause, fix, effort
303
- - [ ] Priority roadmap is ordered correctly (P0 first)
304
- - [ ] No code was modified during audit
305
- - [ ] User informed — awaiting approval before any changes
306
-
307
- ---
308
-
309
- ## Examples
310
-
311
- See `examples/` folder.
312
-
313
- ---
314
-
315
-
316
-
317
- # Frontend Performance Optimizer
318
-
319
- > **Language rule:**
320
- > Use English for: code, identifiers, file names, architecture terms, technical decisions.
321
- > Use the user's language for: explanations, questions, summaries, and feedback.
322
- > The user may write in any language — detect and match it automatically.
323
-
324
- ---
325
-
326
- ## Trigger
327
-
328
- Activate this skill when:
329
- - User reports "app is slow", "loading takes too long", or "UI freezes"
330
- - Core Web Vitals (LCP, FID/INP, CLS) are failing
331
- - React DevTools shows excessive re-renders
332
- - `project-audit` flags a performance issue (P2)
333
- - Need to optimize images, bundle size, or data fetching
334
-
335
- ---
336
-
337
- ## Scope
338
-
339
- - ✅ **Render Optimization:** Prevent unnecessary re-renders (React `memo`, `useMemo`, `useCallback`).
340
- - ✅ **Bundle Optimization:** Code splitting, lazy loading components/routes (`React.lazy`, Next.js `dynamic`).
341
- - ✅ **Asset Optimization:** Image optimization (WebP, Next/Image, lazy loading `loading="lazy"`).
342
- - ✅ **Data Fetching:** Caching, prefetching, pagination, virtualization for large lists.
343
- - ✅ **Core Web Vitals:** Fix layout shifts (CLS), improve Largest Contentful Paint (LCP).
344
-
345
- ---
346
-
347
- ## Non-goals
348
-
349
- - ❌ Do NOT blindly wrap everything in `useMemo` or `React.memo` (this can degrade performance).
350
- - ❌ Do NOT optimize prematurely if there is no measured performance issue.
351
- - ❌ Do NOT rewrite business logic unless it is the direct cause of the bottleneck.
352
-
353
- ---
354
-
355
- ## Workflow
356
-
357
- ### Phase 1 — Identify the Bottleneck
358
-
359
- Determine what kind of performance issue it is:
360
- 1. **Network/Load Time:** Slow initial page load, large bundle size, heavy images.
361
- 2. **Render/Runtime:** UI is sluggish, typing lags, animation stutters (too many re-renders).
362
- 3. **Data/Memory:** App crashes or slows down over time, large lists lagging.
363
-
364
- ### Phase 2 — Common Fixes by Category
365
-
366
- #### 1. Fixing Unnecessary Re-renders (React)
367
- - Move state down to the smallest possible component.
368
- - Use `React.memo` for heavy pure components that receive the same props.
369
- - Stable references: Use `useMemo` for expensive calculations or object props, and `useCallback` for function props passed to memoized children.
370
- - *Warning:* Measure first! Memoization has an upfront cost.
371
-
372
- #### 2. Fixing Bundle Size (Code Splitting)
373
- - Are large libraries (like `lodash`, `moment`, `echarts`) imported entirely? Use named imports or alternative libraries.
374
- - Lazy load routes or heavy components below the fold:
375
- ```typescript
376
- const HeavyChart = React.lazy(() => import('./HeavyChart'));
377
- // Wrap in <Suspense fallback={<Spinner />}>
378
- ```
379
-
380
- #### 3. Asset & UI Optimization
381
- - Add fixed `width` and `height` to images to prevent Cumulative Layout Shift (CLS).
382
- - Virtualize large lists (e.g., `react-window` or `@tanstack/react-virtual`) instead of rendering 1000 DOM nodes.
383
- - Debounce rapid events (typing in search, window resize).
384
-
385
- ---
386
-
387
- ### Phase 3 — Implementation
388
-
389
- Apply the targeted fix. Document why the fix improves performance.
390
-
391
- ---
392
-
393
- ## Decision Tree
394
-
395
- ```
396
- Is the issue related to initial load time?
397
- ├── Yes → Focus on Code Splitting (lazy loading), Image Optimization, and bundle size reduction.
398
- └── No → Is the UI lagging during interaction?
399
- ├── Yes → Profile renders. Check for state updates triggering massive re-renders. Use `memo` or state colocation.
400
- └── No → Is a specific list or table slow?
401
- ├── Yes → Implement virtualization (react-window) or pagination.
402
- ```
403
-
404
- ---
405
-
406
- ## Output Format
407
-
408
- ```
409
- ⚡ Performance Optimization Report
410
- ─────────────────────────────────────────────────
411
- Target: [Component / Page]
412
- Bottleneck: [Brief description, e.g., "Expensive list rendering on every keystroke"]
413
-
414
- 🔧 Fixes Applied:
415
- ✅ Extracted Search Input state to prevent list re-rendering
416
- ✅ Wrapped heavy `ChartComponent` in `React.memo`
417
- ✅ Lazy-loaded below-the-fold content (`Suspense`)
418
-
419
- 📈 Expected Impact:
420
- - Reduced re-renders on typing from O(N) to O(1)
421
- - Initial JS bundle size reduced by ~X KB
422
-
423
- ⚠️ Notes:
424
- Please test this on lower-end devices to confirm smooth interactions.
425
- ```
426
-
427
- ---
428
-
429
- ## Validation Checklist
430
-
431
- - [ ] Fix addresses the specific bottleneck
432
- - [ ] No premature memoization applied blindly
433
- - [ ] Layout shift (CLS) prevented (if changing images/layout)
434
- - [ ] Application behavior remains completely unchanged
435
-
436
- ---
437
-
438
-
439
-
440
- # Refactor — Safe Restructuring
441
-
442
- > **Language rule:**
443
- > Use English for: code, identifiers, file names, architecture terms, technical decisions.
444
- > Use the user's language for: explanations, questions, summaries, and feedback.
445
- > The user may write in any language — detect and match it automatically.
446
-
447
- > ⚠️ **Core constraint: Refactoring must NOT change observable behavior.**
448
- > If behavior changes are needed → that is a feature, not a refactor.
449
- > Stop and clarify with the user before proceeding.
450
-
451
- ---
452
-
453
- ## Trigger
454
-
455
- Activate this skill when:
456
- - User says "clean up", "refactor", "it's too messy", "hard to maintain"
457
- - Code has grown beyond its original design (God component, fat service, spaghetti logic)
458
- - Duplicate patterns exist across multiple files
459
- - `project-audit` identified architecture issues (P2/P3) ready to be addressed
460
- - User asks to "improve code quality" without changing functionality
461
-
462
- **Not this skill** → Use `bug-fix` if behavior is wrong. Use `migration` if upgrading dependencies.
463
-
464
- ---
465
-
466
- ## Scope
467
-
468
- - ✅ Rename for clarity (variables, functions, files, components)
469
- - ✅ Extract reusable logic into functions, hooks, services, or utilities
470
- - ✅ Remove dead code, unused imports, and orphaned files
471
- - ✅ Split large components / functions into focused units
472
- - ✅ Apply consistent patterns across the codebase
473
- - ✅ Improve type coverage (replace `any`, add missing types)
474
- - ✅ Reduce complexity (flatten nested conditions, simplify logic)
475
-
476
- ---
477
-
478
- ## Non-goals
479
-
480
- - ❌ Do NOT change behavior — if you must, stop and discuss first
481
- - ❌ Do NOT change public APIs or exported interfaces without explicit approval
482
- - ❌ Do NOT rewrite everything — prefer incremental, targeted changes
483
- - ❌ Do NOT apply opinionated style changes (formatting belongs to linter/prettier)
484
- - ❌ Do NOT introduce new dependencies
485
- - ❌ Do NOT refactor code unrelated to the stated scope
486
-
487
- ---
488
-
489
- ## Severity Levels (for issues found during analysis)
490
-
491
- | Level | Meaning |
492
- |-------|---------|
493
- | P0 | Refactor introduces breaking change — stop immediately |
494
- | P1 | High coupling or duplication blocking feature work |
495
- | P2 | Code smell reducing maintainability |
496
- | P3 | Minor naming or style inconsistency |
497
-
498
- ---
499
-
500
- ## Workflow
501
-
502
- ### Phase 1 — Understand Current State
503
-
504
- Before changing anything:
505
- 1. Read the target code thoroughly
506
- 2. Identify what it does (behavior, inputs, outputs, side effects)
507
- 3. Note all callers and dependents of the code being refactored
508
- 4. Check for existing tests — these are the safety net
509
-
510
- If there are **no tests** for the code being refactored → recommend writing characterization tests first, or proceed with extra caution and document risks.
511
-
512
- ---
513
-
514
- ### Phase 2 — Identify Refactor Targets
515
-
516
- Common code smells to look for:
517
-
518
- | Smell | Description |
519
- |-------|-------------|
520
- | God Component/Function | Does too many things — split by responsibility |
521
- | Duplicate Logic | Same pattern repeated — extract to shared utility |
522
- | Long Parameter Lists | >4 params — use options object |
523
- | Deep Nesting | >3 levels of if/else — flatten with early returns |
524
- | Magic Numbers/Strings | Unnamed constants — extract to named constants |
525
- | Dead Code | Unused variables, functions, imports — remove |
526
- | Inconsistent Naming | Mixed conventions — standardize |
527
- | Missing Types | `any`, missing return types — add precise types |
528
- | Large Files | >300 lines — consider splitting by concern |
529
-
530
- ---
531
-
532
- ### Phase 3 — Plan the Refactor
533
-
534
- Create a step-by-step plan before touching code:
535
-
536
- 1. List each specific change with its justification
537
- 2. Order changes from lowest to highest risk
538
- 3. Identify what tests must pass after each step
539
- 4. Flag any changes that touch shared/exported code
540
-
541
- Present plan to user if scope is large or changes are risky.
542
-
543
- ---
544
-
545
- ### Phase 4 — Execute Incrementally
546
-
547
- Apply changes in small, verifiable steps:
548
-
549
- **Safe refactor order:**
550
- 1. Rename (lowest risk — IDEs can do this safely)
551
- 2. Extract (pull logic into new functions/hooks without changing callers)
552
- 3. Inline (remove unnecessary abstraction)
553
- 4. Move (relocate to correct file/folder)
554
- 5. Simplify (reduce complexity in logic)
555
- 6. Remove (delete dead code last — confirm nothing breaks)
556
-
557
- After **each step** → verify tests still pass before moving on.
558
-
559
- ---
560
-
561
- ### Phase 5 — Verify Behavior Preserved
562
-
563
- - [ ] All existing tests pass
564
- - [ ] Run lint and type-check — clean
565
- - [ ] Manual smoke test of affected functionality
566
- - [ ] No new `any` types introduced
567
- - [ ] No unused imports or dead code left
568
- - [ ] Public API unchanged (or explicitly approved to change)
569
-
570
- ---
571
-
572
- ### Phase 6 — Report
573
-
574
- Document what changed and why:
575
-
576
- ```
577
- What changed: [List of changes]
578
- Why: [Specific smell or issue addressed]
579
- Risk level: [Low / Medium / High]
580
- Tests status: [All pass / N new tests added]
581
- Behavior: [Unchanged — verified]
582
- ```
583
-
584
- ---
585
-
586
- ## Decision Tree
587
-
588
- ```
589
- Is there existing test coverage?
590
- ├── Yes → Proceed — tests are the safety net
591
- └── No → Recommend characterization tests first
592
- ├── User agrees → write tests then refactor
593
- └── User wants to proceed anyway → proceed with caution, document risk
594
-
595
- Does the refactor change public APIs?
596
- ├── Yes → Stop — confirm with user, this may be a breaking change
597
- └── No → Proceed
598
-
599
- Is the scope larger than expected?
600
- ├── Yes → Present updated plan, get approval before continuing
601
- └── No → Continue
602
- ```
603
-
604
- ---
605
-
606
- ## Output Format
607
-
608
- ```
609
- 🔧 Refactor Summary
610
- ─────────────────────────────────────────────────
611
- Scope: [What was refactored]
612
- Changes: [N files modified, N extracted, N removed]
613
-
614
- Changes applied:
615
- ✅ [Rename: oldName → newName in path/to/file.ts]
616
- ✅ [Extract: logic → useCustomHook in path/to/hook.ts]
617
- ✅ [Remove: dead code in path/to/old.ts]
618
- ✅ [Split: LargeComponent → ComponentA + ComponentB]
619
-
620
- 📊 Quality improvement:
621
- Before: [brief description of the problem]
622
- After: [brief description of improvement]
623
-
624
- ✅ Verification:
625
- Tests: PASS (N tests)
626
- Lint: Clean
627
- Types: No new `any`
628
- Behavior: Unchanged
629
-
630
- ⚠️ Notes:
631
- [Any assumptions, risks, or follow-up suggestions]
632
- ```
633
-
634
- ---
635
-
636
- ## Validation Checklist
637
-
638
- - [ ] Behavior is unchanged — verified with tests or manual check
639
- - [ ] All tests pass
640
- - [ ] Lint and type-check clean
641
- - [ ] No dead code, unused imports, or console.logs left
642
- - [ ] Public APIs unchanged (or explicitly approved)
643
- - [ ] Changes are documented with justification
644
- - [ ] No new dependencies introduced
645
-
646
- ---
647
-
648
- ## Examples
649
-
650
- See `examples/` folder.
1
+ ---
2
+ name: qk-project-health
3
+ version: 3.0.0
4
+ updated: 2026-07-02
5
+ description: Comprehensive audit of Code Smells, Tech Debt, and Architecture.
6
+ category: architecture
7
+ priority: medium
8
+ tags: [audit, architecture, tech-debt, code-smell]
9
+ platforms: [claude-code, cursor, windsurf, gemini-cli]
10
+ trigger: User asks for a project review, architecture audit, or health check.
11
+ inputs: [Project directory]
12
+ outputs: [Health Audit Score, Refactor roadmap]
13
+ allowed_tools: [grep_search, run_command, read_file]
14
+ pipeline: [analyze, review, validate, complete]
15
+ ---
16
+
17
+ # 🛠️ qk-project-health - Standard Operating Procedure
18
+
19
+ > **Goal:** "Khám sức khỏe" toàn diện cho Codebase. Tìm ra các Nợ Kỹ Thuật (Tech Debt), Mã Lỗi Thời (Code Smells), và các rủi ro cấu trúc dài hạn.
20
+
21
+ ## 🔄 1. Chain of Thought (SOP)
22
+ 1. **Analyze (Dependency Scan):**
23
+ - Read `package.json` to identify outdated libraries, bloated dependencies, or unused packages.
24
+ 2. **Review (Architecture Scan):**
25
+ - Use `list_dir` or tree commands to review the directory structure.
26
+ - Check if the project follows a scalable pattern (e.g., Feature-based vs flat `components` folder).
27
+ 3. **Validate (Smell Detection):**
28
+ - Scan for "God Components" (Files > 500 lines).
29
+ - Scan for heavy Prop Drilling (>3 levels deep).
30
+ 4. **Complete (Roadmap):**
31
+ - Generate a prioritized Refactor Roadmap (High, Medium, Low).
32
+
33
+ ## 🛡️ 2. Constraints & Rules
34
+ - **Audit Only - No Touch:** Do not modify any code. You are diagnosing, not performing surgery.
35
+ - **Evidence Based:** Provide concrete metrics (e.g., "Folder `components` has 45 files, making it hard to navigate").
36
+
37
+ ## 🌳 3. Decision Tree
38
+ ```text
39
+ Is the `src/components` folder bloated (>30 files)?
40
+ ├── YES → Recommend migrating to a Feature-driven structure (e.g., `src/features/auth`).
41
+ └── NO → Pass.
42
+
43
+ Are there components exceeding 500 lines?
44
+ ├── YES → Flag as "God Object" and recommend splitting.
45
+ └── NO → Pass.
46
+ ```
47
+
48
+ ## 🤝 4. Handoff Pipeline
49
+ 1. `complete`: Output the Health Audit Report.
50
+
51
+ ## 📝 5. Output Format
52
+ Vui lòng trả kết quả bằng Tiếng Việt.
53
+ - **Tóm tắt (Summary):** Đánh giá tổng quan Sức Khỏe Dự Án (Điểm: X/100).
54
+ - **Chi tiết (Changes):** Phân tích Dependencies, Architecture, Code Smells.
55
+ - **Xác thực (Verification):** Các bằng chứng thu thập được từ code (dòng nào, file nào phình to).
56
+ - **Hành động tiếp (Next Action):** Lên Lộ trình Refactor (Refactor Roadmap) (Cao - Trung - Thấp).