Skip to content

simonmittag/gh-pr-summarizer

gh-pr-summarizer

Opinionated CLI utility to generate pull request summaries from commit history and issue trackers.

Why it matters

Good PR summaries save time. They provide context that code alone cannot. By clearly stating the "Why", "What", and "How" of your PR, reviewers can quickly understand the context.

PR Structure

A generated summary follows an opinionated three-section format:

  • Why: The business or technical reason for the change, often linked to an issue tracker ticket.
  • What: A concise description of the functional changes, optionally generated by AI.
  • How: A bulleted list of the actual implementation steps derived from commit subjects.

Example Output

# Title
🚧 🐛 BUG/PROJ-123: Fix session timeout

# Why
Corrected user session timeout bug, see [PROJ-123](https://linear.app/my-org/issue/PROJ-123)

# What
Updated the session middleware to properly handle expiration timestamps and added a logout redirect for invalidated sessions.

# How
- [x] fix: session timeout calculation
- [x] feat: add redirect on session expiry
- [x] test: add regression test for session middleware

Features

  • Commit Summarization: Collects subjects between current and base branch.
  • Issue Tracker Integration: Fetches ticket details from Linear, GitHub, or Jira.
  • AI-Powered: Optional OpenAI integration for polished descriptions.
  • Configurable: Support for global and project-specific settings.

Installation

macOS (Homebrew)

brew tap simonmittag/cli && brew install simonmittag/cli/gh-pr-summarizer

From source (Go)

go install github.com/simonmittag/gh-pr-summarizer/cmd/gh-pr-summarizer@latest

Usage

Run from any git repository:

gh-pr-summarizer

Flags

  • --current <branch>: Override detected current branch.
  • --base <branch>: Override detected base branch (defaults to main/master).
  • --version: Show version.

Environment Variables

  • OPENAI_API_KEY: Enables AI-generated summaries.
  • GITHUB_TOKEN, LINEAR_API_KEY, ATLASSIAN_TOKEN: Defaults for Tracker authentication.
  • ATLASSIAN_EMAIL: (Optional) Your Atlassian email for Jira API basic auth.

Configuration

Hierarchical system: local .ghpr.toml overrides global ~/.config/gh-pr-summarizer/config.toml.

Example config.toml

tracker = "linear"

[linear]
ticket_url_stem = "https://linear.app/my-org/issue/"
token_env = "MY_CUSTOM_LINEAR_TOKEN_ENV" # Defaults to LINEAR_API_KEY

[github]
token_env = "GITHUB_TOKEN"

[jira]
ticket_url_stem = "https://my-org.atlassian.net/browse/"
token_env = "ATLASSIAN_TOKEN"
email_env = "ATLASSIAN_EMAIL" # Optional

Ticket Detection

Detects ticket IDs in branch names (e.g., feature/PROJ-123-add-login) to fetch context.

Contributing

Contributions are welcome. See CONTRIBUTING.md and our Code of Conduct.

License

Apache 2.0

About

Create GH PR summaries for your (linear|GH) issues from your commit history

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors