pr-validate by boshu2/agentops
npx skills add https://github.com/boshu2/agentops --skill pr-validate针对 PR 的特定验证,确保变更清晰、专注且准备就绪。
通过检查隔离性、上游对齐性、范围限制性和质量门控,验证 PR 分支是否已准备好提交。
输入 : 分支名称(默认:当前分支)
使用时机 :
$pr-prep 之前$pr-implement 完成后1. 分支发现 -> 识别分支和上游
2. 上游对齐 -> 首先:检查变基状态(阻塞性检查)
3. CONTRIBUTING.md -> 验证合规性(阻塞性检查)
4. 隔离性检查 -> 单一类型、主题相关的文件
5. 范围检查 -> 验证变更符合预期范围
6. 质量门控 -> 测试、代码检查(非阻塞性检查)
7. 报告生成 -> 包含通过/失败状态的摘要
# 获取最新的上游代码
git fetch origin main
# 落后多少个提交?
BEHIND=$(git rev-list --count HEAD..origin/main)
echo "落后上游:$BEHIND 个提交"
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 检查项 | 通过标准 |
|---|
| 最小差异 | 落后提交数 < 20 |
| 无冲突 | 合并/变基会成功 |
# 提交类型分析
git log --oneline main..HEAD | sed 's/^[^ ]* //' | grep -oE '^[a-z]+(\([^)]+\))?:' | sort -u
# 文件主题分析
git diff --name-only main..HEAD | cut -d'/' -f1-2 | sort -u
| 检查项 | 通过标准 |
|---|---|
| 单一提交类型 | 所有提交共享相同的前缀 |
| 主题相关文件 | 所有更改的文件都与 PR 范围相关 |
| 原子化范围 | 可以用一句话解释清楚 |
# 从提交信息推断范围
SCOPE=$(git log --format="%s" main..HEAD | grep -oE '\([^)]+\)' | sort -u | head -1)
# 所有文件都应在预期范围内
git diff --name-only main..HEAD | grep -v "$SCOPE"
PR 验证:通过
分支:feature/suggest-validation (5 个提交)
上游:main (同步)
检查项:
[OK] 隔离性:单一类型 (refactor)
[OK] 上游:落后 0 个提交
[OK] 范围:100% 在 internal/suggest/ 内
[OK] 质量:测试通过
已准备好运行 $pr-prep
PR 验证:阻塞
检查项:
[FAIL] 隔离性:混合类型 (refactor, fix, docs)
[WARN] 上游:落后 15 个提交
解决方案:
1. 隔离性:按提交类型拆分分支
git checkout main && git checkout -b refactor/suggest
git cherry-pick <refactor-commits>
解决后请再次运行 $pr-validate。
# 挑选提交到干净分支
git checkout main
git checkout -b ${BRANCH}-clean
git cherry-pick <relevant-commits-only>
# 基于最新的上游代码进行变基
git fetch origin main
git rebase origin/main
| 不要 | 应该这样做 |
|---|---|
| 分析过时的分支 | 首先检查上游 |
| 跳过验证 | 在运行 $pr-prep 前执行 |
| 忽略范围蔓延 | 提取不相关的变更 |
| 混合修复和重构 | 按类型分离 PR |
用户说: "验证这个 PR 分支的隔离性和范围蔓延情况。"
会发生什么:
用户说: "在我运行 $pr-prep 之前,先运行 PR 验证。"
会发生什么:
| 问题 | 原因 | 解决方案 |
|---|---|---|
| 验证报告分支过时 | 上游已更新 | 从上游变基/合并,然后重新运行 |
| 检测到范围蔓延 | 额外的文件或混合的目标 | 将不相关的变更拆分到后续的 PR 中 |
| 对齐检查失败 | 分支与目标期望存在差异 | 协调基础分支和验收标准 |
| 输出不清晰 | 发现的问题未按优先级排序 | 按阻塞性与非阻塞性严重程度对发现的问题进行排序 |
每周安装量
179
仓库
GitHub 星标数
220
首次出现
2026年2月18日
安全审计
安装于
opencode179
github-copilot174
codex174
kimi-cli174
gemini-cli174
amp174
PR-specific validation that ensures changes are clean, focused, and ready.
Validates a PR branch for submission readiness by checking isolation, upstream alignment, scope containment, and quality gates.
Input : Branch name (default: current branch)
When to Use :
$pr-prep$pr-implement completes1. Branch Discovery -> Identify branch and upstream
2. Upstream Alignment -> FIRST: Check rebase status (BLOCKING)
3. CONTRIBUTING.md -> Verify compliance (BLOCKING)
4. Isolation Check -> Single type, thematic files
5. Scope Check -> Verify changes match intended scope
6. Quality Gate -> Tests, linting (non-blocking)
7. Report Generation -> Summary with pass/fail
# Fetch latest upstream
git fetch origin main
# How many commits behind?
BEHIND=$(git rev-list --count HEAD..origin/main)
echo "Behind upstream: $BEHIND commits"
| Check | Pass Criteria |
|---|---|
| Minimal divergence | < 20 commits behind |
| No conflicts | Merge/rebase would succeed |
# Commit type analysis
git log --oneline main..HEAD | sed 's/^[^ ]* //' | grep -oE '^[a-z]+(\([^)]+\))?:' | sort -u
# File theme analysis
git diff --name-only main..HEAD | cut -d'/' -f1-2 | sort -u
| Check | Pass Criteria |
|---|---|
| Single commit type | All commits share same prefix |
| Thematic files | All changed files relate to PR scope |
| Atomic scope | Can explain in one sentence |
# Infer scope from commit messages
SCOPE=$(git log --format="%s" main..HEAD | grep -oE '\([^)]+\)' | sort -u | head -1)
# All files should be within expected scope
git diff --name-only main..HEAD | grep -v "$SCOPE"
PR Validation: PASS
Branch: feature/suggest-validation (5 commits)
Upstream: main (in sync)
Checks:
[OK] Isolation: Single type (refactor)
[OK] Upstream: 0 commits behind
[OK] Scope: 100% in internal/suggest/
[OK] Quality: Tests pass
Ready for $pr-prep
PR Validation: BLOCKED
Checks:
[FAIL] Isolation: Mixed types (refactor, fix, docs)
[WARN] Upstream: 15 commits behind
Resolutions:
1. ISOLATION: Split branch by commit type
git checkout main && git checkout -b refactor/suggest
git cherry-pick <refactor-commits>
Run $pr-validate again after resolution.
# Cherry-pick to clean branch
git checkout main
git checkout -b ${BRANCH}-clean
git cherry-pick <relevant-commits-only>
# Rebase on latest upstream
git fetch origin main
git rebase origin/main
| DON'T | DO INSTEAD |
|---|---|
| Analyze stale branch | Check upstream FIRST |
| Skip validation | Run before $pr-prep |
| Ignore scope creep | Extract unrelated changes |
| Mix fix and refactor | Separate PRs by type |
User says: "Validate this PR branch for isolation and scope creep."
What happens:
User says: "Run PR validation before I run $pr-prep."
What happens:
| Problem | Cause | Solution |
|---|---|---|
| Validation reports stale branch | Upstream advanced | Rebase/merge from upstream then rerun |
| Scope creep detected | Extra files or mixed objectives | Split unrelated changes into follow-up PR |
| Alignment check fails | Branch diverged from target expectations | Reconcile base branch and acceptance criteria |
| Output unclear | Findings not prioritized | Sort findings by blocker vs non-blocker severity |
Weekly Installs
179
Repository
GitHub Stars
220
First Seen
Feb 18, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode179
github-copilot174
codex174
kimi-cli174
gemini-cli174
amp174
agent-browser 浏览器自动化工具 - Vercel Labs 命令行网页操作与测试
152,900 周安装