gh-issues
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGitHub Issues CLI
GitHub Issues CLI
Efficient GitHub Issues management via CLI with AI session context storage.
gh通过 CLI高效管理GitHub Issues,支持AI会话上下文存储。
ghTable of Contents
目录
Quick Reference
快速参考
| Task | Command |
|---|---|
| Create issue | |
| Active tasks | |
| List open bugs | |
| View as JSON | |
| Close with comment | |
| Edit labels | |
| Start work | |
| Create branch | |
| Load context | |
| 任务 | 命令 |
|---|---|
| 创建Issue | |
| 活跃任务 | |
| 列出未关闭的Bug | |
| 以JSON格式查看 | |
| 带评论关闭Issue | |
| 编辑标签 | |
| 开始工作 | |
| 创建分支 | |
| 加载上下文 | |
JSON Output Patterns
JSON输出模式
Always use for parsing. Fields: , , , , , , , , , , , .
--jsonnumbertitlebodystatelabelsassigneesmilestoneauthorcreatedAtupdatedAtcommentsurlbash
gh issue view 123 --json number,title,labels,state
gh issue list --json number,title,labels --jq '.[] | select(.labels[].name == "bug")'
gh issue list -l bug --json number --jq '.[].number'解析时请始终使用参数。支持的字段:, , , , , , , , , , , 。
--jsonnumbertitlebodystatelabelsassigneesmilestoneauthorcreatedAtupdatedAtcommentsurlbash
gh issue view 123 --json number,title,labels,state
gh issue list --json number,title,labels --jq '.[] | select(.labels[].name == "bug")'
gh issue list -l bug --json number --jq '.[].number'Advanced Search Filters
高级搜索筛选器
bash
gh issue list --search "is:open author:username"
gh issue list --search "created:>=2026-01-01 created:<=2026-01-07"
gh issue list --search "label:bug label:priority:high"
gh issue list --search "is:open -label:wontfix"
gh issue list --search "milestone:v2.0"bash
gh issue list --search "is:open author:username"
gh issue list --search "created:>=2026-01-01 created:<=2026-01-07"
gh issue list --search "label:bug label:priority:high"
gh issue list --search "is:open -label:wontfix"
gh issue list --search "milestone:v2.0"Bulk Operations
批量操作
bash
gh issue edit 10 15 20 --add-label "priority:high"
gh issue close 10 15 20 -c "Duplicate of #5"
gh issue list -l needs-triage --json number --jq '.[].number' | \
xargs -I{} gh issue edit {} --add-label reviewedbash
gh issue edit 10 15 20 --add-label "priority:high"
gh issue close 10 15 20 -c "Duplicate of #5"
gh issue list -l needs-triage --json number --jq '.[].number' | \
xargs -I{} gh issue edit {} --add-label reviewedIssue to PR Workflow
Issue转PR工作流
bash
gh issue develop 123 --checkout # Create branch from issue
git add . && git commit -m "fix: #123" # Commit with reference
gh pr create --fill # Create PR (auto-links)
gh issue close 123 -c "Fixed in PR #456" # Close when mergedbash
gh issue develop 123 --checkout # 从Issue创建分支
git add . && git commit -m "fix: #123" # 提交并关联Issue
gh pr create --fill # 创建PR(自动关联)
gh issue close 123 -c "Fixed in PR #456" # 合并后关闭IssueMilestones via API
通过API管理里程碑
bash
gh api repos/:owner/:repo/milestones --jq '.[].title'
gh issue edit 123 -m "v2.0"bash
gh api repos/:owner/:repo/milestones --jq '.[].title'
gh issue edit 123 -m "v2.0"AI Session Context
AI会话上下文
Store session context in GitHub issues for seamless task handoff.
在GitHub Issues中存储会话上下文,实现无缝任务交接。
Read Context
读取上下文
bash
undefinedbash
undefinedGet AI context from issue comments
从Issue评论中获取AI上下文
gh issue view 45 --json comments --jq '
.comments[] | select(.body | contains("AI-CONTEXT:START")) | .body
'
gh issue view 45 --json comments --jq '
.comments[] | select(.body | contains("AI-CONTEXT:START")) | .body
'
Get comment ID for updates
获取评论ID用于更新
gh issue view 45 --json comments --jq '
.comments[] | select(.body | contains("AI-CONTEXT:START")) | .id
'
undefinedgh issue view 45 --json comments --jq '
.comments[] | select(.body | contains("AI-CONTEXT:START")) | .id
'
undefinedSave Context
保存上下文
bash
undefinedbash
undefinedCreate new context comment
创建新的上下文评论
gh issue comment 45 --body-file .ai-context.md
gh issue comment 45 --body-file .ai-context.md
Update existing (replace COMMENT_ID)
更新现有上下文(替换COMMENT_ID)
gh api repos/:owner/:repo/issues/comments/COMMENT_ID
--method PATCH -f body="$(cat .ai-context.md)"
--method PATCH -f body="$(cat .ai-context.md)"
undefinedgh api repos/:owner/:repo/issues/comments/COMMENT_ID
--method PATCH -f body="$(cat .ai-context.md)"
--method PATCH -f body="$(cat .ai-context.md)"
undefinedContext Template
上下文模板
See for full template. Minimal version:
references/context-template.mdmarkdown
<!-- AI-CONTEXT:START -->完整模板请查看。极简版本:
references/context-template.mdmarkdown
<!-- AI-CONTEXT:START -->Context | IN_PROGRESS
上下文 | IN_PROGRESS
Files: ,
Done: task1, task2
Next: next task
Resume: One-line summary for cold start
<!-- AI-CONTEXT:END -->
file.py:45other.py:120undefined文件: ,
已完成: task1, task2
下一步: next task
恢复点: 冷启动用的单行摘要
<!-- AI-CONTEXT:END -->
file.py:45other.py:120undefinedWorkflow
工作流
- Start work — load context from issue
- Work on task — track progress mentally
- Pause/Stop — save context to issue comment
- Resume later — load context, continue
- 开始工作 — 从Issue中加载上下文
- 处理任务 — 记录进度
- 暂停/停止 — 将上下文保存到Issue评论
- 恢复工作 — 加载上下文,继续任务
Task Workflow
任务工作流
Manage issue lifecycle with labels.
通过标签管理Issue生命周期。
Labels
标签
| Label | Meaning |
|---|---|
| In queue |
| Active work |
| Blocked |
| Needs review |
| 标签 | 含义 |
|---|---|
| 待办队列 |
| 进行中 |
| 阻塞 |
| 待审核 |
View Active Tasks
查看活跃任务
bash
undefinedbash
undefinedMy active issues
我的活跃Issues
gh issue list -l in-progress -s open
gh issue list -l in-progress -s open
All my assigned issues
所有分配给我的Issues
gh issue list --assignee @me -s open
gh issue list --assignee @me -s open
Issues with context
带上下文的Issues
gh issue list -s open --json number,title,labels --jq '
.[] | select(.labels[].name == "in-progress") | "#(.number): (.title)"
'
undefinedgh issue list -s open --json number,title,labels --jq '
.[] | select(.labels[].name == "in-progress") | "#(.number): (.title)"
'
undefinedStart Working
开始工作
bash
undefinedbash
undefinedMark as in-progress
标记为进行中
gh issue edit 45 --add-label in-progress --remove-label backlog
gh issue edit 45 --add-label in-progress --remove-label backlog
View issue + load context
查看Issue并加载上下文
gh issue view 45 --json number,title,body,comments --jq '{
number, title, body,
context: (.comments[] | select(.body | contains("AI-CONTEXT")) | .body) // "No context"
}'
undefinedgh issue view 45 --json number,title,body,comments --jq '{
number, title, body,
context: (.comments[] | select(.body | contains("AI-CONTEXT")) | .body) // "无上下文"
}'
undefinedPause/Block
暂停/标记阻塞
bash
undefinedbash
undefinedMark as blocked
标记为阻塞
gh issue edit 45 --add-label blocked --remove-label in-progress
gh issue edit 45 --add-label blocked --remove-label in-progress
Add blocking comment
添加阻塞说明评论
gh issue comment 45 --body "Blocked: waiting for API access"
undefinedgh issue comment 45 --body "阻塞:等待API访问权限"
undefinedComplete
完成任务
bash
undefinedbash
undefinedClose with comment
带评论关闭Issue
gh issue close 45 -c "Done in commit abc123"
gh issue close 45 -c "已在提交abc123中修复"
Or close via PR (auto-closes if PR body contains "Fixes #45")
或通过PR关闭(如果PR描述包含"Fixes #45"则自动关联关闭)
undefinedundefinedExamples
示例
Create Issue for Task
为任务创建Issue
bash
gh issue create -t "Simplify bot flow" -b "## Problem
Bot stopped converting. Current flow is complex.bash
gh issue create -t "简化机器人流程" -b "## 问题
机器人停止转换。当前流程过于复杂。Reference
参考
Simple flow example from competitor.
竞品的简单流程示例。
Tasks
任务
- Analyze current flow
- Create new diagram
- Implement"
undefined- 分析当前流程
- 创建新流程图
- 实现"
undefinedStart Working on Issue
开始处理Issue
bash
undefinedbash
undefined1. View issue with context
1. 查看Issue及上下文
gh issue view 45 --json number,title,body,comments --jq '{
number, title, body,
context: (.comments[] | select(.body | contains("AI-CONTEXT")) | .body) // "No context"
}'
gh issue view 45 --json number,title,body,comments --jq '{
number, title, body,
context: (.comments[] | select(.body | contains("AI-CONTEXT")) | .body) // "无上下文"
}'
2. Create branch
2. 创建分支
gh issue develop 45 --checkout
gh issue develop 45 --checkout
3. Work...
3. 开始工作...
undefinedundefinedSave Progress Before Stopping
停止前保存进度
bash
undefinedbash
undefinedCreate context file
创建上下文文件
cat > .ai-context.md << 'EOF'
<!-- AI-CONTEXT:START -->cat > .ai-context.md << 'EOF'
<!-- AI-CONTEXT:START -->AI Session Context
AI会话上下文
Last updated: 2026-01-07 16:00
最后更新:2026-01-07 16:00
Status
状态
IN_PROGRESS
IN_PROGRESS
Progress
进度
- Analyzed current flow
- Create new diagram
- 分析了当前流程
- 创建新流程图
Key Files
关键文件
- — start handler
handlers/start.py:45-78 - — config
data/courses.yaml
- — 启动处理器
handlers/start.py:45-78 - — 配置文件
data/courses.yaml
Next Steps
下一步
- Draw simplified flow
- Implement changes
- 绘制简化流程图
- 实现修改
Resume Context
恢复上下文
Simplifying bot flow. Analyzed current state. Next: create diagram.
<!-- AI-CONTEXT:END -->
EOF
正在简化机器人流程。已分析当前状态。下一步:创建流程图。
<!-- AI-CONTEXT:END -->
EOF
Save to issue
保存到Issue
gh issue comment 45 --body-file .ai-context.md
undefinedgh issue comment 45 --body-file .ai-context.md
undefinedResume Work
恢复工作
bash
undefinedbash
undefinedLoad context
加载上下文
CONTEXT=$(gh issue view 45 --json comments --jq '
.comments[] | select(.body | contains("AI-CONTEXT")) | .body
' 2>/dev/null)
echo "$CONTEXT"
CONTEXT=$(gh issue view 45 --json comments --jq '
.comments[] | select(.body | contains("AI-CONTEXT")) | .body
' 2>/dev/null)
echo "$CONTEXT"
Continue from where you left off...
从上次中断处继续...
undefinedundefinedCommon Mistakes
常见错误
| Mistake | Fix |
|---|---|
Missing | Always |
| Loop instead of multi-arg | |
Using | Use |
Forgot | Default is open only |
| Use |
| Duplicate context comments | Update existing, don't create new |
| 错误 | 解决方法 |
|---|---|
未使用 | 始终使用 |
| 循环处理而非多参数 | 使用 |
对输出使用 | 使用 |
忘记用 | 默认仅显示未关闭的 |
API中使用 | 使用 |
| 重复创建上下文评论 | 更新现有评论,不要创建新的 |