Keep your GitHub PRs updated with their target branch and CI passing.
- Finds all your open PRs in the configured organization
- Updates branches that are behind their target (merge commits, not rebase)
- Waits for CI to complete
- Retries failed CI once (handles flaky tests)
- Reports conflicts and persistent failures for manual attention
This tool can ONLY:
- Update PR branches with their base branch
- Re-run failed CI jobs
It CANNOT merge, close, or make other changes to your PRs.
- Node.js 18+
- GitHub CLI (
gh) installed and authenticatedgh auth status # Verify authentication
# Clone the repository
git clone https://github.com/jleo-py/pr_sync.git
cd pr_sync
# Install dependencies
pnpm install
# Build
pnpm buildCopy the example config and customize:
cp config.example.json config.jsonEdit config.json:
{
"org": "YourOrg",
"maxConcurrency": 3,
"staggerDelayMs": 30000,
"ciRetryCount": 1,
"ciPollIntervalMs": 30000,
"ciTimeoutMs": 1800000,
"excludeRepos": [],
"includeRepos": null
}| Option | Default | Description |
|---|---|---|
org |
"PerformYard" |
GitHub organization to search |
maxConcurrency |
3 |
Number of PRs to process in parallel |
staggerDelayMs |
30000 |
Delay between starting concurrent PRs (ms) |
ciRetryCount |
1 |
Times to retry failed CI (0 = no retries) |
ciPollIntervalMs |
30000 |
How often to check CI status (ms) |
ciTimeoutMs |
1800000 |
Max time to wait for CI (30 min) |
excludeRepos |
[] |
Repos to skip (e.g., ["legacy-app"]) |
includeRepos |
null |
Only process these repos (null = all) |
# Run with config file
pnpm start
# Or with CLI options
pnpm start --org MyOrg --max-concurrency 2
# See all options
pnpm start --helpPR Sync - Keep your PRs up to date
──────────────────────────────────────────────────
🔍 Searching for open PRs by jleo in PerformYard...
🔍 Found 4 open PRs
(sorted by dependency chain - base branches first)
├─ PerformYard#1234: Add user authentication...
✅ PerformYard#1234 - already up to date
PerformYard#1234: ✅ CI passing
├─ PerformYard#1235: Fix pagination bug...
🚀 PerformYard#1235 - updated
PerformYard#1235: ⏳ Waiting for CI...
PerformYard#1235: ✅ CI passing
├─ Logan#456: Update analytics...
🔴 Logan#456 - merge conflict
├─ 🔄 PerformYard#1237: refreshing status...
├─ PerformYard#1237: Improve search filters...
🚀 PerformYard#1237 - updated
PerformYard#1237: ⚠️ CI failing (2 failed runs)
PerformYard#1237: 🔄 Re-running 2 failed jobs...
PerformYard#1237: ✅ CI passing after retry
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
SUMMARY
✅ Passing: 3
PerformYard#1234
PerformYard#1235
PerformYard#1237
🔴 Merge Conflicts: 1 (needs manual resolution)
https://github.com/PerformYard/Logan/pull/456
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# Run tests
pnpm test
# Run tests in watch mode
pnpm test:watch
# Build
pnpm build
# Run without building (dev mode)
pnpm devsrc/
├── index.ts # CLI entry point
├── config.ts # Configuration loading
├── github.ts # GitHub operations (safety-scoped)
├── ci.ts # CI status and retries
├── runner.ts # Orchestration logic
├── output.ts # Terminal formatting
└── types.ts # TypeScript types
tests/
├── github.test.ts
├── runner.test.ts
└── mocks/
└── gh.ts # Mock gh CLI for testing
- Share this directory or create a git repo
- Each user copies
config.example.jsontoconfig.json - Users customize
orgif working with different organizations - The tool auto-detects the current GitHub user via
gh api user
"No PRs found"
- Verify you're authenticated:
gh auth status - Check the organization name in config
- Ensure you have open PRs:
gh pr list --author @me
"Command failed" errors
- Check GitHub CLI is up to date:
gh --version - Re-authenticate if needed:
gh auth login
Rate limits
- Reduce
maxConcurrencyin config - Increase
staggerDelayMsto space out API calls