| name | create-pr |
| description | Rebase from the latest origin/main, squash branch commits, and create or update a GitHub pull request. Use when asked to prepare or create a PR. |
Create Pull Request
Rebase from the latest origin/main, squash commits, and create a PR on GitHub with an
intelligent title and description.
Usage
$create-pr [--draft] [--base <branch>]
Arguments:
--draft: Create as draft PR
--base <branch>: Target branch (default: main)
Workflow
Step 1: Verify Prerequisites
git branch --show-current
if [[ $(git branch --show-current) == "main" || $(git branch --show-current) == "master" ]]; then
echo "ERROR: Cannot create PR from main/master branch"
exit 1
fi
git status --short
gh --version
Action: If there are uncommitted changes, stop, and then ask user to commit or stash
them first.
Step 2: Check for Existing PR
gh pr view --json number,title,url 2>/dev/null || echo "No existing PR"
Handle Existing PR:
- If PR exists, inform user and ask permission to force-update it
- Warn that this will rewrite the commit history and PR description
- If user declines, abort the process
Step 3: Fetch and Rebase
git fetch origin main
git log --oneline HEAD ^origin/main
git rebase origin/main
Handle Conflicts: If rebase fails due to conflicts, abort and let user handle rebase
manually:
git rebase --abort
echo "Rebase failed due to conflicts. Please resolve manually and retry $create-pr"
exit 1
Step 4: Squash Commits into Single Commit
After successful rebase, squash all commits since origin/main into a single commit:
git rev-list --count origin/main..HEAD
git reset --soft origin/main
Generate Commit Message (following $gen-commit-msg format):
-
Analyze staged changes:
git diff --cached --name-only
git diff --cached
-
Categorize changes (feat/fix/docs/refactor/test/chore/perf)
-
Determine scope from changed files (workflow/engine/reward/dataset/api/docs/etc.)
-
Generate message in format:
<type>(<scope>): <subject>
<body>
[Optional sections:]
Key changes:
- change 1
- change 2
Refs: #123, #456
-
Commit with generated message:
git commit -m "$(cat <<'EOF'
<generated commit message>
EOF
)"
Step 5: Analyze Combined Changes
After squashing into a single commit:
git diff origin/main...HEAD --name-only
git diff origin/main...HEAD
git log --oneline origin/main..HEAD
Categorize Changes:
Follow same categorization as $gen-commit-msg:
| Type | When to Use |
|---|
feat | New feature or capability |
fix | Bug fix |
docs | Documentation only |
refactor | Code change without feature/fix |
test | Adding or fixing tests |
chore | Build, deps, config changes |
perf | Performance improvement |
Determine Scope:
Infer from changed files:
src/workflow/ → workflow
src/engine/ → engine
src/reward/ → reward
src/dataset/ → dataset
src/api/ → api
src/utils/ → utils
src/infra/ → infra
docs/ → docs
examples/ → examples
- Multiple areas → omit scope or use broader term
Step 6: Generate PR Title and Description
PR Title Format:
<type>(<scope>): <brief description>
Rules:
- Keep under 70 characters
- Use imperative mood
- No period at end
- Mirror commit message style
PR Description Format:
MUST strictly follow the GitHub PR template:
## Description
<!-- Clear and concise description of what this PR does -->
## Related Issue
<!-- Link to the issue this PR addresses -->
Fixes #(issue)
## Type of Change
<!-- Mark the relevant option with an 'x' -->
- [ ] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation update
- [ ] Code refactoring (no functional changes)
- [ ] Performance improvement
- [ ] Test coverage improvement
## Checklist
<!-- Mark with 'x' what you've done -->
- [ ] I have read the [Contributing Guide](../CONTRIBUTING.md)
- [ ] I have run formatting tools (pre-commit or manual)
- [ ] I have run relevant unit tests and they pass
- [ ] I have added tests for new functionality
- [ ] I have updated documentation if needed
- [ ] My branch is up to date with main
- [ ] This PR introduces breaking changes (if yes, fill out details below)
- [ ] If this PR changes documentation, I have built and previewed it locally with `jb build docs`
- [ ] No critical issues raised by AI reviewers (`/gemini review`)
**Breaking Change Details (if applicable):**
<!-- Describe what breaks and how users should migrate -->
## Additional Context
<!-- Add any other context, screenshots, logs, or explanations here -->
How to Fill the Template:
- Description: 2-4 sentences explaining what this PR does and why
- Related Issue: Link to issue (search for related issues if exists)
- Type of Change: Mark ONE primary type with
[x]
- Checklist: Mark completed items with
[x], leave uncompleted as [ ]
- Breaking Change Details: Only if breaking changes checkbox is marked
- Additional Context: Any extra info, related PRs, performance numbers, etc.
Step 7: Push and Create/Update PR
Show preview to user:
─────────────────────────────────────────────────
Branch: feat/vision-rlvr → main
PR Title:
feat(workflow): add vision support to ImageProcessing
PR Description:
## Description
Add ImageProcessingWorkflow for vision-language RL training. Supports image inputs
alongside text prompts and integrates with existing ImageProcessing pipeline.
## Related Issue
Fixes #789
## Type of Change
- [ ] Bug fix (non-breaking change that fixes an issue)
- [x] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation update
- [ ] Code refactoring (no functional changes)
- [ ] Performance improvement
- [ ] Test coverage improvement
## Checklist
- [x] I have read the [Contributing Guide](../CONTRIBUTING.md)
- [x] I have run formatting tools (pre-commit or manual)
- [ ] I have run relevant unit tests and they pass
- [x] I have added tests for new functionality
- [x] I have updated documentation if needed
- [x] My branch is up to date with main
- [ ] This PR introduces breaking changes (if yes, fill out details below)
- [x] If this PR changes documentation, I have built and previewed it locally with `jb build docs`
- [ ] No critical issues raised by AI reviewers (`/gemini review`)
**Breaking Change Details (if applicable):**
N/A
## Additional Context
Requires Pillow>=10.0.0 for image processing.
Files changed:
- `src/workflow/image_processing.py`: New ImageProcessingWorkflow class
- `src/api/config.py:45`: Add image processing config fields
- `examples/vision_rlvr.py`: Example training script
- `docs/workflows/vision.md`: Documentation
─────────────────────────────────────────────────
Commands to execute:
1. git push -u origin feat/vision-rlvr
2. gh pr create --title "..." --body "..." [--draft]
─────────────────────────────────────────────────
Confirm with user, then execute:
git push -f -u origin $(git branch --show-current)
if gh pr view &>/dev/null; then
gh pr edit \
--title "feat(workflow): add vision support to ImageProcessing" \
--body "$(cat <<'EOF'
[PR description here]
EOF
)"
else
gh pr create \
--base main \
--title "feat(workflow): add vision support to ImageProcessing" \
--body "$(cat <<'EOF'
## Description
Add ImageProcessingWorkflow for vision-language RL training. Supports image inputs
alongside text prompts and integrates with existing ImageProcessing pipeline.
## Related Issue
Fixes #789
## Type of Change
- [ ] Bug fix (non-breaking change that fixes an issue)
- [x] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation update
- [ ] Code refactoring (no functional changes)
- [ ] Performance improvement
- [ ] Test coverage improvement
## Checklist
- [x] I have read the [Contributing Guide](../CONTRIBUTING.md)
- [x] I have run formatting tools (pre-commit or manual)
- [ ] I have run relevant unit tests and they pass
- [x] I have added tests for new functionality
- [x] I have updated documentation if needed
- [x] My branch is up to date with main
- [ ] This PR introduces breaking changes (if yes, fill out details below)
- [x] If this PR changes documentation, I have built and previewed it locally with `jb build docs`
- [ ] No critical issues raised by AI reviewers (`/gemini review`)
**Breaking Change Details (if applicable):**
N/A
## Additional Context
Requires Pillow>=10.0.0 for image processing.
Files changed:
- `src/workflow/image_processing.py`: New ImageProcessingWorkflow class
- `src/api/config.py:45`: Add image processing config fields
- `examples/vision_rlvr.py`: Example training script
- `docs/workflows/vision.md`: Documentation
EOF
)"
fi
Add --draft flag if requested.
Capture PR URL and display to user:
✓ PR created/updated successfully!
https://github.com/example/project/pull/123
Examples
Example 1: Feature PR
Changes: New dataset loader for MATH dataset
PR Title:
feat(dataset): add MATH dataset loader
PR Description:
## Description
Add MathDataset loader for mathematics problem solving with LaTeX rendering and
symbolic math parsing. Includes reward function for automatic answer verification
and full test coverage.
## Related Issue
Fixes #456
## Type of Change
- [ ] Bug fix (non-breaking change that fixes an issue)
- [x] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation update
- [ ] Code refactoring (no functional changes)
- [ ] Performance improvement
- [ ] Test coverage improvement
## Checklist
- [x] I have read the [Contributing Guide](../CONTRIBUTING.md)
- [x] I have run formatting tools (pre-commit or manual)
- [x] I have run relevant unit tests and they pass
- [x] I have added tests for new functionality
- [x] I have updated documentation if needed
- [x] My branch is up to date with main
- [ ] This PR introduces breaking changes (if yes, fill out details below)
- [x] If this PR changes documentation, I have built and previewed it locally with `jb build docs`
- [ ] No critical issues raised by AI reviewers (`/gemini review`)
**Breaking Change Details (if applicable):**
N/A
## Additional Context
Dataset requires ~500MB download on first use. Added comprehensive test suite
covering all 12,500 problems with >95% reward function accuracy.
Files changed:
- `src/dataset/math.py`: New MathDataset class
- `src/scoring/math_scoring.py`: Symbolic math scoring function
- `examples/math_training.py`: Training script
- `docs/datasets/math.md`: Dataset documentation
- `tests/test_math_dataset.py`: Unit tests
Example 2: Bug Fix PR
Changes: Fix memory leak in ComputeEngine
PR Title:
fix(engine): resolve memory leak in ComputeEngine rollout
PR Description:
## Description
Fix memory leak during ComputeEngine rollout phase by clearing cached activations
after each batch and moving tensors to CPU before deletion. Reduces memory usage
by ~2GB per rollout iteration.
## Related Issue
Fixes #872
## Type of Change
- [x] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation update
- [ ] Code refactoring (no functional changes)
- [ ] Performance improvement
- [ ] Test coverage improvement
## Checklist
- [x] I have read the [Contributing Guide](../CONTRIBUTING.md)
- [x] I have run formatting tools (pre-commit or manual)
- [x] I have run relevant unit tests and they pass
- [x] I have added tests for new functionality
- [ ] I have updated documentation if needed
- [x] My branch is up to date with main
- [ ] This PR introduces breaking changes (if yes, fill out details below)
- [ ] If this PR changes documentation, I have built and previewed it locally with `jb build docs`
- [ ] No critical issues raised by AI reviewers (`/gemini review`)
**Breaking Change Details (if applicable):**
N/A
## Additional Context
Tested with 100 rollout iterations without OOM. Memory usage stable at 8GB
(previously would grow to 10GB+). Output correctness validated unchanged.
Backported to v0.5.x branch.
Files changed:
- `src/engine/compute.py:234`: Add explicit cache clearing
- `src/engine/compute.py:456`: Move tensor to CPU before deletion
- `tests/test_compute_memory.py`: Add memory leak regression test
Example 3: Breaking Change PR
Changes: Refactor reward API for better extensibility
PR Title:
refactor(reward): simplify reward function interface
PR Description:
## Description
Simplify reward function API from 4 methods to 2 by consolidating compute and
compute_batch into a single batched interface. Improves type hints and
documentation. All existing reward functions updated.
## Related Issue
Fixes #901
## Type of Change
- [ ] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [x] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation update
- [ ] Code refactoring (no functional changes)
- [ ] Performance improvement
- [ ] Test coverage improvement
## Checklist
- [x] I have read the [Contributing Guide](../CONTRIBUTING.md)
- [x] I have run formatting tools (pre-commit or manual)
- [x] I have run relevant unit tests and they pass
- [ ] I have added tests for new functionality
- [x] I have updated documentation if needed
- [x] My branch is up to date with main
- [x] This PR introduces breaking changes (if yes, fill out details below)
- [x] If this PR changes documentation, I have built and previewed it locally with `jb build docs`
- [ ] No critical issues raised by AI reviewers (`/gemini review`)
**Breaking Change Details (if applicable):**
Old `compute_batch` method is deprecated and will be removed in v0.7.0.
See migration guide in `docs/migration/reward_api.md` for details.
## Additional Context
All existing tests pass. Performance unchanged at 10k rewards/sec. Backward
compatibility warnings added for deprecated methods.
Files changed:
- `src/api/scoring_api.py:12`: Consolidate compute/compute_batch
- `src/scoring/math_scoring.py`: Update to new API
- `src/scoring/code_scoring.py`: Update to new API
- `src/scoring/geometry_scoring.py`: Update to new API
- `docs/customization/reward.md`: Update documentation
- `docs/migration/reward_api.md`: Migration guide
- `examples/custom_reward.py`: Update example
Error Handling
Rebase Conflicts
If rebase fails:
- Show conflict files
- Provide resolution instructions
- Wait for user to resolve
- After resolution, continue with squashing step
- Offer to abort rebase if needed:
git rebase --abort
Squash Failures
If squash/commit fails:
- Check if there are changes to commit:
git status
- Verify no conflicts remain:
git diff --cached
- If needed, abort and return to pre-rebase state
Push Failures
If force push fails:
- Verify remote branch exists
- Check GitHub authentication:
gh auth status
- Confirm branch protection rules allow force push
- Provide manual push instructions if needed
PR Creation/Update Failures
If gh pr create or gh pr edit fails:
- Check if PR already exists:
gh pr view
- Verify GitHub authentication:
gh auth status
- Check for branch protection rules
- Provide manual PR creation/update link
Safety Checks
Before Starting:
- Confirm no uncommitted changes
- Confirm not on main/master branch
- Check for existing PR and get user permission to overwrite if exists
- Backup branch:
git branch backup/$(git branch --show-current)-$(date +%s)
Before Rebase:
- Fetch latest from origin
- Show divergence summary
Before Squash:
- Show commits that will be squashed
- Confirm user wants to proceed
Before Force Push:
- CRITICAL: Warn user that force push will rewrite history
- Show current commit that will replace remote history
- Confirm branch name
- If PR exists, emphasize that PR history will be rewritten
Before PR Creation/Update:
- Show full preview of title/description
- Confirm target branch
- If updating existing PR, show what will change