5.1 KiB
5.1 KiB
description, preapprovedTools
| description | preapprovedTools | ||||||
|---|---|---|---|---|---|---|---|
| Create a pull request with conventional commits formatting |
|
You are tasked with creating a pull request following these strict requirements:
Branch Management
- Check the current branch using
git branch --show-current - Get the default branch using
git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@' - If we're on the main/default branch:
- Analyze the changes to determine the appropriate conventional commit type
- Create a new branch using the format:
{type}/{short-description}(e.g.,fix/auth-token-validation,feat/add-dark-mode) - The short-description should be kebab-case and descriptive
- Check out the new branch
Conventional Commit Types
Use these standard types for commits and branch names:
feat: New featurefix: Bug fixdocs: Documentation onlystyle: Code style changes (formatting, no logic change)refactor: Code refactoring (no functional changes)perf: Performance improvementstest: Adding or updating testschore: Build process, dependencies, toolingci: CI/CD configuration changesrevert: Reverting previous commits
Commit Creation
- Review all staged and unstaged changes using
git statusandgit diff - Review recent commit messages for style consistency using
git log -5 --oneline - Selectively stage files (NEVER use
git add .orgit add -A):- Review the output of
git statuscarefully - Stage files individually using
git add <file1> <file2> ... - EXCLUDE these file patterns (never stage):
- Secret/credential files:
.env,.env.*,credentials.json,secrets.*,*.key,*.pem - IDE configs:
.vscode/,.idea/,*.swp,*.swo,.DS_Store - Build artifacts:
node_modules/,dist/,build/,target/,*.log - Temporary files:
tmp/,temp/,*.tmp,*.cache - Personal configs:
.env.local,config.local.*
- Secret/credential files:
- If you detect any of these patterns in changed files, STOP and ask the user before proceeding
- Only stage files that are directly related to the changes being committed
- Review the output of
- Create commits with:
- Title format:
{type}({scope}): {short description}or{type}: {short description} - Title should be max 72 characters
- Use imperative mood ("add feature" not "added feature")
- Extended description: Multi-line explanation of:
- What changed and why
- Any breaking changes or important notes
- Related issues or tickets
- NEVER include co-authorship credit to Claude or any AI agent
- Format: Use git commit with heredoc for proper multi-line formatting
- Title format:
Example commit:
git commit -m "$(cat <<'EOF'
feat(auth): add user authentication system
Implements JWT-based authentication with refresh tokens.
Includes middleware for protected routes and token validation.
Adds login, logout, and token refresh endpoints.
Breaking change: API now requires Authorization header for protected routes.
EOF
)"
Pull Request Creation
-
Push the branch to remote with tracking:
git push -u origin {branch-name} -
Create PR using
gh pr createwith:- PR Title: Same format as commit title -
{type}({scope}): {short description} - PR Description: Use Problem & Solution format with temp file:
- Write initial template to temp file using Write tool at
/tmp/claude/pr-body.md:## Problem [Describe the problem being solved, why this change is needed, or what gap this fills] ## Solution [Explain the approach taken to solve the problem] [Include specific implementation details] [Note any important technical decisions] ## Testing [How to test these changes] ## Related Issues [Link any related issues if applicable] - Use Edit tool to replace placeholders with actual content based on git diff and commit analysis
- Use Read tool to verify the final content before creating PR
- Create PR:
gh pr create --title "type(scope): description" --body-file /tmp/claude/pr-body.md
- Write initial template to temp file using Write tool at
- PR Title: Same format as commit title -
-
Return the PR URL to the user
Important Rules
- NEVER add "Co-Authored-By: Claude" or any AI attribution to commits or PRs
- NEVER push directly to main/default branch
- NEVER use
git add .orgit add -A- always stage files selectively - Always use conventional commit format
- Keep commit titles concise and descriptive (max 72 chars)
- Include meaningful extended descriptions for context
- Ensure commits are atomic and focused
- Use Problem & Solution format for all PR descriptions
- STOP and ask user if potentially sensitive files are detected in changes
Workflow Summary
- Check current branch → create feature branch if on main
- Review changes with
git statusandgit diff→ determine commit type - Selectively stage files (review each file, exclude sensitive/generated files)
- Create conventional commit with extended description
- Push branch → create PR with Problem & Solution format
- Return PR URL
Proceed with creating the pull request following these guidelines.