PR Management
Pull request automation scripts for analysis, configuration, and quality checks
The PR Management script suite automates the full pull request lifecycle in Portfolio OS: from creating and configuring PRs, to analyzing quality, coordinating reviews, and keeping GitHub Projects in sync.
These scripts are designed to work together with the CI/CD workflows and multi-agent automation system documented elsewhere in the docs.
Note:
All scripts live under scripts/pr-management/ and require PowerShell 7+ and the
GitHub CLI (gh) authenticated against the target repository.
Overview
Folder Structure
scripts/pr-management/
├── automate-pr-unified.ps1 # Main PR automation entrypoint
├── configure-pr-auto.ps1 # Configure PR fields and project metadata
├── assign-pr-agents.ps1 # Assign PRs to agents / reviewers
├── configure-sprint-estimate.ps1 # Sprint estimation and capacity planning
├── get-pr-aliases.ps1 # PR alias and quick access utilities
├── test-pr-identification.ps1 # PR identification and validation
├── pr-monitor.ps1 # Real-time PR monitoring
├── pr-analyzer.ps1 # Comprehensive PR analysis
├── pr-quality-checker.ps1 # Quality checks and test orchestration
└── DEVELOPER_GUIDE.md # In-depth implementation details
Common Requirements
- PowerShell 7+ (
pwsh) - GitHub CLI (
gh) withrepo,project, andworkflowscopes - Run from the repo root (
portfolio-os) GITHUB_TOKENavailable to scripts (typically provided byghor CI)
Most scripts also support common flags:
| Parameter | Type | Description |
|---|---|---|
-DryRun | Switch | Preview actions without making changes |
-Verbose | Switch | Enable detailed logging |
-Force | Switch | Skip confirmations where supported |
Use Get-Help .\script-name.ps1 -Full for the authoritative parameter list.
automate-pr-unified.ps1
Path: scripts/pr-management/automate-pr-unified.ps1
Purpose: Unified automation entrypoint for PR analysis, CR-GPT integration, monitoring,
and response handling.
Capabilities
- Analyze PRs and their code changes
- Coordinate with CR-GPT-based review automation
- Generate suggested responses to review feedback
- Monitor PR status and keep project fields updated
Key Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
-PRNumber | int | Yes | Pull request number to process |
-Action | string | Yes | analyze, respond, monitor, or all |
-AutoFix | Switch | No | Apply safe automated fixes when supported |
-Detailed | Switch | No | Include additional analysis details in output |
-DryRun | Switch | No | Show planned operations without executing |
Usage Examples
# Run complete PR automation (analysis + responses + monitoring)
.\scripts\pr-management\automate-pr-unified.ps1 `
-PRNumber 150 `
-Action all `
-AutoFix
# Analyze a PR and CR-GPT feedback without modifying anything
.\scripts\pr-management\automate-pr-unified.ps1 `
-PRNumber 150 `
-Action analyze `
-Detailed `
-DryRun
# Generate suggested responses to existing review/CR-GPT comments
.\scripts\pr-management\automate-pr-unified.ps1 `
-PRNumber 150 `
-Action respond `
-AutoFix
Common Issues
-
"PR not found"
- Check that
-PRNumberis correct and the PR exists in the target repo. - Ensure you are in the
portfolio-osrepo directory.
- Check that
-
GitHub authentication errors
- Run
gh auth statusand, if needed,gh auth login. - Make sure you have
repoandprojectscopes.
- Run
-
CR-GPT / AI service errors
- Ensure any required API keys are configured (see
core-utilities/manage-ai-services.ps1). - Review logs with
-Verboseto see the underlying error.
- Ensure any required API keys are configured (see
configure-pr-auto.ps1
Path: scripts/pr-management/configure-pr-auto.ps1
Purpose: Configure PR fields and GitHub Project data consistently based on PR content.
Capabilities
- Set PR status, priority, size, app, and area
- Update project board fields for the PR’s associated issue(s)
- Apply labels and maintain naming conventions
Key Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
-PRNumber | int | Yes | Pull request number |
-Priority | string | No | P0, P1, P2, P3 (defaults from heuristics) |
-Size | string | No | XS, S, M, L, XL |
-App | string | No | Portfolio Site, Dashboard, Docs, Infra |
-Area | string | No | Frontend, Backend, Infra, Content, etc. |
-DryRun | Switch | No | Preview field changes without updating GitHub |
Usage Examples
# Configure a PR using defaults inferred from content
.\scripts\pr-management\configure-pr-auto.ps1 -PRNumber 150
# Configure a high-priority backend PR for the dashboard
.\scripts\pr-management\configure-pr-auto.ps1 `
-PRNumber 150 `
-Priority P0 `
-Size L `
-App "Dashboard" `
-Area "Backend"
# Preview all configuration changes without applying them
.\scripts\pr-management\configure-pr-auto.ps1 `
-PRNumber 150 `
-DryRun
Troubleshooting
- If project fields are not updated, confirm the underlying GitHub Project IDs and field configuration in your environment matches what the script expects.
assign-pr-agents.ps1
Path: scripts/pr-management/assign-pr-agents.ps1
Purpose: Assign PRs to agents or reviewers based on workload and domain.
Capabilities
- Distribute PRs across agents using workload and priority information
- Generate assignment reports for review
- Support dry-run preview before applying assignments
Key Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
-ProjectNumber | string | Yes | GitHub Project number (e.g. "20") |
-Owner | string | Yes | Project owner / org (e.g. "jschibelli") |
-DryRun | Switch | No | Show assignments without updating in GitHub |
-ExportTo | string | No | Optional path to export assignment report |
Usage Examples
# Propose assignments for all PRs in a project (preview only)
.\scripts\pr-management\assign-pr-agents.ps1 `
-ProjectNumber "20" `
-Owner "jschibelli" `
-DryRun
# Apply assignments and export a markdown report
.\scripts\pr-management\assign-pr-agents.ps1 `
-ProjectNumber "20" `
-Owner "jschibelli" `
-ExportTo "assignment-report.md"
pr-monitor.ps1
Path: scripts/pr-management/pr-monitor.ps1
Purpose: Monitor PRs in real time and export status reports.
Key Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
-Filter | string | No | Filter by PR state (e.g. open) |
-WatchMode | Switch | No | Continuously monitor PRs |
-Interval | int | No | Watch interval in seconds |
-IncludeCRGPT | Switch | No | Include CR-GPT-related events where applicable |
-ExportTo | string | No | Export results to a file (JSON/MD, etc.) |
Usage Examples
# Monitor open PRs once
.\scripts\pr-management\pr-monitor.ps1 -Filter open
# Watch open PRs with CR-GPT-related activity every 30 seconds
.\scripts\pr-management\pr-monitor.ps1 `
-Filter open `
-WatchMode `
-Interval 30 `
-IncludeCRGPT
# Generate a snapshot report of open PRs
.\scripts\pr-management\pr-monitor.ps1 `
-Filter open `
-ExportTo "pr-report.json"
pr-analyzer.ps1
Path: scripts/pr-management/pr-analyzer.ps1
Purpose: Perform detailed PR analysis (scope, risk, complexity, and review status).
Analysis Modes
comprehensive– Full PR analysissecurity– Security-focused checksperformance– Performance-related impactcomplexity– Code complexity and review effortreview– Review status, feedback, and blockerschanges– Focus on change impact and touched areas
Key Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
-PRNumber | int | Yes | PR number |
-Analysis | string | Yes | One of the analysis modes listed above |
-ExportTo | string | No | Optional path to export analysis (JSON/MD, etc.) |
-Detailed | Switch | No | Include additional diagnostic data |
Usage Examples
# Run full analysis with detailed console output
.\scripts\pr-management\pr-analyzer.ps1 `
-PRNumber 150 `
-Analysis comprehensive `
-Detailed
# Generate a security analysis report
.\scripts\pr-management\pr-analyzer.ps1 `
-PRNumber 150 `
-Analysis security `
-ExportTo "security-report.json"
pr-quality-checker.ps1
Path: scripts/pr-management/pr-quality-checker.ps1
Purpose: Run automated quality checks and tests for a given PR.
Check Types
all– Run the full suite of checkslinting– Lint and formattingformatting– Formatting onlysecurity– Security scanningperformance– Performance-related checksdocumentation– Documentation completenesstests– Run associated test suites
Key Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
-PRNumber | int | Yes | PR number |
-Checks | string | No | Comma-separated list of check types or all |
-RunTests | Switch | No | Ensure tests are executed as part of the run |
-AutoFix | Switch | No | Apply safe auto-fixes where possible |
-ExportTo | string | No | Export quality report to a file |
Usage Examples
# Run full quality check with auto-fix
.\scripts\pr-management\pr-quality-checker.ps1 `
-PRNumber 150 `
-Checks all `
-AutoFix
# Run security + performance checks and export report
.\scripts\pr-management\pr-quality-checker.ps1 `
-PRNumber 150 `
-Checks security,performance `
-ExportTo "quality-report.json"
# Focus on tests and documentation
.\scripts\pr-management\pr-quality-checker.ps1 `
-PRNumber 150 `
-Checks tests,documentation `
-RunTests
Supporting Utilities
In addition to the main automation scripts, the PR Management folder includes:
configure-sprint-estimate.ps1– Manage sprint estimates and capacity for PR-related work.get-pr-aliases.ps1– Create and use human-friendly aliases for PRs.test-pr-identification.ps1– Validate that PR metadata and identification logic works as expected.
Each of these scripts follows the same conventions as above: use Get-Help for the complete
parameter list and -DryRun + -Verbose during first use.
Troubleshooting & Best Practices
- Always start with
-DryRunwhen integrating a script into CI/CD or new workflows. - Check
gh auth statusbefore running scripts that interact with GitHub. - Prefer smaller, focused PRs – the automation works best when changes are well scoped.
- Use the CI/CD workflows in combination with these scripts to enforce quality gates on every PR.
For deeper architectural context and advanced usage patterns, see the in-repo
scripts/pr-management/DEVELOPER_GUIDE.md.