create-pr
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCreate a PR
创建PR
⚠️ MANDATORY: Issue Linking
⚠️ 强制要求:关联Issue
Every PR MUST link to related issues and use closing keywords.
- PRs without issue links are incomplete
- Use or
Closes #Xto auto-close issues on mergeFixes #X - Reference ALL related issues, even if not closing them
每个PR都必须关联相关Issue,并使用关闭关键词。
- 未关联Issue的PR视为不完整
- 使用或
Closes #X,以便在合并时自动关闭IssueFixes #X - 引用所有相关Issue,即使不关闭它们
Instructions
操作步骤
Step 1: Identify Related Issues
步骤1:识别相关Issue
bash
undefinedbash
undefinedCheck current branch name for issue hints
查看当前分支名称以获取Issue线索
git branch --show-current
git branch --show-current
Search for related issues
搜索相关Issue
gh issue list --search "relevant keywords"
gh issue list --search "相关关键词"
View specific issue
查看特定Issue详情
gh issue view <number>
**Find ALL issues this PR addresses:**
- Issues explicitly being fixed
- Issues partially addressed
- Related issues for contextgh issue view <number>
**找出此PR解决的所有Issue:**
- 明确修复的Issue
- 部分解决的Issue
- 作为上下文的相关IssueStep 2: Gather Context
步骤2:收集上下文信息
bash
undefinedbash
undefinedSee what changed
查看变更内容
git log main..HEAD --oneline
git diff main..HEAD --stat
git log main..HEAD --oneline
git diff main..HEAD --stat
Get commit messages for context
获取提交信息以了解上下文
git log main..HEAD --format="%s%n%b"
undefinedgit log main..HEAD --format="%s%n%b"
undefinedStep 3: Create PR with Issue Links
步骤3:创建关联Issue的PR
Use the skill for clear writing, then follow pr_guide.
writing-clearly-and-conciselyIMPORTANT: Do NOT include "Generated with Claude Code" or similar tool attribution footers in PR descriptions.
bash
gh pr create --title "[type]: [emoji] [description]" --body "$(cat <<'EOF'
[Two-sentence summary of what and why]使用技能确保表述清晰,然后遵循pr_guide的规范。
writing-clearly-and-concisely重要提示:PR描述中请勿包含“Generated with Claude Code”或类似工具的署名页脚。
bash
gh pr create --title "[type]: [emoji] [description]" --body "$(cat <<'EOF'
[两句话总结变更内容及原因]Key Changes
关键变更
- [Change 1]
- [Change 2]
- [变更1]
- [变更2]
Related Issues
相关Issue
Closes:
- Closes #X - [brief description of what's fixed]
- Closes #Y - [brief description]
Related (not closing):
- Related to #Z - [why related]
- See also #W - [context]
已关闭:
- Closes #X - [修复内容的简要描述]
- Closes #Y - [简要描述]
相关(未关闭):
- Related to #Z - [关联原因]
- See also #W - [上下文信息]
Testing
测试情况
- [How it was tested]
- [测试方式]
Files Changed
变更文件
- [List key files] EOF )"
undefined- [列出关键文件] EOF )"
undefinedIssue Linking Keywords
Issue关联关键词
GitHub recognizes these keywords to auto-close issues on merge:
| Keyword | Example | Effect |
|---|---|---|
| | Closes issue when PR merges |
| | Closes issue when PR merges |
| | Closes issue when PR merges |
Use format:
Closes #X - brief descriptionGitHub会识别以下关键词,在PR合并时自动关闭Issue:
| 关键词 | 示例 | 效果 |
|---|---|---|
| | PR合并时关闭Issue |
| | PR合并时关闭Issue |
| | PR合并时关闭Issue |
使用格式:
Closes #X - 简要描述Step 4: Verify Issue Links
步骤4:验证Issue关联
After creating PR:
bash
undefined创建PR后:
bash
undefinedVerify the PR shows linked issues
验证PR是否显示关联的Issue
gh pr view <number> --json closingIssuesReferences
gh pr view <number> --json closingIssuesReferences
Check the issue shows the PR link
检查Issue是否显示PR链接
gh issue view <number>
---gh issue view <number>
---PR Description Template
PR描述模板
markdown
[Two-sentence summary: what changed and why it was needed]markdown
[两句话总结:变更内容及必要性]Key Changes
关键变更
- [Most important change]
- [Second important change]
- [Third important change]
- [最重要的变更]
- [次要重要变更]
- [第三项重要变更]
Related Issues
相关Issue
Closes:
- Closes #X - [what requirement this addresses]
- Fixes #Y - [what bug this fixes]
Related:
- Related to #Z - [provides context but doesn't close]
已关闭:
- Closes #X - [此变更解决的需求]
- Fixes #Y - [此变更修复的Bug]
相关:
- Related to #Z - [提供上下文但不关闭]
Testing
测试情况
- [Manual testing performed]
- [Automated tests added/passing]
- [手动测试内容]
- [新增/通过的自动化测试]
Architectural Impact
架构影响
[If significant: explain system-wide effects]
[若影响重大:说明对系统整体的影响]
Files Changed
变更文件
- - [what changed]
path/to/file1.ts - - [what changed]
path/to/file2.ts
---- - [变更内容]
path/to/file1.ts - - [变更内容]
path/to/file2.ts
---Anti-Patterns
反模式示例
❌ WRONG:
gh pr create --title "Fix bug" --body "Fixed the thing"
❌ WRONG:
"Related: #123" (no closing keyword, issue won't close)
❌ WRONG:
No mention of any issues at all
✅ CORRECT:
gh pr create --title "fix: 🔧 Resolve auth token expiration" --body "
Fixes session timeout by implementing token refresh.❌ 错误示例:
gh pr create --title "Fix bug" --body "Fixed the thing"
❌ 错误示例:
"Related: #123"(未使用关闭关键词,Issue不会自动关闭)
❌ 错误示例:
完全未提及任何Issue
✅ 正确示例:
gh pr create --title "fix: 🔧 Resolve auth token expiration" --body "
通过实现令牌刷新修复会话超时问题。Related Issues
相关Issue
- Closes #123 - Auth token expires incorrectly
- Closes #124 - Users logged out unexpectedly
- Related to #100 - Auth system overhaul (partial) "
---- Closes #123 - 令牌过期处理错误
- Closes #124 - 用户意外登出
- Related to #100 - 认证系统全面改造(部分完成) "
---Mermaid Diagrams in PRs
PR中的Mermaid图表
Use Mermaid diagrams to visualize changes, flows, and architectural impacts.
GitHub renders Mermaid natively. Include diagrams when:
- Showing before/after state changes
- Illustrating new data flows
- Explaining component interactions
- Depicting architectural changes
使用Mermaid图表可视化变更、流程和架构影响。
GitHub原生支持Mermaid渲染。在以下场景中添加图表:
- 展示变更前后的状态变化
- 说明新的数据流程
- 解释组件交互
- 描述架构变更
When to Include Diagrams
何时添加图表
| PR Type | Diagram Use |
|---|---|
| Bug fix | Before/after flow showing fix |
| New feature | User journey or data flow |
| Refactor | Component dependency changes |
| API changes | Request/response sequence |
| PR类型 | 图表用途 |
|---|---|
| Bug修复 | 展示修复前后的流程 |
| 新功能 | 用户旅程或数据流程 |
| 重构 | 组件依赖变更 |
| API变更 | 请求/响应序列 |
Example: PR with Diagram
示例:包含图表的PR
markdown
undefinedmarkdown
undefinedKey Changes
关键变更
Added token refresh flow when session expires.
新增会话过期时的令牌刷新流程。
New Authentication Flow
新认证流程
mermaid
sequenceDiagram
participant C as Client
participant A as Auth Service
participant D as Database
C->>A: Request with expired token
A-->>C: 401 Token Expired
C->>A: POST /refresh with refresh_token
A->>D: Validate refresh token
D-->>A: Token valid
A-->>C: New access token
C->>A: Retry original request
A-->>C: 200 Successmermaid
sequenceDiagram
participant C as Client
participant A as Auth Service
participant D as Database
C->>A: Request with expired token
A-->>C: 401 Token Expired
C->>A: POST /refresh with refresh_token
A->>D: Validate refresh token
D-->>A: Token valid
A-->>C: New access token
C->>A: Retry original request
A-->>C: 200 SuccessRelated Issues
相关Issues
- Closes #123 - Token expiration handling
undefined- Closes #123 - 令牌过期处理
undefinedDiagram Types for PRs
PR适用的图表类型
markdown
undefinedmarkdown
undefinedFlow changes: flowchart
流程变更:flowchart
API interactions: sequenceDiagram
API交互:sequenceDiagram
State machines: stateDiagram-v2
状态机:stateDiagram-v2
Data models: erDiagram
数据模型:erDiagram
**Tips:**
- Keep diagrams focused (5-10 nodes)
- Show the change, not entire system
- Before/after pairs are powerful
- Embed in PR body, not as links
---
**提示:**
- 保持图表简洁(5-10个节点)
- 展示变更部分,而非整个系统
- 前后对比的图表效果极佳
- 嵌入PR正文中,而非使用链接
---Quick Reference
快速参考
- Find issues:
gh issue list --search "keywords" - Create PR with closing keywords: ,
Closes #XFixes #X - Always include: Related Issues section in PR body
- Verify:
gh pr view --json closingIssuesReferences - Add Mermaid diagrams for complex changes
- 查找Issue:
gh issue list --search "keywords" - 使用关闭关键词创建PR:、
Closes #XFixes #X - 务必包含:PR正文中的“相关Issue”部分
- 验证关联:
gh pr view --json closingIssuesReferences - 复杂变更添加Mermaid图表