@torus-engineering/tas-kit 1.7.0 → 1.9.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 (73) hide show
  1. package/.claude/commands/tas-adr.md +33 -29
  2. package/.claude/commands/tas-apitest-plan.md +173 -0
  3. package/.claude/commands/tas-apitest.md +143 -0
  4. package/.claude/commands/tas-bug.md +113 -109
  5. package/.claude/commands/tas-design.md +37 -33
  6. package/.claude/commands/tas-dev.md +128 -115
  7. package/.claude/commands/tas-e2e-mobile.md +155 -0
  8. package/.claude/commands/tas-e2e-web.md +163 -0
  9. package/.claude/commands/tas-e2e.md +102 -0
  10. package/.claude/commands/tas-epic.md +35 -31
  11. package/.claude/commands/tas-feature.md +47 -43
  12. package/.claude/commands/tas-fix.md +51 -47
  13. package/.claude/commands/tas-functest-mobile.md +144 -0
  14. package/.claude/commands/tas-functest-web.md +192 -0
  15. package/.claude/commands/tas-functest.md +76 -0
  16. package/.claude/commands/tas-plan.md +200 -184
  17. package/.claude/commands/tas-prd.md +37 -33
  18. package/.claude/commands/tas-review.md +111 -104
  19. package/.claude/commands/tas-sad.md +43 -39
  20. package/.claude/commands/tas-security.md +81 -80
  21. package/.claude/commands/tas-story.md +91 -87
  22. package/.claude/commands/tas-verify.md +51 -41
  23. package/.claude/rules/common/post-review-agent.md +49 -39
  24. package/.claude/rules/common/testing.md +24 -0
  25. package/.claude/rules/common/token-logging.md +27 -0
  26. package/.claude/rules/csharp/api-testing.md +171 -0
  27. package/.claude/rules/csharp/patterns.md +10 -0
  28. package/.claude/rules/python/patterns.md +10 -0
  29. package/.claude/rules/typescript/patterns.md +10 -0
  30. package/.claude/rules/web/performance.md +9 -0
  31. package/.claude/skills/api-design/SKILL.md +3 -1
  32. package/.claude/skills/{backend-patterns → js-backend-patterns}/SKILL.md +2 -1
  33. package/.claude/skills/tas-implementation-complete/SKILL.md +99 -97
  34. package/.claude/skills/tas-tdd/SKILL.md +123 -82
  35. package/.claude/skills/token-logger/SKILL.md +19 -0
  36. package/.tas/templates/API-Test-Spec.md +400 -0
  37. package/.tas/templates/E2E-Execution-Report.md +198 -0
  38. package/.tas/templates/E2E-Mobile-Spec.md +130 -0
  39. package/.tas/templates/E2E-Report.md +174 -0
  40. package/.tas/templates/E2E-Scenario.md +180 -0
  41. package/.tas/templates/E2E-Web-Spec.md +164 -0
  42. package/.tas/templates/Feature.md +55 -55
  43. package/.tas/templates/Func-Test-Script.md +254 -0
  44. package/.tas/templates/Func-Test-Spec.md +187 -0
  45. package/.tas/templates/SAD.md +274 -274
  46. package/.tas/templates/Story.md +90 -88
  47. package/bin/cli.js +56 -56
  48. package/lib/deleted-files.json +36 -0
  49. package/lib/install.js +213 -176
  50. package/package.json +34 -34
  51. package/.claude/agents/README.md +0 -83
  52. package/.claude/agents/ado-agent.md +0 -39
  53. package/.claude/agents/code-architect.md +0 -62
  54. package/.claude/agents/code-simplifier.md +0 -53
  55. package/.claude/agents/comment-analyzer.md +0 -59
  56. package/.claude/agents/conversation-analyzer.md +0 -57
  57. package/.claude/agents/docs-lookup.md +0 -55
  58. package/.claude/agents/harness-optimizer.md +0 -62
  59. package/.claude/agents/loop-operator.md +0 -56
  60. package/.claude/agents/performance-optimizer.md +0 -78
  61. package/.claude/agents/pr-test-analyzer.md +0 -68
  62. package/.claude/agents/pytorch-build-resolver.md +0 -76
  63. package/.claude/agents/refactor-cleaner.md +0 -70
  64. package/.claude/agents/seo-specialist.md +0 -75
  65. package/.claude/agents/silent-failure-hunter.md +0 -69
  66. package/.claude/agents/type-design-analyzer.md +0 -75
  67. package/.claude/rules/common/agents.md +0 -65
  68. package/.claude/rules/common/coding-style.md +0 -90
  69. package/.claude/rules/common/development-workflow.md +0 -44
  70. package/.claude/rules/common/git-workflow.md +0 -24
  71. package/.claude/rules/common/performance.md +0 -55
  72. package/.claude/skills/agent-harness-construction/SKILL.md +0 -77
  73. package/.claude/skills/agent-introspection-debugging/SKILL.md +0 -157
@@ -55,6 +55,15 @@ const { ScrollTrigger } = await import('gsap/ScrollTrigger');
55
55
  - Use `requestAnimationFrame` or established animation libraries for JS motion
56
56
  - Avoid scroll handler churn; use IntersectionObserver or well-behaved libraries
57
57
 
58
+ ## React Performance Anti-Patterns
59
+
60
+ Avoid these in React and React Native:
61
+
62
+ - **Unnecessary re-renders**: component re-renders when props haven't changed — add `React.memo`, `useMemo`, `useCallback` at proven bottlenecks (measure first)
63
+ - **Missing code splitting**: large component trees not split with `React.lazy()` — lazy-load routes and heavy components
64
+ - **Missing list virtualization**: rendering large lists without `react-window` (web) or `FlatList`/`FlashList` (RN)
65
+ - **Over-fetching**: requesting full entities when only a few fields are needed — scope API calls to what the component actually renders
66
+
58
67
  ## Performance Checklist
59
68
 
60
69
  - [ ] All images have explicit dimensions
@@ -4,7 +4,9 @@ description: |
4
4
  Auto-invoke when designing new REST API endpoints, reviewing existing API contracts,
5
5
  planning pagination or filtering strategy, implementing error response formats,
6
6
  adding API versioning, or building public/partner-facing APIs.
7
- NOT for backend implementation layers (use backend-patterns instead).
7
+ Used in /tas-plan whenever a Story involves backend API design (any stack) — produces
8
+ API Spec (URL structure, HTTP methods, status codes, request/response shapes) before implementation.
9
+ NOT for backend implementation layers (use js-backend-patterns for Node.js instead).
8
10
  origin: ECC
9
11
  allowed-tools: Read, Grep, Glob
10
12
  ---
@@ -1,9 +1,10 @@
1
1
  ---
2
- name: backend-patterns
2
+ name: js-backend-patterns
3
3
  description: |
4
4
  Auto-invoke when implementing repository, service, or controller layers on Node.js/Express/Next.js,
5
5
  fixing N+1 query problems, setting up Redis caching, adding auth middleware, or structuring
6
6
  background job processing. NOT for API contract design (use api-design instead).
7
+ Specifically for Node.js/Express/Next.js stacks — not for .NET C# or Python.
7
8
  origin: ECC
8
9
  allowed-tools: Read, Grep, Glob
9
10
  ---
@@ -1,97 +1,99 @@
1
- ---
2
- name: tas-implementation-complete
3
- description: |
4
- Auto-invoke khi user báo hiệu đã hoàn thành implement: "done", "xong", "finished",
5
- "đã xong", "đã implement xong", "implementation complete", "code xong rồi",
6
- "viết xong rồi", "đã code xong". Trigger parallel post-implementation review gate.
7
- allowed-tools: Read, Bash, Grep, Glob, Agent
8
- ---
9
-
10
- # TAS Implementation Complete
11
-
12
- Khi user báo hiệu implementation xong, tự động trigger post-implementation review gate.
13
- Không chờ user chạy `/tas-review-code` thủ công.
14
-
15
- ## When to Use
16
-
17
- - User vừa implement xong một Story hoặc một feature
18
- - User nói "xong", "done", "finished" sau khi viết code
19
- - KHÔNG invoke khi: user đang hỏi về trạng thái, hỏi về plan, hay chưa có code thay đổi
20
-
21
- ## Always / Ask / Never
22
-
23
- | | Hành động |
24
- |---|---|
25
- | **Always** | Xác nhận scope với user trước khi launch agents |
26
- | **Always** | Launch code-reviewer + security-reviewer đồng thời |
27
- | **Always** | Báo cáo gate result rõ ràng: pass hoặc block với lý do |
28
- | **Ask** | Khi không chắc scope review là gì (file path? git diff? Story?) |
29
- | **Ask** | Khi có >5 files thay đổi — confirm user muốn review toàn bộ |
30
- | **Never** | Tự động commit sau khi review pass |
31
- | **Never** | Skip review và báo "looks good" mà không chạy agents |
32
-
33
- ## Process
34
-
35
- ### Bước 1 — Xác định scope
36
- Hỏi user hoặc tự suy luận từ context:
37
- - Có Story ID? → lấy danh sách files từ Story
38
- - Không có? → dùng `git diff HEAD --name-only` để lấy files vừa thay đổi
39
-
40
- ### Bước 2 — Stack Detection
41
- Đọc `CLAUDE.md` tại root, tìm section `## Tech Stack`:
42
- - Backend chứa `.NET` / `C#` → `lang_agent = csharp-reviewer`
43
- - Backend chứa `Node.js` / `TypeScript` → `lang_agent = typescript-reviewer`
44
- - Backend chứa `Python` / `FastAPI` / `Django` → `lang_agent = python-reviewer`
45
- - Frontend chứa `React` → bổ sung `typescript-reviewer`
46
-
47
- ### Bước 3 — Launch Parallel Review Gate
48
-
49
- Launch các agents ĐỒNG THỜI:
50
-
51
- **Agent 1 — `code-reviewer`** (luôn chạy):
52
- > Review [scope]. Đọc `.tas/checklists/code-review.md`.
53
- > Tập trung: acceptance criteria compliance, naming, error handling, test coverage, DRY.
54
- > Format: Critical / High / Medium / Low với file:line và fix cụ thể.
55
-
56
- **Agent 2 — `security-reviewer`** (luôn chạy):
57
- > Security audit [scope]. Đọc `.claude/rules/common/security.md`.
58
- > Tập trung: user input handling, SQL injection, hardcoded secrets, auth checks.
59
- > Format: Critical / High / Medium / Low với file:line và remediation.
60
-
61
- **Agent 3 — Language reviewer** (theo stack detection):
62
- > Language-specific review [scope].
63
- > Đọc `.claude/rules/[stack]/coding-style.md` `.claude/rules/[stack]/patterns.md`.
64
- > Format: Critical / High / Medium / Low với file:line.
65
-
66
- Chờ TẤT CẢ agents hoàn thành.
67
-
68
- ### Bước 4 Gate Decision
69
-
70
- **Có Critical/High findings:**
71
- → Liệt kê rõ từng finding, DỪNG, yêu cầu fix trước khi tiếp tục.
72
- Không tick Definition of Done.
73
-
74
- **Chỉ Medium/Low:**
75
- → List gợi ý, hỏi user có muốn fix không.
76
- Sau khi user confirm: nhắc chạy `/tas-review-code` để review đầy đủ (hygiene scan + test run).
77
-
78
- ## Red Flags
79
-
80
- - User nói "xong" nhưng không có file nào thay đổi trong git diff → hỏi lại
81
- - Review gate bị skip vì "code đơn giản" → không có ngoại lệ, luôn chạy gate
82
- - Agent trả về "No issues found" trên codebase lớn verify agent đã đọc đúng files
83
-
84
- ## Verification
85
-
86
- - [ ] `git diff HEAD --name-only` có ít nhất 1 file thay đổi
87
- - [ ] Tất cả agents đã chạy và trả về kết quả (không timeout)
88
- - [ ] Gate decision được đưa ra ràng: pass hoặc block
89
- - [ ] Nếu pass: user biết bước tiếp theo `/tas-review-code`
90
-
91
- ## Anti-Rationalization
92
-
93
- | Rationalization | Counter |
94
- |---|---|
95
- | "Code đơn giản, không cần review" | Review gate luôn chạy — đây là safety net, không phải quality judgment |
96
- | "Security reviewer sẽ slow down workflow" | Parallel execution — 3 agents chạy cùng lúc, không cộng thêm thời gian |
97
- | "User chưa hỏi về review" | Skill auto-invoke khi user nói "done" — đây là expected behavior |
1
+ ---
2
+ name: tas-implementation-complete
3
+ description: |
4
+ Auto-invoke khi user báo hiệu đã hoàn thành implement: "done", "xong", "finished",
5
+ "đã xong", "đã implement xong", "implementation complete", "code xong rồi",
6
+ "viết xong rồi", "đã code xong". Trigger parallel post-implementation review gate.
7
+ allowed-tools: Read, Bash, Grep, Glob, Agent
8
+ ---
9
+
10
+ # TAS Implementation Complete
11
+
12
+ Khi user báo hiệu implementation xong, tự động trigger post-implementation review gate.
13
+ Không chờ user chạy `/tas-review-code` thủ công.
14
+
15
+ ## When to Use
16
+
17
+ - User vừa implement xong một Story hoặc một feature
18
+ - User nói "xong", "done", "finished" sau khi viết code
19
+ - KHÔNG invoke khi: user đang hỏi về trạng thái, hỏi về plan, hay chưa có code thay đổi
20
+
21
+ ## Always / Ask / Never
22
+
23
+ | | Hành động |
24
+ |---|---|
25
+ | **Always** | Xác nhận scope với user trước khi launch agents |
26
+ | **Always** | Launch code-reviewer + security-reviewer đồng thời |
27
+ | **Always** | Báo cáo gate result rõ ràng: pass hoặc block với lý do |
28
+ | **Ask** | Khi không chắc scope review là gì (file path? git diff? Story?) |
29
+ | **Ask** | Khi có >5 files thay đổi — confirm user muốn review toàn bộ |
30
+ | **Never** | Tự động commit sau khi review pass |
31
+ | **Never** | Skip review và báo "looks good" mà không chạy agents |
32
+
33
+ ## Process
34
+
35
+ ### Bước 1 — Xác định scope
36
+ Hỏi user hoặc tự suy luận từ context:
37
+ - Có Story ID? → lấy danh sách files từ Story
38
+ - Không có? → dùng `git diff HEAD --name-only` để lấy files vừa thay đổi
39
+
40
+ ### Bước 2 — Stack Detection
41
+ Đọc `CLAUDE.md` tại root, tìm section `## Tech Stack`:
42
+ - Backend chứa `.NET` / `C#` → `lang_agent = csharp-reviewer`
43
+ - Backend chứa `Node.js` / `TypeScript` → `lang_agent = typescript-reviewer`
44
+ - Backend chứa `Python` / `FastAPI` / `Django` → `lang_agent = python-reviewer`
45
+ - Frontend chứa `React` → bổ sung `typescript-reviewer`
46
+
47
+ ### Bước 3 — Launch Parallel Review Gate
48
+
49
+ Launch các agents ĐỒNG THỜI:
50
+
51
+ **Agent 1 — `code-reviewer`** (luôn chạy):
52
+ > Review [scope]. Đọc `.tas/checklists/code-review.md`.
53
+ > Tập trung: acceptance criteria compliance, naming, error handling, test coverage, DRY.
54
+ > Format: Critical / High / Medium / Low với file:line và fix cụ thể.
55
+
56
+ **Agent 2 — `security-reviewer`** (luôn chạy):
57
+ > Security audit [scope]. Đọc `.claude/rules/common/security.md`.
58
+ > Nếu stack đã xác định, đọc thêm `.claude/rules/[stack]/security.md`.
59
+ > Tập trung: user input handling, SQL injection, hardcoded secrets, auth checks.
60
+ > Format: Critical / High / Medium / Low với file:line và remediation.
61
+
62
+ **Agent 3 — Language reviewer** (theo stack detection):
63
+ > Language-specific review [scope].
64
+ > Đọc `.claude/rules/[stack]/coding-style.md`, `.claude/rules/[stack]/patterns.md`, `.claude/rules/[stack]/testing.md`.
65
+ > Nếu stack có React: đọc thêm `.claude/rules/web/design-quality.md`, `.claude/rules/web/testing.md`, `.claude/rules/web/performance.md`.
66
+ > Format: Critical / High / Medium / Low với file:line.
67
+
68
+ Chờ TẤT CẢ agents hoàn thành.
69
+
70
+ ### Bước 4 — Gate Decision
71
+
72
+ **Có Critical/High findings:**
73
+ → Liệt kê rõ từng finding, DỪNG, yêu cầu fix trước khi tiếp tục.
74
+ Không tick Definition of Done.
75
+
76
+ **Chỉ Medium/Low:**
77
+ → List gợi ý, hỏi user có muốn fix không.
78
+ Sau khi user confirm: nhắc chạy `/tas-review-code` để review đầy đủ (hygiene scan + test run).
79
+
80
+ ## Red Flags
81
+
82
+ - User nói "xong" nhưng không file nào thay đổi trong git diff hỏi lại
83
+ - Review gate bị skip vì "code đơn giản" → không có ngoại lệ, luôn chạy gate
84
+ - Agent trả về "No issues found" trên codebase lớn → verify agent đã đọc đúng files
85
+
86
+ ## Verification
87
+
88
+ - [ ] `git diff HEAD --name-only` ít nhất 1 file thay đổi
89
+ - [ ] Tất cả agents đã chạy trả về kết quả (không timeout)
90
+ - [ ] Gate decision được đưa ra rõ ràng: pass hoặc block
91
+ - [ ] Nếu pass: user biết bước tiếp theo là `/tas-review-code`
92
+
93
+ ## Anti-Rationalization
94
+
95
+ | Rationalization | Counter |
96
+ |---|---|
97
+ | "Code đơn giản, không cần review" | Review gate luôn chạy — đây là safety net, không phải quality judgment |
98
+ | "Security reviewer sẽ slow down workflow" | Parallel execution — 3 agents chạy cùng lúc, không cộng thêm thời gian |
99
+ | "User chưa hỏi về review" | Skill auto-invoke khi user nói "done" — đây là expected behavior |
@@ -1,82 +1,123 @@
1
- ---
2
- name: tas-tdd
3
- description: |
4
- TDD workflow. Auto-invoke khi: user implement feature mới, viết tests,
5
- hoặc khi use_tdd=true trong tas.yaml. Enforce Red-Green-Refactor cycle
6
- với verification gates giữa mỗi phase.
7
- allowed-tools: Read, Write, Edit, Bash, Grep
8
- ---
9
-
10
- # TAS TDD Workflow
11
-
12
- Khi `use_tdd=true` trong `tas.yaml`, enforce strict Red-Green-Refactor cycle.
13
- Không có ngoại lệ — mọi feature đều bắt đầu từ test.
14
-
15
- ## When to Use
16
-
17
- - Implement feature mới theo Story với acceptance criteria rõ ràng
18
- - Bug fix: viết regression test trước khi fix
19
- - Refactor: đảm bảo test coverage trước khi thay đổi code
20
- - KHÔNG dùng TDD cho: config changes, documentation, migration scripts thuần data
21
-
22
- ## Always / Ask / Never
23
-
24
- | | Hành động |
25
- |---|---|
26
- | **Always** | Viết test TRƯỚC, chạy để xác nhận FAIL, sau đó mới viết code |
27
- | **Always** | Commit sau mỗi Green phase thành công |
28
- | **Always** | Chạy full test suite sau Refactor phase |
29
- | **Ask** | Khi acceptance criteria mơ hồ — làm rõ trước khi viết test |
30
- | **Ask** | Khi test quá khó viết — có thể interface/design cần cải thiện |
31
- | **Never** | Viết implementation trước test (dù "chỉ để thử") |
32
- | **Never** | Bỏ qua Red phase vì "test rõ ràng sẽ fail" |
33
- | **Never** | Viết nhiều hơn code tối thiểu cần thiết để pass test ở Green phase |
34
-
35
- ## Process
36
-
37
- ### Red Phase — Viết Test Trước
38
-
39
- 1. Đọc acceptance criteria trong Story
40
- 2. Viết test cases cover từng criteria
41
- 3. Chạy tests: `npm test` / `dotnet test` / `python -m pytest`
42
- 4. **Verify**: tests PHẢI FAIL — nếu pass ngay → test sai, viết lại
43
-
44
- ### Green Phase Code Tối Thiểu
45
-
46
- 1. Viết code tối thiểu để pass tests
47
- 2. Không refactor, không optimize ở phase này
48
- 3. Chạy tests: xác nhận PASS
49
- 4. **Verify**: tất cả tests mới phải pass, không có regression
50
-
51
- ### Refactor Phase — Clean Up
52
-
53
- 1. Loại bỏ duplication, cải thiện naming, giảm complexity
54
- 2. KHÔNG thay đổi behavior — tests là safety net
55
- 3. Chạy full test suite sau mỗi refactor step
56
- 4. **Verify**: coverage >= 80%, tất cả tests vẫn pass
57
- 5. Commit sau khi refactor thành công
58
-
59
- ## Red Flags
60
-
61
- - Test pass ngay lần đầu khi chưa viết implementation → test không test đúng thứ cần test
62
- - Test quá broad ("everything works") → không có giá trị, viết test cụ thể hơn
63
- - Green phase code quá nhiều logic → chỉ viết đủ để pass, không hơn
64
- - Refactor phase làm test fail refactor sai, roll back từng bước
65
- - Viết nhiều test cùng lúc trước khi fix từng cái chỉ fix một test tại một thời điểm
66
-
67
- ## Verification
68
-
69
- - [ ] Red: test file tồn tại và chạy ra FAIL output
70
- - [ ] Green: test output chuyển từ FAIL → PASS sau khi thêm implementation
71
- - [ ] Refactor: `npm test` / `dotnet test` / `pytest` toàn bộ suite PASS
72
- - [ ] Coverage report: >= 80% cho files vừa thay đổi
73
- - [ ] Không có test nào bị skip hay comment out
74
-
75
- ## Anti-Rationalization
76
-
77
- | Rationalization | Counter |
78
- |---|---|
79
- | "Test ràng sẽ fail, không cần chạy" | Bỏ qua Red phase làm mất điểm kiểm chứng — luôn chạy |
80
- | "Viết test sau nhanh hơn" | TDD tiết kiệm debugging time nhiều hơn thời gian viết test trước |
81
- | "Code này quá đơn giản cần test" | Đơn giản hôm nay, phức tạp sau refactor — test bảo vệ future changes |
82
- | "Interface chưa clear, viết code trước cho rõ" | Test khó viết là signal interface cần cải thiện — Ask, không skip |
1
+ ---
2
+ name: tas-tdd
3
+ description: |
4
+ TDD workflow. Auto-invoke khi: user implement feature mới, viết tests,
5
+ hoặc khi use_tdd=true trong tas.yaml. Enforce Red-Green-Refactor cycle
6
+ với verification gates giữa mỗi phase.
7
+ allowed-tools: Read, Write, Edit, Bash, Grep
8
+ ---
9
+
10
+ # TAS TDD Workflow
11
+
12
+ Khi `use_tdd=true` trong `tas.yaml`, enforce strict Red-Green-Refactor cycle.
13
+ Không có ngoại lệ — mọi feature đều bắt đầu từ test.
14
+
15
+ ## When to Use
16
+
17
+ - Implement feature mới theo Story với acceptance criteria rõ ràng
18
+ - Bug fix: viết regression test trước khi fix
19
+ - Refactor: đảm bảo test coverage trước khi thay đổi code
20
+ - KHÔNG dùng TDD cho: config changes, documentation, migration scripts thuần data
21
+
22
+ ## Always / Ask / Never
23
+
24
+ | | Hành động |
25
+ |---|---|
26
+ | **Always** | Viết test TRƯỚC, chạy để xác nhận FAIL, sau đó mới viết code |
27
+ | **Always** | Commit sau mỗi Green phase thành công |
28
+ | **Always** | Chạy full test suite sau Refactor phase |
29
+ | **Ask** | Khi acceptance criteria mơ hồ — làm rõ trước khi viết test |
30
+ | **Ask** | Khi test quá khó viết — có thể interface/design cần cải thiện |
31
+ | **Never** | Viết implementation trước test (dù "chỉ để thử") |
32
+ | **Never** | Bỏ qua Red phase vì "test rõ ràng sẽ fail" |
33
+ | **Never** | Viết nhiều hơn code tối thiểu cần thiết để pass test ở Green phase |
34
+
35
+ ## Process
36
+
37
+ ### Red Phase — Viết Test Trước
38
+
39
+ 1. Đọc acceptance criteria trong Story
40
+ 2. Viết test cases cover từng criteria theo platform:
41
+
42
+ **Mobile (React Native)**:
43
+ - **Unit Tests (REQUIRED)**: Jest + React Testing Library
44
+ - Components: `render`, `fireEvent`, `screen` queries
45
+ - Hooks: `renderHook` từ `@testing-library/react-hooks`
46
+ - Services/API: Jest mocks + MSW
47
+ - Utils: Pure function testing
48
+ - Zustand stores: Test actions + selectors
49
+ - **E2E Tests**: Detox
50
+
51
+ **Web (React + Node)**:
52
+ - **Unit Tests (REQUIRED)**: Vitest/Jest + React Testing Library
53
+ - Components: `render`, `fireEvent`, `screen` queries
54
+ - Hooks: `renderHook`
55
+ - Services: Vitest/Jest mocks + MSW
56
+ - Backend services: Jest
57
+ - **E2E Tests**: Playwright (Chromium, Firefox, WebKit)
58
+
59
+ **Backend (.NET)**:
60
+ - **Unit Tests**: xUnit cho services, repositories
61
+ - **Integration Tests**: xUnit + TestServer
62
+ - **API Tests**: xUnit + WebApplicationFactory
63
+
64
+ 3. Chạy tests: `npm test` / `yarn test` / `dotnet test` / `python -m pytest`
65
+ 4. **Verify**: tests PHẢI FAIL nếu pass ngay → test sai, viết lại
66
+
67
+ ### Green Phase — Code Tối Thiểu
68
+
69
+ 1. Viết code tối thiểu để pass tests
70
+ 2. Không refactor, không optimize phase này
71
+ 3. Chạy tests: xác nhận PASS
72
+ 4. **Verify**: tất cả tests mới phải pass, không regression
73
+
74
+ ### Refactor Phase — Clean Up
75
+
76
+ 1. Loại bỏ duplication, cải thiện naming, giảm complexity
77
+ 2. KHÔNG thay đổi behavior — tests là safety net
78
+ 3. Chạy full test suite sau mỗi refactor step
79
+ 4. **Verify**: coverage >= 80%, tất cả tests vẫn pass
80
+ 5. Commit sau khi refactor thành công
81
+
82
+ ## Red Flags
83
+
84
+ - Test pass ngay lần đầu khi chưa viết implementation → test không test đúng thứ cần test
85
+ - Test quá broad ("everything works") → không có giá trị, viết test cụ thể hơn
86
+ - Green phase code quá nhiều logic → chỉ viết đủ để pass, không hơn
87
+ - Refactor phase làm test fail → refactor sai, roll back từng bước
88
+ - Viết nhiều test cùng lúc trước khi fix từng cái → chỉ fix một test tại một thời điểm
89
+
90
+ ## Verification
91
+
92
+ - [ ] Red: test file tồn tại và chạy ra FAIL output
93
+ - [ ] Green: test output chuyển từ FAIL → PASS sau khi thêm implementation
94
+ - [ ] Refactor: `npm test` / `dotnet test` / `pytest` toàn bộ suite PASS
95
+ - [ ] Coverage report: >= 80% cho files vừa thay đổi
96
+ - [ ] Không có test nào bị skip hay comment out
97
+
98
+ ## Test Naming Convention
99
+
100
+ ```
101
+ {PROJECT}_E{EPIC}_F{FEATURE}_S{STORY}_{TYPE}_{NUMBER}_{MODIFIER}
102
+ ```
103
+
104
+ | TYPE | Ý nghĩa | Layer |
105
+ |------|---------|-------|
106
+ | UT | Unit Test | 1 |
107
+ | IT | Integration Test | 1 |
108
+ | API | API Test | 1 |
109
+ | FT | Functional Test | 2 |
110
+ | E2E | End-to-End Test | 3 |
111
+
112
+ MODIFIER: `H` (Happy), `N` (Negative), `E` (Edge), `S` (Security), `P` (Performance)
113
+
114
+ ---
115
+
116
+ ## Anti-Rationalization
117
+
118
+ | Rationalization | Counter |
119
+ |---|---|
120
+ | "Test rõ ràng sẽ fail, không cần chạy" | Bỏ qua Red phase làm mất điểm kiểm chứng — luôn chạy |
121
+ | "Viết test sau nhanh hơn" | TDD tiết kiệm debugging time nhiều hơn thời gian viết test trước |
122
+ | "Code này quá đơn giản cần test" | Đơn giản hôm nay, phức tạp sau refactor — test bảo vệ future changes |
123
+ | "Interface chưa clear, viết code trước cho rõ" | Test khó viết là signal interface cần cải thiện — Ask, không skip |
@@ -0,0 +1,19 @@
1
+ ---
2
+ name: token-logger
3
+ description: |
4
+ Invoke khi TAS command hoàn thành để ghi AI Usage Log vào artifact file.
5
+ Auto-invoke sau /tas-* commands khi có Write/Edit vào docs/.
6
+ KHÔNG invoke khi user tự tay edit file hoặc dùng non-TAS commands.
7
+ allowed-tools: Read, Edit, Write
8
+ ---
9
+
10
+ # Token Logger
11
+
12
+ Ghi `## AI Usage Log` vào artifact file sau khi TAS command hoàn thành.
13
+
14
+ ## Process
15
+
16
+ 1. Xác định artifact file: từ lời gọi (nếu được chỉ định) hoặc file `docs/` cuối cùng được Write/Edit trong session.
17
+ 2. Đọc `.claude/rules/common/token-logging.md` để lấy format và update rules.
18
+ 3. Đọc artifact file — kiểm tra `## AI Usage Log` đã tồn tại chưa.
19
+ 4. Ghi hoặc cập nhật section. Silent on success — không output ra conversation.