Claude Skills 的集合,將常見的 GitHub CI/CD 工作流程封裝為 AI 可呼叫的能力。每個 Skill 都可由 Claude 根據自然語言觸發,針對真實的 GitHub 儲存庫執行,並回傳結構化的結果。
本專案以 Anthropic Skills 規範作為示範,展示如何以清晰的邊界、安全控制與冪等性保證,封裝 CI/CD 操作。
GitSkills/
├── README.md
├── docs
│ ├── 需求規格_開發進度.md
│ └── 需求釐清.md
├── prompt
├── evals
│ └── 自行驗測報告.md
├── pyproject.toml
├── requirements.txt
├── src
│ ├── __init__.py
│ └── skills
│ ├── __init__.py
│ ├── build_and_release
│ │ └── SKILL.md
│ ├── dependency_audit
│ │ ├── SKILL.md
│ │ ├── __init__.py
│ │ └── scripts
│ │ ├── __init__.py
│ │ ├── run_skill.py ← 進入點
│ │ └── write_cache.py
│ ├── lint_and_test
│ │ ├── SKILL.md
│ │ ├── __init__.py
│ │ └── scripts
│ │ ├── __init__.py
│ │ ├── run_sandboxed.py
│ │ ├── run_skill.py ← 進入點
│ │ └── write_cache.py
│ └── security_scan
│ ├── SKILL.md
│ └── scripts
│ ├── __pycache__
│ ├── run_skill.py
│ └── write_cache.py
└── tests
| Skill | 用途 | 是否寫入 GitHub |
|---|---|---|
lint_and_test |
在沙箱環境中執行 Lint 與測試 | ❌ |
dependency_audit |
掃描第三方套件的已知 CVE 漏洞 | ❌ |
security_scan |
對原始碼進行靜態安全分析(SAST) | ❌ |
build_and_release |
在本地端建置並發布 GitHub Release | ✅ |
- Python 3.10+
- Git
- Docker(
lint_and_test沙箱使用;無 Docker 時自動 fallback 至 venv) - 語言特定工具(依 Skill 與儲存庫語言而定):
- Node.js / npm(Node.js 儲存庫)
- Go 1.21+(Go 儲存庫)
pip-audit(dependency_audit Python)bandit、semgrep(security_scan Python)
GitSkills 專為在 Claude Code 命令列環境中使用而設計。透過本專案 skills資料夾放入專案的 .claude/skills/ 目錄,Claude 會自動載入這些能力,你只需用自然語言下指令即可。
完成後目錄結構應如下:
your-project/
├── .claude/
│ └── skills/
│ ├── lint_and_test/
│ ├── dependency_audit/
│ ├── security_scan/
│ └── build_and_release/
└── ...(你的專案檔案)
直接用自然語言對 Claude 下指令即可
在沙箱環境中,對 GitHub 儲存庫執行 Lint 檢查與自動化測試。
支援語言:Node.js、Python、Go、Ruby、Rust(自動偵測)
沙箱策略:
- 有 Docker → 在隔離容器內執行(lint/test 階段使用
--network=none) - 無 Docker → 退而使用隔離的 venv / 本地套件目錄
cd src/skills/lint_and_test
python scripts/run_skill.py \
--repo "owner/repo" \
[--ref "main"] \
[--token "ghp_..."] \
[--config '{"timeout_seconds": 300}']{
"lint_command": "自訂 lint 指令",
"test_command": "自訂測試指令",
"timeout_seconds": 300
}{
"status": "success | partial | failed | error",
"commit_sha": "abc123...",
"cache_hit": false,
"language_detected": "python",
"sandbox": "docker | venv",
"lint": {
"passed": true,
"exit_code": 0,
"errors": [],
"warnings": [],
"raw_output": "All checks passed!"
},
"test": {
"passed": true,
"total": 42,
"passed_count": 42,
"failed_count": 0,
"skipped_count": 0,
"failures": []
},
"duration_seconds": 15.67
}| 狀態 | 意義 |
|---|---|
success |
Lint 與測試均通過 |
partial |
一項通過,一項失敗(使用者程式碼問題) |
failed |
兩者均失敗(使用者程式碼問題) |
error |
Skill 無法完成(儲存庫錯誤、不支援的工具鏈、逾時) |
| 儲存庫 | 語言 | Lint | 測試 | 狀態 |
|---|---|---|---|---|
| LLMSystems/github-cicd-practice | Python | ✅ | ✅ 4/4 | success |
| psf/requests | Python | ❌ | failed | |
| pallets/flask | Python | ✅ | partial | |
| tiangolo/fastapi | Python | ✅ | ❌ error | partial |
| encode/httpx | Python | ✅ | partial | |
| lodash/lodash | Node.js | ➖ | ✅ 7152/7152 | success |
| google/uuid | Go | ✅ | ✅ | success |
透過讀取 lock 檔案並查詢漏洞資料庫,檢查儲存庫的第三方相依套件是否存在已知安全漏洞(CVE)。不會執行任何儲存庫程式碼。
與 security_scan 的關鍵差異:
dependency_audit→ 檢查第三方套件的已知 CVEsecurity_scan→ 檢查你自己的程式碼是否有不安全的寫法
支援語言與工具:
| 語言 | Lock 檔案 | 工具 |
|---|---|---|
| Node.js | package-lock.json |
npm audit |
| Python | requirements.txt / pyproject.toml |
pip-audit |
| Go | go.sum |
govulncheck |
| Ruby | Gemfile.lock |
bundle audit |
| Rust | Cargo.lock |
cargo audit |
cd src/skills/dependency_audit
python scripts/run_skill.py \
--repo "owner/repo" \
[--ref "main"] \
[--token "ghp_..."] \
[--config '{"severity_threshold": "high"}']{
"severity_threshold": "low | medium | high | critical",
"timeout_seconds": 120
}{
"status": "clean | success | error",
"commit_sha": "abc123...",
"language_detected": "node",
"lock_file": "package-lock.json",
"audit_tool": "npm audit",
"vulnerabilities_found": 86,
"critical": 40,
"high": 46,
"medium": 0,
"low": 0,
"vulnerabilities": [
{
"package": "lodash",
"installed_version": "4.17.15",
"severity": "critical",
"cve": "CVE-2021-23337",
"description": "透過 template 進行指令注入",
"fix_version": "4.17.21",
"more_info": "https://..."
}
],
"duration_seconds": 4.2
}| 狀態 | 意義 |
|---|---|
clean |
稽核完成,未發現任何漏洞 |
success |
稽核完成,發現漏洞 |
error |
Skill 無法完成 |
| 儲存庫 | 語言 | 漏洞數 | Critical | High | 狀態 |
|---|---|---|---|---|---|
| LLMSystems/github-cicd-practice | Python | 0 | 0 | 0 | clean |
| milk333445/vuln-test | Python | 48 | 0 | 0 | success |
| psf/requests | Python | 10 | 0 | 0 | success |
| pallets/flask | Python | 10 | 0 | 0 | success |
| encode/httpx | Python | 4 | 0 | 0 | success |
| lodash/lodash | Node.js | 86 | 40 | 46 | success |
注意:
pip-audit不提供 CVSS 嚴重性評分——Python 漏洞的severity欄位將顯示為unknown。npm audit 則提供完整的嚴重性分類。
使用 bandit(Python)與 semgrep(所有語言)對原始碼執行靜態安全分析(SAST),以尋找不安全的程式碼寫法、硬式編碼的機密,以及常見漏洞類型。不會執行任何儲存庫程式碼。
與 dependency_audit 的關鍵差異:
dependency_audit→ 檢查第三方套件的已知 CVEsecurity_scan→ 檢查你自己的程式碼是否有不安全的寫法
工具說明:
| 工具 | 支援語言 | 偵測項目 |
|---|---|---|
bandit |
僅限 Python | eval() 濫用、硬式編碼密碼、SQL 注入、不安全的加密 |
semgrep |
Python、JS/TS、Go、Ruby、Java 等 | XSS、SSRF、機密外洩、不安全模式 |
cd src/skills/security_scan
python scripts/run_skill.py \
--repo "owner/repo" \
[--ref "main"] \
[--token "ghp_..."] \
[--config '{"severity_threshold": "medium", "tools": ["bandit", "semgrep"]}']{
"severity_threshold": "low | medium | high",
"tools": ["bandit", "semgrep"],
"timeout_seconds": 120
}{
"status": "clean | success | error",
"commit_sha": "abc123...",
"language_detected": "python",
"tools_run": ["bandit", "semgrep"],
"issues_found": 3,
"high": 0,
"medium": 0,
"low": 3,
"issues": [
{
"tool": "bandit",
"rule_id": "B101",
"severity": "low",
"title": "偵測到 assert 的使用",
"file": "tests/test_calculator.py",
"line": 7,
"code_snippet": "assert add(1, 2) == 3",
"more_info": "https://bandit.readthedocs.io/..."
}
],
"duration_seconds": 8.4
}| 儲存庫 | 語言 | 問題數 | High | Medium | Low | 狀態 |
|---|---|---|---|---|---|---|
| LLMSystems/github-cicd-practice | Python | 3 | 0 | 0 | 3 | success |
| psf/requests | Python | 688 | 0 | 127 | 561 | success |
| pallets/flask | Python | 1107 | 3 | 20 | 1084 | success |
| encode/httpx | Python | 1335 | 1 | 10 | 1324 | success |
| lodash/lodash | Node.js | 21 | 0 | 21 | 0 | success |
注意:由於 semgrep 預設規則集範圍較廣,問題數量可能偏高,其中許多低嚴重性的結果為誤報。建議將
severity_threshold設為"medium"或"high",以聚焦於真正需要處理的問題。
協助使用者建置本地端儲存庫,並將結果發布為 GitHub Release。Claude 將直接執行所有步驟,無需進行 clone 操作。
這是唯一會寫入 GitHub 的 Skill。 需要具備 contents:write 權限的 Token。
以自然語言請 Claude 執行此 Skill:
將我位於 /path/to/project 的本地儲存庫以 v1.0.0 版本發布
Claude 將詢問以下資訊:
repo— GitHubowner/repotag— 版本標籤(例如v1.0.0)——不得已存在於 Release 中token— 具備contents:write權限的 GitHub Tokenworkdir— 儲存庫的本地路徑
- 驗證標籤與 Token
- 檢查 Release 是否已存在(冪等性保障——若已存在則略過)
- 偵測語言與建置指令
- 在本地 workdir 執行建置
- 將產出物打包為
.tar.gz - 若尚未建立 git tag,則建立並推送
- 透過 API 建立 GitHub Release
- 將產出物上傳至 Release
- 回傳 Release URL
Repository access: Only select repositories → 選擇目標儲存庫
Permissions → Contents: Read and write
對於需要管理員核准細粒度 Token 的組織儲存庫,具備
reposcope 的傳統 PAT 同樣適用。
| 考量面向 | 處理方式 |
|---|---|
| 程式碼執行隔離 | lint_and_test 使用 Docker 沙箱;Docker 不可用時退回 venv |
| 網路隔離 | Docker 模式:lint/test 階段使用 --network=none |
| 資源限制 | Docker:每個階段限制 512MB 記憶體、1 CPU |
| Token 處理 | 僅注入至 git credential URL——從不記錄或寫入磁碟 |
| Token 範圍 | 除 build_and_release(contents:write)外,所有 Skill 均為唯讀 |
| 輸出遮蔽 | 回傳前掃描所有 stdout/stderr,移除 Token、密碼、API 金鑰 |
所有 Skill 以 commit_sha 作為快取鍵——而非分支名稱。這意味著:
- 對同一個 commit 執行兩次 Skill,永遠會得到相同的結果
- 快取 TTL:
lint_and_test與security_scan為 24 小時;dependency_audit為 6 小時(CVE 資料庫更新頻繁) - 錯誤結果不會被快取——可安全重試
build_and_release在建立 Release 前會先確認其是否存在——永不建立重複項目
pip-audit不提供 CVSS 嚴重性——Python CVE 的嚴重性顯示為unknown- 自訂測試框架(例如 lodash)可能無法解析測試數量
- Go、Ruby 和 Rust 需要在系統層級安裝工具——venv 無法提供這些環境
security_scan的大量問題包含來自 semgrep 廣泛規則集的誤報- venv 沙箱模式不具備網路或檔案系統隔離(正式環境建議使用 Docker)