pr-implement

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

PR 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
$pr-plan
or repo URL
When 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
    $pr-plan
    first)

借助Fork隔离执行贡献计划。通过在实现前和实现过程中运行隔离检查,确保PR干净且聚焦。
输入:来自
$pr-plan
的计划工件或仓库URL
适用场景
  • 执行已规划的开源贡献
  • 需要通过隔离强制保障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-prep

Phase -1: Prior Work Check (BLOCKING)

阶段-1:前置工作检查(阻塞型)

bash
undefined
bash
undefined

Search 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
undefined
bash
undefined

Commit 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

指导原则

GuidelineWhy
Single concernEach commit = one logical change
Match conventionsFollow project style exactly
Test incrementallyRun 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
undefined
bash
undefined

Commit 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-prep

Implementation complete. Isolation checks passed.

Branch: origin/$BRANCH_NAME
Commits: N commits, +X/-Y lines

Next step: $pr-prep

Anti-Patterns

反模式

DON'TDO INSTEAD
Skip isolation pre-checkRun Phase 3 FIRST
Skip isolation post-checkRun Phase 5 before push
Mix concerns in commitsOne type prefix per PR
Implement without planRun $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:
  1. Run pre-checks for branch and scope isolation.
  2. Implement only in planned files/areas.
  3. Run post-checks and prepare handoff for PR prep.
用户指令:"Implement this external PR plan with isolation checks."
执行流程
  1. 运行分支和范围隔离的预检查。
  2. 仅在计划的文件/区域内进行实现。
  3. 运行后检查并为PR准备阶段做好交接。

Enforce Single-Concern Commit Set

强制单一关注点提交集

User says: "Make sure this branch is still single-purpose before I prep the PR."
What happens:
  1. Inspect commit/file patterns against stated scope.
  2. Flag mixed concerns and suggest extraction steps.
  3. Produce a clean handoff to
    $pr-prep
    .
用户指令:"Make sure this branch is still single-purpose before I prep the PR."
执行流程
  1. 根据指定范围检查提交/文件模式。
  2. 标记混合关注点并建议提取步骤。
  3. $pr-prep
    交付干净的代码分支。

Troubleshooting

故障排查

ProblemCauseSolution
Isolation check failsUnrelated changes on branchMove unrelated edits to separate branch/PR
Commits mix concernsImplementation drifted from planRe-split commits by concern and revalidate
Scope keeps expandingWeak boundaries in planRe-anchor to
Out of Scope
and stop additional changes
Hard to hand offMissing summary/test contextAdd concise change summary and verification notes
问题原因解决方案
隔离检查失败分支上存在无关变更将无关编辑迁移至单独分支/PR
提交混合多个关注点实现偏离计划按关注点重新拆分提交并重新验证
范围持续扩大计划边界不清晰重新锚定到「超出范围」定义,停止新增变更
交接困难缺少摘要/测试上下文添加简洁的变更摘要和验证说明