| name | pr |
| description | Create or update a pull request. Use when the user wants to create a PR, submit changes for review, or merge their work. Handles git operations, tests, CI monitoring, and PR creation. |
Create Pull Request
You are creating or updating a pull request. Follow these steps in order.
Step 1: Check for Uncommitted Changes
Run git status to check for uncommitted changes. If there are changes:
- Stage and commit them with a clear, descriptive message
- Push to the remote branch
Step 2: Review and Update README.md
Check if any changes in this PR require documentation updates:
- New features or commands
- Changed setup/installation steps
- New environment variables or configuration
- Updated dev workflow
- API changes that affect usage examples
- Changes to ARCHITECTURE.md if architectural patterns changed
If updates are needed, make them and commit before proceeding.
Step 3: Run Tests
Run these checks and ensure they pass:
- Dart analysis: Execute
flutter analyze - no warnings or errors allowed
- Unit tests: Execute
flutter test - all tests must pass
- Build check: Execute
flutter build apk --debug to verify build works (Android)
STOP if any tests fail. Fix the failures and re-run until all tests pass. Do not proceed to PR creation with failing tests.
Step 4: Create the PR
Once tests pass:
- Push any remaining commits to the remote branch
- Create the PR using
gh pr create
Step 5: Continuous CI and Review Monitoring Loop
After the PR is created, continuously monitor until ready to merge:
5a. Self Code Review
Review the PR diff using gh pr diff and look for:
- Code duplication that could be extracted (DRY principle)
- Performance improvements without added complexity
- Patterns that don't match ARCHITECTURE.md conventions
- Missing error handling (Either types)
- Domain logic leaking into wrong layers
- Missing const constructors
Apply good refactoring opportunities you identify - don't defer them to future PRs unless they require significant architectural changes.
5b. Monitor CI Status
- Check CI status:
gh pr checks
- If checks are still running, wait 30 seconds and check again
- If checks fail:
- Review the logs:
gh run view <run-id> --log-failed
- Fix the issues, commit, push
- Return to monitoring loop
- Check for warnings in annotations:
- Use
gh api repos/{owner}/{repo}/check-runs/{job_id}/annotations to fetch annotations
- ALL warnings must be addressed - either fix or document why not
5c. Monitor for AI Reviews
Poll for CodeRabbit and Copilot reviews:
- CodeRabbit: Use
gh pr checks - wait until CodeRabbit shows "Review completed"
- Copilot/Sourcery: Check
gh pr view <number> --comments for bot comments
- If reviews not yet complete, wait 30 seconds and check again
- Keep monitoring - reviews may come in multiple rounds
5d. Address All Comments
When comments appear from reviewers (human or AI):
- Read each comment carefully, including high-level feedback
- For line comments:
- If addressing: React with thumbs up, then make the fix
- If not addressing: Reply explaining why
- Apply good refactoring suggestions when they:
- Reduce code duplication (DRY principle)
- Improve performance without adding complexity
- Follow existing patterns in the codebase
- Commit, push, and return to Step 5b (CI monitoring loop)
5e. Loop Completion Criteria
Continue the monitoring loop until ALL of these are true:
Step 6: Automatic Merge
Once the monitoring loop is complete (all CI checks pass, all reviews complete, all comments addressed):
Merge automatically:
gh pr merge --squash --delete-branch
Then notify the user the PR was merged and ask what to work on next.
Post-Merge
After merging:
- Confirm the PR was merged successfully
- Check if there's an associated GitHub issue to close
- Ask the user what to work on next (e.g., next issue in the backlog)