universal-dev-standards 5.13.3 → 5.15.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 (71) hide show
  1. package/bin/uds.js +2 -0
  2. package/bundled/ai/standards/ai-instruction-standards.ai.yaml +190 -3
  3. package/bundled/ai/standards/knowledge-graph-memory.ai.yaml +83 -0
  4. package/bundled/core/ai-instruction-standards.md +136 -11
  5. package/bundled/core/knowledge-graph-memory.md +119 -0
  6. package/bundled/locales/COVERAGE.md +226 -0
  7. package/bundled/locales/zh-CN/CHANGELOG.md +43 -3
  8. package/bundled/locales/zh-CN/README.md +1 -1
  9. package/bundled/locales/zh-CN/SECURITY.md +1 -1
  10. package/bundled/locales/zh-CN/core/ai-instruction-standards.md +111 -5
  11. package/bundled/locales/zh-TW/CHANGELOG.md +47 -3
  12. package/bundled/locales/zh-TW/README.md +1 -1
  13. package/bundled/locales/zh-TW/SECURITY.md +1 -1
  14. package/bundled/locales/zh-TW/core/ai-instruction-standards.md +130 -5
  15. package/bundled/locales/zh-TW/core/knowledge-graph-memory.md +127 -0
  16. package/bundled/locales/zh-TW/core/self-review-protocol.md +9 -1
  17. package/bundled/locales/zh-TW/skills/ac-coverage/SKILL.md +192 -0
  18. package/bundled/locales/zh-TW/skills/ai-collaboration-standards/SKILL.md +5 -1
  19. package/bundled/locales/zh-TW/skills/deploy-assistant/SKILL.md +187 -0
  20. package/bundled/locales/zh-TW/skills/dev-methodology/SKILL.md +108 -0
  21. package/bundled/locales/zh-TW/skills/journey-test-assistant/SKILL.md +222 -0
  22. package/bundled/locales/zh-TW/skills/knowledge-graph/SKILL.md +56 -0
  23. package/bundled/locales/zh-TW/skills/orchestrate/SKILL.md +172 -0
  24. package/bundled/locales/zh-TW/skills/plan/SKILL.md +239 -0
  25. package/bundled/locales/zh-TW/skills/project-structure-guide/SKILL.md +5 -1
  26. package/bundled/locales/zh-TW/skills/push/SKILL.md +241 -0
  27. package/bundled/locales/zh-TW/skills/skill-builder/SKILL.md +165 -0
  28. package/bundled/locales/zh-TW/skills/spec-derivation/SKILL.md +83 -0
  29. package/bundled/locales/zh-TW/skills/sweep/SKILL.md +149 -0
  30. package/bundled/skills/adr-assistant/SKILL.md +1 -1
  31. package/bundled/skills/ai-collaboration-standards/SKILL.md +1 -1
  32. package/bundled/skills/ai-friendly-architecture/SKILL.md +1 -1
  33. package/bundled/skills/ai-instruction-standards/SKILL.md +1 -1
  34. package/bundled/skills/api-design-assistant/SKILL.md +1 -1
  35. package/bundled/skills/audit-assistant/SKILL.md +1 -1
  36. package/bundled/skills/ci-cd-assistant/SKILL.md +1 -1
  37. package/bundled/skills/contract-test-assistant/SKILL.md +1 -1
  38. package/bundled/skills/database-assistant/SKILL.md +1 -1
  39. package/bundled/skills/deploy-assistant/SKILL.md +1 -1
  40. package/bundled/skills/documentation-guide/SKILL.md +1 -1
  41. package/bundled/skills/error-code-guide/SKILL.md +1 -1
  42. package/bundled/skills/git-workflow-guide/SKILL.md +1 -1
  43. package/bundled/skills/incident-response-assistant/SKILL.md +1 -1
  44. package/bundled/skills/journey-test-assistant/SKILL.md +1 -1
  45. package/bundled/skills/knowledge-graph/SKILL.md +58 -0
  46. package/bundled/skills/knowledge-graph/guide.md +69 -0
  47. package/bundled/skills/logging-guide/SKILL.md +1 -1
  48. package/bundled/skills/observability-assistant/SKILL.md +1 -1
  49. package/bundled/skills/orchestrate/SKILL.md +1 -1
  50. package/bundled/skills/plan/SKILL.md +1 -1
  51. package/bundled/skills/pr-automation-assistant/SKILL.md +1 -1
  52. package/bundled/skills/project-structure-guide/SKILL.md +1 -1
  53. package/bundled/skills/push/SKILL.md +1 -1
  54. package/bundled/skills/retrospective-assistant/SKILL.md +1 -1
  55. package/bundled/skills/reverse-engineer/SKILL.md +1 -1
  56. package/bundled/skills/runbook-assistant/SKILL.md +1 -1
  57. package/bundled/skills/security-assistant/SKILL.md +1 -1
  58. package/bundled/skills/security-scan-assistant/SKILL.md +1 -1
  59. package/bundled/skills/slo-assistant/SKILL.md +1 -1
  60. package/bundled/skills/sweep/SKILL.md +1 -1
  61. package/bundled/skills/testing-guide/SKILL.md +1 -1
  62. package/package.json +1 -1
  63. package/src/commands/check.js +91 -1
  64. package/src/commands/init.js +8 -1
  65. package/src/commands/update.js +49 -14
  66. package/src/i18n/messages.js +32 -5
  67. package/src/installers/skills-installer.js +49 -0
  68. package/src/lint/i18n.js +338 -0
  69. package/src/utils/config-manager.js +39 -0
  70. package/src/utils/skills-installer.js +39 -7
  71. package/standards-registry.json +16 -4
@@ -0,0 +1,172 @@
1
+ ---
2
+ name: orchestrate
3
+ source: ../../../../skills/orchestrate/SKILL.md
4
+ source_version: 2.0.0
5
+ translation_version: 1.0.0
6
+ last_synced: 2026-05-28
7
+ scope: universal
8
+ description: |
9
+ [UDS] 以 Claude 原生 Agent tool 編排多任務執行計畫(DAG-based,無外部引擎)。
10
+ Use when: executing a plan.json file with parallel/sequential task dependencies.
11
+ Keywords: orchestrate, plan, execute, DAG, task plan, 編排, 執行計畫, 並行.
12
+ argument-hint: "<plan.json> [--dry-run]"
13
+ ---
14
+
15
+ # /orchestrate — 任務計畫編排 Skill
16
+
17
+ > **語言**: [English](../../../../skills/orchestrate/SKILL.md) | 繁體中文
18
+
19
+ ## 用法
20
+
21
+ ```
22
+ /orchestrate <plan.json> # 執行計畫
23
+ /orchestrate <plan.json> --dry-run # 僅驗證,不執行
24
+ ```
25
+
26
+ ---
27
+
28
+ ## 執行流程
29
+
30
+ ### Step 1:讀取與解析計畫(Claude-native)
31
+
32
+ 使用 Read tool 讀取 plan.json,直接由 Claude 解析:
33
+
34
+ 1. 讀取 JSON 檔案,解析為任務清單
35
+ 2. 驗證結構:`tasks` 非空、每個 task 含 `id`、`title`、`spec`
36
+ 3. 安全掃描:檢查 `task.spec` 是否含危險指令(`rm -rf /`、`DROP DATABASE`、`git push --force`)
37
+ - 若發現安全問題,列出所有問題並**詢問使用者是否繼續**
38
+ 4. 拓撲排序:依 `depends_on` 欄位將 tasks 分組為執行層(layers)
39
+ - Layer 0:沒有依賴的 tasks(可並行)
40
+ - Layer N:依賴全部在 Layer 0..N-1 中的 tasks
41
+
42
+ 若 `validation.valid` 為 false,輸出錯誤訊息並停止。
43
+
44
+ ---
45
+
46
+ ### Step 2:呈現執行計畫
47
+
48
+ 向使用者顯示解析結果:
49
+
50
+ ```
51
+ 計畫:<project> 品質:<quality>
52
+ ──────────────────────────────────
53
+ Layer 0 (並行):T-001, T-002
54
+ Layer 1 (序列):T-003 (依賴 T-001)
55
+ Layer 2 (序列):T-004 (依賴 T-002, T-003)
56
+ ──────────────────────────────────
57
+ 共 4 個任務,3 個執行層
58
+ ```
59
+
60
+ 若使用 `--dry-run`:顯示以上摘要後**立即停止**,不啟動任何 Agent。
61
+
62
+ ---
63
+
64
+ ### Step 3:逐層執行
65
+
66
+ 對 `layers` 陣列中的每一層:
67
+
68
+ 1. **同層並行**:同一層的 tasks 在同一訊息中啟動多個 Agent tool
69
+ 2. **Agent tool 參數**:
70
+ - `prompt`:task.spec + acceptance_criteria + user_intent 組合而成的執行提示
71
+ - `isolation: "worktree"`:每個 task 在獨立 git worktree 執行
72
+ - `description`:`"Task {task.id}: {task.title}"`
73
+ 3. **等待完成**:所有同層 agents 完成後,才進入下一層
74
+
75
+ **Agent 提示範本**:
76
+ ```
77
+ Task: {task.title}
78
+
79
+ Spec:
80
+ {task.spec}
81
+
82
+ Acceptance Criteria:
83
+ {task.acceptance_criteria 逐條列出}
84
+
85
+ User Intent:
86
+ {task.user_intent}
87
+
88
+ After completing the task, run: {task.verify_command}
89
+ ```
90
+
91
+ ---
92
+
93
+ ### Step 4:依賴失敗處理
94
+
95
+ 如果某個 task 的 agent 回報失敗:
96
+ - 標記該 task 為 `failed`
97
+ - 後續層中 `depends_on` 包含該 task ID 的所有 tasks 標記為 `skipped`
98
+ - 繼續執行不受影響的 tasks
99
+ - 最終報告中標示失敗原因
100
+
101
+ ---
102
+
103
+ ### Step 5:Quality Gate
104
+
105
+ 每個 task 完成後,若 task 定義了 `verify_command`:
106
+
107
+ 1. 使用 Bash tool 執行 `verify_command`
108
+ 2. **成功**:記錄 `status: "success"`
109
+ 3. **失敗**:
110
+ - 若 `quality` 為 `"strict"` 或 `"standard"`:啟動 Fix Loop
111
+ - Fix Loop:將錯誤輸出回傳給 agent,重新執行(最多 3 次)
112
+ - 超過重試上限:標記為 `failed`
113
+
114
+ ---
115
+
116
+ ### Step 6:Judge 審查(選用)
117
+
118
+ 如果 task 定義了 `judge: true`:
119
+ - 啟動一個額外的 Agent tool 進行審查
120
+ - 提示:`審查 task {id} 的 git diff,依照 code-review 標準檢查`
121
+ - Judge 結果附加到最終報告
122
+
123
+ ---
124
+
125
+ ### Step 7:產出報告
126
+
127
+ 彙整所有 task 結果,輸出執行報告:
128
+
129
+ ```json
130
+ {
131
+ "summary": {
132
+ "total_tasks": 4,
133
+ "succeeded": 3,
134
+ "failed": 1,
135
+ "skipped": 0,
136
+ "total_duration_ms": 120000
137
+ },
138
+ "tasks": [
139
+ { "task_id": "T-001", "status": "success", "duration_ms": 30000 },
140
+ { "task_id": "T-002", "status": "failed", "error": "..." },
141
+ { "task_id": "T-003", "status": "skipped", "reason": "依賴任務失敗" }
142
+ ]
143
+ }
144
+ ```
145
+
146
+ ---
147
+
148
+ ## 品質設定檔
149
+
150
+ | Profile | 行為 |
151
+ |---------|------|
152
+ | `strict` | 全部檢查 + Fix Loop 最多 5 次 |
153
+ | `standard` | lint + test + Fix Loop 最多 3 次(預設) |
154
+ | `minimal` | 僅跑 verify_command,不 Fix Loop |
155
+ | `none` | 不執行任何驗證 |
156
+
157
+ ---
158
+
159
+ ## 重要注意事項
160
+
161
+ - 每個 Agent tool 的 `isolation: "worktree"` 會自動建立 git worktree
162
+ - `depends_on: []` 的 tasks 在同一層內全部並行
163
+ - 使用繁體中文回覆使用者
164
+
165
+ ---
166
+
167
+ ## 版本歷程
168
+
169
+ | 版本 | 日期 | 變更 |
170
+ |------|------|------|
171
+ | 2.0.0 | 2026-04-28 | 升格為 UDS 正式 Skill;Step 1 改為 Claude-native 解析(移除 plan-resolver-cli.js 依賴);新增 Quality Gate / Fix Loop 章節(XSPEC-097 Phase 3) |
172
+ | 1.0.0 | 2026-04-09 | 初始發布(從上游遷移) |
@@ -0,0 +1,239 @@
1
+ ---
2
+ name: plan
3
+ source: ../../../../skills/plan/SKILL.md
4
+ source_version: 2.0.0
5
+ translation_version: 1.0.0
6
+ last_synced: 2026-05-28
7
+ scope: universal
8
+ description: |
9
+ [UDS] 從 Spec 文件、OpenSpec 變更或自由文字需求生成 plan.json。
10
+ Use when: converting specifications into executable task plans for /orchestrate.
11
+ Keywords: plan, spec, task plan, 計畫, 規格, 任務, plan.json, DAG.
12
+ argument-hint: "[spec-file.md | openspec-dir/ | \"需求描述文字\" | (互動模式)]"
13
+ ---
14
+
15
+ # /plan — 從 Spec 自動生成 plan.json
16
+
17
+ > **語言**: [English](../../../../skills/plan/SKILL.md) | 繁體中文
18
+
19
+ ## 用法
20
+
21
+ ```
22
+ /plan <spec-file.md> # Spec 模式(自有格式 / SpecKit)
23
+ /plan <openspec-change-dir/> # OpenSpec 模式
24
+ /plan "需求描述文字" # 需求模式
25
+ /plan # 互動模式(自動偵測)
26
+ ```
27
+
28
+ ---
29
+
30
+ ## 執行流程
31
+
32
+ ### Step 1:輸入辨識與格式偵測
33
+
34
+ 根據引數類型判斷使用模式:
35
+
36
+ **引數是 .md 檔案:**
37
+ 1. 讀取檔案內容
38
+ 2. 偵測格式:
39
+ - 含 `## Requirements` **且** `## Technical Design` → **自有格式**(SPEC-NNN-*.md)
40
+ - 含 `## Summary` **且** `## Detailed Design` → **SpecKit 格式**
41
+ - 其他 .md → 嘗試解析為通用 Spec(按自有格式處理,缺少的欄位由 AI 補充)
42
+
43
+ **引數是目錄:**
44
+ 1. 檢查是否含 `proposal.md` + `tasks.md` → **OpenSpec 格式**
45
+ 2. 否則報錯:「此目錄不符合 OpenSpec 結構」
46
+
47
+ **引數是字串描述(非檔案路徑):**
48
+ → **需求模式**
49
+
50
+ **無引數:**
51
+ → **互動模式**
52
+ 1. 偵測 `openspec/` 目錄存在? → 列出 changes 讓使用者選擇
53
+ 2. 偵測 `specs/*.md` 存在? → 列出可用 Spec 讓使用者選擇
54
+ 3. 都沒有 → 進入需求模式問答
55
+
56
+ ---
57
+
58
+ ### Step 2:專案 Context 收集
59
+
60
+ 讀取目標專案的關鍵資訊:
61
+
62
+ 1. **CLAUDE.md / AGENTS.md** — 語言、框架、測試工具、開發規範
63
+ 2. **package.json / pyproject.toml** — 可用 scripts(build, test, lint)
64
+
65
+ 從 Context 推斷:
66
+ - 主要語言(TypeScript / Python / 其他)
67
+ - 預設 verify_command(如 `pnpm build && pnpm test`、`pytest -x`)
68
+ - 預設 lint_command(如 `pnpm lint`、`ruff check .`)
69
+
70
+ ---
71
+
72
+ ### Step 3:Spec 解析
73
+
74
+ 依偵測到的格式,解析 Spec 內容:
75
+
76
+ #### 自有格式(SPEC-NNN-*.md)
77
+
78
+ 提取以下區段:
79
+ - **Summary / Motivation** → 理解背景與需求動機
80
+ - **Requirements (REQ-NNN)** → 功能需求列表
81
+ - **Acceptance Criteria (AC-N)** → Given/When/Then 驗收條件
82
+ - **Technical Design** → Phase 分層、每個 Phase 的實作項目
83
+ - **Test Plan** → 測試清單
84
+ - **Risks** → 風險評估
85
+
86
+ #### OpenSpec(change 目錄)
87
+
88
+ 讀取以下檔案:
89
+ - `proposal.md` → Why(動機)、What Changes(變更項目)、Impact
90
+ - `tasks.md` → `- [ ]` checklist 項目
91
+ - `design.md`(若存在)→ 技術決策
92
+ - `specs/*/spec.md`(若存在)→ Requirements(SHALL / MUST 語句)、Scenarios
93
+
94
+ #### SpecKit(SPEC-ID.md)
95
+
96
+ 提取以下區段:
97
+ - **Summary / Motivation** → 背景
98
+ - **Detailed Design** → 技術實作步驟
99
+ - **Acceptance Criteria** → checkbox 驗收條件
100
+ - **Dependencies** → 外部依賴
101
+ - **Risks** → 風險
102
+
103
+ ---
104
+
105
+ ### Step 4:Task 切分
106
+
107
+ 依格式套用不同映射規則:
108
+
109
+ #### 自有格式映射規則
110
+
111
+ | Spec 區段 | plan.json 欄位 | 映射規則 |
112
+ |-----------|---------------|----------|
113
+ | Technical Design > Phase | 一組 tasks | 每個 Phase 的每個實作項目 = 1 個 task |
114
+ | Phase 實作項目描述 | `task.spec` | 合併:項目描述 + 相關 REQ + 技術細節 |
115
+ | Acceptance Criteria (AC-N) | `task.acceptance_criteria` | 分配到最相關的 task |
116
+ | Summary / Motivation | `task.user_intent` | 萃取與 task 最相關的意圖 |
117
+ | Test Plan | `task.verify_command` | 推斷測試指令 |
118
+
119
+ #### OpenSpec 映射規則
120
+
121
+ | OpenSpec 檔案 | plan.json 欄位 | 映射規則 |
122
+ |--------------|---------------|----------|
123
+ | `tasks.md` 的 checklist 項目 | tasks | 每個 `- [ ]` 項目 = 1 個 task |
124
+ | `proposal.md` > Why | `task.user_intent` | 所有 tasks 共用 |
125
+ | `proposal.md` > What Changes | 融入 `task.spec` | 提供變更脈絡 |
126
+ | `design.md` 技術細節 | 融入 `task.spec` | 補充實作指引 |
127
+ | `specs/*/spec.md` > Scenarios | `task.acceptance_criteria` | 每個 Scenario 映射為一條 criteria |
128
+ | `specs/*/spec.md` > Requirements | 融入 `task.spec` | SHALL / MUST 語句轉為具體實作指引 |
129
+
130
+ ---
131
+
132
+ ### Step 5:依賴推斷
133
+
134
+ 為 tasks 建立 `depends_on` 關係:
135
+
136
+ 1. **Phase / Stage 順序**:後面的 Phase 的第一個 task depends_on 前面 Phase 的最後一個 task
137
+ 2. **同 Phase 內順序**:型別定義 → 實作 → 整合 → 測試
138
+ 3. **檔案依賴**:A 建立的檔案被 B import → B depends_on A
139
+ 4. **無依賴的 tasks**:`depends_on: []`(可並行)
140
+
141
+ ---
142
+
143
+ ### Step 6:verify_command 推斷
144
+
145
+ 依以下優先順序推斷:
146
+
147
+ 1. **Test Plan / Scenarios 有明確測試項** → 對應測試指令
148
+ 2. **TypeScript 專案** → `pnpm build && pnpm test`
149
+ 3. **Python 專案** → `pytest -x`
150
+ 4. **其他** → 使用 Step 2 收集的專案 scripts
151
+ 5. **無法推斷** → 不設(後續品質警告會提醒)
152
+
153
+ ---
154
+
155
+ ### Step 7:品質設定
156
+
157
+ - 預設 `quality: "standard"`
158
+ - 使用者可在互動確認時調整
159
+
160
+ ---
161
+
162
+ ### Step 8:組裝 plan.json
163
+
164
+ ```json
165
+ {
166
+ "project": "<專案名稱>",
167
+ "quality": "standard",
168
+ "defaults": {
169
+ "max_turns": 30,
170
+ "max_budget_usd": 2.0,
171
+ "verify_command": "<推斷的預設驗證指令>"
172
+ },
173
+ "tasks": [
174
+ {
175
+ "id": "T-001",
176
+ "title": "<task 標題>",
177
+ "spec": "<詳細的 task 規格說明>",
178
+ "depends_on": [],
179
+ "verify_command": "<task 層級驗證指令(可選)>",
180
+ "acceptance_criteria": ["<驗收條件 1>"],
181
+ "user_intent": "<使用者意圖>"
182
+ }
183
+ ]
184
+ }
185
+ ```
186
+
187
+ **注意事項:**
188
+ - Task ID 格式:`T-NNN`(如 T-001, T-002)
189
+ - `spec` 欄位應詳盡——它是 agent 執行任務的唯一規格輸入
190
+ - `acceptance_criteria` 每條都必須是可觀察、可驗證的
191
+
192
+ ---
193
+
194
+ ### Step 9:驗證(Claude-native)
195
+
196
+ Claude 對 plan.json 執行以下驗證(無需外部引擎):
197
+
198
+ 1. **結構驗證**:`tasks` 陣列存在且非空、每個 task 含必填欄位(id, title, spec)
199
+ 2. **DAG 合法性**:`depends_on` 中的所有 ID 均存在、無循環依賴
200
+ 3. **安全掃描**:task.spec 不含危險指令(`rm -rf /`、`DROP DATABASE`、`git push --force`)
201
+ 4. **品質警告**:task 缺少 verify_command、spec 過短(< 20 字)等
202
+
203
+ 若發現問題,在呈現前先自動修正(若可修正)或標示警告。
204
+
205
+ ---
206
+
207
+ ### Step 10:呈現與確認
208
+
209
+ 向使用者呈現生成結果:
210
+
211
+ 1. **摘要表格**:
212
+ ```
213
+ | Task ID | 標題 | 依賴 | 驗證指令 |
214
+ |---------|------|------|----------|
215
+ | T-001 | ... | - | ... |
216
+ | T-002 | ... | T-001| ... |
217
+ ```
218
+
219
+ 2. **DAG 拓撲**:
220
+ ```
221
+ Layer 0: T-001, T-002(並行)
222
+ Layer 1: T-003(依賴 T-001)
223
+ Layer 2: T-004(依賴 T-002, T-003)
224
+ ```
225
+
226
+ 3. **品質設定**:`quality: standard`
227
+
228
+ 4. **品質警告**(若有)
229
+
230
+ 5. **詢問使用者**:確認或修改?確認後寫入檔案(預設路徑:`plans/<spec-name>.plan.json`)
231
+
232
+ ---
233
+
234
+ ## 版本歷程
235
+
236
+ | 版本 | 日期 | 變更 |
237
+ |------|------|------|
238
+ | 2.0.0 | 2026-04-28 | 升格為 UDS 正式 Skill;移除 [DEVAP] 標記;Step 9 改為 Claude-native 驗證(XSPEC-097 Phase 3) |
239
+ | 1.0.0 | 2026-04-09 | 初始發布(從上游遷移) |
@@ -3,8 +3,12 @@ name: project-structure-guide
3
3
  source: ../../../../skills/project-structure-guide/SKILL.md
4
4
  source_version: 1.1.0
5
5
  translation_version: 1.1.0
6
- last_synced: 2026-03-04
6
+ last_synced: 2026-05-28
7
7
  status: current
8
+ description: |
9
+ [UDS] 引導依語言特性最佳實踐組織專案目錄結構。
10
+ Use when: creating projects, reorganizing structure, adding modules, setting up builds, deciding file placement.
11
+ Keywords: project, structure, directory, layout, gitignore, scaffold, file placement, 專案結構, 目錄配置.
8
12
  ---
9
13
 
10
14
  # 專案結構指南
@@ -0,0 +1,241 @@
1
+ ---
2
+ name: push
3
+ source: ../../../../skills/push/SKILL.md
4
+ source_version: 2.0.0
5
+ translation_version: 1.0.0
6
+ last_synced: 2026-05-28
7
+ scope: universal
8
+ description: |
9
+ [UDS] AI 輔助 git push 安全層:品質閘門 + 協作護欄。
10
+ Use when: pushing commits, force pushing, pushing to protected branches, pushing feature branches.
11
+ Keywords: git push, force push, protected branch, quality gate, push receipt, PR automation, 推送, 保護分支, 品質閘門.
12
+ allowed-tools: Read, Bash(git:*), Bash(npm:*), Bash(pnpm:*), Bash(yarn:*), Bash(bun:*)
13
+ argument-hint: "[--force] [--target <branch>] [--skip-gates] [--no-pr]"
14
+ ---
15
+
16
+ # 推送助手
17
+
18
+ > **語言**: [English](../../../../skills/push/SKILL.md) | 繁體中文
19
+
20
+ **版本**:2.0.0
21
+ **建立日期**:2026-04-23
22
+ **適用範圍**:Claude Code Skills
23
+
24
+ ---
25
+
26
+ `git push` 的 AI 輔助安全層。偵測保護分支、強制 force-push 護欄、執行 pre-push 品質閘門、輸出結構化推送收據,並整合 PR 自動化。
27
+
28
+ ## 核心標準
29
+
30
+ 本 Skill 實作 [`.standards/push-standards.ai.yaml`](../../../../.standards/push-standards.ai.yaml)。
31
+
32
+ ---
33
+
34
+ ## 執行工作流程
35
+
36
+ 呼叫 `/push` 後,Claude 原生依序執行以下步驟:
37
+
38
+ ### Step 1:偵測保護分支
39
+ 執行 `git rev-parse --abbrev-ref HEAD` 取得目前分支。
40
+ 比對 `protected_branches` 清單(預設:main、master、release/*、hotfix/*)。
41
+ 若為保護分支:顯示警告 + 待推送的 commit 列表,需使用者明確確認才能繼續。
42
+
43
+ ### Step 2:偵測 Force Push
44
+ 若偵測到 `--force` 或 `--force-with-lease`:
45
+ 執行 `git log origin/<branch>..HEAD --oneline` 找出將被覆蓋的 commits。
46
+ 顯示數量與作者列表。需要使用者輸入 `yes, force push` 才能繼續。
47
+
48
+ ### Step 3:執行 Pre-Push 品質閘門
49
+ 依序使用 Bash tool 執行每個已設定的閘門:
50
+ - `lint`:偵測並執行專案 lint 指令
51
+ - `test`:偵測並執行專案測試指令
52
+ - `type-check`(選用):TypeScript 型別檢查
53
+ - `ac-coverage`(選用):驗收條件覆蓋率
54
+ - `security-scan`(選用):安全漏洞掃描
55
+
56
+ 若任何必要閘門失敗:中止並顯示錯誤訊息。
57
+
58
+ ### Step 4:執行推送
59
+ 執行 `git push <remote> <branch> [--force]`。
60
+ 若推送失敗:顯示 git 錯誤並建議修正方式。
61
+
62
+ ### Step 5:發出推送收據
63
+ 將結構化收據輸出到 console(可選擇寫入 `~/.uds/push-history.jsonl`):
64
+ ```json
65
+ {
66
+ "branch": "<branch>",
67
+ "commit_sha": "<sha>",
68
+ "gates_passed": ["lint", "test"],
69
+ "force_push": false,
70
+ "timestamp": "<ISO8601>",
71
+ "target_remote": "origin"
72
+ }
73
+ ```
74
+
75
+ ### Step 6:PR 整合
76
+ 若 `auto_pr=true` **且** `repo_mode=team` **且**該分支無 open PR:
77
+ 建議使用者執行 `/pr-automation-assistant` 建立 Pull Request。
78
+
79
+ ---
80
+
81
+ ## 功能說明
82
+
83
+ ### 1. 推送目標風險偵測
84
+
85
+ 推送前偵測目標分支是否為保護分支(例如 `main`、`master`、`release/*`、`hotfix/*`)。
86
+
87
+ - 顯示**警告**,列出分支名稱與 commit 清單
88
+ - 需要使用者明確確認才能繼續
89
+ - 使用者未確認則中止推送
90
+
91
+ ### 2. Force-Push 護欄
92
+
93
+ 偵測到 `--force` 時,推送前顯示影響範圍。
94
+
95
+ - 計算遠端將被覆蓋的 commits
96
+ - 顯示被覆蓋 commits 的數量與作者
97
+ - 要求使用者輸入確認字串(`yes, force push`)
98
+ - 在推送收據中記錄 `force_push: true`
99
+
100
+ ### 3. Pre-Push 品質閘門
101
+
102
+ 推送前依序執行已設定的品質閘門。
103
+
104
+ | 閘門 | 說明 |
105
+ |------|------|
106
+ | `lint` | 執行 lint 檢查 |
107
+ | `test` | 執行測試 |
108
+ | `type-check` | TypeScript 型別檢查(選用) |
109
+ | `ac-coverage` | AC 覆蓋率檢查(選用) |
110
+ | `security-scan` | 安全掃描(選用) |
111
+
112
+ ### 4. 推送收據
113
+
114
+ 推送成功後輸出結構化收據,供稽核追蹤使用。
115
+
116
+ ```json
117
+ {
118
+ "branch": "feature/my-feature",
119
+ "commit_sha": "a1b2c3d",
120
+ "gates_passed": ["lint", "test"],
121
+ "gates_skipped": false,
122
+ "force_push": false,
123
+ "timestamp": "2026-04-23T10:00:00Z",
124
+ "target_remote": "origin"
125
+ }
126
+ ```
127
+
128
+ 可選擇附加到 `~/.uds/push-history.jsonl` 以持久化稽核追蹤。
129
+
130
+ ### 5. PR 自動化整合入口
131
+
132
+ 推送 feature branch 後,若尚無 PR,提示使用者建立 Pull Request。
133
+
134
+ - 檢查該分支是否已有 open PR
135
+ - 提示使用者執行 `pr-automation-assistant`
136
+ - 在 `single-owner` repo 模式或使用 `--no-pr` 旗標時跳過
137
+
138
+ ---
139
+
140
+ ## 使用方式
141
+
142
+ ```bash
143
+ # 標準推送(自動執行品質閘門)
144
+ /push
145
+
146
+ # Force push(顯示被覆蓋 commits,需要確認)
147
+ /push --force
148
+
149
+ # 推送到指定的遠端分支
150
+ /push --target main
151
+
152
+ # 跳過品質閘門(緊急情況)
153
+ /push --skip-gates
154
+
155
+ # 推送但不提示建立 PR
156
+ /push --no-pr
157
+
158
+ # Force push 且不提示建立 PR(例如更新個人分支)
159
+ /push --force --no-pr
160
+ ```
161
+
162
+ ## 參數說明
163
+
164
+ | 參數 | 說明 |
165
+ |------|------|
166
+ | `--force` | 啟用 force push,含護欄確認 |
167
+ | `--target <branch>` | 明確指定目標遠端分支 |
168
+ | `--skip-gates` | 跳過品質閘門(僅緊急情況) |
169
+ | `--no-pr` | 推送後不提示建立 PR |
170
+
171
+ ---
172
+
173
+ ## 設定
174
+
175
+ 透過 `uds.project.yaml` 設定:
176
+
177
+ ```yaml
178
+ push:
179
+ repo_mode: team # "team" | "single-owner"
180
+ protected_branches:
181
+ - main
182
+ - master
183
+ - "release/*"
184
+ - "hotfix/*"
185
+ push_gates:
186
+ default:
187
+ - lint
188
+ - test
189
+ optional:
190
+ - type-check
191
+ - ac-coverage
192
+ - security-scan
193
+ receipt:
194
+ output: console # "console" | "file" | "both"
195
+ file_path: "~/.uds/push-history.jsonl"
196
+ auto_pr: true # 推送到非保護分支後是否提示建立 PR
197
+ ```
198
+
199
+ ### 選項模式
200
+
201
+ | Option 檔案 | 模式 | 說明 |
202
+ |-------------|------|------|
203
+ | [`options/push/team-mode.md`](../../../../options/push/team-mode.md) | `team` | 完整協作護欄(預設) |
204
+ | [`options/push/single-owner-mode.md`](../../../../options/push/single-owner-mode.md) | `single-owner` | 個人 repo 低摩擦模式 |
205
+
206
+ ---
207
+
208
+ ## 下一步引導
209
+
210
+ `/push` 完成後,AI 助手應建議:
211
+
212
+ > **推送完成。建議下一步:**
213
+ > - 執行 `/pr-automation-assistant` 建立或更新 Pull Request ⭐ **推薦** — 確保協作流程完整
214
+ > - 執行 `/checkin` 確認程式碼簽入品質 — 下次提交前的品質確認
215
+ > - 查看 `~/.uds/push-history.jsonl` 確認推送紀錄 — 稽核追蹤
216
+
217
+ ---
218
+
219
+ ## 相關標準
220
+
221
+ - [Push Standards](../../../../.standards/push-standards.ai.yaml) — 核心推送安全規則
222
+ - [Git Workflow](../../../../.standards/git-workflow.ai.yaml) — 分支策略
223
+ - [Commit Message](../../../../.standards/commit-message.ai.yaml) — Commit 慣例
224
+ - [PR Automation](../pr-automation-assistant/SKILL.md) — Pull Request 自動化
225
+
226
+ ---
227
+
228
+ ## 版本歷程
229
+
230
+ | 版本 | 日期 | 變更 |
231
+ |------|------|------|
232
+ | 2.0.0 | 2026-04-28 | 還原 workflow 執行步驟(XSPEC-097 採用層解耦);移除棄用通知 |
233
+ | 1.0.0 | 2026-04-23 | 初始版本 — XSPEC-081 Phase 1 |
234
+
235
+ ---
236
+
237
+ ## 授權
238
+
239
+ 本 Skill 採用 [MIT License](https://opensource.org/licenses/MIT) 與 [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) 雙重授權發布。
240
+
241
+ **來源**:[universal-dev-standards](https://github.com/AsiaOstrich/universal-dev-standards)