gh-create-pr
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCreate Pull Request
创建拉取请求
Commit changes, push to remote, and create a pull request with a conventional commit-style title and comprehensive description: $ARGUMENTS
提交更改,推送到远程仓库,并使用约定式提交风格的标题和全面的描述创建拉取请求:$ARGUMENTS
Current Repository State
当前仓库状态
- Git status: !
git status --porcelain - Current branch: !
git branch --show-current - Default branch: !
git rev-parse --abbrev-ref origin/HEAD 2>/dev/null | sed 's|origin/||' || echo main - Staged changes: !
git diff --cached --stat - Unstaged changes: !
git diff --stat - Recent commits on this branch: !
git log --oneline -10 - Existing PR for branch: !
gh pr view --json number,title,body 2>/dev/null || echo "No existing PR"
- Git状态:!
git status --porcelain - 当前分支:!
git branch --show-current - 默认分支:!
git rev-parse --abbrev-ref origin/HEAD 2>/dev/null | sed 's|origin/||' || echo main - 已暂存更改:!
git diff --cached --stat - 未暂存更改:!
git diff --stat - 该分支上的近期提交:!
git log --oneline -10 - 分支已有PR:!
gh pr view --json number,title,body 2>/dev/null || echo "No existing PR"
What This Command Does
该命令的功能
- Stage and commit changes using conventional commit format (follow the gh-commit skill conventions)
- If there are unstaged changes, stage and commit them with appropriate conventional commit messages
- If multiple distinct logical changes exist, create separate commits for each
- ALWAYS attribute AI-assisted code authorship in commits
- Push the branch to the remote repository
- If the current branch is the default branch (main/master), create a new feature branch first
- Use to set upstream tracking
git push -u origin <branch>
- Analyze all changes in the branch relative to the base branch
- Run to review the full scope of changes
git diff origin/<default-branch>...HEAD - Read relevant modified files to understand the context and impact of changes
- Run
- Generate a PR title following Conventional Commits format:
- Format:
<type>[optional scope]: <description> - Types: ,
feat,fix,docs,style,refactor,perf,test,build,ci,chorerevert - Use after type/scope for breaking changes:
!feat(api)!: change response format - Keep the title concise (under 72 characters)
- For multi-commit PRs, synthesize a higher-level title that captures the overall theme
- Format:
- Generate a PR description with the structure defined in the PR Description Template below
- Create or update the pull request
- If no PR exists for this branch:
gh pr create --title "TITLE" --body "DESCRIPTION" - If a PR already exists:
gh pr edit <number> --title "TITLE" --body "DESCRIPTION"
- If no PR exists for this branch:
- 暂存并提交更改 采用Conventional Commit格式(遵循gh-commit技能约定)
- 如果存在未暂存更改,暂存这些更改并使用合适的约定式提交信息提交
- 如果存在多个独立的逻辑变更,为每个变更创建单独的提交
- 务必在提交中注明AI辅助代码的署名
- 推送分支 到远程仓库
- 如果当前分支是默认分支(main/master),先创建新的功能分支
- 使用设置上游跟踪
git push -u origin <branch>
- 分析分支相对于基准分支的所有变更
- 运行查看完整的变更范围
git diff origin/<default-branch>...HEAD - 读取相关修改文件以了解变更的上下文和影响
- 运行
- 生成符合Conventional Commits格式的PR标题
- 格式:
<type>[optional scope]: <description> - 类型:,
feat,fix,docs,style,refactor,perf,test,build,ci,chorerevert - 破坏性变更在类型/范围后添加:
!feat(api)!: change response format - 保持标题简洁(不超过72个字符)
- 对于多提交PR,提炼更高层级的标题体现整体变更主题
- 格式:
- 按照下方PR描述模板定义的结构生成PR描述
- 创建或更新拉取请求
- 如果该分支不存在PR:
gh pr create --title "TITLE" --body "DESCRIPTION" - 如果该分支已有PR:
gh pr edit <number> --title "TITLE" --body "DESCRIPTION"
- 如果该分支不存在PR:
PR Title Examples
PR标题示例
feat(auth): add JWT token refresh endpoint
fix(ui): resolve layout shift on mobile navigation
docs: update API reference for v2 endpoints
refactor(db): migrate from raw SQL to query builder
feat(api)!: change pagination response format
chore(deps): bump TypeScript to 5.xfeat(auth): add JWT token refresh endpoint
fix(ui): resolve layout shift on mobile navigation
docs: update API reference for v2 endpoints
refactor(db): migrate from raw SQL to query builder
feat(api)!: change pagination response format
chore(deps): bump TypeScript to 5.xPR Description Template
PR描述模板
Use this structure for the PR body. Omit sections that are not applicable.
markdown
undefined使用该结构编写PR正文,省略不适用的章节。
markdown
undefinedSummary
概述
[1-2 sentence overview of what this PR does and why]
[1-2句话概括该PR的功能和开发背景]
Changes
变更内容
- [Key change 1]
- [Key change 2]
- [Key change 3]
- [核心变更1]
- [核心变更2]
- [核心变更3]
Breaking Changes
破坏性变更
[Describe what breaks and required migration steps]
[描述受影响的功能以及所需的迁移步骤]
Notes
备注
[Additional context, testing instructions, or deployment considerations]
undefined[额外上下文、测试说明或部署注意事项]
undefinedGuidelines
使用指南
- Respect existing content: If the PR title already follows conventional commit format, keep it unless it's inaccurate. If a PR already has a meaningful description, enhance it rather than replace it entirely.
- Issue references: If the branch name contains an issue number (e.g., ), reference it in the description with
feat/123-add-authorCloses #123.Refs #123 - Holistic analysis: The PR title should capture the overall intent of the changes, not just list individual commits.
- Single-commit PRs: The PR title can mirror the commit message.
- Multi-commit PRs: Synthesize a higher-level title that captures the full scope.
- Use markdown formatting in the description for readability.
- 尊重现有内容:如果PR标题已经符合约定式提交格式,除非内容不准确否则保留。如果PR已经有意义完整的描述,优先优化而非完全替换。
- 关联Issue:如果分支名称包含Issue编号(例如),在描述中使用
feat/123-add-auth或Closes #123关联对应Issue。Refs #123 - 整体分析:PR标题应体现变更的整体意图,而非仅罗列单个提交内容。
- 单提交PR:PR标题可与提交信息保持一致。
- 多提交PR:提炼更高层级的标题覆盖完整变更范围。
- 在描述中使用markdown格式提升可读性。
Important Notes
重要注意事项
- By default, pre-commit checks (defined in ) will run to ensure code quality
.pre-commit-config.yaml- IMPORTANT: DO NOT SKIP pre-commit checks
- ALWAYS attribute AI-Assisted Code Authorship in commit messages
- Always review the diff before generating the title and description to ensure accuracy
- If CLI is not authenticated, prompt the user to run
ghfirstgh auth login
- 默认会运行pre-commit检查(定义在中)以保障代码质量
.pre-commit-config.yaml- 重要提示:请勿跳过pre-commit检查
- 务必在提交信息中注明AI辅助代码的署名
- 生成标题和描述前始终检查diff确保内容准确
- 如果CLI未完成认证,提示用户先运行
ghgh auth login