关于 pr-template-builder
pr-template-builder 是帮助团队统一 GitHub 拉取请求、议题和讨论模板的技能。还涵盖贡献指南、CODEOWNERS 和基于工作流的 PR 自动标记。
主要功能
- 01创建 PR 和议题模板
- 02配置讨论模板
- 03设置 CODEOWNERS
- 04编写 CONTRIBUTING.md 指南
- 05自动添加 PR 标签
适用场景
- 01统一拉取请求提交内容
- 02引导提交错误报告和功能请求
- 03分配代码负责人并标记 PR
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ patricio0312rev/ skills --skill pr-template-builder安装后在 Claude Code 中输入/pr-template-builder确认已加载。
详细介绍
PR 模板构建器
创建标准化的 GitHub 模板,用于拉取请求、议题和讨论,以简化协作。
核心工作流
- 确定模板需求:PR、议题、讨论
- 创建 .github 目录:模板的标准存放位置
- 设计 PR 模板:检查清单、分区、填写指引
- 创建议题模板:错误报告、功能请求
- 添加 config.yml:控制议题/PR 的创建流程
- 测试模板:确认模板在 GitHub 上的呈现效果
目录结构
.github/
├── PULL_REQUEST_TEMPLATE.md # Default PR template
├── PULL_REQUEST_TEMPLATE/ # Multiple PR templates
│ ├── feature.md
│ ├── bugfix.md
│ └── hotfix.md
├── ISSUE_TEMPLATE/
│ ├── config.yml # Issue template config
│ ├── bug_report.yml # Bug report form
│ ├── feature_request.yml # Feature request form
│ └── question.yml # Question form
├── DISCUSSION_TEMPLATE/
│ ├── announcements.yml
│ └── ideas.yml
├── CONTRIBUTING.md # Contribution guidelines
├── CODE_OF_CONDUCT.md # Community standards
└── CODEOWNERS # Auto-assign reviewers
拉取请求模板
标准 PR 模板
## Summary
## Related Issue
Fixes #
## Type of Change
- [ ] Bug fix (non-breaking change fixing an issue)
- [ ] New feature (non-breaking change adding functionality)
- [ ] Breaking change (fix or feature causing existing functionality to change)
- [ ] Documentation update
- [ ] Refactoring (no functional changes)
- [ ] Performance improvement
- [ ] Test updates
## Changes Made
-
-
-
## Screenshots
## Testing
- [ ] Unit tests added/updated
- [ ] Integration tests added/updated
- [ ] Manual testing performed
### Test Instructions
1.
2.
3.
## Checklist
- [ ] My code follows the project's style guidelines
- [ ] I have performed a self-review of my code
- [ ] I have commented my code where necessary
- [ ] I have updated the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests proving my fix/feature works
- [ ] All new and existing tests pass
- [ ] Any dependent changes have been merged
## Additional Notes
功能 PR 模板
## Feature: [Feature Name]
### Summary
### Motivation
### Implementation Details
### User Impact
### API Changes
| Endpoint | Method | Change |
|----------|--------|--------|
| | | |
### Database Changes
- [ ] Migration added
- [ ] Migration tested on staging data
### Feature Flag
- [ ] Feature flag: `FEATURE_NAME`
- [ ] No feature flag needed
### Testing
- [ ] Unit tests added
- [ ] Integration tests added
- [ ] E2E tests added
- [ ] Manual testing completed
### Documentation
- [ ] README updated
- [ ] API docs updated
- [ ] Changelog entry added
### Rollback Plan
### Checklist
- [ ] Code review requested
- [ ] CI/CD pipeline passes
- [ ] Performance impact assessed
- [ ] Security review (if needed)
- [ ] Accessibility requirements met
错误修复 PR 模板
## Bug Fix: [Brief Description]
### Issue
Fixes #
### Root Cause
### Solution
### Regression Risk
- Risk level: Low / Medium / High
- Areas affected:
### Testing
#### Reproduction Steps (Before Fix)
1.
2.
3.
#### Verification Steps (After Fix)
1.
2.
3.
### Test Coverage
- [ ] Unit test added to prevent regression
- [ ] Integration test added
- [ ] Manual verification completed
### Checklist
- [ ] Root cause identified
- [ ] Fix verified locally
- [ ] No new warnings introduced
- [ ] Tests added for regression prevention
- [ ] Related issues linked
议题模板
错误报告(YAML 表单)
# .github/ISSUE_TEMPLATE/bug_report.yml
name: Bug Report
description: Report a bug or unexpected behavior
title: "[Bug]: "
labels: ["bug", "triage"]
assignees: []
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to report this bug!
Please fill out the form below to help us investigate.
- type: textarea
id: description
attributes:
label: Bug Description
description: A clear and concise description of the bug
placeholder: What happened?
validations:
required: true
- type: textarea
id: reproduction
attributes:
label: Steps to Reproduce
description: Steps to reproduce the behavior
placeholder: |
1. Go to '...'
2. Click on '...'
3. Scroll down to '...'
4. See error
validations:
required: true
- type: textarea
id: expected
attributes:
label: Expected Behavior
description: What did you expect to happen?
validations:
required: true
- type: textarea
id: actual
attributes:
label: Actual Behavior
description: What actually happened?
validations:
required: true
- type: textarea
id: screenshots
attributes:
label: Screenshots
description: If applicable, add screenshots to help explain the problem
validations:
required: false
- type: dropdown
id: environment
attributes:
label: Environment
description: Where are you experiencing this bug?
options:
- Production
- Staging
- Development
- Local
validations:
required: true
- type: dropdown
id: browser
attributes:
label: Browser
description: What browser are you using?
multiple: true
options:
- Chrome
- Firefox
- Safari
- Edge
- Other
validations:
required: false
- type: input
id: version
attributes:
label: App Version
description: What version of the app are you using?
placeholder: e.g., 1.2.3
validations:
required: false
- type: textarea
id: logs
attributes:
label: Relevant Logs
description: Please copy and paste any relevant log output
render: shell
validations:
required: false
- type: checkboxes
id: terms
attributes:
label: Checklist
options:
- label: I have searched for existing issues
required: true
- label: I have provided all requested information
required: true
功能请求(YAML 表单)
# .github/ISSUE_TEMPLATE/feature_request.yml
name: Feature Request
description: Suggest a new feature or improvement
title: "[Feature]: "
labels: ["enhancement", "triage"]
assignees: []
body:
- type: markdown
attributes:
value: |
Thanks for suggesting a new feature!
Please describe your idea in detail.
- type: textarea
id: problem
attributes:
label: Problem Statement
description: What problem would this feature solve?
placeholder: I'm always frustrated when...
validations:
required: true
- type: textarea
id: solution
attributes:
label: Proposed Solution
description: Describe the solution you'd like
validations:
required: true
- type: textarea
id: alternatives
attributes:
label: Alternatives Considered
description: Describe any alternative solutions you've considered
validations:
required: false
- type: dropdown
id: priority
attributes:
label: Priority
description: How important is this feature to you?
options:
- Nice to have
- Important
- Critical - blocking my work
validations:
required: true
- type: textarea
id: context
attributes:
label: Additional Context
description: Add any other context, mockups, or screenshots
validations:
required: false
- type: checkboxes
id: contribution
attributes:
label: Contribution
options:
- label: I would be willing to help implement this feature
required: false
议题模板配置
# .github/ISSUE_TEMPLATE/config.yml
blank_issues_enabled: false
contact_links:
- name: Documentation
url: https://docs.example.com
about: Check our documentation for answers
- name: Discord Community
url: https://discord.gg/example
about: Ask questions and get help from the community
- name: Stack Overflow
url: https://stackoverflow.com/questions/tagged/example
about: Search for existing answers
讨论模板
# .github/DISCUSSION_TEMPLATE/ideas.yml
title: "[Idea]: "
labels:
- idea
body:
- type: markdown
attributes:
value: |
Share your ideas for improving the project!
- type: textarea
id: idea
attributes:
label: Your Idea
description: Describe your idea in detail
validations:
required: true
- type: textarea
id: benefits
attributes:
label: Benefits
description: What benefits would this bring?
validations:
required: true
- type: textarea
id: drawbacks
attributes:
label: Potential Drawbacks
description: Any potential downsides?
validations:
required: false
CODEOWNERS
# .github/CODEOWNERS
# Default owners for everything
* @org/core-team
# Frontend ownership
/src/components/ @org/frontend-team
/src/pages/ @org/frontend-team
*.tsx @org/frontend-team
*.css @org/frontend-team
# Backend ownership
/src/api/ @org/backend-team
/src/services/ @org/backend-team
/prisma/ @org/backend-team
# DevOps ownership
/.github/ @org/devops-team
/docker/ @org/devops-team
Dockerfile @org/devops-team
*.yml @org/devops-team
# Documentation
/docs/ @org/docs-team
*.md @org/docs-team
# Security-sensitive files
/src/auth/ @org/security-team @org/backend-team
*.pem @org/security-team
CONTRIBUTING.md
# Contributing to [Project Name]
Thank you for your interest in contributing! This document provides guidelines
and steps for contributing.
## Code of Conduct
By participating, you agree to abide by our [Code of Conduct](CODE_OF_CONDUCT.md).
## How to Contribute
### Reporting Bugs
1. Check if the bug has already been reported in [Issues](../../issues)
2. If not, create a new issue using the Bug Report template
3. Provide as much detail as possible
### Suggesting Features
1. Check if the feature has been suggested in [Issues](../../issues)
2. Create a new issue using the Feature Request template
3. Explain the use case and benefits
### Submitting Changes
#### First Time Contributors
1. Fork the repository
2. Clone your fork: `git clone https://github.com/YOUR_USERNAME/REPO_NAME`
3. Add upstream remote: `git remote add upstream https://github.com/ORG/REPO_NAME`
4. Create a branch: `git checkout -b feature/your-feature-name`
#### Development Workflow
1. Sync with upstream: `git fetch upstream && git rebase upstream/main`
2. Make your changes
3. Run tests: `npm test`
4. Run linting: `npm run lint`
5. Commit using [Conventional Commits](https://www.conventionalcommits.org/):
feat(scope): add new feature fix(scope): fix bug description docs(scope): update documentation
6. Push to your fork: `git push origin feature/your-feature-name`
7. Create a Pull Request
### Pull Request Guidelines
- Fill out the PR template completely
- Link related issues
- Include tests for new functionality
- Update documentation as needed
- Ensure CI passes
- Request review from appropriate team members
## Development Setup
```bash
# Install dependencies
npm install
# Start development server
npm run dev
# Run tests
npm test
# Run linting
npm run lint
风格指南
代码风格
- 所有新代码均使用 TypeScript
- 遵循现有代码风格
- 使用有意义的变量和函数名称
- 为复杂逻辑添加注释
提交消息
feat:新功能fix:修复错误docs:文档style:格式调整refactor:代码重构test:添加测试chore:日常维护
分支命名
feature/- 新功能fix/- 错误修复docs/- 文档refactor/- 代码重构
获取帮助
许可证
参与贡献即表示你同意,你的贡献将根据项目的 MIT License 获得许可。
## Workflow Automation
### Auto-label PRs
```yaml
# .github/workflows/labeler.yml
name: PR Labeler
on:
pull_request:
types: [opened, synchronize]
jobs:
label:
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v5
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
# .github/labeler.yml
frontend:
- changed-files:
- any-glob-to-any-file:
- 'src/components/**'
- 'src/pages/**'
- '**/*.tsx'
- '**/*.css'
backend:
- changed-files:
- any-glob-to-any-file:
- 'src/api/**'
- 'src/services/**'
documentation:
- changed-files:
- any-glob-to-any-file:
- '**/*.md'
- 'docs/**'
tests:
- changed-files:
- any-glob-to-any-file:
- '**/*.test.ts'
- '**/*.spec.ts'
- '__tests__/**'
PR 大小标签
# .github/workflows/pr-size.yml
name: PR Size
on:
pull_request:
types: [opened, synchronize]
jobs:
size:
runs-on: ubuntu-latest
steps:
- uses: codelytv/pr-size-labeler@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
xs_label: 'size/XS'
xs_max_size: 10
s_label: 'size/S'
s_max_size: 100
m_label: 'size/M'
m_max_size: 500
l_label: 'size/L'
l_max_size: 1000
xl_label: 'size/XL'
fail_if_xl: false
最佳实践
- 让模板目标明确:每个模板只用于一种目的
- 使用 YAML 表单:用于议题时,用户体验优于 Markdown
- 添加有帮助的说明:引导用户填写各字段
- 有策略地将字段设为必填:平衡信息完整度与填写阻力
- 包含检查清单:确保内容完整
- 链接到文档:帮助用户查找答案
- 禁用空白议题:强制使用模板
- 添加 CODEOWNERS:自动分配审核人
- 在 GitHub 上测试:确认呈现效果和验证规则
输出检查清单
每套模板都应包括:
- 已创建 .github/ 目录
- 含检查清单的 PULL_REQUEST_TEMPLATE.md
- 错误报告议题模板(YAML 表单)
- 功能请求议题模板(YAML 表单)
- 议题模板 config.yml
- 用于自动分配的 CODEOWNERS 文件
- CONTRIBUTING.md 指南
- 已定义用于分类的标签
- 用于自动标记 PR 的工作流
- 已在 GitHub 上测试模板
评论
支持 Markdown