Communitygithub.com

github-cli

GitHub CLI (gh) 整合,可從終端機直接管理議題、拉取請求、分支、提交和程式碼審查。

github-cli 是什麼?

這項技能提供了透過 GitHub CLI (`gh`) 直接從終端機操作 GitHub 工作流程的完整能力。對於經常處理議題管理、拉取請求、分支建立、提交和程式碼審查的開發人員與 AI 代理(如 Claude Code、Codex 或 Cursor)來說,此技能至關重要。它支援所有主要的 GitHub Actions 工作流程管理任務,包括檢視執行記錄、觸發工作流程以及重新執行失敗的任務。此技能支援任何已安裝並通過認證 `gh` CLI 的環境,可讓使用者在不切換到瀏覽器的情況下有效率地管理儲存庫。其文件詳細說明了標準工作流程、常見旗標參考、環境變數設定,以及處理包含 Markdown 的多行描述等進階使用技巧。

相容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/cdcoonce/Portfolio_Website/tree/HEAD/.claude/skills/github-cli

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

GitHub CLI (gh) 技能

使用 gh CLI 從終端機與 GitHub 儲存庫、議題、拉取請求及 GitHub Actions 工作流程互動。

先決條件

確認已安裝 gh 並完成驗證:

gh --version
gh auth status

若未驗證,請執行 gh auth login 並依照提示操作。

核心工作流程

議題管理

# 列出議題
gh issue list                             # 目前儲存庫中的開放議題
gh issue list --state all                 # 所有議題(包含已關閉)
gh issue list --assignee @me              # 指派給您的議題
gh issue list --label "bug"               # 依標籤篩選

# 建立議題
gh issue create -t "標題" -b "說明"
gh issue create -t "標題" --label "bug,priority:high" --milestone "milestone-1"
gh issue create                           # 互動模式

# 檢視/更新議題
gh issue view 123                         # 檢視議題詳細資訊
gh issue view 123 --web                   # 在瀏覽器中開啟
gh issue edit 123 --add-label "in-progress"
gh issue close 123
gh issue reopen 123

# 新增留言
gh issue comment 123 -b "目前正在處理"

分支與提交工作流程

# 建立功能/修正分支
 git checkout -b feature/my-feature
 git checkout -b fix/issue-123
 git checkout -b draft/wip-experiment

# 暫存並提交變更
 git add .
 git commit -m "feat: 新增功能"
 git commit -m "fix: 解決 issue #123"

# 推送分支至遠端
 git push -u origin feature/my-feature

拉取請求管理

# 建立 PR(多種方式)
gh pr create                              # 互動模式
gh pr create --fill                       # 從提交記錄自動填入
gh pr create --draft                      # 建立為草稿
gh pr create --draft --fill               # 草稿並自動填入
gh pr create -t "標題" -b "說明" -B main
gh pr create --label "review-needed" --assignee @me

# 列出 PR
gh pr list                                # 開放中的 PR
gh pr list --assignee @me                 # 您的 PR
gh pr list --search "review-requested:@me"  # 要求您審查的 PR
gh pr list --draft                        # 僅顯示草稿 PR

# 檢視 PR 詳細資訊
gh pr view 45                             # 在終端機檢視 PR
gh pr view 45 --web                       # 在瀏覽器中開啟

程式碼審查工作流程

# 在本地端簽出 PR 以進行測試
gh pr checkout 45                         # 在本地端簽出 PR 分支

# 檢視變更內容
gh pr diff 45                             # 檢視 PR 的差異
gh pr diff                                # 目前分支 PR 的差異

# 新增審查留言
gh pr comment 45 -b "LGTM,第 42 行有個小建議"
gh pr comment -b "請新增測試"             # 對目前分支的 PR 留言

# 提交正式審查
gh pr review 45 --approve
gh pr review 45 --request-changes -b "請修正錯誤處理"
gh pr review 45 --comment -b "整體不錯,有幾點建議"

# 合併
gh pr merge 45                            # 互動式合併
gh pr merge 45 --squash                   # 壓縮合併
gh pr merge 45 --rebase                   # 變基合併
gh pr merge 45 --merge                    # 標準合併提交
gh pr merge 45 --auto                     # 在檢查通過時自動合併

更新現有 PR

gh pr edit 45 --title "新標題"
gh pr edit 45 --body "已更新的說明"
gh pr edit 45 --base develop
gh pr edit 45 --add-label "ready-for-review"
gh pr ready 45                            # 標記為就緒(移除草稿狀態)

GitHub Actions 工作流程管理

# 列出工作流程執行
gh run list                               # 最近的工作流程執行
gh run list --workflow=ci.yml             # 特定工作流程
gh run list --status=failure              # 僅顯示失敗的執行

# 檢視工作流程執行詳細資訊
gh run view                               # 互動式執行選擇器
gh run view 12345                         # 特定執行
gh run view 12345 --web                   # 在瀏覽器中開啟

# 觸發工作流程
gh workflow run ci.yml                    # 在預設分支上執行
gh workflow run ci.yml --ref feature/x    # 在特定分支上執行
gh workflow run ci.yml -f key=value       # 帶入輸入參數

# 重新執行失敗的任務
gh run rerun 12345                        # 重新執行所有任務
gh run rerun 12345 --failed               # 僅重新執行失敗的任務

# 檢視任務日誌
gh run view 12345 --log                   # 完整日誌輸出
gh run view 12345 --log-failed            # 僅失敗任務的日誌

# 監控進行中的執行
gh run watch                              # 監控目前執行
gh run watch 12345                        # 監控特定執行

常見旗標參考

旗標說明
-R, --repo OWNER/REPO指定不同的儲存庫
-B, --basePR 的基礎分支
-H, --headPR 的來源分支
-t, --title議題/PR 的標題
-b, --body議題/PR 的內文/說明
-l, --label標籤(以逗號分隔)
-a, --assignee指派的使用者名稱
-m, --milestone里程碑名稱
--draft建立為草稿 PR
--fill從提交訊息自動填入
--web在瀏覽器中開啟
-y, --yes跳過確認提示

環境變數

export GH_TOKEN="ghp_xxxx"               # 個人存取權杖
export GH_HOST="github.example.com"      # GitHub Enterprise 執行個體
export GH_REPO="owner/repo"              # 預設儲存庫

提示與注意事項

使用 Markdown 的多行說明

當建立包含含 Markdown(程式碼區塊、反引號)的長篇說明的議題或 PR 時,請避免使用可能會因 shell 解譯而失敗的 heredoc。建議改用:

# 步驟 1:將說明寫入暫存檔案(在 bash 之外)
# 步驟 2:從暫存檔案建立
gh issue create -t "標題" -b "$(cat temp_description.txt)"
# 步驟 3:清理
rm temp_description.txt

這可以避免下列問題:

  • 程式碼區塊中的反引號與命令替換衝突
  • 特殊字元被 shell 解譯
  • Heredoc 結束標記衝突

從現有檔案讀取說明

若要從 Markdown 計劃檔案建立議題或 PR:

# 使用 body-file 旗標以獲得基於檔案的乾淨說明
gh issue create -t "標題" --body-file docs/plans/my-plan.md
gh pr create -t "標題" --body-file docs/plans/my-plan.md

詳細參考

如需完整的命令選項與範例,請參閱 references/commands.md。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

cdcoonce/Portfolio_Website

Git commit workflow with enforced conventional commit style. Use when Claude needs to stage and commit changes, craft commit messages, or the user asks to commit, make a commit, or save their work. Ensures consistent commit message format, proper scoping, and atomic commits across the project.

cdcoonce/Portfolio_Website

AI-powered code quality analysis for Python, Markdown, and Mermaid diagrams. Use this skill when: (1) reviewing code for quality issues, (2) checking Python files for PEP8 violations, unused code, missing type hints, docstring problems, complexity issues, or potential runtime errors, (3) validating Markdown documentation for broken links, heading structure, or formatting issues, (4) validating Mermaid diagram syntax, (5) the user asks for a "code review" or "quality check", (6) analyzing code snippets pasted in conversation, or (7) suggesting and applying fixes for code quality issues.

cdcoonce/Portfolio_Website

Deploy the portfolio chat agent Lambda function to AWS. Use when the user asks to deploy, redeploy, push to Lambda, update the chat agent, or after updating context files or lambda_function.py. Rebuilds the knowledge base, packages dependencies, and deploys to AWS Lambda.

cdcoonce/Portfolio_Website

Generate multiple radically different interface designs for a module using parallel sub-agents. Use when user wants to design an API, explore interface options, compare module shapes, or mentions "design it twice".

cdcoonce/Portfolio_Website

Orchestrate the full GitHub-issues-driven development lifecycle. 7-phase pipeline from brainstorm through PR with state tracking and cross-conversation resume. Use when user says "dev cycle", "development workflow", "full development pipeline", or invokes /dev-cycle.

cdcoonce/Portfolio_Website

Production Python coding standards with automatic version detection (3.10-3.13). Use when writing, reviewing, or refactoring Python to ensure adherence to modern type syntax, LBYL exception handling, pathlib operations, ABC-based interfaces, and production-tested patterns. Not Dagster-specific - applies to any Python project.

cdcoonce/Portfolio_Website

Set up Claude Code hooks to block dangerous git commands (push, reset --hard, clean, branch -D, etc.) before they execute. Use when user wants to prevent destructive git operations, add git safety hooks, or block git push/reset in Claude Code.

cdcoonce/Portfolio_Website

Interview the user relentlessly about a plan or design until reaching shared understanding, resolving each branch of the decision tree. Use when user wants to stress-test a plan, get grilled on their design, or mentions "grill me".

cdcoonce/Portfolio_Website

Explore a codebase to find opportunities for architectural improvement, focusing on making the codebase more testable by deepening shallow modules. Use when user wants to improve architecture, find refactoring opportunities, consolidate tightly-coupled modules, or make a codebase more AI-navigable.

cdcoonce/Portfolio_Website

CEO/founder-mode plan review. Rethink the problem, find the 10-star product, challenge premises, expand scope when it creates a better product. Three modes: SCOPE EXPANSION (dream big), HOLD SCOPE (maximum rigor), SCOPE REDUCTION (strip to essentials). Use when the user asks for a plan review, CEO review, mega review, or wants a plan challenged/stress-tested before implementation.

cdcoonce/Portfolio_Website

Break a PRD into independently-grabbable GitHub issues using tracer-bullet vertical slices. Use when user wants to convert a PRD to issues, create implementation tickets, or break down a PRD into work items.

cdcoonce/Portfolio_Website

Turn a PRD into a multi-phase implementation plan using tracer-bullet vertical slices, saved as a local Markdown file in docs/plans/. Use when user wants to break down a PRD, create an implementation plan, plan phases from a PRD, or mentions "tracer bullets".

cdcoonce/Portfolio_Website

Generate or update the `.claude/docs/project.md` file that gives Claude project-specific context. Use this skill when the user asks to create, update, regenerate, or refresh project context, or says things like "update project.md", "generate project context", "this repo needs a project.md", or "Claude doesn't know about this project". Also trigger when onboarding Claude to a new repository for the first time.

cdcoonce/Portfolio_Website

Generate comprehensive, high-quality README.md files for code repositories. Use this skill whenever the user asks to create, write, generate, update, or improve a README for any project or repository. Also trigger when the user says things like "document this project", "write docs for this repo", "this repo needs a README", "help me onboard developers to this codebase", or asks for project documentation in markdown. Even if the user just says "README" or "readme" in the context of a codebase, use this skill.

cdcoonce/Portfolio_Website

Create a detailed refactor plan with tiny commits via user interview, then file it as a GitHub issue. Use when user wants to plan a refactor, create a refactoring RFC, or break a refactor into safe incremental steps.

cdcoonce/Portfolio_Website

Set up pre-commit hooks for the current repo. Use when user wants to add pre-commit hooks, configure commit-time linting, formatting, type checking, or testing. Triggers on "pre-commit", "git hooks", "linting hooks", or /setup-pre-commit.

cdcoonce/Portfolio_Website

Test-driven development with red-green-refactor loop. Use when user wants to build features or fix bugs using TDD, mentions "red-green-refactor", wants integration tests, or asks for test-first development.

cdcoonce/Portfolio_Website

Triage a bug or issue by exploring the codebase to find root cause, then create a GitHub issue with a TDD-based fix plan. Use when user reports a bug, wants to file an issue, mentions "triage", or wants to investigate and plan a fix for a problem.

cdcoonce/Portfolio_Website

Rewrites the prose sections of wiki pages in-place. Reads source files to understand current context, then updates only the content inside <!-- claude:prose --> ... <!-- claude:prose:end --> markers. Never touches <!-- generated:start --> ... <!-- generated:end --> blocks. Supports targeting a single page with /update-wiki {PageName}.

cdcoonce/Portfolio_Website

Create a PRD through user interview, codebase exploration, and module design, then submit as a GitHub issue. Use when user wants to write a PRD, create a product requirements document, or plan a new feature.

相關技能