当前位置: 首页 > Skill >

Gitcode Pr Comment Workflow

Gitcode Pr Comment Workflow

Gitcode Pr Comment Workflow

GitCode PR 评审评论响应工作流:接受 PR 链接,获取评审评论,检出源分支,提出修改建议。

1.0.2 2026.11.14 236
获取Skill文件查看使用说明
作 者:陆安 许可证: 更新时间:2026.11.14
本文目录展开

GitCode PR Comment Workflow

Workflow: PR Link → Fetch Review Comments → Understand User Approach → Design Document → Checkout Source Branch → Propose Changes → User Confirm → Apply & Push → Reply Unaddressed Comments

Prerequisites

  • gitcode CLI: GitCode CLI. Source: https://github.com/codeasier/gitcode-cli
  • git: Standard git CLI
  • GitCode Token: Stored in MEMORY.md or provided by user
  • Local repo: User must confirm the local repository path

CLI command name:

  • gitcode — full command name, works on all platforms (recommended on Windows)
  • gc — short alias, works on macOS/Linux (conflicts with PowerShell Get-Content on Windows)

gitcode CLI detection (follow this order):

  1. Try gitcode --version first (recommended, works everywhere)
  2. If not found, try gc --version (macOS/Linux fallback)
  3. If neither found, ask user for the full path to the executable
  4. If not installed, prompt to install from https://github.com/codeasier/gitcode-cli

gitcode CLI authentication check: After confirming the CLI is installed, try a lightweight command to verify authentication (e.g., gitcode pr view <number> --repo <owner>/<repo>). If it returns a token-related error, the CLI is not authenticated.

Stop and prompt the user to authenticate first:

gitcode auth login

Or if they have a token, use --with-token (not --token):

echo <your_token> | gitcode auth login --with-token

Windows note: If the CLI outputs emoji characters and throws UnicodeEncodeError: 'gbk' codec can't encode character, set the Python IO encoding before running CLI commands:

$env:PYTHONIOENCODING="utf-8"
gitcode pr view <number> --repo <owner>/<repo>

Do not proceed with the workflow until authentication is successful.

Windows note: On PowerShell, gc is an alias for Get-Content. Always use gitcode on Windows.

9-Step Workflow

Step 1: Parse PR Link & Fetch Info

Accept a PR URL from the user. The URL format is:

https://gitcode.com/<owner>/<repo>/pulls/<number>

Parse from the URL:

  • owner: Repository owner
  • repo: Repository name
  • number: PR number

Fetch PR details:

gitcode pr view <number> --repo <owner>/<repo>

Key info to extract:

  • PR title and description
  • Source branch (head): the branch being merged from
  • Target branch (base): the branch being merged into
  • Source repo/fork: which repo the source branch is from (may be a fork)
  • PR state (open/closed/merged)

⚠️ If the PR is closed or already merged, warn the user and stop.

Step 2: Fetch Review Comments

Fetch comments on the PR to identify review feedback:

gitcode pr view <number> --repo <owner>/<repo> --comments

Or use the GitCode API:

curl.exe -s "https://api.gitcode.com/api/v5/repos/<owner>/<repo>/pulls/<number>/comments?access_token=<token>"

Parse and categorize comments:

  • Review comments: Comments that contain critique, suggestions, or requested changes (look for keywords like "建议", "建议修改", "需要", "请修改", "review", "nit", "concern", "TODO", "FIXME", or inline file-level comments)
  • General comments: Conversational comments, approvals ("LGTM"), or status updates

Present to user:

  1. Extract all review comments (the ones requesting changes)
  2. For each review comment, show:
    • Author and timestamp
    • File path and line reference (if inline comment)
    • Comment content
  3. Summarize: total review comments found, how many require code changes

Save review comments to temp/pr_review_comments.json for reference:

{
  "pr": {
    "owner": "<owner>",
    "repo": "<repo>",
    "number": <number>,
    "source_branch": "<head_branch>",
    "target_branch": "<base_branch>",
    "source_repo": "<fork_owner>/<repo>"
  },
  "review_comments": [
    {
      "id": <comment_id>,
      "author": "<username>",
      "created_at": "<timestamp>",
      "path": "<file_path_or_null>",
      "line": <line_number_or_null>,
      "body": "<comment_text>",
      "requires_code_change": true
    }
  ]
}

Step 3: Understand & Challenge User's Modification Approach

If no review comments require code changes, summarize the comments and ask whether the user wants any non-code response; do not enter the modification workflow.

If one or more review comments require code changes, must stop here before checkout, file editing, or concrete implementation planning. Ask the user for their intended modification approach, then apply the essence of the understand-me workflow until the user explicitly confirms the approach.

Required conversation flow:

  1. Restate the PR context and review comments in your own words.
  2. Identify which comments require code changes and which are informational/nits.
  3. Ask the user for their modification approach if they have not provided one.
  4. Convert the PR comments + user's approach into a design decision tree:
    • upstream decisions first: review intent, desired behavior, scope, compatibility, success criteria
    • downstream decisions later: target modules/files, implementation strategy, tests, commit/push scope
    • mark dependencies explicitly, e.g. depends on: D1
  5. Ruthlessly but constructively interrogate the approach one branch at a time:
    • ask exactly one question per turn
    • for every question, provide your recommended answer and a short reason
    • do not bundle multiple questions
    • do not proceed while a dependency blocker is unresolved
  6. If an answer can be found in the PR description, review comments, linked docs, or repository files already fetched/read, search/read those materials first instead of asking the user.
  7. After each user answer, update the decision tree delta and ask the next highest-leverage single question.
  8. Continue until the user explicitly confirms the modification approach (e.g. “确认”, “yes”, “按这个思路改”).

Suggested response shape during this step:

## 我的理解
<PR context + review comment summary + user's approach>

## 设计决策树(当前版本)
- D1: <review intent/scope>
  - A: ...
  - B: ...
- D2: <implementation direction>
  - depends on: D1
  - A: ...
  - B: ...

## 当前要拷问的问题
<one question only>

**我的推荐答案:** <recommended answer>
**推荐理由:** <brief reason>

Do not move to Step 4 until the approach is confirmed.

Step 4: Generate Design Document

Must generate a design document after the user confirms the modification approach and before any code modification.

Create a Markdown design document under temp/ first, for example:

temp/pr-<number>-review-comment-design.md

The design document must include:

  1. PR summary: title, link, source/target branches, current intent.
  2. Review comment summary: comments requiring code changes, comments not requiring code changes, file/line references.
  3. Confirmed modification approach: the final user-confirmed direction from Step 3.
  4. Design decision tree: resolved decisions, rejected branches, and remaining assumptions.
  5. Affected scope: expected modules/files/components to inspect or modify.
  6. Implementation plan: ordered, minimal change steps.
  7. Compatibility and risk analysis: behavior changes, edge cases, regression risk.
  8. Validation plan: tests, commands, manual checks, screenshots if needed.
  9. Non-goals: explicitly list what will not be changed in this PR update.

After writing the document:

  1. Show the design document path and a concise summary to the user.
  2. Ask the user to confirm the design document.
  3. If the user requests changes, revise the document and ask again.
  4. Do not inspect/modify target code for implementation beyond what is necessary to draft the design unless the user confirms.

Do not move to Step 5 until the design document is confirmed.

Step 5: Confirm Local Repository & Checkout Source Branch

Must confirm with user before proceeding:

  1. Ask user for the local repository path (or confirm if already known)
  2. Verify the repo exists:
cd <repo_path>
git status
git log --oneline -3
  1. Add the source repo as a remote (if it's a fork and not already added):
# Check if remote already exists
git remote -v

# Add remote for the source fork if needed
git remote add <source_remote_name> <source_repo_url>
# or if it already exists, just fetch
git fetch <source_remote_name>
  1. Checkout the PR's source branch:
# Create/check out the local tracking branch
git checkout -b <local_branch_name> <source_remote_name>/<source_branch>
# Or if already exists locally:
git checkout <local_branch_name>
git pull <source_remote_name> <source_branch>

⚠️ Important:

  • If the working tree is dirty, stash first (git stash) and warn the user
  • Pull latest from the source branch to ensure we're on the current code
  • Verify the branch is correct: git log --oneline -3 should show PR-related commits
  1. Pull latest code to ensure we're up to date:
git pull <source_remote_name> <source_branch>

Step 6: Read Files & Propose Changes

For each review comment that requires code changes:

  1. Read the relevant file(s) using the read tool
  2. Locate the problematic code referenced by the comment
  3. Propose a modification plan

Present the modification plan to the user:

For each review comment:

## 检视意见 #N

**Reviewer**: <author>
**文件**: <file_path>
**行号**: L<line>
**意见**: <original comment text>

### 修改方案

**修改文件**: <file_path>
**修改位置**: L<start>-L<end>
**修改方式**: <description of the change>

```diff
- <old code>
+ <new code>

理由:


**Group related changes** if multiple comments affect the same file.

**Wait for user confirmation before proceeding.** If the user requests adjustments, revise the plan and re-present.

**⚠️ External write constraint:** All file modifications require explicit user approval. Show the complete plan first, then ask: "是否确认按以上方案进行修改?(yes/no)"

Step 7: Apply Changes

After user approval:

  1. Apply each change using the edit tool:
# Use edit tool for precise replacements
edit <file_path> oldText -> newText
  1. Verify changes:
cd <repo_path>
git diff
  1. Show the complete diff to the user for final confirmation before committing.

Step 8: Commit & Push to Source Branch

8.1 Commit

Commit message format: [type]([module]): address review comments

Use a descriptive type:

  • fix: Bug fixes from review
  • refactor: Code structure improvements
  • style: Formatting/style changes
  • docs: Documentation updates
git add <changed_files>
git commit -m "<type>(<module>): address review comments on PR #<number>"

For multiple distinct changes, consider separate commits per logical change.

8.2 Push

⚠️ Must confirm the push remote with the user.

# Show available remotes
git remote -v

# Push to the source branch
git push <source_remote_name> HEAD:<source_branch>

Important:

  • Push to the same branch that the PR is based on
  • If the user's fork is the source, push to their fork remote
  • If the user has write access to the upstream repo, they may push directly

8.3 Confirm & Report

After push, present a summary:

Item Value
PR URL https://gitcode.com/<owner>/<repo>/pulls/<number>
PR Number #<number>
Source Branch <source_branch>
Target Branch <target_branch>
Files Changed <count>
Review Comments Addressed <count>
Status Changes pushed

Optionally, post a comment on the PR acknowledging the review and confirming changes:

感谢审查!已根据检视意见修改并推送到源分支。

修改内容:
- <summary of change 1>
- <summary of change 2>

⚠️ Posting PR comments requires user confirmation before executing.

Step 9: Reply to Unaddressed Review Comments

After pushing code changes, identify review comments that were not addressed in this round (skipped, deferred, or out of scope) and reply to them on the PR to close the loop.

9.1 Identify Unaddressed Comments

From the review comments collected in Step 2, identify comments that:

  • Were not modified in the code changes (Steps 6-7)
  • Were not already resolved/closed by the reviewer
  • Were not already replied to by the PR author

Cross-reference with the design document's "Non-goals" section and the user's confirmed modification scope.

9.2 Ask User for Confirmation

Present the list of unaddressed comments to the user:

## 未修改的检视意见

| # | 严重度 | 文件 | 意见摘要 | 建议回复 |
|---|--------|------|----------|----------|
| 8 | 建议 | interface.ts | status 移除 | string | 暂不修改,后续单独处理 |
| 14 | 建议 | KernelE2ETimeTable.tsx | rowClassName 性能优化 | 暂不修改,建议级优化后续单独处理 |
| ... | ... | ... | ... | ... |

是否需要回复这些检视意见?

Ask the user:

  1. Whether to reply to unaddressed comments
  2. If yes, whether to use the suggested replies or customize them
  3. For each comment, the user may provide a different reply text

⚠️ Must get user confirmation before posting any replies.

9.3 Reply via GitCode API

Use the Reply to PR Comment API to post replies within each comment's discussion thread.

Get the access token from gitcode CLI config:

TOKEN=$(python -c "from gitcode_cli.config import get_token; print(get_token())")

Reply to a comment using its discussion_id (obtained from Step 2's API response):

# Write body to file to avoid encoding issues on Windows
echo '{"body": "<reply text>"}' > /tmp/reply_body.json

curl -s -X POST 
  "https://api.gitcode.com/api/v5/repos/<owner>/<repo>/pulls/<number>/discussions/<discussion_id>/comments?access_token=${TOKEN}" 
  -H "Content-Type: application/json" 
  -d @/tmp/reply_body.json

Batch reply example (same reply for multiple comments):

TOKEN=$(python -c "from gitcode_cli.config import get_token; print(get_token())")
echo '{"body": "暂不修改,建议级优化后续单独处理。"}' > /tmp/reply_body.json

for did in "<discussion_id_1>" "<discussion_id_2>" "<discussion_id_3>"; do
  curl -s -X POST 
    "https://api.gitcode.com/api/v5/repos/<owner>/<repo>/pulls/<number>/discussions/${did}/comments?access_token=${TOKEN}" 
    -H "Content-Type: application/json" 
    -d @/tmp/reply_body.json
done

⚠️ Notes:

  • The discussion_id comes from the GET /repos/{owner}/{repo}/pulls/{number}/comments API response's discussion_id field
  • On Windows, always write JSON body to a file first and use -d @file.json to avoid encoding issues with non-ASCII characters
  • Each reply is posted within the existing discussion thread, keeping the conversation context
  • Clean up temp files after replying: rm -f /tmp/reply_body.json

9.4 Confirm & Report

After replying, present a summary:

# 检视意见 discussion_id 回复内容 note_id
8 status | string 92909e71... 暂不修改,后续单独处理 173582636
... ... ... ... ...

Total: N unaddressed comments replied.

Key Constraints

Safety Rules

  1. Never push to the wrong branch — always verify the source branch before pushing
  2. Never modify files without user approval — always show proposed changes first
  3. Never assume repository paths — always confirm with user
  4. Never assume push remote — always list remotes and ask user to choose
  5. All external write operations require explicit user confirmation

Git Workflow Rules

  1. Always pull latest from source branch before making changes
  2. Stash dirty working trees before checking out
  3. Commit messages must be descriptive and reference the PR number
  4. Always verify changes with git diff before committing

Asking vs Doing

Action Ask First?
Parse PR URL, fetch PR info ❌ Just do it
Fetch review comments ❌ Just do it
Confirm local repo path ✅ Must confirm
Checkout source branch ✅ Confirm branch name
Ask/challenge modification approach ✅ Required if comments need code changes
Generate design document ✅ Required before code modification
Confirm design document ✅ Required before code modification
Read files, analyze code ❌ Just do it after design confirmation
Propose changes ❌ Present plan
Modify files ✅ Wait for approval
Commit changes ✅ Show commit message
Push to remote ✅ Confirm remote and branch
Post PR comment ✅ Always confirm
Reply to unaddressed review comments ✅ Always confirm

Temp File Management

All temporary files generated during the workflow must be stored in temp/ directory under the workspace:

workspace/temp/
├── pr_review_comments.json              # Downloaded review comments
├── pr-<number>-review-comment-design.md # Confirmed design document
├── *.md                                 # Review notes
└── *                                    # Other temp files

⚠️ Clean up temp/ directory after workflow completion:

Remove-Item -Recurse -Force temp/  # Windows
rm -rf temp/                        # Linux/macOS

GitCode API Reference (PR Comments)

See references/gitcode-api.md for full API reference.

Get PR Comments

GET https://api.gitcode.com/api/v5/repos/{owner}/{repo}/pulls/{number}/comments?access_token=<token>

Post PR Comment

POST https://api.gitcode.com/api/v5/repos/{owner}/{repo}/pulls/{number}/comments?access_token=<token>

Body:

{
  "body": "<comment text (markdown)>",
  "commit_id": "<commit_sha>",
  "path": "<file_path>",
  "position": <line_number>
}

Get PR Diff

GET https://gitcode.com/api/v5/repos/{owner}/{repo}/pulls/{number}/diff

Headers:

Authorization: Bearer <token>

Note: Diff endpoint uses gitcode.com not api.gitcode.com.

Reply to PR Comment

Reply to an existing PR review comment within its discussion thread.

POST https://api.gitcode.com/api/v5/repos/{owner}/{repo}/pulls/{number}/discussions/{discussion_id}/comments?access_token=<token>

Body:

{
  "body": "<reply text (markdown)>"
}

The discussion_id is obtained from the GET /repos/{owner}/{repo}/pulls/{number}/comments response's discussion_id field.

PowerShell Notes

  • Use ; to chain commands (not &&)
  • Use curl.exe (not curl which aliases to Invoke-WebRequest)
  • For JSON payloads, write to file first then use -d @file.json to avoid escaping issues
  • Remove temp files: Remove-Item -Recurse -Force temp/

推荐文章

更多
PHP时间戳与日期字符串相互转换方法详解

本文介绍PHP中时间数值(Unix时间戳)与日期字符串之间的相互转换方法。通过strtotime和date函数,实现将当前时间、指定日期转换为时间戳,以及将时间戳格式化为可读的日期时间字符串,并提供相关在线计算工具推荐。

2025.11.30 1,035
PHP日期转时间戳时区偏差怎么解决

在 PHP 中将日期字符串转换为时间戳时,若未显式指定时区,默认使用脚本配置的 date.timezone 或系统时区。当服务器时区与业务逻辑预期(如 UTC )不一致时,会产生偏差。解决核心是确保输入字符串携带明确时区信息,或在转换前统一设置时区上下文。

2026.10.24 1,031
PHP跨域配置:怎么安全地允许指定域名而非使用通配符

在 PHP 中安全地允许指定域名跨域,核心是解析请求头中的 Origin ,验证其是否在白名单内,然后动态设置 Access-Control-Allow-Origin 响应头。不要使用通配符 * ,也不要硬编码单一域名。

2025.03.29 1,019
JavaScript中利用replace结合正则实现replaceAll效果

JavaScript原生仅支持replace()进行单次或全局替换,缺乏类似Java的replaceAll()便捷方法。本文总结四种在JS中实现全量替换的方案:使用带g标志的正则、带gm标志的正则、扩展String原型以及split后join。通过对比代码示例,展示各方法的实现细节与适用场景,帮助开发者根据需求选择最优解。

2025.04.29 1,017
OpenAI的Jalapeno芯片未落地,教你分辨300兆瓦算力消息

OpenAI计划在SB Energy租赁的数据中心部署约300兆瓦自研Jalapeno推理芯片,但目前双方仍处于洽谈阶段,交易细节与上线时间表均未公布。本文带你按报道原文核实项目所处阶段,厘清芯片发布、电力功率与实际推理算力的边界,并将融资意向与签约、开工、投运节点分开追踪,避免误将规划容量计入现有算力。

2026.12.02 1,014
PHP实现基础文件上传:HTML表单与$_FILES处理流程

在 HTML 表单中设置 enctype="multipart/form-data" ,并在 PHP 后端通过 $_FILES 数组接收文件,调用 move_uploaded_file() 将临时文件移动到目标目录即可完成上传。

2026.09.07 1,014
Skill 文件
  • SKILL.md
    • GitCode PR Comment Workflow
    • Prerequisites
    • 9-Step Workflow
      • Step 1: Parse PR Link & Fetch Info
      • Step 2: Fetch Review Comments
      • Step 3: Understand & Challenge User's Modification Approach
      • Step 4: Generate Design Document
      • Step 5: Confirm Local Repository & Checkout Source Branch
      • Step 6: Read Files & Propose Changes
      • Step 7: Apply Changes
      • Step 8: Commit & Push to Source Branch
        • 8.1 Commit
        • 8.2 Push
        • 8.3 Confirm & Report
      • Step 9: Reply to Unaddressed Review Comments
        • 9.1 Identify Unaddressed Comments
        • 9.2 Ask User for Confirmation
        • 9.3 Reply via GitCode API
        • 9.4 Confirm & Report
    • Key Constraints
      • Safety Rules
      • Git Workflow Rules
      • Asking vs Doing
    • Temp File Management
    • GitCode API Reference (PR Comments)
      • Get PR Comments
      • Post PR Comment
      • Get PR Diff
      • Reply to PR Comment
    • PowerShell Notes
  • 项目或源文件

相关 Skill

更多
service-qa-coach service-qa-coach Review support quality for chat, email, phone, social DM, or marketplace service teams. Use when a team needs a QA scorecard, failure-mode analysis, coaching plan, calibration checklist, or service-improvement brief without live ticketing, CRM, or contact-center system access.
高中数学作业批改助手 高中数学作业批改助手 >图片识别 直接读取学生手写作答照片,识别公式、符号、步骤 🧮 自动推导 根据题目自动生成参考答案和评分细则,无需教师预设 📊 逐步给分 每个关键步骤独立评分,体现过程分 📝 结构化报告 输出含识别内容、参考答案、逐步评分、改进建议的完整报告 🗂 批量批改 支持一次性批改多道题,最终汇总得分表
Vibration Analysis Vibration Analysis 分析来自CMS趋势、RMS/峰值、频谱及SCADA报警的风机传动链(主轴、齿轮箱、发电机)振动数据。
Traditional Bone Tool Making Basics Traditional Bone Tool Making Basics Use when you need custom, durable, repairable tools like awls, needles, scrapers, harpoons, or fishing hooks made from local animal bones or antlers and comm...
音频混音工具 音频混音工具 名称:Sound Mixing Tool(标识 sound-mixing-tool) 短简介(≤60字):音乐/音效响度精确对齐 + 融合混音工作流:用 ffmpeg 两段式 loudnorm 把多组素材 LUFS 偏差压到 <0.10,再最小干预融合、导出可进引擎的独立分轨。 标签/关键词:音频混音 响度匹配 LUFS ffmpeg 游戏音频 音效设计 Wwise FMOD 分轨导出 后期处理 触发词:混音 · 响度匹配 · LUFS 对齐 · MIX 版本 · 音乐音效分轨 · 融合 · 不打架 · 不能盖住 适用场景 :游戏音频集成、影视短视频配乐、播客后期