pre-merge
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePre-Merge Verification
预合并验证
Comprehensive verification workflow before merging changes to production.
合并代码到生产环境前的全面验证工作流。
When to Use This Skill
何时使用此技能
Use this skill when:
- Creating a pull request for review
- About to merge code to main/production branch
- Need systematic verification checklist
- Want to catch issues before code review
在以下场景使用此技能:
- 创建用于评审的Pull Request(PR)时
- 即将将代码合并到主分支/生产分支时
- 需要系统化的验证检查清单时
- 希望在代码评审前发现问题时
Pre-Commit Verification
提交前验证
Before committing code, verify:
- Type checking passes (language-appropriate: ,
tsc --noEmit, etc.)mypy - Linting passes with no errors (ESLint, Pylint, etc.)
- All existing tests pass locally
- No console.log/debug statements left in code
- Code follows project style guide
- No commented-out code blocks
提交代码前,需验证:
- 类型检查通过(根据语言选择:、
tsc --noEmit等)mypy - 代码检查(Linting)无错误通过(ESLint、Pylint等)
- 所有现有本地测试通过
- 代码中无遗留的console.log/debug语句
- 代码遵循项目风格指南
- 无注释掉的代码块
Commands by Language
各语言对应的命令
TypeScript/JavaScript:
bash
undefinedTypeScript/JavaScript:
bash
undefinedType check
类型检查
npx tsc --noEmit
npx tsc --noEmit
Lint
代码检查
npm run lint
npm run lint
or: pnpm lint
或: pnpm lint
or: npx eslint .
或: npx eslint .
Tests
测试
npm test
npm test
or: pnpm test
或: pnpm test
**Python**:
```bash
**Python**:
```bashType check
类型检查
mypy src/
mypy src/
Lint
代码检查
pylint src/
pylint src/
or: flake8 src/
或: flake8 src/
or: ruff check src/
或: ruff check src/
Tests
测试
pytest
pytest
or: python -m pytest
或: python -m pytest
**Go**:
```bash
**Go**:
```bashFormat check
格式检查
gofmt -l .
gofmt -l .
Lint
代码检查
golangci-lint run
golangci-lint run
Tests
测试
go test ./...
undefinedgo test ./...
undefinedPre-PR Verification
PR创建前验证
Before creating a pull request, ensure:
创建Pull Request前,需确保:
Required Information
必要信息
- Changeset added for user-facing changes (if using changesets)
- PR description is complete with:
- Summary of changes
- Related ticket references (ENG-XXX, HEL-XXX, JIRA-XXX, etc.)
- Screenshots for UI changes (desktop, tablet, mobile)
- Breaking changes documented
- Migration guide (if breaking changes)
- New tests added for new functionality
- Documentation updated if needed (README, API docs, etc.)
- 若涉及用户可见变更,已添加变更记录(使用changesets的情况)
- PR描述完整,包含:
- 变更摘要
- 关联工单引用(ENG-XXX、HEL-XXX、JIRA-XXX等)
- UI变更的截图(桌面端、平板端、移动端)
- 破坏性变更说明
- 迁移指南(若存在破坏性变更)
- 为新功能添加了新测试
- 必要时更新了文档(README、API文档等)
Security Checklist (if API changes)
安全检查清单(若涉及API变更)
- Authentication required on protected routes
- Authorization checks implemented
- Input validation with schema (Zod, Pydantic, etc.)
- No sensitive data in logs
- No SQL injection vulnerabilities
- No XSS vulnerabilities
- Rate limiting considered
- 受保护路由需身份验证
- 已实现权限校验
- 使用Schema进行输入验证(Zod、Pydantic等)
- 日志中无敏感数据
- 无SQL注入漏洞
- 无XSS漏洞
- 考虑了速率限制
Database Changes (if schema changes)
数据库变更(若涉及Schema变更)
- Migration file created
- Migration tested on local database
- Migration tested on staging database
- Down migration available (rollback plan)
- No breaking changes without migration guide
- Schema changes documented
- 创建了迁移文件
- 在本地数据库测试了迁移
- 在 staging 数据库测试了迁移
- 提供了回滚迁移方案
- 无未提供迁移指南的破坏性变更
- 已记录Schema变更
UI Changes (if applicable)
UI变更(若适用)
- Screenshots included:
- Desktop view (1920x1080)
- Tablet view (768x1024)
- Mobile view (375x667)
- Responsive behavior verified
- Accessibility checked (keyboard navigation, screen readers)
- Loading states implemented
- Error states implemented
- 包含截图:
- 桌面端视图(1920x1080)
- 平板端视图(768x1024)
- 移动端视图(375x667)
- 验证了响应式表现
- 检查了可访问性(键盘导航、屏幕阅读器)
- 实现了加载状态
- 实现了错误状态
Pre-Merge Verification
合并前验证
Before merging to main branch, confirm:
合并到主分支前,需确认:
CI/CD Checks
CI/CD检查
- All CI checks pass (lint, type-check, tests, build)
- Code review approved by at least one reviewer
- No TypeScript errors in changed files
- No merge conflicts with target branch
- Build succeeds without warnings
- 所有CI检查通过(代码检查、类型检查、测试、构建)
- 至少有一位评审者批准了代码评审
- 变更文件中无TypeScript错误
- 与目标分支无合并冲突
- 构建成功且无警告
Functional Verification
功能验证
- Database migrations run successfully (if applicable)
- No regression in existing functionality
- Performance benchmarks within acceptable range
- Manual testing completed for critical paths
- 数据库迁移运行成功(若适用)
- 现有功能无回归问题
- 性能基准在可接受范围内
- 关键路径已完成手动测试
Documentation
文档
- CHANGELOG.md updated (if using)
- API documentation updated (if API changes)
- README updated (if setup/usage changes)
- Migration guide provided (if breaking changes)
- 已更新CHANGELOG.md(若使用)
- 已更新API文档(若涉及API变更)
- 已更新README(若涉及安装/使用方式变更)
- 提供了迁移指南(若存在破坏性变更)
PR Description Template
PR描述模板
Use this template for comprehensive PR descriptions:
markdown
undefined使用以下模板编写全面的PR描述:
markdown
undefinedSummary
摘要
[Brief description of what this PR does]
[此PR的简要说明]
Related Tickets
关联工单
- Fixes #123
- Closes ENG-456
- Related to HEL-789
- 修复 #123
- 关闭 ENG-456
- 关联 HEL-789
Changes
变更内容
- Feature: [Description]
- Bug Fix: [Description]
- Refactor: [Description]
- Documentation: [Description]
- 功能:[描述]
- Bug修复:[描述]
- 重构:[描述]
- 文档:[描述]
Testing
测试
Unit Tests
单元测试
- Added tests for [feature/function]
- Coverage: X%
- 为[功能/函数]添加了测试
- 覆盖率:X%
Manual Testing
手动测试
- Tested on desktop (Chrome, Firefox, Safari)
- Tested on mobile (iOS Safari, Android Chrome)
- Tested edge cases: [list specific cases]
- 在桌面端(Chrome、Firefox、Safari)测试
- 在移动端(iOS Safari、Android Chrome)测试
- 测试了边缘场景:[列出具体场景]
Screenshots
截图
Desktop
桌面端
Tablet
平板端
Mobile
移动端
Breaking Changes
破坏性变更
[List any breaking changes or write "None"]
[列出所有破坏性变更,若无则写“无”]
Migration Guide
迁移指南
[If breaking changes, provide migration steps]
[若存在破坏性变更,提供迁移步骤]
Performance Impact
性能影响
[Describe any performance implications or write "No impact"]
[描述性能影响,若无则写“无影响”]
Security Considerations
安全考量
[Describe security implications or write "No security impact"]
[描述安全影响,若无则写“无安全影响”]
Rollback Plan
回滚方案
[Describe how to rollback if issues occur]
[描述出现问题时的回滚方式]
Deployment Notes
部署说明
[Any special deployment considerations or write "Standard deployment"]
undefined[特殊部署注意事项,若无则写“标准部署”]
undefinedCommon Pitfalls to Avoid
需避免的常见陷阱
Pre-Commit
提交前
- ❌ Committing code with failing tests
- ❌ Leaving console.log/debug statements
- ❌ Committing without running type checker
- ❌ Committing large blocks of commented code
- ❌ 提交测试未通过的代码
- ❌ 遗留console.log/debug语句
- ❌ 未运行类型检查就提交
- ❌ 提交大量注释掉的代码块
Pre-PR
PR创建前
- ❌ Creating PR without description
- ❌ Missing screenshots for UI changes
- ❌ Not linking to related tickets
- ❌ Not documenting breaking changes
- ❌ Missing test coverage for new code
- ❌ 创建无描述的PR
- ❌ UI变更未附带截图
- ❌ 未关联相关工单
- ❌ 未记录破坏性变更
- ❌ 新代码无测试覆盖
Pre-Merge
合并前
- ❌ Merging with failing CI checks
- ❌ Merging without code review approval
- ❌ Merging with merge conflicts
- ❌ Merging without testing migrations
- ❌ Merging without considering rollback plan
- ❌ 合并CI检查未通过的代码
- ❌ 未获得代码评审批准就合并
- ❌ 合并存在冲突的代码
- ❌ 未测试迁移就合并
- ❌ 未考虑回滚方案就合并
Quick Verification Script
快速验证脚本
Create a pre-commit verification script:
JavaScript/TypeScript (pre-commit.sh):
bash
#!/bin/bash
set -e
echo "Running type check..."
npx tsc --noEmit
echo "Running linter..."
npm run lint
echo "Running tests..."
npm test -- --run
echo "✅ All checks passed!"Python (pre-commit.sh):
bash
#!/bin/bash
set -e
echo "Running type check..."
mypy src/
echo "Running linter..."
pylint src/
echo "Running tests..."
pytest
echo "✅ All checks passed!"Make executable:
bash
chmod +x pre-commit.sh创建提交前验证脚本:
JavaScript/TypeScript(pre-commit.sh):
bash
#!/bin/bash
set -e
echo "运行类型检查..."
npx tsc --noEmit
echo "运行代码检查..."
npm run lint
echo "运行测试..."
npm test -- --run
echo "✅ 所有检查通过!"Python(pre-commit.sh):
bash
#!/bin/bash
set -e
echo "运行类型检查..."
mypy src/
echo "运行代码检查..."
pylint src/
echo "运行测试..."
pytest
echo "✅ 所有检查通过!"设置可执行权限:
bash
chmod +x pre-commit.shAutomation with Git Hooks
使用Git Hooks自动化
Set up automatic pre-commit checks:
设置自动提交前检查:
Using Husky (JavaScript/TypeScript)
使用Husky(JavaScript/TypeScript)
bash
npm install --save-dev husky
npx husky install
npx husky add .husky/pre-commit "npm run lint && npm test"bash
npm install --save-dev husky
npx husky install
npx husky add .husky/pre-commit "npm run lint && npm test"Using pre-commit (Python)
使用pre-commit(Python)
Create :
.pre-commit-config.yamlyaml
repos:
- repo: local
hooks:
- id: type-check
name: Type Check
entry: mypy src/
language: system
pass_filenames: false
- id: lint
name: Lint
entry: pylint src/
language: system
pass_filenames: false
- id: test
name: Test
entry: pytest
language: system
pass_filenames: falseInstall hooks:
bash
pre-commit install创建 :
.pre-commit-config.yamlyaml
repos:
- repo: local
hooks:
- id: type-check
name: Type Check
entry: mypy src/
language: system
pass_filenames: false
- id: lint
name: Lint
entry: pylint src/
language: system
pass_filenames: false
- id: test
name: Test
entry: pytest
language: system
pass_filenames: false安装钩子:
bash
pre-commit installSuccess Criteria
成功标准
Pre-Commit Success
提交前成功标准
- ✅ All local checks pass
- ✅ Code is formatted correctly
- ✅ No debug statements remain
- ✅ Tests pass locally
- ✅ 所有本地检查通过
- ✅ 代码格式正确
- ✅ 无调试语句遗留
- ✅ 本地测试通过
Pre-PR Success
PR创建前成功标准
- ✅ PR description is comprehensive
- ✅ All required information included
- ✅ Screenshots attached (if UI changes)
- ✅ Breaking changes documented
- ✅ PR描述全面
- ✅ 包含所有必要信息
- ✅ 附带UI变更截图(若适用)
- ✅ 已记录破坏性变更
Pre-Merge Success
合并前成功标准
- ✅ CI pipeline is green
- ✅ Code review approved
- ✅ No conflicts with target branch
- ✅ Manual testing completed
- ✅ CI流水线全部通过
- ✅ 代码评审已批准
- ✅ 与目标分支无冲突
- ✅ 已完成手动测试
Related Skills
相关技能
- - Screenshot verification for UI changes
universal-verification-screenshot - - Bug fix verification workflow
universal-verification-bug-fix - - API security testing
toolchains-universal-security-api-review - - Git workflow best practices
universal-collaboration-git-workflow
- - UI变更截图验证
universal-verification-screenshot - - Bug修复验证工作流
universal-verification-bug-fix - - API安全测试
toolchains-universal-security-api-review - - Git工作流最佳实践
universal-collaboration-git-workflow