gh-issues

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

GitHub Issues CLI

GitHub Issues CLI

Efficient GitHub Issues management via
gh
CLI with AI session context storage.
通过
gh
CLI高效管理GitHub Issues,支持AI会话上下文存储。

Table of Contents

目录

Quick Reference

快速参考

TaskCommand
Create issue
gh issue create -t "Title" -b "Body" -l bug -a @me
Active tasks
gh issue list -l in-progress -s open
List open bugs
gh issue list -l bug -s open
View as JSON
gh issue view 123 --json number,title,body,labels,state
Close with comment
gh issue close 123 -c "Fixed in #456"
Edit labels
gh issue edit 123 --add-label priority:high
Start work
gh issue edit 45 --add-label in-progress
Create branch
gh issue develop 123 --checkout
Load context
gh issue view 45 --json comments --jq '.comments[] | select(.body | contains("AI-CONTEXT"))' 
任务命令
创建Issue
gh issue create -t "Title" -b "Body" -l bug -a @me
活跃任务
gh issue list -l in-progress -s open
列出未关闭的Bug
gh issue list -l bug -s open
以JSON格式查看
gh issue view 123 --json number,title,body,labels,state
带评论关闭Issue
gh issue close 123 -c "Fixed in #456"
编辑标签
gh issue edit 123 --add-label priority:high
开始工作
gh issue edit 45 --add-label in-progress
创建分支
gh issue develop 123 --checkout
加载上下文
gh issue view 45 --json comments --jq '.comments[] | select(.body | contains("AI-CONTEXT"))' 

JSON Output Patterns

JSON输出模式

Always use
--json
for parsing. Fields:
number
,
title
,
body
,
state
,
labels
,
assignees
,
milestone
,
author
,
createdAt
,
updatedAt
,
comments
,
url
.
bash
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'
解析时请始终使用
--json
参数。支持的字段:
number
,
title
,
body
,
state
,
labels
,
assignees
,
milestone
,
author
,
createdAt
,
updatedAt
,
comments
,
url
bash
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 reviewed
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 reviewed

Issue 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 merged
bash
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" # 合并后关闭Issue

Milestones 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
undefined
bash
undefined

Get 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 '
undefined
gh issue view 45 --json comments --jq ' .comments[] | select(.body | contains("AI-CONTEXT:START")) | .id '
undefined

Save Context

保存上下文

bash
undefined
bash
undefined

Create 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)"
undefined
gh api repos/:owner/:repo/issues/comments/COMMENT_ID
--method PATCH -f body="$(cat .ai-context.md)"
undefined

Context Template

上下文模板

See
references/context-template.md
for full template. Minimal version:
markdown
<!-- AI-CONTEXT:START -->
完整模板请查看
references/context-template.md
。极简版本:
markdown
<!-- AI-CONTEXT:START -->

Context | IN_PROGRESS

上下文 | IN_PROGRESS

Files:
file.py:45
,
other.py:120
Done: task1, task2 Next: next task Resume: One-line summary for cold start
<!-- AI-CONTEXT:END -->
undefined
文件:
file.py:45
,
other.py:120
已完成: task1, task2 下一步: next task 恢复点: 冷启动用的单行摘要
<!-- AI-CONTEXT:END -->
undefined

Workflow

工作流

  1. Start work — load context from issue
  2. Work on task — track progress mentally
  3. Pause/Stop — save context to issue comment
  4. Resume later — load context, continue
  1. 开始工作 — 从Issue中加载上下文
  2. 处理任务 — 记录进度
  3. 暂停/停止 — 将上下文保存到Issue评论
  4. 恢复工作 — 加载上下文,继续任务

Task Workflow

任务工作流

Manage issue lifecycle with labels.
通过标签管理Issue生命周期。

Labels

标签

LabelMeaning
backlog
In queue
in-progress
Active work
blocked
Blocked
review
Needs review
标签含义
backlog
待办队列
in-progress
进行中
blocked
阻塞
review
待审核

View Active Tasks

查看活跃任务

bash
undefined
bash
undefined

My 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)" '
undefined
gh issue list -s open --json number,title,labels --jq ' .[] | select(.labels[].name == "in-progress") | "#(.number): (.title)" '
undefined

Start Working

开始工作

bash
undefined
bash
undefined

Mark 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" }'
undefined
gh issue view 45 --json number,title,body,comments --jq '{ number, title, body, context: (.comments[] | select(.body | contains("AI-CONTEXT")) | .body) // "无上下文" }'
undefined

Pause/Block

暂停/标记阻塞

bash
undefined
bash
undefined

Mark 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"
undefined
gh issue comment 45 --body "阻塞:等待API访问权限"
undefined

Complete

完成任务

bash
undefined
bash
undefined

Close 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"则自动关联关闭)

undefined
undefined

Examples

示例

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
  • 分析当前流程
  • 创建新流程图
  • 实现"
undefined

Start Working on Issue

开始处理Issue

bash
undefined
bash
undefined

1. 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. 开始工作...

undefined
undefined

Save Progress Before Stopping

停止前保存进度

bash
undefined
bash
undefined

Create 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

关键文件

  • handlers/start.py:45-78
    — start handler
  • data/courses.yaml
    — config
  • handlers/start.py:45-78
    — 启动处理器
  • data/courses.yaml
    — 配置文件

Next Steps

下一步

  1. Draw simplified flow
  2. Implement changes
  1. 绘制简化流程图
  2. 实现修改

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
undefined
gh issue comment 45 --body-file .ai-context.md
undefined

Resume Work

恢复工作

bash
undefined
bash
undefined

Load 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...

从上次中断处继续...

undefined
undefined

Common Mistakes

常见错误

MistakeFix
Missing
--json
Always
--json field1,field2
Loop instead of multi-arg
gh issue edit 1 2 3
Using
grep
on output
Use
--jq
Forgot
-s all
for closed
Default is open only
{owner}/{repo}
in API
Use
:owner/:repo
Duplicate context commentsUpdate existing, don't create new
错误解决方法
未使用
--json
始终使用
--json field1,field2
循环处理而非多参数使用
gh issue edit 1 2 3
对输出使用
grep
使用
--jq
忘记用
-s all
查看已关闭Issues
默认仅显示未关闭的
API中使用
{owner}/{repo}
使用
:owner/:repo
重复创建上下文评论更新现有评论,不要创建新的