pr-implement
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePR Implement Skill
PR Implement 技能
Fork-based implementation for open source contributions with mandatory isolation check.
面向开源贡献的基于Fork的实现方案,带有强制隔离检查。
Overview
概述
Execute a contribution plan with fork isolation. Ensures PRs are clean
and focused by running isolation checks before and during implementation.
Input: Plan artifact from or repo URL
$pr-planWhen to Use:
- Implementing a planned OSS contribution
- Need isolation enforcement for clean PRs
- After completing
$pr-plan
When NOT to Use:
- Internal project work (use )
$implement - Haven't planned yet (run first)
$pr-plan
借助Fork隔离执行贡献计划。通过在实现前和实现过程中运行隔离检查,确保PR干净且聚焦。
输入:来自的计划工件或仓库URL
$pr-plan适用场景:
- 执行已规划的开源贡献
- 需要通过隔离强制保障PR的整洁性
- 完成之后
$pr-plan
不适用场景:
- 内部项目工作(使用)
$implement - 尚未完成规划(先运行)
$pr-plan
Workflow
工作流
-1. Prior Work Check -> BLOCKING: Check for competing PRs
0. Input Discovery -> Find plan artifact or repo
1. Fork Setup -> Ensure fork exists and is current
2. Worktree Creation -> Create isolated worktree
3. Isolation Pre-Check -> BLOCK if mixed concerns
4. Implementation -> Execute plan
5. Isolation Post-Check -> BLOCK if scope creep
6. Commit Preparation -> Stage with proper commit type
7. Handoff -> Ready for $pr-prep-1. Prior Work Check -> BLOCKING: Check for competing PRs
0. Input Discovery -> Find plan artifact or repo
1. Fork Setup -> Ensure fork exists and is current
2. Worktree Creation -> Create isolated worktree
3. Isolation Pre-Check -> BLOCK if mixed concerns
4. Implementation -> Execute plan
5. Isolation Post-Check -> BLOCK if scope creep
6. Commit Preparation -> Stage with proper commit type
7. Handoff -> Ready for $pr-prepPhase -1: Prior Work Check (BLOCKING)
阶段-1:前置工作检查(阻塞型)
bash
undefinedbash
undefinedSearch for open PRs on this topic
Search for open PRs on this topic
gh pr list -R <owner/repo> --state open --search "<topic>" --limit 10
gh pr list -R <owner/repo> --state open --search "<topic>" --limit 10
Check target issue status
Check target issue status
gh issue view <issue-number> -R <repo> --json state,assignees
| Finding | Action |
|---------|--------|
| Open PR exists | Coordinate or wait |
| Issue assigned | Coordinate or find alternative |
| No competing work | Proceed |
---gh issue view <issue-number> -R <repo> --json state,assignees
| 发现结果 | 操作 |
|---------|--------|
| 存在已开放的PR | 协调沟通或等待 |
| 问题已被分配 | 协调沟通或寻找替代方案 |
| 无竞争工作 | 继续执行 |
---Phase 3: Isolation Pre-Check (BLOCKING)
阶段3:隔离预检查(阻塞型)
bash
undefinedbash
undefinedCommit type analysis
Commit type analysis
git log --oneline main..HEAD | sed 's/^[^ ]* //' | grep -oE '^[a-z]+(([^)]+))?:' | sort -u
git log --oneline main..HEAD | sed 's/^[^ ]* //' | grep -oE '^[a-z]+(([^)]+))?:' | sort -u
File theme analysis
File theme analysis
git diff --name-only main..HEAD | cut -d'/' -f1-2 | sort -u
| Check | Pass Criteria |
|-------|---------------|
| Single commit type | 0 or 1 prefix |
| Thematic files | All match plan scope |
| Branch fresh | Based on recent main |
**DO NOT PROCEED IF PRE-CHECK FAILS.**
---git diff --name-only main..HEAD | cut -d'/' -f1-2 | sort -u
| 检查项 | 通过标准 |
|-------|---------------|
| 单一提交类型 | 0个或1个前缀 |
| 文件主题一致 | 所有文件均符合计划范围 |
| 分支为最新状态 | 基于近期的main分支 |
**如果预检查不通过,请勿继续执行。**
---Phase 4: Implementation
阶段4:实现
Guidelines
指导原则
| Guideline | Why |
|---|---|
| Single concern | Each commit = one logical change |
| Match conventions | Follow project style exactly |
| Test incrementally | Run tests after each change |
| 指导原则 | 原因 |
|---|---|
| 单一关注点 | 每个提交对应一个逻辑变更 |
| 遵循约定 | 严格遵循项目风格 |
| 增量测试 | 每次变更后运行测试 |
Commit Convention
提交约定
bash
git commit -m "type(scope): brief description
Longer explanation if needed.
Related: #issue-number"bash
git commit -m "type(scope): brief description
Longer explanation if needed.
Related: #issue-number"Phase 5: Isolation Post-Check (BLOCKING)
阶段5:隔离后检查(阻塞型)
bash
undefinedbash
undefinedCommit type analysis
Commit type analysis
git log --oneline main..HEAD | sed 's/^[^ ]* //' | grep -oE '^[a-z]+(([^)]+))?:' | sort -u
git log --oneline main..HEAD | sed 's/^[^ ]* //' | grep -oE '^[a-z]+(([^)]+))?:' | sort -u
Summary stats
Summary stats
git diff --stat main..HEAD
| Check | Pass Criteria |
|-------|---------------|
| **Single commit type** | All commits share same prefix |
| **Thematic files** | All files relate to PR scope |
| **Atomic scope** | Can explain in one sentence |
---git diff --stat main..HEAD
| 检查项 | 通过标准 |
|-------|---------------|
| **单一提交类型** | 所有提交使用相同前缀 |
| **文件主题一致** | 所有文件均与PR范围相关 |
| **原子化范围** | 可用一句话解释变更内容 |
---Phase 7: Handoff
阶段7:交接
Implementation complete. Isolation checks passed.
Branch: origin/$BRANCH_NAME
Commits: N commits, +X/-Y lines
Next step: $pr-prepImplementation complete. Isolation checks passed.
Branch: origin/$BRANCH_NAME
Commits: N commits, +X/-Y lines
Next step: $pr-prepAnti-Patterns
反模式
| DON'T | DO INSTEAD |
|---|---|
| Skip isolation pre-check | Run Phase 3 FIRST |
| Skip isolation post-check | Run Phase 5 before push |
| Mix concerns in commits | One type prefix per PR |
| Implement without plan | Run $pr-plan first |
| 禁止操作 | 替代方案 |
|---|---|
| 跳过隔离预检查 | 首先运行阶段3 |
| 跳过隔离后检查 | 推送前运行阶段5 |
| 提交中混合多个关注点 | 每个PR使用单一类型前缀 |
| 无计划直接实现 | 先运行$pr-plan |
Examples
示例
Implement From Contribution Plan
从贡献计划开始实现
User says: "Implement this external PR plan with isolation checks."
What happens:
- Run pre-checks for branch and scope isolation.
- Implement only in planned files/areas.
- Run post-checks and prepare handoff for PR prep.
用户指令:"Implement this external PR plan with isolation checks."
执行流程:
- 运行分支和范围隔离的预检查。
- 仅在计划的文件/区域内进行实现。
- 运行后检查并为PR准备阶段做好交接。
Enforce Single-Concern Commit Set
强制单一关注点提交集
User says: "Make sure this branch is still single-purpose before I prep the PR."
What happens:
- Inspect commit/file patterns against stated scope.
- Flag mixed concerns and suggest extraction steps.
- Produce a clean handoff to .
$pr-prep
用户指令:"Make sure this branch is still single-purpose before I prep the PR."
执行流程:
- 根据指定范围检查提交/文件模式。
- 标记混合关注点并建议提取步骤。
- 向交付干净的代码分支。
$pr-prep
Troubleshooting
故障排查
| Problem | Cause | Solution |
|---|---|---|
| Isolation check fails | Unrelated changes on branch | Move unrelated edits to separate branch/PR |
| Commits mix concerns | Implementation drifted from plan | Re-split commits by concern and revalidate |
| Scope keeps expanding | Weak boundaries in plan | Re-anchor to |
| Hard to hand off | Missing summary/test context | Add concise change summary and verification notes |
| 问题 | 原因 | 解决方案 |
|---|---|---|
| 隔离检查失败 | 分支上存在无关变更 | 将无关编辑迁移至单独分支/PR |
| 提交混合多个关注点 | 实现偏离计划 | 按关注点重新拆分提交并重新验证 |
| 范围持续扩大 | 计划边界不清晰 | 重新锚定到「超出范围」定义,停止新增变更 |
| 交接困难 | 缺少摘要/测试上下文 | 添加简洁的变更摘要和验证说明 |