pushlisted
Install: claude install-skill AsiaOstrich/universal-dev-standards
# 推送助手
> **語言**: [English](../../../../skills/push/SKILL.md) | 繁體中文
**版本**:2.0.0
**建立日期**:2026-04-23
**適用範���**:Claude Code Skills
---
`git push` 的 AI 輔助安全層。偵測保護分支、強制 force-push 護欄、執行 pre-push 品質閘門、輸出結構化推送收據,並整合 PR 自動化。
## 核心標準
本 Skill 實作 [`.standards/push-standards.ai.yaml`](../../../../.standards/push-standards.ai.yaml)。
---
## 執行工作流程
呼叫 `/push` 後,Claude 原生依序執行以下步驟:
### Step 1:偵測保護分支
執行 `git rev-parse --abbrev-ref HEAD` 取得目前分支。
比對 `protected_branches` 清單(預設:main、master、release/*、hotfix/*)。
若為保護分支:顯示警告 + 待推送的 commit 列表,需使用者明確確認才能繼續。
### Step 2:偵測 Force Push
若偵測到 `--force` 或 `--force-with-lease`:
執行 `git log origin/<branch>..HEAD --oneline` 找出將被覆蓋的 commits。
顯示數量與作者列表。需要使用者輸入 `yes, force push` 才能繼續。
### Step 3:執行 Pre-Push 品質閘門
依序使用 Bash tool 執行每個已設定的閘門:
- `lint`:偵測並執行專案 lint 指令
- `test`:偵測並執行專案測試指令
- `type-check`(選用):TypeScript 型別檢查
- `ac-coverage`(選用):驗收條件覆蓋率
- `security-scan`(選用):安全漏洞掃描
若任何必要閘門失敗:中止並顯示錯誤訊息。
### Step 4:執行推送
執行 `git push <remote> <branch> [--force]`。
若推送失敗:顯示 git 錯誤並建議修正方式。
### Step 5:發出推送收據
將結構化收據輸出到 console(可選擇寫入 `~/.uds/push-history.jsonl`):
```json
{
"branch": "<branch>",
"commit_sha": "<sha>",
"gates_passed": ["lint", "test"],
"force_push": false,
"timestamp": "<ISO8601>",
"target_remote": "origin"
}
```
### Step 6:PR 整合
若 `auto_pr=true` **且** `repo_mode=team` **且**該分支無 open PR:
建議使用者執行 `/pr-automation-assistant` 建立 Pull Request。
---
## 功能說明
### 1. 推送目標風險偵測
推送前偵測目標分支是否為保護分支(例如 `main`、`master`、`release/*`、`hotfix/*`)。
- 顯示*