Install
openclaw skills install gitcode-pr-comment-workflowGitCode PR review comment response workflow. Accepts a PR link, fetches review comments from the PR, checks out the PR's source branch locally, proposes modification plans based on review feedback, applies changes after user confirmation, and commits/pushes back to the source branch. Triggers on phrases like "根据 review 修改 PR", "处理 PR 审查意见", "fix PR review comments", "PR review workflow", "按检视意见修改", "review comment workflow". Requires gitcode CLI and git. NOT for creating new PRs (use gitcode-issue-workflow) or initiating code reviews (use code-review skill).
openclaw skills install gitcode-pr-comment-workflowWorkflow: PR Link → Fetch Review Comments → Understand User Approach → Design Document → Checkout Source Branch → Propose Changes → User Confirm → Apply & Push
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):
gitcode --version first (recommended, works everywhere)gc --version (macOS/Linux fallback)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.
Accept a PR URL from the user. The URL format is:
https://gitcode.com/<owner>/<repo>/pulls/<number>
Parse from the URL:
owner: Repository ownerrepo: Repository namenumber: PR numberFetch PR details:
gitcode pr view <number> --repo <owner>/<repo>
Key info to extract:
head): the branch being merged frombase): the branch being merged into⚠️ If the PR is closed or already merged, warn the user and stop.
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:
Present to user:
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
}
]
}
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:
depends on: D1Suggested 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.
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:
After writing the document:
Do not move to Step 5 until the design document is confirmed.
Must confirm with user before proceeding:
cd <repo_path>
git status
git log --oneline -3
# 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>
# 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:
git stash) and warn the usergit log --oneline -3 should show PR-related commitsgit pull <source_remote_name> <source_branch>
For each review comment that requires code changes:
read toolPresent 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>
理由: <explanation of how this addresses the review comment>
**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:
```bash
# Use edit tool for precise replacements
edit <file_path> oldText -> newText
cd <repo_path>
git diff
Commit message format: [type]([module]): address review comments
Use a descriptive type:
fix: Bug fixes from reviewrefactor: Code structure improvementsstyle: Formatting/style changesdocs: Documentation updatesgit add <changed_files>
git commit -m "<type>(<module>): address review comments on PR #<number>"
For multiple distinct changes, consider separate commits per logical change.
⚠️ 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:
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.
git diff before committing| 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 |
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
See references/gitcode-api.md for full API reference.
GET https://api.gitcode.com/api/v5/repos/{owner}/{repo}/pulls/{number}/comments?access_token=<token>
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 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.
; to chain commands (not &&)curl.exe (not curl which aliases to Invoke-WebRequest)-d @file.json to avoid escaping issuesRemove-Item -Recurse -Force temp/