Automating GitHub Pull Requests with AI: A Step-by-Step Implementation Guide
Pull requests are the backbone of collaborative software development, but they’re also one of the biggest time sinks. Creating branches, writing commit messages, drafting PR descriptions, requesting reviews, addressing feedback, and managing merges — a single PR lifecycle can consume 30-60 minutes of developer time.
This guide shows you how to automate the entire PR workflow using AI agent skills, reducing that time to under 2 minutes while maintaining code quality standards.
What You’ll Automate
By the end of this guide, your AI agent will handle:
- Branch creation with consistent naming conventions
- Conventional commit messages based on code changes
- PR description generation with context, changes summary, and testing notes
- Automated code review with inline comments
- Review feedback resolution
- Merge strategy selection and execution
Prerequisites
- Hermes Agent or OpenClaw installed and configured
- GitHub CLI (
gh) authenticated with your account - Repository with branch protection rules (recommended)
- The GitHub PR Workflow skill from OpenByt
Step 1: Install the Skill
Download the GitHub PR Workflow skill and place it in your agent’s skills directory:
# For Hermes Agent
cp github-pr-workflow.md ~/.hermes/skills/
# For OpenClaw
cp github-pr-workflow.md ~/.openclaw/skills/
# Verify installation
hermes skills list | grep github-pr
The skill activates automatically when you ask your agent to create a PR, submit changes, or push code for review.
Step 2: Configure Branch Naming
The skill uses conventional branch naming by default:
# Pattern: type/short-description
feature/add-user-authentication
fix/resolve-memory-leak
refactor/extract-payment-module
docs/update-api-reference
To customize the naming convention, add a .github/agent-config.yml to your repository:
# .github/agent-config.yml
branch_naming:
pattern: "{type}/{ticket}-{description}"
types: [feature, fix, refactor, docs, test, chore]
ticket_prefix: "PROJ"
# Example output: feature/PROJ-123-add-auth
Step 3: Commit Message Standards
The skill generates commit messages following the Conventional Commits specification:
feat(auth): add OAuth2 login with Google provider
- Implement OAuth2 flow with PKCE
- Add session management with secure cookies
- Create login/callback route handlers
- Add unit tests for token validation
Closes #142
The agent analyzes your staged changes to determine:
- Type — feat, fix, refactor, docs, test, chore, perf
- Scope — The module or component affected
- Description — What changed and why
- Body — Detailed list of changes
- Footer — Issue references, breaking changes
Step 4: PR Description Generation
When the agent creates a PR, it generates a structured description:
## Summary
Add OAuth2 authentication with Google as the identity provider.
Users can now sign in with their Google account instead of
email/password.
## Changes
- `src/auth/oauth.ts` — OAuth2 flow implementation with PKCE
- `src/auth/session.ts` — Session management with httpOnly cookies
- `src/routes/login.ts` — Login initiation endpoint
- `src/routes/callback.ts` — OAuth callback handler
- `tests/auth/oauth.test.ts` — Unit tests for token validation
## Testing
- [x] Unit tests pass (`npm test`)
- [x] Manual testing with Google OAuth sandbox
- [x] Session expiry and refresh verified
- [ ] Load testing (deferred to follow-up)
## Screenshots
N/A (backend changes only)
## Related
Closes #142 | Depends on #138 (merged)
The description is generated by analyzing the diff, commit history, and any linked issues. It’s not a template — it’s contextual to your actual changes.
Step 5: Automated Code Review
The Code Review skill works in tandem with the PR workflow. When a PR is opened (by you or a teammate), the agent can review it:
# Ask your agent to review a PR
"Review PR #47 and leave inline comments"
# Or set up automatic review on new PRs
"Review all new PRs in this repo"
The agent checks for:
- Security issues — SQL injection, XSS, hardcoded secrets, insecure dependencies
- Performance concerns — N+1 queries, unnecessary re-renders, missing indexes
- Code quality — Dead code, duplicated logic, missing error handling
- Convention violations — Naming inconsistencies, import ordering, missing types
- Logic errors — Off-by-one, null pointer risks, race conditions
Comments are left inline on the specific lines, with severity levels (critical, warning, suggestion) and fix recommendations.
Step 6: Handling Review Feedback
When reviewers leave comments on your PR, the agent can address them:
"Address the review comments on PR #47"
The agent will:
- Read all pending review comments
- Categorize them (code change needed, question to answer, style preference)
- Make the requested code changes
- Reply to each comment explaining what was done
- Push the fixes as a new commit
- Re-request review
⚠️ Important
The agent won’t force-push or amend commits by default. It creates new commits for review feedback so reviewers can see exactly what changed. Configure amend_on_feedback: true in agent-config.yml if you prefer squashed commits.
Step 7: Merge Strategy
Once approved, the agent selects the appropriate merge strategy based on your repository’s configuration:
- Squash merge — Default for feature branches. Combines all commits into one clean commit on main.
- Merge commit — Used when preserving individual commit history matters (large features with meaningful commit boundaries).
- Rebase — Used when the branch is behind main and needs a linear history.
# The agent handles the full merge flow:
1. Check CI status (all checks must pass)
2. Verify approval count meets branch protection rules
3. Update branch if behind main
4. Execute merge with appropriate strategy
5. Delete the source branch
6. Verify the merge commit appears on main
Complete Workflow Example
Here’s what the full automated workflow looks like in practice:
# You: "Create a PR for the auth changes I just made"
# Agent executes:
1. Detects staged/committed changes on current branch
2. If on main, creates feature branch: feature/add-oauth-auth
3. Generates conventional commit message from diff analysis
4. Commits changes
5. Pushes branch to origin
6. Creates PR with generated title and description
7. Assigns reviewers based on CODEOWNERS
8. Links related issues from commit messages
9. Reports back: "PR #47 created: feat(auth): add OAuth2 login"
# Total time: ~45 seconds
# Manual equivalent: ~30 minutes
Measuring Impact
After implementing this workflow, teams typically see:
- 70% reduction in time spent on PR mechanics (branch, commit, describe, merge)
- 40% faster review turnaround (automated first-pass catches obvious issues)
- Consistent quality — Every PR has a proper description, conventional commits, and linked issues
- Fewer back-and-forth cycles — Automated review catches issues before human reviewers see the PR
Troubleshooting
Agent creates PR on wrong branch
Ensure you’re on the correct branch before asking the agent to create a PR. The skill uses the current branch as the source. Run git branch --show-current to verify.
Commit messages don’t match your convention
Add a .github/agent-config.yml with your specific commit format. The skill reads this file before generating messages.
Reviews are too strict/lenient
Adjust the review sensitivity in your agent config. Set review_level: strict for production repos or review_level: relaxed for experimental projects.
CI checks not detected
The skill checks GitHub Actions status checks. If you use a different CI provider, ensure it reports status to GitHub via the Checks API or commit statuses.
Get the GitHub PR Workflow Skill
Automate your entire PR lifecycle. One-time purchase, works with Hermes Agent and OpenClaw.
Get Skill — $4.99 →