@torus-engineering/tas-kit 1.9.0 → 1.11.1

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 (68) hide show
  1. package/.claude/commands/ado-create.md +17 -17
  2. package/.claude/commands/ado-delete.md +11 -11
  3. package/.claude/commands/ado-get.md +12 -12
  4. package/.claude/commands/ado-status.md +12 -12
  5. package/.claude/commands/ado-update.md +15 -15
  6. package/.claude/commands/tas-adr.md +33 -33
  7. package/.claude/commands/tas-apitest-plan.md +173 -173
  8. package/.claude/commands/tas-apitest.md +143 -143
  9. package/.claude/commands/tas-brainstorm.md +14 -14
  10. package/.claude/commands/tas-bug.md +113 -113
  11. package/.claude/commands/tas-design.md +37 -37
  12. package/.claude/commands/tas-dev.md +128 -128
  13. package/.claude/commands/tas-e2e-mobile.md +155 -155
  14. package/.claude/commands/tas-e2e-web.md +163 -163
  15. package/.claude/commands/tas-e2e.md +102 -102
  16. package/.claude/commands/tas-epic.md +35 -35
  17. package/.claude/commands/tas-feature.md +47 -47
  18. package/.claude/commands/tas-fix.md +51 -51
  19. package/.claude/commands/tas-functest-mobile.md +144 -144
  20. package/.claude/commands/tas-functest-web.md +192 -192
  21. package/.claude/commands/tas-functest.md +76 -76
  22. package/.claude/commands/tas-init.md +14 -14
  23. package/.claude/commands/tas-plan.md +198 -200
  24. package/.claude/commands/tas-prd.md +37 -37
  25. package/.claude/commands/tas-review.md +111 -111
  26. package/.claude/commands/tas-sad.md +43 -43
  27. package/.claude/commands/tas-security.md +87 -81
  28. package/.claude/commands/tas-spec.md +20 -20
  29. package/.claude/commands/tas-status.md +13 -13
  30. package/.claude/commands/tas-story.md +91 -91
  31. package/.claude/commands/tas-verify.md +51 -51
  32. package/.claude/rules/common/post-review-agent.md +49 -49
  33. package/.claude/rules/common/project-status.md +14 -14
  34. package/.claude/rules/common/stack-detection.md +6 -6
  35. package/.claude/rules/common/token-logging.md +27 -27
  36. package/.claude/rules/csharp/api-testing.md +171 -171
  37. package/.claude/skills/ado-integration/SKILL.md +36 -36
  38. package/.claude/skills/tas-conventions/SKILL.md +32 -32
  39. package/.claude/skills/tas-implementation-complete/SKILL.md +100 -99
  40. package/.claude/skills/tas-tdd/SKILL.md +123 -123
  41. package/.claude/skills/token-logger/SKILL.md +19 -19
  42. package/.tas/README.md +266 -1520
  43. package/.tas/checklists/code-review.md +13 -13
  44. package/.tas/checklists/security.md +3 -3
  45. package/.tas/checklists/story-done.md +11 -11
  46. package/.tas/hooks/README.md +138 -0
  47. package/.tas/hooks/pre-commit +26 -0
  48. package/.tas/hooks/security-scan.js +599 -0
  49. package/.tas/project-status-example.yaml +3 -3
  50. package/.tas/tas-example.yaml +25 -8
  51. package/.tas/templates/ADR.md +16 -16
  52. package/.tas/templates/API-Test-Spec.md +3 -3
  53. package/.tas/templates/Bug.md +12 -12
  54. package/.tas/templates/Design-Spec.md +8 -8
  55. package/.tas/templates/E2E-Execution-Report.md +1 -1
  56. package/.tas/templates/Epic.md +1 -1
  57. package/.tas/templates/Feature.md +10 -10
  58. package/.tas/templates/Func-Test-Spec.md +3 -3
  59. package/.tas/templates/SAD.md +106 -106
  60. package/.tas/templates/Security-Report.md +3 -3
  61. package/.tas/templates/Story.md +9 -9
  62. package/.tas/tools/tas-ado-readme.md +169 -169
  63. package/.tas/tools/tas-ado.py +1 -1
  64. package/CLAUDE-Example.md +37 -58
  65. package/README.md +294 -42
  66. package/bin/cli.js +24 -7
  67. package/lib/install.js +161 -47
  68. package/package.json +1 -1
@@ -1,27 +1,27 @@
1
- # /ado-create $ARGUMENTS
1
+ # /ado-create $ARGUMENTS
2
2
 
3
- Tạo work item mới trên Azure DevOps từ file .md local.
3
+ Create new work item on Azure DevOps from local .md file.
4
4
 
5
- ## Cú pháp
5
+ ## Syntax
6
6
  /ado-create <type> <temp-id> [--parent-id <id>]
7
7
 
8
8
  - type: epic | feature | story | bug
9
- - temp-id: ID tạm trong tên file local (sẽ được rename sau khi tạo trên ADO)
10
- - --parent-id: ADO ID của parent work item (optional)
9
+ - temp-id: Temporary ID in local filename (will be renamed after creating on ADO)
10
+ - --parent-id: ADO ID of parent work item (optional)
11
11
 
12
- ## Ví dụ
12
+ ## Examples
13
13
  /ado-create story 789 --parent-id 456
14
14
  /ado-create epic 001
15
15
  /ado-create bug 003 --parent-id 123
16
16
 
17
- ## Hành động
18
- 1. Đọc `tas.yaml`, kiểm tra `ado.enabled`. Nếu `false` hoặc không có: báo "ADO integration bị tắt (`ado.enabled: false` trong tas.yaml)." rồi dừng.
19
- 2. Chạy: python .tas/tools/tas-ado.py create-<type> <temp-id> [--parent-id <id>]
20
- 2. Script sẽ:
21
- - Tìm file theo pattern {type}-{temp-id}-*.md
22
- - Extract title description
23
- - Tạo work item trên ADO
24
- - Rename file thành {type}-{ado_id}-*.md
25
- - Thêm parent relation nếu --parent-id
26
- - Cập nhật frontmatter: ado_id, last_ado_sync
27
- 3. Cập nhật root/project-status.yaml
17
+ ## Actions
18
+ 1. Read `tas.yaml`, check `ado.enabled`. If `false` or missing: report "ADO integration is disabled (`ado.enabled: false` in tas.yaml)." then stop.
19
+ 2. Run: python .tas/tools/tas-ado.py create-<type> <temp-id> [--parent-id <id>]
20
+ 3. Script will:
21
+ - Find file by pattern {type}-{temp-id}-*.md
22
+ - Extract title and description
23
+ - Create work item on ADO
24
+ - Rename file to {type}-{ado_id}-*.md
25
+ - Add parent relation if --parent-id provided
26
+ - Update frontmatter: ado_id, last_ado_sync
27
+ 4. Update root/project-status.yaml
@@ -1,21 +1,21 @@
1
1
  # /ado-delete $ARGUMENTS
2
2
 
3
- Xóa work item trên Azure DevOps. KHÔNG xóa file local.
3
+ Delete work item on Azure DevOps. Does NOT delete local file.
4
4
 
5
- ## Cú pháp
5
+ ## Syntax
6
6
  /ado-delete <type> <ado-id>
7
7
 
8
8
  - type: epic | feature | story | bug
9
9
 
10
- ## Ví dụ
10
+ ## Examples
11
11
  /ado-delete story 1234
12
12
  /ado-delete bug 5678
13
13
 
14
- ## Hành động
15
- 1. Đọc `tas.yaml`, kiểm tra `ado.enabled`. Nếu `false` hoặc không có: báo "ADO integration bị tắt (`ado.enabled: false` trong tas.yaml)." rồi dừng.
16
- 2. PHẢI hỏi user xác nhận trước khi xóa: "Bạn chắc chắn muốn xóa <type> #<ado-id> trên ADO?"
17
- 3. Sau khi user xác nhận, chạy: python .tas/tools/tas-ado.py delete-<type> <ado-id>
18
- 3. Script sẽ:
19
- - Xóa work item trên ADO
20
- - KHÔNG xóa file local (giữ lại để tham khảo)
21
- - Cập nhật frontmatter: ado_state = Removed, last_ado_sync
14
+ ## Actions
15
+ 1. Read `tas.yaml`, check `ado.enabled`. If `false` or missing: report "ADO integration is disabled (`ado.enabled: false` in tas.yaml)." then stop.
16
+ 2. MUST ask user confirmation before deleting: "Are you sure you want to delete <type> #<ado-id> on ADO?"
17
+ 3. After user confirms, run: python .tas/tools/tas-ado.py delete-<type> <ado-id>
18
+ 4. Script will:
19
+ - Delete work item on ADO
20
+ - NOT delete local file (keep for reference)
21
+ - Update frontmatter: ado_state = Removed, last_ado_sync
@@ -1,20 +1,20 @@
1
1
  # /ado-get $ARGUMENTS
2
2
 
3
- Pull work item từ Azure DevOps về file .md local.
3
+ Pull work item from Azure DevOps to local .md file.
4
4
 
5
- ## Cú pháp
5
+ ## Syntax
6
6
  /ado-get <ado-id>
7
7
 
8
- ## Ví dụ
8
+ ## Examples
9
9
  /ado-get 5345
10
10
  /ado-get 1234
11
11
 
12
- ## Hành động
13
- 1. Đọc `tas.yaml`, kiểm tra `ado.enabled`. Nếu `false` hoặc không có: báo "ADO integration bị tắt (`ado.enabled: false` trong tas.yaml)." rồi dừng.
14
- 2. Chạy: python .tas/tools/tas-ado.py get <ado-id>
15
- 2. Script sẽ:
16
- - Lấy work item từ ADO
17
- - Convert description HTML sang Markdown
18
- - Tạo file {type}-{ado_id}-{slug}.md với frontmatter + nội dung
19
- - Cập nhật last_ado_sync
20
- 3. Nếu file đã tồn tại, hỏi user muốn overwrite không
12
+ ## Actions
13
+ 1. Read `tas.yaml`, check `ado.enabled`. If `false` or missing: report "ADO integration is disabled (`ado.enabled: false` in tas.yaml)." then stop.
14
+ 2. Run: python .tas/tools/tas-ado.py get <ado-id>
15
+ 3. Script will:
16
+ - Fetch work item from ADO
17
+ - Convert description HTML to Markdown
18
+ - Create file {type}-{ado_id}-{slug}.md with frontmatter + content
19
+ - Update last_ado_sync
20
+ 4. If file already exists, ask user if they want to overwrite
@@ -1,18 +1,18 @@
1
- # /ado-status $ARGUMENTS
1
+ # /ado-status $ARGUMENTS
2
2
 
3
- Cập nhật chỉ trạng thái work item trên Azure DevOps (nhanh, không push nội dung).
3
+ Update only work item status on Azure DevOps (fast, no content push).
4
4
 
5
- ## Cú pháp
5
+ ## Syntax
6
6
  /ado-status <ado-id> --status <state> [--assign <name/email>]
7
7
 
8
- ## Ví dụ
8
+ ## Examples
9
9
  /ado-status 1234 --status "In Progress"
10
- /ado-status 5678 --status "Resolved" --assign "nguyenvana@torus.vn"
10
+ /ado-status 5678 --status "Resolved" --assign "user@example.com"
11
11
 
12
- ## Hành động
13
- 1. Đọc `tas.yaml`, kiểm tra `ado.enabled`. Nếu `false` hoặc không có: báo "ADO integration bị tắt (`ado.enabled: false` trong tas.yaml)." rồi dừng.
14
- 2. Chạy: python .tas/tools/tas-ado.py update-status <ado-id> --status <state> [--assign ...]
15
- 2. Script sẽ:
16
- - Chỉ cập nhật state và/hoặc assigned-to trên ADO
17
- - Tìm file local, cập nhật frontmatter: ado_state, last_ado_sync
18
- - Cập nhật root/project-status.yaml
12
+ ## Actions
13
+ 1. Read `tas.yaml`, check `ado.enabled`. If `false` or missing: report "ADO integration is disabled (`ado.enabled: false` in tas.yaml)." then stop.
14
+ 2. Run: python .tas/tools/tas-ado.py update-status <ado-id> --status <state> [--assign ...]
15
+ 3. Script will:
16
+ - Only update state and/or assigned-to on ADO
17
+ - Find local file, update frontmatter: ado_state, last_ado_sync
18
+ - Update root/project-status.yaml
@@ -1,26 +1,26 @@
1
1
  # /ado-update $ARGUMENTS
2
2
 
3
- Cập nhật work item trên Azure DevOps từ file .md local.
3
+ Update work item on Azure DevOps from local .md file.
4
4
 
5
- ## Cú pháp
5
+ ## Syntax
6
6
  /ado-update <type> <ado-id> [--assign <name/email>] [--status <state>]
7
7
 
8
8
  - type: epic | feature | story | bug
9
9
  - ado-id: ADO work item ID
10
- - --assign: gán cho người (optional)
11
- - --status: cập nhật trạng thái (optional)
10
+ - --assign: assign to person (optional)
11
+ - --status: update status (optional)
12
12
 
13
- ## Ví dụ
13
+ ## Examples
14
14
  /ado-update story 1234 --status "In Progress"
15
- /ado-update bug 5678 --assign "tranvanb@torus.vn" --status "Committed"
15
+ /ado-update bug 5678 --assign "user@example.com" --status "Committed"
16
16
  /ado-update feature 456
17
17
 
18
- ## Hành động
19
- 1. Đọc `tas.yaml`, kiểm tra `ado.enabled`. Nếu `false` hoặc không có: báo "ADO integration bị tắt (`ado.enabled: false` trong tas.yaml)." rồi dừng.
20
- 2. Chạy: python .tas/tools/tas-ado.py update-<type> <ado-id> [--assign ...] [--status ...]
21
- 2. Script sẽ:
22
- - Tìm file local theo pattern *-<ado-id>-*.md
23
- - Đọc title description từ file
24
- - Cập nhật work item trên ADO
25
- - Cập nhật frontmatter: ado_state, ado_assigned_to, last_ado_sync
26
- 3. Nếu không --assign --status, push toàn bộ nội dung file lên ADO
18
+ ## Actions
19
+ 1. Read `tas.yaml`, check `ado.enabled`. If `false` or missing: report "ADO integration is disabled (`ado.enabled: false` in tas.yaml)." then stop.
20
+ 2. Run: python .tas/tools/tas-ado.py update-<type> <ado-id> [--assign ...] [--status ...]
21
+ 3. Script will:
22
+ - Find local file by pattern *-<ado-id>-*.md
23
+ - Read title and description from file
24
+ - Update work item on ADO
25
+ - Update frontmatter: ado_state, ado_assigned_to, last_ado_sync
26
+ 4. If no --assign and --status provided, push entire file content to ADO
@@ -1,33 +1,33 @@
1
- # /tas-adr $ARGUMENTS
2
-
3
- Vai trò: SE - Software Engineer
4
- Tạo mới hoặc cập nhật Architecture Decision Record.
5
-
6
- ## Hành động
7
- 1. Cần context từ .tas/templates/ADR.md
8
- 2. Quét docs/adr/ để xác định các ADR hiện có
9
- 3. Xác định chế độ dựa vào $ARGUMENTS:
10
-
11
- ### Chế độ CREATE ($ARGUMENTS tiêu đề mới, dụ: "Use CQRS for Order Service"):
12
- 4. Xác định số thứ tự tiếp theo (ADR-001, ADR-002...)
13
- 5. Nếu docs/sad.md tồn tại, cần context từ SAD để đảm bảo ADR consistent
14
- 6. Tạo file docs/adr/ADR-{NNN}-{slug}.md
15
- 7. Cập nhật `project-status.yaml` theo `.claude/rules/common/project-status.md` — thêm entry vào `adrs`.
16
-
17
- ### Chế độ UPDATE ($ARGUMENTS ADR ID, dụ: "ADR-001"):
18
- 4. Cần context từ file ADR hiện tại
19
- 5. Hỏi user cần thay đổi (cập nhật status, thêm consequences, supersede...)
20
- 6. Cập nhật file, thêm changelog
21
- 7. Nếu supersede: cập nhật status ADR thành "Superseded by ADR-{NNN}"
22
- 8. Cập nhật `project-status.yaml` theo `.claude/rules/common/project-status.md` — cập nhật `adrs.{ADR_ID}.status`.
23
-
24
- ## Nguyên tắc
25
- - ADR phải có: Context, Decision, Rationale, Consequences, Alternatives Considered
26
- - Status: Proposed | Accepted | Deprecated | Superseded
27
- - Mỗi ADR độc lập, tự chứa đủ context để hiểu
28
- - Link sang ADR liên quan nếu (Supersedes, Related to)
29
- - Sơ đồ Mermaid tuân thủ quy tắc: :::mermaid wrapper, không dùng ()
30
-
31
- ## Bước cuối — Token Log
32
-
33
- Invoke skill `token-logger`: ghi AI Usage Log vào file ADR đang làm việc.
1
+ # /tas-adr $ARGUMENTS
2
+
3
+ Role: SE - Software Engineer
4
+ Create or update Architecture Decision Record.
5
+
6
+ ## Actions
7
+ 1. Need context from .tas/templates/ADR.md
8
+ 2. Scan docs/adr/ to identify existing ADRs
9
+ 3. Determine mode based on $ARGUMENTS:
10
+
11
+ ### CREATE mode ($ARGUMENTS is new title, e.g., "Use CQRS for Order Service"):
12
+ 4. Determine next sequence number (ADR-001, ADR-002...)
13
+ 5. If docs/sad.md exists, need context from SAD to ensure ADR consistency
14
+ 6. Create file docs/adr/ADR-{NNN}-{slug}.md
15
+ 7. Update `project-status.yaml` per `.claude/rules/common/project-status.md` — add entry to `adrs`.
16
+
17
+ ### UPDATE mode ($ARGUMENTS is ADR ID, e.g., "ADR-001"):
18
+ 4. Need context from current ADR file
19
+ 5. Ask user what needs changing (update status, add consequences, supersede...)
20
+ 6. Update file, add changelog
21
+ 7. If supersede: update old ADR status to "Superseded by ADR-{NNN}"
22
+ 8. Update `project-status.yaml` per `.claude/rules/common/project-status.md` — update `adrs.{ADR_ID}.status`.
23
+
24
+ ## Principles
25
+ - ADR must have: Context, Decision, Rationale, Consequences, Alternatives Considered
26
+ - Status: Proposed | Accepted | Deprecated | Superseded
27
+ - Each ADR is independent, self-contained with enough context to understand
28
+ - Link to related ADRs if any (Supersedes, Related to)
29
+ - Mermaid diagram rules: :::mermaid wrapper, no () in node labels
30
+
31
+ ## Final Step — Token Log
32
+
33
+ Invoke skill `token-logger`: write AI Usage Log to working ADR file.
@@ -1,173 +1,173 @@
1
- # /tas-apitest-plan $ARGUMENTS
2
-
3
- Vai trò: SE - Software Engineer
4
- Generate API Test Specification (Markdown) từ API Spec (OpenAPI 3.0, Markdown, YAML) hoặc phân tích code API.
5
-
6
- ## Always / Ask / Never
7
-
8
- | | Hành động |
9
- |---|---|
10
- | **Always** | Đọc toàn bộ spec hoặc phân tích code trước khi tạo test spec |
11
- | **Always** | Tổ chức test cases theo API version — mỗi version một section riêng |
12
- | **Always** | Append-only: không sửa sections trong version đã tồn tại |
13
- | **Always** | Coverage matrix: mỗi endpoint cần ≥1 happy path + ≥1 error path |
14
- | **Always** | Đọc `.claude/rules/csharp/api-testing.md` để nắm convention |
15
- | **Ask** | Khi spec không expected response schema hoặc business rule |
16
- | **Never** | Sử dụng version folder/syntax trong test spec file (dùng section headers thay vì) |
17
- | **Never** | Bỏ qua error path — mỗi endpoint cần cover validation errors |
18
-
19
- ## Hành động
20
-
21
- ### Bước 1 — Locate Inputs
22
-
23
- `$ARGUMENTS` path đến:
24
- - API Spec file (OpenAPI 3.0 JSON/YAML, Markdown)
25
- - Hoặc Story ID — glob tìm `docs/epics/**/Story-{ID}*.md`
26
- - Hoặc path tới project code API cần phân tích
27
-
28
- Nếu không hỏi user:
29
- ```
30
- Nhập input cho /tas-apitest-plan:
31
- 1. Path đến API Spec file (OpenAPI/Markdown/YAML)
32
- 2. Story ID (để tìm link spec trong Story)
33
- 3. Path đến code API cần phân tích tự động
34
- ```
35
-
36
- ### Bước 2 — Detect Existing Test Spec
37
-
38
- Glob tìm `docs/tests/API-Test-Spec-*.md`.
39
-
40
- - **Tìm thấy**: Đọc file, detect versions đã có (tìm section headers `## v{N}`)
41
- - **Không tìm thấy**: Tạo mới với version v1
42
-
43
- ### Bước 3 — Parse Input
44
-
45
- **Nếu API Spec file:**
46
- - Đọc parse OpenAPI/Markdown/YAML
47
- - Thu thập cho mỗi endpoint:
48
- - HTTP method + path, path/query params, request body schema
49
- - Response schemas theo từng status code
50
- - Auth requirement, description/summary
51
- - Tags để nhóm endpoints
52
-
53
- **Nếu Story:**
54
- - Đọc Story để tìm link spec trong `## Technical Plan` hoặc `## Acceptance Criteria`
55
- - Parse spec như trên
56
- - Thêm AC mapping vào test spec
57
-
58
- **Nếu code path:**
59
- - Glob tìm controller/handler files (`.cs`, `.ts`, `.py` tùy stack)
60
- - Phân tích attributes/routes để phát hiện endpoints
61
- - Extract DTO classes để biết request/response schema
62
- - Hỏi user confirm nếu detect không rõ
63
-
64
- ### Bước 4 — Detect API Version
65
-
66
- Ưu tiên theo thứ tự:
67
- 1. `info.version` trong OpenAPI
68
- 2. Prefix trong URL path (v1/, v2/)
69
- 3. Hỏi user
70
-
71
- Version format: `v1`, `v2` (không dot).
72
-
73
- ### Bước 5 — Determine Output Path
74
-
75
- Output: `docs/tests/API-Test-Spec-{slug}.md`
76
-
77
- **Slug generation:**
78
- - Từ `api_name` trong spec → lowercase, replace spaces với dashes
79
- - Hoặc hỏi user nhập slug ngắn gọn ( dụ: `users`, `orders`, `products`)
80
-
81
- ### Bước 6 — Determine Update Mode
82
-
83
- Nếu spec file đã tồn tại và version đã có:
84
- - **Append mode** (default): thêm test cases mới vào cuối section version hiện tại
85
- - Hỏi user nếu muốn tạo version mới (v2, v3...):
86
-
87
- ```
88
- Spec file đã với version {current}. Bạn muốn:
89
- 1. Append test cases vào version {current} (default)
90
- 2. Tạo version mới (v{next}) cho test cases
91
- ```
92
-
93
- ### Bước 7 — Generate Test Spec
94
-
95
- Đọc template `.tas/templates/API-Test-Spec.md` để nắm cấu trúc.
96
-
97
- **Phân tích endpoints để tạo coverage matrix:**
98
-
99
- Với mỗi endpoint, generate test cases cho:
100
- 1. **Happy path** (2xx) — luôn
101
- 2. **Unauthorized** (401) — nếu endpoint yêu cầu auth
102
- 3. **Forbidden** (403) — nếu RBAC/ownership check
103
- 4. **Not found** (404) — nếu path param
104
- 5. **Validation error** (400/422) — nếu required fields hoặc business rules
105
- 6. **Business rules** — từ Story ACs hoặc spec descriptions
106
-
107
- **Coverage matrix format:**
108
- ```
109
- | Endpoint | Happy Path | 401 Unauthorized | 403 Forbidden | 404 Not Found | 400/422 Validation | Business Rule |
110
- |----------|:---------:|:----------------:|:-------------:|:-------------:|:------------------:|:-------------:|
111
- | GET /api/users | ✓ | ✓ | | | | |
112
- | POST /api/users | ✓ | ✓ | | | ✓ | |
113
- ```
114
-
115
- **Test case detail format:**
116
- ```
117
- #### TC-XXX: {Title} — {Modifier}
118
- - **Endpoint**: `{METHOD} {path}`
119
- - **Auth**: Required/Not Required
120
- - **Preconditions**:
121
- - {List preconditions}
122
- - **Request Query/Path/Body**:
123
- - {Request details}
124
- - **Expected Response**:
125
- - Status: {code}
126
- - Body: {schema}
127
- - **Assertions**:
128
- - {List assertions}
129
- - **AC Reference**: AC-{N} (nếu )
130
- - **Test Method Name**: `{Method}_{Resource}_Returns{Status}_When{Condition}`
131
- ```
132
-
133
- ### Bước 8 — Write Test Spec File
134
-
135
- **File chưa tồn tại:** Tạo mới từ template.
136
-
137
- **File đã tồn tại (append mode):**
138
- - Đọc file hiện tại
139
- - Find section `## v{N}` đang làm việc
140
- - Append test cases mới vào cuối section trước `## Version History` hoặc `## Changelog`
141
- - Preserve toàn bộ content
142
-
143
- ### Bước 9 — Summary
144
-
145
- Hiển thị:
146
- 1. Output file path
147
- 2. Number of endpoints detected
148
- 3. Number of test cases generated
149
- 4. Coverage matrix
150
- 5. Next steps:
151
- - Review test spec file
152
- - Run `/tas-apitest docs/tests/API-Test-Spec-{slug}.md` để generate code
153
-
154
- ```
155
- ## API Test Spec Generated
156
-
157
- **Output**: `docs/tests/API-Test-Spec-{slug}.md`
158
- **Version**: v{N}
159
- **Endpoints**: {N}
160
- **Test Cases**: {N}
161
-
162
- ### Coverage Matrix
163
- [Print coverage matrix]
164
-
165
- ### Next Steps
166
- 1. Review test spec: `docs/tests/API-Test-Spec-{slug}.md`
167
- 2. Generate test code: `/tas-apitest docs/tests/API-Test-Spec-{slug}.md`
168
- 3. Run tests: `dotnet test tests/ApiTests/`
169
- ```
170
-
171
- ## Bước cuối — Token Log
172
-
173
- Invoke skill `token-logger`: ghi AI Usage Log vào test spec file.
1
+ # /tas-apitest-plan $ARGUMENTS
2
+
3
+ Role: SE - Software Engineer
4
+ Generate API Test Specification (Markdown) from API Spec (OpenAPI 3.0, Markdown, YAML) or analyze API code.
5
+
6
+ ## Always / Ask / Never
7
+
8
+ | | Action |
9
+ |---|---|
10
+ | **Always** | Read entire spec or analyze code before creating test spec |
11
+ | **Always** | Organize test cases by API version — each version separate section |
12
+ | **Always** | Append-only: don't modify sections in existing old version |
13
+ | **Always** | Coverage matrix: each endpoint needs ≥1 happy path + ≥1 error path |
14
+ | **Always** | Read `.claude/rules/csharp/api-testing.md` for conventions |
15
+ | **Ask** | When spec unclear about expected response schema or business rule |
16
+ | **Never** | Use version folder/syntax in test spec file (use section headers instead) |
17
+ | **Never** | Skip error path — each endpoint needs cover validation errors |
18
+
19
+ ## Actions
20
+
21
+ ### Step 1 — Locate Inputs
22
+
23
+ `$ARGUMENTS` is path to:
24
+ - API Spec file (OpenAPI 3.0 JSON/YAML, Markdown)
25
+ - Or Story ID — glob find `docs/epics/**/Story-{ID}*.md`
26
+ - Or path to API code project to analyze
27
+
28
+ If not providedask user:
29
+ ```
30
+ Enter input for /tas-apitest-plan:
31
+ 1. Path to API Spec file (OpenAPI/Markdown/YAML)
32
+ 2. Story ID (to find spec link in Story)
33
+ 3. Path to API code to auto-analyze
34
+ ```
35
+
36
+ ### Step 2 — Detect Existing Test Spec
37
+
38
+ Glob find `docs/tests/API-Test-Spec-*.md`.
39
+
40
+ - **Found**: Read file, detect existing versions (find section headers `## v{N}`)
41
+ - **Not found**: Create new with version v1
42
+
43
+ ### Step 3 — Parse Input
44
+
45
+ **If API Spec file:**
46
+ - Read and parse OpenAPI/Markdown/YAML
47
+ - Collect for each endpoint:
48
+ - HTTP method + path, path/query params, request body schema
49
+ - Response schemas per status code
50
+ - Auth requirement, description/summary
51
+ - Tags to group endpoints
52
+
53
+ **If Story:**
54
+ - Read Story to find spec link in `## Technical Plan` or `## Acceptance Criteria`
55
+ - Parse spec as above
56
+ - Add AC mapping to test spec
57
+
58
+ **If code path:**
59
+ - Glob find controller/handler files (`.cs`, `.ts`, `.py` per stack)
60
+ - Analyze attributes/routes to detect endpoints
61
+ - Extract DTO classes to know request/response schema
62
+ - Ask user confirm if detection unclear
63
+
64
+ ### Step 4 — Detect API Version
65
+
66
+ Prioritize in order:
67
+ 1. `info.version` in OpenAPI
68
+ 2. Prefix in URL path (v1/, v2/)
69
+ 3. Ask user
70
+
71
+ Version format: `v1`, `v2` (no dot).
72
+
73
+ ### Step 5 — Determine Output Path
74
+
75
+ Output: `docs/tests/API-Test-Spec-{slug}.md`
76
+
77
+ **Slug generation:**
78
+ - From `api_name` in spec → lowercase, replace spaces with dashes
79
+ - Or ask user for short slug (e.g., `users`, `orders`, `products`)
80
+
81
+ ### Step 6 — Determine Update Mode
82
+
83
+ If spec file exists and version already exists:
84
+ - **Append mode** (default): add new test cases to end of current version section
85
+ - Ask user if want new version (v2, v3...):
86
+
87
+ ```
88
+ Spec file already exists with version {current}. You want:
89
+ 1. Append test cases to version {current} (default)
90
+ 2. Create new version (v{next}) for test cases
91
+ ```
92
+
93
+ ### Step 7 — Generate Test Spec
94
+
95
+ Read template `.tas/templates/API-Test-Spec.md` for structure.
96
+
97
+ **Analyze endpoints to create coverage matrix:**
98
+
99
+ For each endpoint, generate test cases for:
100
+ 1. **Happy path** (2xx) — always have
101
+ 2. **Unauthorized** (401) — if endpoint requires auth
102
+ 3. **Forbidden** (403) — if has RBAC/ownership check
103
+ 4. **Not found** (404) — if has path param
104
+ 5. **Validation error** (400/422) — if has required fields or business rules
105
+ 6. **Business rules** — from Story ACs or spec descriptions
106
+
107
+ **Coverage matrix format:**
108
+ ```
109
+ | Endpoint | Happy Path | 401 Unauthorized | 403 Forbidden | 404 Not Found | 400/422 Validation | Business Rule |
110
+ |----------|:---------:|:----------------:|:-------------:|:-------------:|:------------------:|:-------------:|
111
+ | GET /api/users | ✓ | ✓ | | | | |
112
+ | POST /api/users | ✓ | ✓ | | | ✓ | |
113
+ ```
114
+
115
+ **Test case detail format:**
116
+ ```
117
+ #### TC-XXX: {Title} — {Modifier}
118
+ - **Endpoint**: `{METHOD} {path}`
119
+ - **Auth**: Required/Not Required
120
+ - **Preconditions**:
121
+ - {List preconditions}
122
+ - **Request Query/Path/Body**:
123
+ - {Request details}
124
+ - **Expected Response**:
125
+ - Status: {code}
126
+ - Body: {schema}
127
+ - **Assertions**:
128
+ - {List assertions}
129
+ - **AC Reference**: AC-{N} (if any)
130
+ - **Test Method Name**: `{Method}_{Resource}_Returns{Status}_When{Condition}`
131
+ ```
132
+
133
+ ### Step 8 — Write Test Spec File
134
+
135
+ **File doesn't exist:** Create new from template.
136
+
137
+ **File exists (append mode):**
138
+ - Read current file
139
+ - Find section `## v{N}` being worked on
140
+ - Append new test cases to end of section before `## Version History` or `## Changelog`
141
+ - Preserve all old content
142
+
143
+ ### Step 9 — Summary
144
+
145
+ Display:
146
+ 1. Output file path
147
+ 2. Number of endpoints detected
148
+ 3. Number of test cases generated
149
+ 4. Coverage matrix
150
+ 5. Next steps:
151
+ - Review test spec file
152
+ - Run `/tas-apitest docs/tests/API-Test-Spec-{slug}.md` to generate code
153
+
154
+ ```
155
+ ## API Test Spec Generated
156
+
157
+ **Output**: `docs/tests/API-Test-Spec-{slug}.md`
158
+ **Version**: v{N}
159
+ **Endpoints**: {N}
160
+ **Test Cases**: {N}
161
+
162
+ ### Coverage Matrix
163
+ [Print coverage matrix]
164
+
165
+ ### Next Steps
166
+ 1. Review test spec: `docs/tests/API-Test-Spec-{slug}.md`
167
+ 2. Generate test code: `/tas-apitest docs/tests/API-Test-Spec-{slug}.md`
168
+ 3. Run tests: `dotnet test tests/ApiTests/`
169
+ ```
170
+
171
+ ## Final Step — Token Log
172
+
173
+ Invoke skill `token-logger`: write AI Usage Log to test spec file.