跳到正文
cccskills
免费在 GitHub 公开

pr-review

Review PR changes against project standards and post feedback

中文简介正在准备中。当前显示原文说明。

集成工具GitHub
查看安装方法

包含的文件(1)

  • SKILL.md6.9 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

/pr-review - Pull Request Review

Review PR changes against project standards for this user-agent parsing library.

Usage

/pr-review              # Review current branch's PR
/pr-review 123          # Review PR #123
/pr-review --comment    # Post review as PR comment

Workflow

Step 1: Get PR Context (run in parallel)

# Detect repo
REPO=$(git remote get-url origin | sed 's/.*github.com[:/]\(.*\)\.git/\1/' | sed 's/.*github.com[:/]\(.*\)/\1/')

gh pr view --json number,title,baseRefName,headRefName,files
git diff origin/main...HEAD --name-only
git diff origin/main...HEAD --stat

If a PR number was provided, use gh pr view <number> and gh pr diff <number> instead.

Step 2: Categorize Changed Files

CategoryPatterns
Parser Coreuser_agent_parser/parser.py
Advanced Engineuser_agent_parser/advanced_engine.py
Analyticsuser_agent_parser/analytics.py
Public APIuser_agent_parser/__init__.py
Constants/Devicesuser_agent_parser/constants.py, user_agent_parser/modern_devices.py
Teststests/**/*.py
CI/Config.github/workflows/*, pyproject.toml, poetry.lock
Docs*.md, CHANGELOG.md

Step 3: Apply Review Checks

Read changed files and verify against these standards:

Regex & Parser Correctness

CheckStandard
Regex testedEvery new/changed regex has real UA string test cases
browser_rules orderNew entries don't break priority (Edge before Chrome, Chrome before Safari, etc.)
_token boundsEvery self._token[n] access has len() guard
Compiled patternsHot-path regex uses cached compiled patterns, not re.compile() per call
ReDoS safetyNo nested quantifiers or overlapping alternations that cause catastrophic backtracking

Backward Compatibility

CheckStandard
parse() 7-tupleparse() still returns (browser, browser_version, os, os_version, device_type, device_name, device_host)
Public API stableFunctions in __init__.py / __all__ unchanged in signature
AdvancedResult fieldsNo removed/renamed fields in AdvancedResult, BrowserCapabilities, SecurityFingerprint
DeviceCategory enumNo removed/renamed enum values, only additions
Constants immutableOS, DeviceType, DeviceName attributes not changed, only extended

Python 3.8+ Compatibility

CheckStandard
No match/casematch/case requires 3.10+ — use if/elif
No union syntaxX | Y in types requires 3.10+ — use Union[X, Y]
No TypeAliasRequires 3.10+ — use plain assignment
No ParamSpecRequires 3.10+ — use typing_extensions if needed

Cache Safety

CheckStandard
lru_cache returns immutableCached functions return tuples, not lists/dicts/sets
Cache key hashableAll arguments to cached functions are hashable
No cache side effectsCached functions are pure (no mutations, no I/O)

Test Coverage

CheckStandard
New features testedNew parser/engine features have parametrized test cases
Real UA stringsTests use real-world user agent strings, not fabricated ones
Edge cases coveredEmpty string, None, very long strings, missing parentheses
New source filesNew .py files in user_agent_parser/ have test coverage

Thread Safety

CheckStandard
Batch processingThreadPoolExecutor usage includes proper cleanup (with statement)
No shared mutationBatch operations don't share mutable state across threads

Code Quality

CheckStandard
Type hintsPublic functions have parameter and return type hints
CHANGELOGNon-trivial changes have CHANGELOG.md entry
Device code formatMOBILE_DEVICE_CODE_NAME entries follow key→name format, no duplicates
Consistent namingNew methods/constants follow existing naming patterns

Step 4: Generate Report

Structure findings by severity:

## PR Review: #<number> - <title>

**Files Changed:** N | **Additions:** +N | **Deletions:** -N

### 🔴 Critical (blocks merge)
- [ ] `user_agent_parser/parser.py:78` - `self._token[3]` accessed without bounds check
- [ ] `user_agent_parser/__init__.py:15` - `parse()` return changed from 7-tuple to 8-tuple — breaks all consumers
- [ ] `user_agent_parser/parser.py:45` - New browser regex `(Chrome|CriOS)(\d+)*` has nested quantifier — ReDoS risk

### 🟡 Standards (should fix)
- [ ] `user_agent_parser/advanced_engine.py:120` - Uses `match/case` — Python 3.10+ only, project supports 3.8+
- [ ] `tests/test_user_agent_parser.py` - New Brave detection has no parametrized test cases
- [ ] Missing CHANGELOG.md entry for new feature

### 🟢 Suggestions (nice to have)
- [ ] `user_agent_parser/parser.py:90` - Add type hint to `get_device_name()` return
- [ ] `user_agent_parser/advanced_engine.py:45` - Browser detection duplicates logic from parser.py — consider reuse

---
**Verdict:** APPROVE | REQUEST_CHANGES | COMMENT
*Review based on project standards in CLAUDE.md*

Step 5: Determine Verdict

ConditionVerdict
No critical issues, 0-2 standards issuesAPPROVE
No critical issues, 3+ standards issuesCOMMENT
Any critical issuesREQUEST_CHANGES

Step 6: Post Comment (if --comment)

Based on verdict:

# Clean — approve
gh pr review <number> --approve --body "$(cat <<'EOF'
<review-report>
EOF
)"

# Suggestions only — comment
gh pr review <number> --comment --body "$(cat <<'EOF'
<review-report>
EOF
)"

# Critical issues — request changes
gh pr review <number> --request-changes --body "$(cat <<'EOF'
<review-report>
EOF
)"

Quick Reference: What to Check by File

FileKey Checks
parser.pyRegex correctness, browser_rules order, _token bounds, lru_cache mutation, compiled pattern caching
advanced_engine.pyAdvancedResult field stability, confidence bounds [0,1], DeviceCategory enum stability, ThreadPoolExecutor cleanup
analytics.pyThread safety in BatchProcessor, export format correctness
constants.pyNo changed existing values, consistent MOBILE_DEVICE_CODE_NAME format, no duplicate keys
modern_devices.pyDeviceSpec format consistency
__init__.pyPublic API unchanged, all consistent, parse() 7-tuple preserved
tests/*.pyParametrized with real UA strings, edge cases covered, backward compat verified
CHANGELOG.mdEntry exists for non-trivial changes
.github/workflows/*Python version matrix includes 3.8–3.15, codecov integration intact
pyproject.tomlPython requirement still >=3.8, no incompatible dependency versions

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

commit

免费

Create well-formatted git commits following project conventions with emoji, type, and scope

中文简介正在准备中。当前显示原文说明。

Purushot14/user-agent-parser62026年3月18日 更新

pr

免费

Create or update a pull request from current branch to origin main with auto-generated title and description

中文简介正在准备中。当前显示原文说明。

Purushot14/user-agent-parser62026年3月18日 更新

review

免费

Review working changes - code quality, security, library correctness, and standards auto-fix

中文简介正在准备中。当前显示原文说明。

Purushot14/user-agent-parser62026年3月18日 更新

查看 Purushot14 的全部技能

报告此技能的问题