AgentSkillsCN

pr

创建一份文档详实的 GitHub Pull Request,附带质量检查、恰当描述与测试计划。适用于推送分支、创建合并请求,或为代码审查做准备时使用。

SKILL.md
--- frontmatter
name: pr
description: Create a well-documented GitHub pull request with quality checks, proper description, and test plan. Use when pushing a branch, creating a merge request, or preparing code for review.
triggers:
  - create PR
  - pull request
  - ready for review
  - open PR

Create Pull Request

Purpose: Create a well-documented PR with proper description and test plan Usage: /pr

Constraints

  • All tests must pass before creating PR
  • Never force push without explicit request
  • Always verify changes are committed before pushing
  • Requires gh (GitHub CLI) for PR creation
  • Flag mixed-concern PRs (feature + refactor) as candidates for splitting

Note: Command examples use npm as default. Adapt to the project's package manager per ai-assistant-protocol — Project Commands.

Workflow

Step 1: Verify Changes

bash
MAIN=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@' || echo "main")

git status
git diff $MAIN...HEAD --stat
git log $MAIN..HEAD --oneline

Step 2: Ensure Quality

Before creating PR, run validation:

bash
npm run typecheck
npm run lint
npm run test

Checklist:

  • All tests pass
  • No type errors
  • Linting passes
  • No hardcoded secrets or credentials in changed files
  • No insecure patterns (eval, innerHTML, raw SQL interpolation)
  • Changes are committed

Step 3: Check for Mixed Concerns

Review the diff for mixed-concern changes. If commits include both feature work and refactoring, or both bug fixes and cleanup, suggest splitting into separate PRs for faster review.

Step 4: Push Branch

bash
git push -u origin HEAD

Step 5: Create PR

bash
gh pr create --title "[Type]: Brief description" --body "$(cat <<'EOF'
## Summary

[1-3 bullet points describing what this PR does]

## Changes

- [Specific change 1]
- [Specific change 2]

## Test Plan

- [ ] [How to test change 1]
- [ ] [How to test change 2]

## Security

- [ ] No secrets or credentials in code
- [ ] Input validation on new endpoints/handlers
- [ ] Auth checks on protected operations
- [ ] N/A — no security-sensitive changes

## Screenshots (if applicable)

[Add screenshots for UI changes]
EOF
)"

PR Title Conventions

code
feat: add user authentication
fix: resolve login issue with special characters
refactor: extract validation logic
docs: update API documentation
test: add tests for auth module
chore: update dependencies

Example PR Body

markdown
## Summary

- Add JWT-based authentication to API endpoints
- Implement login and registration endpoints
- Protect existing routes with auth middleware

## Changes

- `src/middleware/auth.ts` - New auth middleware
- `src/routes/auth.ts` - Login/register endpoints
- `src/models/User.ts` - User model with password hashing

## Test Plan

- [ ] Register new user with valid credentials
- [ ] Login with correct credentials returns token
- [ ] Protected routes reject requests without token

## Breaking Changes

None - new endpoints only.