Xpersona
C

code-review-for-gitcode

CLAWHUB · Unverified

Handles full GitCode PR code reviews by automating security scans, manual analysis, selecting top issues, formatting results, and optionally posting review c...

62
Rank
84
Safety
1.1k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1.1K downloads reported by the source. Last updated 10/11/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s17f9m0x7ek58c96t233aedh5583xbw9:code-review-for-gitcode
  1. Install using `clawhub skill install s17f9m0x7ek58c96t233aedh5583xbw9:code-review-for-gitcode` in an isolated environment before connecting it to live workloads.
  2. No published capability contract is available yet, so validate auth and request/response behavior manually.
  3. Review the upstream CLAWHUB listing at https://clawhub.ai/guitenbay/code-review-for-gitcode before using production credentials.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-guitenbay-code-review-for-gitcode/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

60,401 characters of source documentation, loaded on request.

Extracted files

4 files captured from the source.

SKILL.md

---
name: code-review
description: Complete code review workflow for GitCode PRs. Combines automated security scanning with manual code review, outputs formatted findings, and posts comments to PR. Use when reviewing GitCode pull requests - follows 5-step process: automated scan, manual review, issue selection, formatted output, and optional PR comment posting.
---

# Code Review Skill

Complete 5-step code review workflow for GitCode PRs.

## 📁 Temp Directory Management

**所有审查过程中生成的临时文件必须存放在 `temp/` 目录下**:

| 文件 | 说明 |
|:---|:---|
| `temp/review_result.json` | Step 1 自动化扫描结果 |
| `temp/top3_issues.json` | Step 3 选择的 Top 问题 |
| `temp/formatted_review.json` | Step 4 格式化后的评论 |
| `temp/*.py` | 脚本运行时缓存的文件 |
| `temp/*` | 获取的 diff 文件,下载的代码文件 |

**⚠️ 重要**:审查完成后必须清理 `temp/` 目录,删除所有临时文件。

## 5-Step Review Process

### Step 1: Automated Scanning

Run script to detect critical issues:

```bash
python scripts/review_pr.py <pr_url> [token]
```

Detects: SQL injection, command injection, XSS, eval(), hardcoded credentials, resource leaks, infinite loops.

**Features**:
- ✅ **Automatic line number verification** - Downloads the actual file and verifies line numbers match the code snippets
- ✅ **Smart caching** - Avoids redundant downloads for the same PR
- ✅ **Line number correction** - Automatically fixes incorrect line numbers and logs changes

**Output**: `temp/review_result.json` (with verified line numbers)

### Step 2: Manual Review (REQUIRED)

**Always read all changed code manually.** Script misses:

- Logic errors and edge cases
- Design flaws
- Performance issues
- Missing error handling
- Business logic errors
- Code duplication
- Test coverage gaps

**How to get diff**:

```bash
curl -H "Authorization: Bearer <token>" \
  "https://gitcode.com/api/v5/repos/<owner>/<repo>/pulls/<number>/diff"
```

**Important**: For each issue found, record:

- **File path**: e.g., `src/components/Table.tsx`
- **Line range**: e.g., `L42-L45` (the line numbers of the problematic code)
- **Problem code**: The actual code snippet
- **Description**: Detailed explanation of the issue
- **Suggestion**: Specific fix recommendation

**How to find the correct line number in the new file**:

Use the provided helper script to find exact line numbers:

```bash
# Single line
python scripts/find_line_numbers.py <file_path> "code snippet"

# Multi-line (use \n to separate lines)
python scripts/find_line_numbers.py <file_path> "line1\nline2\nline3"
```

**Example**:
```bash
python scripts/find_line_numbers.py file_parser.py "return entries"
# Output: 第 119 行

python scripts/find_line_numbers.py file_parser.py "line.startswith('[ERROR] HCCL') or\n                        line.startswith('[INFO] HCCL')"
# Output: 第 103-104 行
```

**Important**: The `position` in your JSON must be the **last line** of the problematic code range (e.g., if problem spans L103-L105, use `105`).

**Manual method** (if script unavailable):

When reviewing a diff file, the line numbers shown in the diff (after

_meta.json

{
  "ownerId": "kn71hhs8vx4t10s0j9hjk5z8h182szn0",
  "slug": "code-review-for-gitcode",
  "version": "0.1.3",
  "publishedAt": 1776050566329
}

API.md

# GitCode PR 评论 API 文档

当需要向 PR 添加评论时,参考此文档。

## 提交 PR 评论

### API 端点

```
POST https://api.gitcode.com/api/v5/repos/{owner}/{repo}/pulls/{number}/comments
```

### 请求参数

#### Path Parameters

| 参数 | 类型 | 必需 | 说明 |
|------|------|------|------|
| owner | string | 是 | 仓库所属空间地址(组织或个人) |
| repo | string | 是 | 仓库路径 |
| number | integer | 是 | PR 序号 |

#### Query Parameters

| 参数 | 类型 | 必需 | 说明 |
|------|------|------|------|
| access_token | string | 是 | 用户授权码(GitCode Token) |

#### Request Body (application/json)

| 字段 | 类型 | 必需 | 说明 |
|------|------|------|------|
| body | string | 是 | 评论内容 |
| path | string | 否 | 文件的相对路径(行级评论必需) |
| position | integer | 否 | 代码所在行数(行级评论必需) |

### 请求示例

```bash
curl -X POST \
  "https://api.gitcode.com/api/v5/repos/Ascend/msinsight/pulls/275/comments?access_token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "body": "【review】可维护性问题。代码中存在硬编码值。建议提取为常量。",
    "path": "src/components/Table.tsx",
    "position": 42
  }'
```

### Python 示例

```python
import urllib.request
import json

def post_pr_comment(owner, repo, pr_number, token, body, path=None, position=None):
    url = f"https://api.gitcode.com/api/v5/repos/{owner}/{repo}/pulls/{pr_number}/comments"
    
    data = {
        "access_token": token,
        "body": body
    }
    
    if path:
        data["path"] = path
    if position:
        data["position"] = position
    
    json_data = json.dumps(data).encode('utf-8')
    
    req = urllib.request.Request(
        url,
        data=json_data,
        headers={'Content-Type': 'application/json'},
        method='POST'
    )
    
    with urllib.request.urlopen(req) as response:
        return json.loads(response.read().decode('utf-8'))

# 使用示例
result = post_pr_comment(
    owner="Ascend",
    repo="msinsight",
    pr_number=275,
    token="your_token_here",
    body="【review】可维护性问题。代码中存在硬编码值。",
    path="src/components/Table.tsx",
    position=42
)
print(f"Comment posted: {result['id']}")
```

### 响应示例 (200 OK)

```json
{
  "id": "28ede3cc57e10bddef15971f0c55bc6c12998bd7",
  "body": "【review】可维护性问题...",
  "path": "src/components/Table.tsx",
  "position": 42,
  "user": {
    "login": "username",
    "id": 12345
  },
  "created_at": "2026-03-10T12:00:00Z"
}
```

### 错误响应

| 状态码 | 说明 |
|--------|------|
| 400 | 请求参数错误 |
| 401 | 未授权(Token 无效) |
| 404 | PR 不存在 |
| 422 | 验证失败(如行号超出范围) |

### 注意事项

1. **Token 权限**: 需要 `repo` 或 `public_repo` 权限
2. **行号**: `position` 是 diff 中的行号,不是文件绝对行号
3. **路径**: `path` 必须是 PR 中变更的文件路径
4. **评论类型**:
   - 提供 `path` 和 `position`: 行级评论(代码审查)
   - 不提供: PR 级评论(普通评论)

### 获取 PR Diff 行号

如需确定正确的 `position`,先获取 PR diff:

```bash
curl -H "Authorization: Bearer TOKEN" \
  "https://gitcode.com/api/v5/repos/{owner}/{repo}/pulls/{number}/diff"
```

Diff 中的 `@@` 标记包含行号信息。

skill-card.md

## Description:

Complete code review workflow for GitCode PRs. Combines automated security scanning with manual code review, outputs formatted findings, and posts comments to PR.

This skill is ready for commercial/non-commercial use.

## Publisher:

[guitenbay](https://clawhub.ai/user/guitenbay)

### License/Terms of Use:

MIT-0

## Use Case:

Developers and engineers use this skill to review GitCode pull requests by combining automated issue scanning with required manual review, selecting the highest-priority findings, formatting comments, and optionally posting them to a PR.

### Deployment Geography for Use:

Global

## Known Risks and Mitigations:

Risk: The workflow can publish GitCode PR comments.

Mitigation: Require a human preview and explicit confirmation before running the posting step.

Risk: GitCode access tokens may be exposed when passed on the command line or in URLs.

Mitigation: Use narrowly scoped tokens, avoid long-lived credentials, do not pass tokens in URLs or shell history, and rotate any token already exposed that way.

Risk: Automated review findings can miss logic, design, performance, error-handling, and test-coverage issues.

Mitigation: Treat scanner output as a starting point and complete the documented manual review checklist before selecting findings.

## Reference(s):

- [ClawHub skill page](https://clawhub.ai/guitenbay/skills/code-review-for-gitcode)
- [GitCode PR comment API](artifact/API.md)

## Skill Output:

**Output Type(s):** [text, markdown, code, shell commands, configuration, guidance]

**Output Format:** [Markdown guidance with shell commands and JSON review artifacts]

**Output Parameters:** [1D]

**Other Properties Related to Output:** [Produces temporary JSON files for scan results, selected issues, and formatted PR comments; final posting is optional and should require explicit confirmation.]

## Skill Version(s):

0.1.3 (source: server release evidence)

## Ethical Considerations:

Users should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment.

Sponsored

Ads related to code-review-for-gitcode and adjacent AI workflows.