Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

newexpand-autopr

newExpand333MIT1.0.2TypeScript support: included

GitHub PR Automation CLI Tool with AI

github, cli, pr, automation, ai, auto-pr, newexpand-autopr, pull-request, code-review, git, github-automation, pr-automation, ai-code-review, github-cli, git-automation, pr-management, github-tools

readme

AutoPR CLI User Guide

➡️ Changelog (CHANGELOG.md)

한국어 문서: README-kr.md

AI-powered PR & Review: Test Case

The v1.0.0 Release Pull Request was created and reviewed as a test case to verify the effectiveness of AI-powered PR and review automation.

  • This PR was used to check if the AI system could detect critical bugs and issues in real-world scenarios.
  • Earlier versions used hardcoded logic, but now all sensitive operations (such as authentication) are tokenized for improved security and flexibility.
  • The PR and its review process demonstrate the practical value of AI integration in this CLI.

See the test PR & review details here.

Introduction

AutoPR CLI is a command-line tool that automates various GitHub workflows such as Pull Request (PR) creation, review, merge, commit, collaborator management, and daily reports. It provides powerful features including AI-based commit messages, PR descriptions, code reviews, branch patterns, templates, and reviewer groups.

  • Supported Environments: Node.js 18+ / macOS, Linux, Windows
  • Main Features:
    • Create/update/merge/review/list/reopen PRs, daily commit reports
    • AI-powered commit messages, PR descriptions, code reviews, conflict resolution suggestions
    • Collaborator/Reviewer/Reviewer Group/Template management
    • Supports GitHub App and OAuth authentication

Installation

npm install -g newexpand-autopr
  • Requires Node.js 18 or higher
  • After installation, use the autopr command

Basic Usage

autopr <command> [options]

Example:

autopr init

Main Commands & Features

1. Initialization & Authentication (init)

autopr init
  • Creates/initializes the project config file (.autopr.json)
  • OAuth authentication (required for PR/merge and basic features)
  • GitHub App authentication (optional, for AI review and advanced features, can be run anytime with a separate command)
  • AI token issuance (automatic)
  • Set language, default reviewers, etc.

⚠️ Important:
When authenticating the GitHub App, make sure you select the correct user or organization for your project.
If you authenticate with the wrong account/organization, key features such as PR automation, review, and permission management may not work as expected.
If you see a '404 not found' or 'Resource not accessible by integration' error after initialization and authentication, please make sure you selected the correct user/organization during GitHub App authentication.

Authentication Notice:
When authenticating with GitHub (during init, auth, etc.), an "authentication code" and "authentication URL" will be shown in your terminal.
Copy the code from the terminal, open the provided URL (Device Flow authentication page) in your browser, and paste the code to complete authentication.
If your browser does not open automatically, copy and paste the URL from the terminal into your browser manually.

Workflow:

Run autopr init
   ↓
Create/initialize project config file
   ↓
OAuth authentication (required for PR/merge)
   ↓
AI token issuance (automatic)
   ↓
GitHub App authentication (optional, for AI review/advanced features)
   ↓
Set language/reviewers/etc
   ↓
Save config file and show guide message
  • You can always run GitHub App authentication separately with:

    autopr auth github-app
  • If a GitHub user token is already registered, you can choose whether to re-authenticate. Selecting 'No' will keep the existing token.

1-1. Run GitHub App Authentication Separately (auth github-app)

autopr auth github-app
  • Run GitHub App authentication separately (can be run anytime for additional/re-authentication)
  • Required for AI review, automatic review comments, and other advanced features
  • Shows success/failure messages

2. Create PR (new)

autopr new
  • Create PRs based on branch patterns/templates
  • AI automatically generates PR title/body/review
  • Link related issues, assign reviewers, support Draft PR
  • Optionally run code review/line-by-line review after PR creation (requires GitHub App authentication)

Note:
The autopr new command creates a PR from the currently checked-out branch
to the target branch you specify (e.g., main, develop, etc).
For example, if you run autopr new on the feature/login branch and select main as the target,
a PR from feature/login to main will be created.

3. List PRs & Actions (list)

autopr list
  • View PRs by state (open/closed/all)
  • Select a PR to merge/update/open in browser/cancel, etc.

4. Update PR Info (update)

autopr update <pr-number>
  • Update PR title/body/status (draft/ready)

5. Merge PR (merge)

autopr merge <pr-number>
  • Choose merge method (merge/squash/rebase)
  • If conflicts occur, provides AI-based suggestions and manual guide
  • Automatically deletes/cleans up branch after merge

6. Reopen PR (reopen)

autopr reopen <pr-number>
  • Reopen a closed PR (not possible for merged PRs)

7. Commit & AI Message (commit)

autopr commit [improve] [message] [options]
Option/Shortcut Description
-a, --all Commit and push all changes
-p, --patch Patch mode (interactive, git add -p)
-s, --select Select files to commit
-sp, --selectpush Select files + push
improve Improve last commit message with AI
  • Stage/select/patch/auto-commit changes
  • AI suggests/improves commit messages
  • After commit, auto push and PR creation guide

8. Daily Commit Report (daily-report)

autopr daily-report [options]
  • Daily/periodic commit stats, AI summary, analysis by branch/file type/hour
  • Output as console/JSON/Markdown, support for saving to file

Options:

  • -u, --username <username>: Specific user
  • -f, --format <format>: Output format (console/json/markdown)
  • -d, --date <date>: Specify date
  • -o, --output <path>: Output file path

9. Language Setting (lang)

autopr lang set <ko|en>
autopr lang current
  • Change/check CLI message language

10. Collaborator Management (collaborator)

autopr collaborator invite <username>
autopr collaborator list
autopr collaborator remove
autopr collaborator status <username>
autopr collaborator status-all
  • Invite/set permissions/list/remove collaborators, check invitation status

11. Reviewer Group Management (reviewer-group)

autopr reviewer-group add <name> -m <id1,id2,...> [-s <strategy>]
autopr reviewer-group remove <name>
autopr reviewer-group update <name> [options]
autopr reviewer-group list
Option/Shortcut Description
-m, --members Specify group members (required, comma-separated)
-s, --strategy Reviewer rotation strategy (e.g. round-robin)
  • Add/update/delete/list reviewer groups
  • Supports strategies like round-robin

12. PR Template Management (template)

autopr template list
autopr template create [name]
autopr template edit [name]
autopr template delete [name]
autopr template view [name]
Subcommand Description
list List templates
create [name] Create new template (prompt if name omitted)
edit [name] Edit template (choose from list if omitted)
delete [name] Delete template (choose from list if omitted)
view [name] View template content (choose from list if omitted)
  • Can edit directly in your editor

Configuration File Structure

  • Global config: ~/.autopr/config.json
  • Project config: .autopr.json

Example fields:

{
  "githubApp": {
    "appId": "...",
    "clientId": "...",
    "installationId": 123456
  },
  "defaultReviewers": ["user1", "user2"],
  "reviewerGroups": [
    { "name": "FE", "members": ["user1", "user2"], "rotationStrategy": "round-robin" }
  ],
  "branchPatterns": [
    {
      "pattern": "feat/*",
      "type": "feat",
      "draft": true,
      "labels": ["feature"],
      "template": "feature",
      "autoAssignReviewers": true,
      "reviewers": [],
      "reviewerGroups": []
    }
  ]
}

AI Features

  • AI Token Issuance: Automatically issued on first init. Required for AI features (commit message, PR description, code review, etc). If the token expires or an authentication error occurs, it is automatically reissued, so users do not need to take any extra action.
  • Supported Features:
    • Commit message generation/improvement
    • PR title/body/review/code review/conflict resolution suggestions/daily report summary
  • Server Communication: Communicates with a separate AI server via HTTP
  • Language: Supports Korean/English

Security & Privacy Notice

  • When using the CLI's AI features (commit message, PR description, code review, etc.), related data (code, PR, commit, etc.) is sent to the developer's private server for AI analysis.
  • This server is not open to the public, and the transmitted data (code, PR, commit, etc.) is not stored.
  • The server only logs whether the API request was received and if any errors occurred; the actual content of code/PR/commit is not logged.
  • AI analysis results are generated based on Google AI (Gemini, etc).
  • Sensitive information such as GitHub authentication/tokens is stored only locally and is never sent externally.
  • All code is open source, and you can directly check the data flow and security policy.

FAQ

  • Q. Authentication doesn't work!
    • Try re-authenticating with autopr init. If the browser doesn't open automatically, copy and paste the URL manually.
  • Q. AI features don't work!
    • Check for token expiration or server issues. Reissue the token with autopr init if needed.
  • Q. Commit/PR/reviewer automation doesn't work!
    • Check your config file (.autopr.json) and authentication status.
  • Q. I get a hooks undefined error when switching branches!
    • If you used a previous version of AutoPR CLI, the .git/hooks/post-checkout file may remain. This can cause a hooks undefined or related error when switching branches.
    • Remove the hook file with the following command:
      rm .git/hooks/post-checkout
    • Deleting this file will not affect Git's default behavior, so you can safely remove it.

Contribution & License

  • Contributions are welcome! Please submit PRs or issues.
  • License: MIT

Contact

  • Please contact via GitHub issues or the maintainer.

changelog

Change Log

1.0.2

  • Enhanced UX: Auto push prompt and sync before PR creation
    • When running autopr new, if the current branch does not exist on origin (remote), a prompt is shown to push the branch first
    • If the user selects "Yes", automatically runs git push --set-upstream origin <branch> and proceeds with PR creation
    • If "No" is selected, PR creation is cancelled with a clear message
    • If the branch already exists on origin, autopr new no longer auto-pushes.
      • If there are local commits not pushed to origin, a notice is shown to run git push and try again, and PR creation is aborted until the user pushes manually
    • All related guide/warning/success messages are added to i18n (Korean/English)
    • Users can now safely create PRs without manual git commands or errors

1.0.1

  • Bug Fix: AI Language Setting
    • Fixed an issue where the language setting (language) was not properly passed to AI features (PR creation, code review, etc.), causing inconsistent Korean/English results
    • Now all AI feature calls explicitly pass the language setting, ensuring output matches the configured language

1.0.0

  • Complete CLI Command & Option Overhaul
    • Unified and standardized all major commands (init, PR create/list/update/merge/reopen, commit, daily-report, reviewer group, collaborator, template, language, etc.)
    • Documented all options/shortcuts for each command in tables
    • Improved and unified interactive prompt UX
  • Advanced AI Features & Enhanced Security Notice
    • Full support for AI-powered commit message, PR description, code review, conflict resolution, daily report, and more
    • AI token is automatically issued and reissued on expiration/error (no user action required)
    • AI analysis data is NOT stored on the server; only API request/error logs are kept (actual code/PR/commit content is never logged)
    • AI results are clearly marked as Google AI (Gemini, etc.) based
  • New Security & Privacy Notice
    • Clearly documented data flow, storage policy, and open source status for AI features
    • Emphasized that GitHub authentication/tokens and sensitive info are stored only locally
  • Configuration Structure & Customization Improvements
    • Standardized global/project config (.autopr.json) structure with examples
    • Enhanced customization for branch patterns, PR templates, reviewer groups, etc.
  • Documentation (README) Overhaul
    • Updated and expanded both Korean/English README with detailed commands/options/security/FAQ/config examples
    • Improved FAQ, system requirements, license, and changelog sections
  • Other Improvements
    • Added guidance and solution for hooks undefined error when switching branches
    • Improved workflow for commit/PR/reviewer automation, daily report, template management, and more
  • Major authentication & workflow structure overhaul
    • Separated OAuth authentication as required, GitHub App authentication as optional (for advanced features)
    • Enhanced UX and guide messages for each authentication step, clarified UX on failure/cancellation
    • Refactored code to split authentication/config steps into functions
    • If a user token exists, only ask for re-authentication; 'No' keeps the existing token
    • GitHub App authentication can be run anytime via a separate command (autopr auth github-app)
    • Basic features (PR/merge) work with OAuth only; advanced features require App authentication (with clear branching)
    • All guide/warning/success/failure messages managed via i18n
    • Updated README and docs to reflect new authentication structure, commands, and workflow

0.1.23

  • Updated OpenRouter Free AI Model
    • Changed from Gemini Flash to Qwen 3.0 (30B) model
    • Updated model identifier to "qwen/qwen3-30b-a3b:free"
    • Adjusted model description for improved clarity
    • Maintained all free tier benefits with enhanced capabilities
    • Updated related language strings in localization files
  • Enhanced PR Title Generation
    • Changed token limit from 100 to getMaxTokens("chunk")
    • Improved title generation stability for large changes
    • Fixed title generation failures due to token limit constraints

0.1.22

  • Enhanced AI Provider Configuration Priority
    • Modified AI configuration loading logic in AIFeatures class
    • Improved configuration priority order: project config (.autopr.json) > .env file > default settings
    • Added comprehensive error handling in configuration loading process
    • Enhanced debugging with detailed log messages for configuration source identification
    • Fixed issue where environment variables would override project configuration settings
    • Added graceful fallback to OpenRouter when configuration errors occur

0.1.21

  • Improved Daily Commit Report Feature
    • Fixed AI Summary Display Issue
      • Resolved issue where generated AI summaries weren't displaying in console
      • Enhanced standard output mechanism (console.logprocess.stdout.write)
      • Fixed complex markdown rendering issues in console environments
    • Strengthened Commit Analysis Stability
      • Fixed type errors in date sorting functionality
      • Improved commit sorting logic with better code block structure

0.1.20

  • Package size optimization (0.1.18: 340KB → 0.1.19: 695KB → 0.1.20: 216.8KB)
    • Achieved 36% size reduction from 0.1.19 which had increased package size
    • Applied aggressive tree shaking (preset: 'smallest')
    • Enabled code minification (minify: true)
    • Disabled sourcemaps (sourcemap: false)
    • Enabled code splitting (splitting: true)
    • Eliminated development logs and legal comments
    • Removed duplicate locale files
    • Streamlined i18n file distribution to single path
    • Optimized package file inclusion
  • Enhanced i18n module
    • Strengthened multi-path resolution for locales
    • Added fallback translations when locale files not found
    • Added support for global installation environment paths
    • Improved file loading exception handling

0.1.19

  • Enhanced Build System
    • Introduced tsup bundler for faster build times
    • Applied tree shaking for package optimization
    • Improved ES modules support
    • Optimized i18n file handling
    • Automated build process
    • Eliminated unnecessary duplicate builds

0.1.18

  • Improved AI Manager Structure
    • Refactored AI provider initialization logic using strategy pattern
    • Separated provider-specific code into dedicated methods for better maintainability
    • Enhanced extensibility for adding new AI providers
    • Introduced mapping structure for initialization logic configuration
    • Strengthened exception handling
    • Isolated OpenRouter key status check logic

0.1.17

  • Enhanced Initialization Process
    • Automated Git hooks setup during initialization
    • Automated Release PR template configuration
    • Removed manual hook setup and template customization prompts
    • Added automatic setup status notifications
    • Improved user experience with streamlined setup flow
    • Standardized post-checkout hook installation
    • Simplified onboarding with fewer configuration questions

0.1.16

  • Enhanced Multi-language Documentation
    • Added Korean documentation links to English documents
    • Added Korean README and branch strategy guide links in English README
    • Added detailed description of Korean documentation in multi-language support section
    • Improved documentation accessibility
  • Improved Document Structure
    • Moved change log to separate CHANGELOG files
    • Enhanced README file conciseness
    • Standardized documentation

0.1.15

  • Branch Management Workflow Documentation
    • Added detailed GitFlow-based branch strategy guide (USAGE.md/USAGE-kr.md)
    • Provided standard workflow examples from branch creation to merging
    • Added screenshots of key command execution results
    • Included real PR example links
    • Detailed branch patterns and naming conventions
  • README Improvements
    • Added Branch Management Workflow section
    • Added USAGE document links and summary
    • Optimized document structure

0.1.14

  • Documentation Updates
    • Fixed parameter notation consistency in README files
    • Updated autopr commit -sp command documentation
    • Synchronized English and Korean documentation

0.1.13

  • Added Daily Commit Report Generation
    • Implemented new autopr daily-report command
    • Provides AI-generated summaries of daily commit activities
    • Offers date selection from recent commit history
    • Includes detailed statistics (files changed, lines added/deleted)
    • Generates reports in multiple formats (console, JSON, markdown)
    • Supports both local and remote repository commits
  • Improved Merge Conflict Resolution Experience
    • Simplified conflict resolution workflow
    • Removed unnecessary automatic file opening logic
    • Enhanced step-by-step guidance with clear Git commands
    • Added better conflict marker explanations
    • Maintained valuable AI-powered conflict resolution suggestions
    • Improved multilingual support for conflict resolution
    • Added helpful documentation links for resolving conflicts
  • Added interactive PR selection to list command
    • Select PRs directly from the terminal
    • Quick access to review, merge, update actions
    • Improved workflow efficiency
  • Enhanced display of PR information
    • Better formatting of PR list
    • Numbered list for easier reference
  • Enhanced PR Pagination
    • Improved page-by-page loading for managing large numbers of PRs
    • Added option to continuously load more PRs as needed
    • Support for loading up to 10 pages of PRs
    • Clear page loading status indicators
  • Enhanced Commit Process
    • Fixed interruption handling with Ctrl+C/Command+C to safely cancel commit operations
    • Resolved issue where the commit process would continue after cancellation
    • Added clear cancellation messages for better user feedback
    • Implemented consistent cancellation handling across all prompts
  • Enhanced Localization
    • Updated translations for conflict resolution
    • Improved language consistency
    • Added missing translation keys
    • Added comprehensive translations for interactive features
  • General Performance Improvements
    • Reduced unnecessary code complexity
    • Enhanced error handling
    • Improved cross-platform compatibility

0.1.12

  • Re-enabled File Selection with Auto-Push Feature
    • Added functionality to select specific files to stage, commit, and automatically push to origin
    • Updated option: -sp, --selectpush option provided
    • Improved Commander.js option handling for greater stability
    • Excluded branch selection feature (push only to current branch)
    • Maintained automatic -u option for non-existing remote branches

0.1.11

  • Temporary Disabled Branch Selection Push Feature
    • Implemented to resolve branch conflict issues
    • Changed to push only to current branch
    • Automatically added -u option for non-existing remote branches
    • Temporarily removed related options:
      • Disabled -sp, --select-push option
      • Disabled branch selection prompt
    • Planned future update with improved branch management logic

0.1.10

  • Enhanced Commit Functionality
    • Added File Selection Commit Feature (autopr commit -s)
      • Select specific files to commit from changed files
      • Interactive interface for file selection
    • Added File Selection with Auto-Push Feature (autopr commit -sp)
    • Added Branch Selection Push Feature (autopr commit -a)
      • Push to branches other than the current branch
      • Display remote branch status (remote/local only)
      • Support for creating and pushing new branches
      • Branch checkout options
    • Improved Remote Branch Status Management
      • Automatic detection of branches not existing on remote
      • Automatic -u option for new remote branches
      • Enhanced visual indication of branch status
  • Improved OpenRouter API Key Management
    • Added Automatic API Key Activation
      • Automatic status check when using AI features
      • Silent activation of disabled API keys
      • Background processing for improved user experience
    • On-demand API Key Status Checking
      • Status check every 60 minutes when using AI features
      • Efficient activation to prevent 401 errors
    • Development-mode API Key Management Commands
      • API key information retrieval and status management
      • Enhanced security for sensitive API key information
  • Enhanced AI Initialization and Performance
    • Optimized AI Instance Creation and Initialization
      • Strengthened duplicate initialization prevention
      • AI instance reuse within commands
      • Optimized memory usage
    • Improved API Key Status Check Logic
      • Prevented duplicate API calls through caching
      • Optimized status check frequency (5-minute cache)
    • Enhanced Logging
      • Prevented duplicate log outputs
      • Clarified debug/info level distinction
      • Optimized log messages for better user experience

0.1.9

  • Enhanced User Experience
    • Improved AI Output Visualization
      • Color-coded PR title/description generation
      • Enhanced visual distinction for commit message suggestions
    • Enhanced Log Level Distinction
      • Regular messages: cyan color
      • AI-generated content: white color (📝 symbol)
      • Section dividers: magenta color (=== symbol)
    • Improved Message Formatting
      • Enhanced readability with divider lines
      • Color emphasis for important information
  • Added Automatic Push for release/* Branches
    • Automatic push support during PR creation
    • Robust error handling
  • Improved Branch Strategy
    • Changed base branch configuration to use developmentBranch for all branches except release/*
    • Before: All branches used main as base
    • After: release/* → main, other branches → developmentBranch

0.1.8

  • Fixed AI initialization issues
    • Improved AI initialization process to ensure proper activation
    • Added initialization state management to prevent duplicate initialization
    • Enhanced error handling during AI initialization
    • Fixed OpenRouter configuration loading and validation
    • Added debug logging for AI initialization process
  • Enhanced AI feature reliability
    • Added proper error recovery for AI initialization failures
    • Improved state management for AI features
    • Added initialization promise handling to prevent race conditions
    • Enhanced configuration validation for AI providers

0.1.7

  • Enhanced commit message generation
    • Added full file path support in commit messages
    • Improved file tracking to prevent omissions
    • Enhanced commit message format consistency
    • Added comprehensive changed files list in commit analysis
  • Improved i18n support
    • Synchronized English and Korean translations
    • Enhanced error message consistency
    • Added missing translation keys

0.1.6

  • Added OpenRouter support as AI provider
    • Free Gemini Flash 2.0 model integration
    • Automatic API key and model configuration
    • Optimized token limits for OpenRouter
  • Enhanced commit message generation
    • Improved prompt structure for better clarity
    • Enhanced file change tracking to prevent omissions
    • Added bilingual support with English prompts and Korean output
    • Optimized system prompts for more consistent results
  • Improved i18n support
    • Added comprehensive i18n file tracking
    • Enhanced language-specific prompt handling
    • Improved translation consistency

0.1.5

  • Enhanced Draft PR availability check
    • Automatic detection of Draft PR availability based on repository visibility
    • Improved support for public/private repositories
  • Enhanced AI title generation
    • Added title generation process logging
    • Improved fallback logic for title generation failures
    • Enhanced debugging information