Create Your First Pull Request with /create-pr¶
Learn how to create professional pull requests using the git-workflow plugin's /create-pr command.
Duration: 10 minutes Level: Beginner Plugin: git-workflow
What You'll Learn¶
- How to use the
/create-prcommand - Branch management and naming conventions
- Writing effective PR descriptions
- Code formatting integration
- Draft PR workflow
Prerequisites¶
- Git repository with a remote on GitHub
- git-workflow plugin installed
- Changes committed (ideally via
/commit) - GitHub CLI (
gh) installed and authenticated
Step 1: Prepare Your Changes¶
Before creating a PR, you need committed changes. If you haven't committed yet, use /commit first:
| Bash | |
|---|---|
Integration with /commit
The /create-pr command does not create commits itself. If you have uncommitted changes, it will call /commit automatically.
Step 2: Run /create-pr¶
In Claude Code, simply type:
| Bash | |
|---|---|
Claude will guide you through the entire process:
- Check branch status - Determine if you're on a protected branch
- Create feature branch - If needed, with a descriptive name
- Format code - Run project-specific formatters
- Push to remote - Upload your branch
- Create the PR - With title, description, and test plan
Step 3: Understand Branch Management¶
The command handles branches automatically based on where you are:
Claude creates a new feature branch for you:
| Text Only | |
|---|---|
Branch naming follows the convention: <type>/<description>-<date>
Branch Naming Convention¶
| Type | Prefix | Example |
|---|---|---|
| New feature | feature/ | feature/user-dashboard-2025-01-26 |
| Bug fix | fix/ | fix/login-crash-2025-01-26 |
| Documentation | docs/ | docs/api-reference-2025-01-26 |
| Refactoring | refactor/ | refactor/auth-module-2025-01-26 |
Step 4: Code Formatting¶
Before the PR is created, Claude runs code formatters based on your project type:
Skip Formatting
Use --no-format if you want to skip automatic formatting:
| Bash | |
|---|---|
Step 5: Review the PR Description¶
Claude generates a professional PR description with:
- Summary - What changes were made and why
- Changes list - Bullet points of all modifications
- Test plan - Checklist for verifying the changes
Example PR output:
Step 6: Verify Your PR¶
After creation, Claude shows the PR URL:
| Text Only | |
|---|---|
Click the link to review your PR on GitHub.
Advanced Options¶
Create a Draft PR¶
For work-in-progress changes that aren't ready for review:
| Bash | |
|---|---|
When to Use Draft PRs
Draft PRs are great for:
- Getting early feedback on your approach
- Running CI/CD checks before the code is complete
- Showing team members that you're working on something
Specify Target Branch¶
By default, PRs target main. Change this with:
| Bash | |
|---|---|
Single Commit Mode¶
Squash all changes into one commit:
| Bash | |
|---|---|
Use Professional Workflow Skill¶
For optimized performance with intelligent branch management:
| Bash | |
|---|---|
Best Practices¶
✅ Do¶
- Write clear PR titles - Describe the "what" in under 50 characters
- Explain the "why" - The description should explain motivation, not just list changes
- Keep PRs small - Aim for 150-400 lines of changes
- Self-review first - Check your own diff before submitting
- Link related issues - Reference issues with
Fixes #123orCloses #456 - Use draft PRs - For early feedback on work in progress
❌ Don't¶
- Create huge PRs - Large PRs are hard to review and more likely to have bugs
- Mix unrelated changes - Each PR should address one concern
- Skip the description - Reviewers need context to provide good feedback
- Force push without warning - Communicate with reviewers before rewriting history
- Merge without CI passing - Wait for all checks to complete
Troubleshooting¶
PR Creation Fails¶
Problem: gh pr create returns an error.
Solution:
- Verify GitHub CLI is authenticated:
gh auth status - Check remote is configured:
git remote -v - Ensure branch is pushed:
git push -u origin HEAD
Branch Already Exists¶
Problem: The suggested branch name already exists.
Solution:
- Claude will detect this and suggest an alternative name
- Or delete the old branch if it's no longer needed:
git branch -d old-branch
Formatting Changes Detected¶
Problem: Code formatter modified files after your commit.
Solution:
- Claude automatically commits formatting changes
- These appear as a separate commit in your PR
- To avoid this, run formatters before committing
Complete Workflow Example¶
Here's the full workflow from change to PR:
What's Next?¶
Now that you can create professional PRs, try:
- PRD-Based Workflow - Plan features before coding
- Linear Integration - Connect with project management
- Plugin Catalog - Explore other plugins
Related Resources¶
- Git Workflow Plugin - Full plugin documentation
- Your First Commit - Learn the commit workflow
- Conventional Commits Reference - Commit message format
- Contributing Guide - Contribute to this project