# Changelog ## v1.3.4 - December 7, 2025 ### Added * **Documentation Website:** Launched an official documentation website at [lazypr.raulcarini.dev](https://lazypr.raulcarini.dev) providing comprehensive guides, API references, and usage examples. ### Changed * **BREAKING: Default Branch:** Changed the default branch from `master` to `main` to align with modern Git conventions. Users who previously relied on `master` can restore it by running `lzp config set DEFAULT_BRANCH=master`. * **Documentation:** Improved and streamlined README content, enhancing feature descriptions, installation instructions, and usage guidance. *** ## v1.3.3 - December 2, 2025 ### Added * **Usage Examples:** Added comprehensive examples and configuration files demonstrating LazyPR usage, including CLI commands, GitHub Actions workflows, and multi-provider configuration setups to help users get started quickly. ### Changed * **Dependencies:** Updated core dependencies, including bumping the `ai` package version to `5.0.106`, updating the Biome schema to `2.3.8`, and performing general dependency upgrades for improved stability and compatibility. ### Fixed * **Error Handling:** Improved the `handleGitError` function to provide more robust and user-friendly error handling for Git-related failures. *** ## v1.3.2 - November 27, 2025 ### Added * **Code Quality:** Introduced Biome configuration for consistent linting and formatting across the codebase. * **CI/CD:** Added automated linting step to both npm-publish and test workflows to ensure code quality before execution. ### Changed * **Code Structure:** Reorganized import statements across multiple files for improved readability and maintainability. * **Test Improvements:** Enhanced test assertions to handle potential null values in label colors and refined parsing logic for configuration values. ### Fixed * **Configuration:** Updated Biome linting rules and improved configuration parsing logic for better reliability. *** ## v1.3.1 - November 26, 2025 ### Added * **Test Coverage:** Added comprehensive unit tests for the `config list` command to ensure proper functionality and output formatting. * **Test Coverage:** Added comprehensive unit tests for the `displayConfigBadge` function to validate configuration badge display across various scenarios. ### Changed * **Build Process:** Updated lzp script path in package.json to point to `dist/lzp.js` and added a postbuild script to generate the lzp.js file for improved build automation. * **CI/CD:** Removed the specified bun version from the npm-publish workflow for improved flexibility. ### Fixed * **PR Generation:** Included finish reason in pull request generation output for better debugging and transparency. * **Validation:** Updated title validation length constraints to improve generated PR title quality. *** ## v1.3.0 - November 24, 2025 ### Added * **Multi-Provider Support:** Introduced a flexible provider system allowing users to choose between different AI providers. The new `PROVIDER` configuration option supports switching providers seamlessly. * **Cerebras Provider:** Added Cerebras as a new AI provider option alongside Groq. Users can now leverage Cerebras' high-performance AI inference by setting `PROVIDER=cerebras` and configuring their `CEREBRAS_API_KEY`. * **Provider Configuration:** Added `CEREBRAS_API_KEY` configuration option for Cerebras authentication. ### Changed * **Model Flexibility:** Removed hardcoded model restrictions. The `MODEL` setting now accepts any model name supported by your chosen provider, giving users full flexibility. * **Default Model:** Changed the default model from `openai/gpt-oss-20b` to `llama-3.3-70b` which works well across multiple providers. * **Architecture Refactor:** Refactored the AI integration layer from `groq.ts` to a generic `provider.ts` module, enabling easy addition of future providers. ### Documentation * **README Update:** Updated documentation with multi-provider setup instructions, provider comparison table, and future provider roadmap. *** ## v1.2.7 - November 4, 2025 ### Fixed * **Critical Build Fix:** Fixed a misconfigured file that broke CLI commands in v1.2.6, restoring full functionality. The bin paths in package.json now correctly point to the bundled output. *** ## v1.2.6 - November 4, 2025 ### Added * **Config List Command:** Introduced a new `list` subcommand for configuration management, allowing users to view all current configuration settings with their statuses. Sensitive values (like API keys) are automatically masked for security. ### Fixed * **Build Size Optimization:** Resolved a build configuration issue that was duplicating files in the distribution bundle, which had doubled the package size. The build process now correctly generates a single, optimized output. ### Changed * **CI/CD Optimization:** Removed the build step from the npm publish workflow, streamlining the deployment process. * **Dependencies:** Updated project dependencies to their latest versions. *** ## v1.2.5 - October 24, 2025 ### Added * **Custom Context Option:** Introduced the ability for users to provide custom context to guide PR generation via the `--context` (`-c`) flag or the `CONTEXT` configuration key. This allows users to influence the tone, style, and structure of the generated PR content (e.g., "make it simple and cohesive", "be more technical"). Context is limited to 200 characters maximum. * **Context Badge Display:** Added context display to the configuration badge, providing visual confirmation when custom context is being used for PR generation. * **Context Validation:** Implemented comprehensive validation and testing for the new CONTEXT configuration option to ensure length constraints and proper integration. ### Changed * **Badge Refactor:** Refactored badge display logic to only show enabled settings, providing a cleaner and more focused configuration summary before PR generation. *** ## v1.2.4 - October 17, 2025 ### Added * **Model Badge:** Added model name display to the configuration badge shown before PR generation, providing better visibility of which AI model is being used. ### Changed * **Refactor:** Replaced `noFilter` option with clearer `filter` parameter for improved code clarity and consistency. * **Dependencies:** Updated dependencies to latest versions in package.json and bun.lock. ### Fixed * **CI/CD:** Corrected npm publish command in workflow to use `bunx` and removed redundant 'public' flag. * **CI/CD:** Updated npm publish workflow to include provenance flag and adjusted dependency installation. *** ## v1.2.3 - October 10, 2025 ### Fixed * **Testing & Code Alignment:** Addressed minor issues in test files and logic: * Replaced backtick strings with plain strings in tests and removed unnecessary imports (`mock` from `bun:test`). * Updated color access to use named constants (`LABEL_COLORS.bug`, etc.) instead of array indexing. * Corrected parameter usage when defaulting to the `DEFAULT_BRANCH` to align with the renamed `target` argument. ### Changed * **Performance:** Achieved a significant reduction in the overall package size from **526 KB to 370 KB**, representing a **35% reduction**. * **Dependencies:** Bumped the versions for the `ai` and `zod` dependencies. * **Internal Refactor:** Cleaned up and improved the internal parsing and error handling logic within utility files. *** ## v1.2.2 - October 6, 2025 ### Note * **Re-release:** This version is a direct re-publication of the changes introduced in v1.2.1. It was released to resolve a distribution issue with the v1.2.1 package on the npm registry. No new code changes were introduced in this release. *** ## v1.2.1 - October 6, 2025 ### Security * **Prevented Command Injection (Git):** Patched a potential command injection vulnerability by replacing all instances of the insecure `child_process.exec` with the safer `child_process.execFile` for executing Git commands, fully eliminating the reliance on shell interpretation. ### Fixed * **Template Hashing Reliability:** Improved template content hashing to significantly reduce collisions. The new hash now uses a multi-part strategy combining the total length and specific content slices (first 200, middle 100, and last 100 characters). * **Config Exit Code:** The CLI now correctly exits with a non-zero status code (`1`) when a configuration error occurs, ensuring better pipeline and script integration. ### Changed * **Project Maintenance:** Updated project metadata (`description`, `author`) in `package.json` and removed deprecated scripts. * **Documentation:** Updated the README to reflect the current test and CI setup and removed the obsolete section detailing the standalone binary build process. *** ## v1.2.0 - October 5, 2025 ### Added * **GitHub CLI Integration:** Introduced the `--gh` flag to automatically generate a complete `gh pr create` command using the AI-generated title, description, and labels. This command is then copied to the clipboard, streamlining the process for users who deploy PRs with the GitHub CLI. * **Smart Commit Filtering:** Implemented intelligent commit filtering to improve the quality of AI-generated content. * Commits deemed low-value (e.g., `docs:`, `test:`, `chore:`) are now excluded from the prompt sent to the AI. * Added the `FILTER_COMMITS` configuration option (default `true`) and the `--no-filter` CLI flag to disable this feature. * **Pull Request Label Management:** The AI is now capable of suggesting and generating a core set of labels (`enhancement`, `bug`, `documentation`) based on the changes in the commits, which are included in the generated output and the new `gh pr create` command. * **Enhanced Visuals & UX:** Improved the command-line user experience with colorization for intro banner, branch names, and PR labels. ### Changed * **PR Message Formatting:** Removed emojis from the AI-generated Pull Request titles and descriptions. Added a standard "Review Reminder" boilerplate to the bottom of the generated PR message. * **CI/CD:** Updated the NPM publish script to include a mandatory test step and removed the push-based trigger from the pipeline. *** ## v1.1.0 - October 2, 2025 ### Added * **Pull Request Template Integration:** Implemented full support for standard Git repository templates (`PULL_REQUEST_TEMPLATE.md`). The AI now automatically detects and uses the structure and content of this template to format the generated PR description, allowing users to enforce consistent and custom documentation standards. ([#7](https://github.com/R4ULtv/lazypr/pull/7)) * **AI Usage Reporting:** Introduced transparent API token usage reporting. After the PR is successfully generated, the CLI now displays the total number of prompt tokens and completion tokens consumed, providing users with better visibility into API costs. ([#8](https://github.com/R4ULtv/lazypr/pull/8)) * **Multilingual Support (Locale Flag):** Added the optional `--locale` (`-l`) flag to the main command. This allows users to explicitly request that the AI generate the PR title and description in a specified language (e.g., Italian, Spanish, German), enabling localized output. ([#9](https://github.com/R4ULtv/lazypr/pull/9)) ### Security * **Prevented Command Injection:** Patched a security vulnerability by replacing the insecure `child_process.exec` with `child_process.execFile` in the `getPullRequestCommits` function. This prevents shell interpretation of commands, mitigating potential command injection risks. ([e108786](https://github.com/R4ULtv/lazypr/commit/e108786)) *** ## v1.0.4 - September 30, 2025 ### Added * **Comprehensive Test Suite:** Introduced a comprehensive test suite (Bun) for core utilities and CLI commands, covering configuration parsing, Git helpers, information utilities, and GROQ PR generation logic. This significantly improves code reliability and prevents future regressions. ([#6](https://github.com/R4ULtv/lazypr/pull/6)) ### Fixed * **PR Fetch Reliability:** Updated the pull request commit fetching logic to gracefully handle Git errors (such as a non-existent target branch) by returning an empty array instead of throwing an error. This prevents unexpected crashes during PR generation. ([30edcdf](https://github.com/R4ULtv/lazypr/commit/30edcdf)) *** ## v1.0.3 - September 29, 2025 ### Added * **Config Remove Option:** Added the `remove` subcommand to the `config` command, allowing users to easily delete a configured key from the `.lazypr` file. ([e1c5318](https://github.com/R4ULtv/lazypr/commit/e1c5318)) ### Changed * **UX/Dependency Migration:** Migrated the entire interactive prompt system from legacy libraries to `@clack/prompts` for a modern, consistent, and performant command-line user experience. ([#5](https://github.com/R4ULtv/lazypr/pull/5)) * Performance: This migration resulted in a reduction of the overall package bundle size by approximately 5% (from 545 KB to 517 KB). * Implemented the Clack timer spinner for real-time feedback during long operations. *** ## v1.0.2 - September 28, 2025 ### Changed * **PR Description Quality:** Increased the minimum length requirement for the generated Pull Request description to 100 characters. This enforces a higher standard of detail and quality for the AI-generated content. *** ## v1.0.1 - September 28, 2025 ### Added * **Custom Model Config:** Introduced a new `MODEL` configuration option in the config file (`.lazypr`). This allows users to specify and use custom large language models (LLMs) for pull request generation. ([#3](https://github.com/R4ULtv/lazypr/pull/3)) *** ## v1.0.0 - September 27, 2025 Initial public release of LazyPR. ### Added * **Core Functionality:** Initial project setup, command-line interface (CLI) structure, and core functionality for generating Pull Request titles and descriptions from Git commit history using AI. # Installation import { Tabs, Tab } from 'fumadocs-ui/components/tabs'; import { Callout } from 'fumadocs-ui/components/callout'; ## Prerequisites LazyPR requires **Node.js version 20 or higher**. Check your version: ```bash node --version ``` If you need to update Node.js, visit [nodejs.org](https://nodejs.org). ## Install LazyPR Install LazyPR globally using your preferred package manager: ```bash npm install -g lazypr ``` ```bash pnpm add -g lazypr ``` ```bash yarn global add lazypr ``` ```bash bun add -g lazypr ``` ## Verify Installation Confirm LazyPR is installed correctly: ```bash lazypr --version ``` You can also use the shorter alias: ```bash lzp --version ``` ## First-Time Setup Before generating your first PR, configure your AI provider API key. LazyPR uses Groq by default: ```bash lazypr config set GROQ_API_KEY=your_api_key_here ``` Get your free Groq API key at [console.groq.com](https://console.groq.com). You're now ready to generate your first PR! Continue to the [Quick Start](/docs/quick-start) guide. # Quick Start import { Card, Cards } from 'fumadocs-ui/components/card'; import { Steps, Step } from 'fumadocs-ui/components/steps'; import { Callout } from 'fumadocs-ui/components/callout'; ## What is LazyPR? LazyPR is a command-line tool that analyzes your git commits and uses AI to generate professional pull request titles and descriptions. Say goodbye to writing PR descriptions manually - let AI do the heavy lifting. npm pnpm yarn bun ```bash npm install -g lazypr ``` ```bash pnpm add -g lazypr ``` ```bash yarn global add lazypr ``` ```bash bun add --global lazypr ``` ## Key Features * **AI-Powered Generation**: Leverages Groq and Cerebras AI to create clear, consistent PR content * **Smart Commit Filtering**: Automatically excludes merge commits, dependency updates, and formatting changes * **Multi-Language Support**: Generate PRs in 13 different languages * **GitHub CLI Integration**: Create pull requests directly with the `--gh` flag * **Template Support**: Works seamlessly with your existing PR templates ## Quick Start Get your first AI-generated PR in seconds: ```bash # Configure your API key lazypr config set GROQ_API_KEY=your_key_here # Generate PR content lazypr main ``` Use the short alias `lzp` instead of `lazypr` for faster typing. ## Your First PR Generation Follow these steps to create your first AI-generated pull request: ### Navigate to Your Git Repository Open your terminal and navigate to a git repository with a feature branch: ```bash cd your-project git checkout your-feature-branch ``` ### Run LazyPR Generate PR content by specifying your target branch (usually `main` or `master`): ```bash lazypr main ``` LazyPR will analyze all commits unique to your current branch. ### Review the Generated Content LazyPR will display: * A concise, professional PR title * A markdown-formatted description with bullet points * Summary of changes based on your commits ### Copy to Clipboard An interactive menu appears with options: * **Copy title**: Copy just the PR title * **Copy description**: Copy just the description * **Copy both**: Copy title and description together * **Exit**: Close without copying Use arrow keys to select and press Enter. ## Example Output When you run `lazypr main`, you'll see output like this: ``` Analyzing commits... Found 5 commits ahead of main Generated PR Content: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ feat: Add user authentication with OAuth support ## Changes - Implement OAuth 2.0 authentication flow - Add user session management - Create login and logout endpoints - Add JWT token generation and validation ## Testing Tested OAuth flow with Google and GitHub providers ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ? What would you like to copy? ❯ Copy title Copy description Copy both Exit ``` ## Default Target Branch If you don't specify a target branch, LazyPR defaults to `main`: ```bash lazypr # same as: lazypr main ``` ## Next Steps Now that you've generated your first PR, explore more features: * [Configure settings](/docs/config/settings) to customize behavior * [Use templates](/docs/usage/templates) for consistent PR formatting * [Try GitHub integration](/docs/usage/github-integration) to create PRs directly ## Explore the Docs # What is LazyPR? import { Callout } from 'fumadocs-ui/components/callout'; ## Overview LazyPR is a command-line tool that automatically generates professional pull request titles and descriptions by analyzing your git commits using AI. It eliminates the tedious task of writing PR descriptions manually, saving time while maintaining consistency and quality. ## The Problem Writing good pull requests is time-consuming: * **Manual effort**: Developers spend 5-10 minutes per PR summarizing changes * **Inconsistent quality**: PR descriptions vary wildly between team members * **Context switching**: Breaking coding flow to write documentation * **Repetitive work**: Explaining the same commits you already wrote ## The Solution LazyPR automates PR creation in seconds: ```bash lazypr main ``` That's it. LazyPR analyzes your commits, understands the changes, and generates a professional PR with: * A clear, concise title following conventional commits * Structured description with bullet points * Testing information derived from your commits * Proper formatting ready to paste into GitHub ## How It Works 1. **Analyze Commits**: LazyPR reads all commits between your feature branch and target branch 2. **Smart Filtering**: Automatically excludes merge commits, dependency updates, and noise 3. **AI Generation**: Sends commit data to your chosen AI provider (Groq, Cerebras) 4. **Professional Output**: Receives a formatted PR title and description 5. **Easy Copy**: Interactive menu to copy to clipboard or create PR directly ## Key Benefits ### Save Time Generate PRs in **10-15 seconds** instead of 5-10 minutes. For teams creating multiple PRs daily, that's hours saved per week. ### Consistent Quality Every PR follows the same professional format, making code reviews faster and more efficient. ### Team Collaboration International teams can generate PRs in 13 different languages while maintaining the same structure. ### Focus on Coding Spend less time documenting and more time building. LazyPR handles the PR writing so you can stay in flow. ## Who Uses LazyPR? **Individual Developers**: Save time and create professional PRs effortlessly. **Development Teams**: Standardize PR quality across the team with templates and shared configuration. **Open Source Projects**: Help contributors create consistent, high-quality PRs regardless of their experience level. **International Teams**: Generate PRs in each developer's native language while maintaining consistency. ## Features at a Glance * **Multi-Provider Support**: Choose between Groq and Cerebras AI providers * **Smart Filtering**: Excludes irrelevant commits automatically * **Template Support**: Works with your existing `.github` PR templates * **Multilingual**: Generate PRs in 13 languages * **GitHub Integration**: Create PRs directly with `gh` CLI integration * **Customizable**: Add context guidance to match your team's style * **Fast**: Most PRs generated in 1-3 seconds LazyPR is free and open source. Get started in under 2 minutes. ## Example Output **Your commits**: ``` feat: implement OAuth flow feat: add JWT tokens fix: handle token expiration test: add auth tests ``` **Generated PR**: ``` feat: Implement OAuth 2.0 authentication ## Changes - Implement OAuth 2.0 authorization flow - Add JWT token generation and validation - Handle token expiration gracefully - Add comprehensive authentication tests ## Testing Unit and integration tests added for auth flow Manual testing with Google and GitHub providers ``` Clean, professional, and ready to submit. ## Getting Started Ready to transform your PR workflow? 1. [Install LazyPR](/docs/installation) in under 1 minute 2. [Create your first PR](/docs/quick-start) in seconds 3. [Configure providers](/docs/config/providers) to match your needs LazyPR is actively maintained and open source. Contributions welcome on [GitHub](https://github.com/R4ULtv/lazypr)! # Commit Filtering import { Callout } from 'fumadocs-ui/components/callout'; ## What is Commit Filtering? Commit filtering is LazyPR's intelligent feature that automatically excludes noise from your PR descriptions. It analyzes commit messages and patterns to focus on meaningful changes. ## What Gets Filtered? By default, LazyPR excludes: ### Merge Commits ``` Merge branch 'main' into feature-branch Merge pull request #123 from user/branch ``` Merge commits add no meaningful information about your changes. ### Dependency Updates ``` chore: update dependencies chore: bump package.json versions build: upgrade eslint to 8.0.0 ``` Version bumps and dependency updates clutter PR descriptions without adding context about your work. ### Formatting Changes ``` style: fix linting errors style: run prettier chore: format code ``` Code formatting and style fixes don't represent functional changes. ### Build and CI Changes ``` ci: update GitHub Actions workflow build: modify webpack config ``` Infrastructure changes are often less important than feature work. ## Why Filter? **Cleaner Descriptions**: Focus on what matters - your actual feature work and bug fixes. **Better AI Output**: Filtering helps the AI generate more focused, relevant descriptions. **Reduced Token Usage**: Fewer commits mean fewer tokens consumed and faster generation. **Professional PRs**: Your PRs highlight important changes, not noise. ## Disabling Filtering Sometimes you want to include all commits: ### Per-Run Disable Use the `--no-filter` flag: ```bash lazypr main --no-filter ``` This includes all commits for this single run. ### Global Disable Turn off filtering permanently: ```bash lazypr config set FILTER_COMMITS=false ``` Re-enable anytime: ```bash lazypr config set FILTER_COMMITS=true ``` Disabling filtering may result in verbose, cluttered PR descriptions. Use sparingly. ## When to Disable Filtering Consider disabling filtering when: **Dependency update PRs**: If the PR is specifically about dependency updates: ```bash lazypr main --no-filter ``` **Infrastructure changes**: When build/CI modifications are the main focus. **Small refactors**: When formatting or style changes are the primary work. **Debugging**: To see exactly which commits are being analyzed. ## How Filtering Works LazyPR uses pattern matching on commit messages to identify filtered commits. It looks for: 1. **Keywords**: merge, dependency, deps, bump, format, prettier, eslint, ci, build 2. **Patterns**: Version numbers, package names, automated commit signatures 3. **Conventional commits**: Specific types like `chore:`, `style:`, `build:`, `ci:` ## Example: Filtered vs Unfiltered **Commits in branch**: ``` feat: add user authentication fix: resolve login redirect bug chore: update dependencies Merge branch 'main' into feature style: format auth module test: add auth integration tests ``` **With filtering** (default): ``` LazyPR analyzes: - feat: add user authentication - fix: resolve login redirect bug - test: add auth integration tests ``` **Without filtering** (`--no-filter`): ``` LazyPR analyzes all 6 commits including: - chore: update dependencies - Merge branch 'main' into feature - style: format auth module ``` ## Smart Filtering LazyPR's filtering is smart enough to: * Preserve important chore commits that add significant value * Include dependency updates if they fix security issues * Keep formatting commits if they're part of a larger refactor The AI considers context, not just keywords. ## Custom Filtering Logic Currently, LazyPR doesn't support custom filtering rules. The built-in logic covers most common cases. If you need specific commits excluded, consider: 1. Using `--no-filter` and manually editing the output 2. Structuring commit messages to match filtering patterns 3. Creating separate branches for filtered vs. important commits ## Best Practices ### Write Clear Commit Messages Use conventional commits to help filtering work effectively: ```bash # Will be included feat: add login feature fix: resolve security bug # Will be filtered chore: update packages style: run formatter ``` ### Separate Concerns Keep infrastructure and feature work in separate branches when possible: ```bash # Feature branch - filtering works great git checkout -b feature/auth [make feature commits] # Separate dependency update branch git checkout -b chore/deps [update dependencies] ``` ### Review Before Submitting Always review the generated PR description. If important commits were filtered, regenerate with `--no-filter` and manually edit. Filtering is enabled by default because it produces better results 95% of the time. Disable only when needed. # Context Guidance import { Callout } from 'fumadocs-ui/components/callout'; ## What is Context? Context is custom style guidance you provide to influence how LazyPR generates PR descriptions. It's like giving the AI a "personality" or "instructions" for writing PRs. Maximum length: **200 characters** ## Setting Global Context Configure context that applies to all PR generations: ```bash lazypr config set CONTEXT="Use conventional commits format and keep descriptions concise" ``` Every time you run `lazypr`, this guidance influences the output. ## Per-Run Context Override global context for a single generation: ```bash lazypr main -c "Focus on security improvements" lazypr main -c "Emphasize performance benefits" lazypr main -c "Keep it brief, max 3 bullet points" ``` Per-run context takes precedence over global context. ## Effective Context Examples ### Focus on Style ```bash # Concise, bullet-point style lazypr main -c "Keep descriptions concise with bullet points" # Detailed explanations lazypr main -c "Provide detailed explanations for each change" # Technical focus lazypr main -c "Use technical terminology and avoid simplification" ``` ### Emphasize Specific Aspects ```bash # Business value lazypr main -c "Emphasize business value and user impact" # Technical implementation lazypr main -c "Focus on technical implementation details" # Testing and quality lazypr main -c "Highlight testing approach and quality improvements" ``` ### Audience-Specific ```bash # Non-technical stakeholders lazypr main -c "Write for non-technical stakeholders" # Senior developers lazypr main -c "Assume senior developer audience" # Product managers lazypr main -c "Focus on product features and user value" ``` ### Team Standards ```bash # Conventional commits lazypr main -c "Follow conventional commits specification" # Include ticket numbers lazypr main -c "Reference ticket numbers and user stories" # Testing requirements lazypr main -c "Always mention testing strategy" ``` ## Context Best Practices ### Be Specific **Good** (specific): ```bash "Focus on security improvements and mention any vulnerabilities addressed" ``` **Less effective** (vague): ```bash "Make it good" ``` ### Keep It Short Remember the 200-character limit. Be concise: **Good** (concise): ```bash "Emphasize performance gains and include metrics" ``` **Too long**: ```bash "I want you to really emphasize the performance gains we've made and include specific metrics wherever possible and also mention any trade-offs we had to make and explain the reasoning behind technical decisions" ``` ### Match Your Team's Voice Analyze your team's existing PRs and create context that matches: ```bash # Formal, corporate lazypr main -c "Professional tone, formal language" # Casual, startup lazypr main -c "Casual tone, focus on impact" # Technical, open-source lazypr main -c "Technical detail, community-friendly" ``` Great context guidance aligns AI output with your team's existing PR style and standards. ## Examples with Output ### Without Context ```bash lazypr main ``` **Output**: ```markdown feat: Add user authentication ## Changes - Implement OAuth 2.0 authentication flow - Add JWT token management - Create login and logout endpoints - Add session persistence ``` ### With "Keep it brief" Context ```bash lazypr main -c "Keep descriptions very brief, max 3 points" ``` **Output**: ```markdown feat: Add user authentication ## Changes - Implement OAuth 2.0 flow - Add JWT token management - Create authentication endpoints ``` ### With "Business focus" Context ```bash lazypr main -c "Emphasize business value and user impact" ``` **Output**: ```markdown feat: Add user authentication ## Changes - Enable secure user login via OAuth 2.0, improving security and user trust - Implement session management for seamless user experience - Support multiple OAuth providers, increasing user convenience ## Impact Provides enterprise-grade security while reducing friction in the login process. ``` ### With "Technical detail" Context ```bash lazypr main -c "Include technical implementation details" ``` **Output**: ```markdown feat: Add user authentication ## Changes - Implement OAuth 2.0 authorization code flow with PKCE - Add JWT token generation using RS256 algorithm - Create RESTful endpoints: POST /auth/login, POST /auth/logout - Implement Redis-based session store with 24h TTL ``` ## Common Use Cases ### Security PRs ```bash lazypr main -c "Highlight security improvements and vulnerabilities fixed" ``` ### Performance PRs ```bash lazypr main -c "Focus on performance gains with specific metrics" ``` ### Refactoring PRs ```bash lazypr main -c "Explain refactoring rationale and benefits" ``` ### Bug Fix PRs ```bash lazypr main -c "Describe the bug, root cause, and fix approach" ``` ## Combining with Other Features Context works alongside other LazyPR features: ```bash # Context + Template + Language lazypr main --template -l es -c "Enfoque en seguridad" # Context + GitHub CLI + Token usage lazypr main --gh -c "Keep it brief" -u ``` ## Managing Context ### View Current Context ```bash lazypr config get CONTEXT ``` ### Clear Context Remove global context: ```bash lazypr config set CONTEXT="" ``` Or just use per-run context to override: ```bash lazypr main -c "Different guidance for this PR" ``` ## Limitations **Character limit**: 200 characters maximum. LazyPR truncates longer context. **Not instructions**: Context is guidance, not strict instructions. The AI interprets context creatively. **Commit-dependent**: Output quality still depends on your commit messages. Great context can't fix vague commits. Context influences but doesn't guarantee specific output. Review and edit generated PRs as needed. ## Tips for Success 1. **Experiment**: Try different context styles to see what works for your team 2. **Iterate**: Refine your context based on results 3. **Be consistent**: Use similar context for similar types of PRs 4. **Combine approaches**: Use global context for team standards, per-run for special cases 5. **Document**: Share effective context examples with your team ## Troubleshooting **Context not working**: Ensure your context is clear and specific. Vague guidance produces minimal change. **Output too different**: Your context may be too prescriptive. Try more general guidance. **Character limit**: If truncated, prioritize the most important guidance first. # Multilingual Support import { Callout } from 'fumadocs-ui/components/callout'; ## Supported Languages LazyPR can generate pull request descriptions in 13 languages: | Code | Language | Native Name | Flag | | ---- | ---------- | ----------- | ---- | | `en` | English | English | 🇬🇧 | | `es` | Spanish | Español | 🇪🇸 | | `pt` | Portuguese | Português | 🇵🇹 | | `fr` | French | Français | 🇫🇷 | | `de` | German | Deutsch | 🇩🇪 | | `it` | Italian | Italiano | 🇮🇹 | | `ja` | Japanese | 日本語 | 🇯🇵 | | `ko` | Korean | 한국어 | 🇰🇷 | | `zh` | Chinese | 中文 | 🇨🇳 | | `ru` | Russian | Русский | 🇷🇺 | | `nl` | Dutch | Nederlands | 🇳🇱 | | `pl` | Polish | Polski | 🇵🇱 | | `tr` | Turkish | Türkçe | 🇹🇷 | **Default language**: English (`en`) ## Setting Default Language Configure your preferred language globally: ```bash lazypr config set LOCALE=es # Spanish lazypr config set LOCALE=ja # Japanese lazypr config set LOCALE=de # German ``` All subsequent PR generations will use your configured language: ```bash lazypr main # Uses your configured locale ``` ## One-Time Language Override Generate a PR in a different language without changing your config: ```bash lazypr main -l fr # French for this run only lazypr main -l zh # Chinese for this run only ``` This is useful when: * Working on international projects * Collaborating with non-native speakers * Creating PRs for specific regional teams ## Example Outputs ### English (en) ```markdown feat: Add user authentication ## Changes - Implement OAuth 2.0 authentication flow - Add JWT token management - Create login and logout endpoints ``` ### Spanish (es) ```markdown feat: Agregar autenticación de usuario ## Cambios - Implementar flujo de autenticación OAuth 2.0 - Agregar gestión de tokens JWT - Crear endpoints de inicio y cierre de sesión ``` ### Japanese (ja) ```markdown feat: ユーザー認証を追加 ## 変更内容 - OAuth 2.0認証フローの実装 - JWTトークン管理の追加 - ログイン・ログアウトエンドポイントの作成 ``` ### French (fr) ```markdown feat: Ajouter l'authentification utilisateur ## Modifications - Implémenter le flux d'authentification OAuth 2.0 - Ajouter la gestion des tokens JWT - Créer les endpoints de connexion et déconnexion ``` ## Use Cases ### International Teams Teams distributed across regions can use their preferred language: ```bash # Developer in Spain lazypr config set LOCALE=es # Developer in Japan lazypr config set LOCALE=ja # Developer in Germany lazypr config set LOCALE=de ``` Everyone works in their native language, improving clarity and reducing miscommunication. ### Localized Projects Projects with language-specific branches or repositories: ```bash # Feature for English market git checkout feature/us-payments lazypr main -l en # Feature for Japanese market git checkout feature/jp-payments lazypr main -l ja ``` ### Learning and Documentation Non-native English speakers can read and understand PR descriptions in their language, accelerating onboarding and collaboration. ## Best Practices ### Be Consistent Pick a language for your project and stick to it. Mixed-language PRs can be confusing: **Good** (consistent): ``` All PRs in English All PRs in Spanish ``` **Confusing** (mixed): ``` Some PRs in English, some in French ``` ### Consider Your Audience Choose the language your reviewers and stakeholders understand best. If your team is international but uses English, stick with English. ### Use Context for Better Results Adding context in the target language can improve output quality: ```bash lazypr main -l es -c "Enfocarse en cambios de seguridad" ``` ### Conventional Commit Titles Keep commit prefixes (`feat:`, `fix:`) in English even when descriptions are in other languages. This maintains compatibility with tooling: ```markdown # Good feat: Añadir autenticación de usuario # Less compatible with tooling característica: Añadir autenticación de usuario ``` LazyPR will automatically use English conventional commit prefixes in titles even when the description is in another language. ## Limitations **Code examples**: Code snippets, variable names, and technical terms remain in their original language/format. Only descriptive text is translated. **Quality varies**: Output quality for less common languages may vary. English and major European/Asian languages typically produce excellent results. **Context understanding**: The AI understands commit messages in any language but works best when commits are in English or the target language. ## Troubleshooting **Strange characters**: Ensure your terminal supports UTF-8 encoding for proper display of non-Latin characters. **Poor translation quality**: Try being more explicit in commit messages or adding context with the `-c` flag. **Language not working**: Verify you're using the correct language code from the supported list above. ## Checking Current Language View your configured language: ```bash lazypr config get LOCALE ``` If not set, LazyPR defaults to English (`en`). # AI Providers import { Callout } from 'fumadocs-ui/components/callout'; import { Tabs, Tab } from 'fumadocs-ui/components/tabs'; ## Overview LazyPR uses AI providers to analyze your commits and generate professional PR descriptions. Choose the provider that best fits your needs based on speed, cost, and availability. ## Provider Comparison | Provider | Speed | Free Tier | Reliability | Model Options | Setup | Status | | ------------------ | ----------------- | ------------ | ----------- | -------------------- | ------ | ----------- | | Groq (Default) | Fast (1-3s) | Generous | High | Multiple | Easy | ✅ Available | | Cerebras | Ultra-fast (\<1s) | Varies | High | Multiple | Easy | ✅ Available | | OpenAI | Fast (2-4s) | Limited | High | GPT-5 Pro, Mini | Easy | 🚧 Soon | | Anthropic (Claude) | Fast (2-4s) | Limited | High | Opus, Sonnet, Haiku | Easy | 🚧 Soon | | Google AI (Gemini) | Fast (2-4s) | Generous | High | Gemini Pro, Flash | Easy | 🚧 Soon | | Ollama | Variable | Free (Local) | High | Llama, Mistral, etc. | Medium | 🚧 Soon | | LM Studio | Variable | Free (Local) | High | Various quantized | Medium | 🚧 Soon | Want to see a specific provider added sooner? Let us know on [GitHub](https://github.com/R4ULtv/lazypr/issues)! ## Getting Started ### Setting Up Groq (Default) #### Get Your API Key 1. Visit [console.groq.com](https://console.groq.com) 2. Sign up or log in to your account 3. Navigate to API Keys section 4. Create a new API key #### Configure LazyPR ```bash lazypr config set GROQ_API_KEY=gsk_your_api_key_here ``` Groq offers generous free tier limits, perfect for getting started. ### Setting Up Cerebras #### Get Your API Key 1. Visit the Cerebras platform 2. Create an account and generate an API key #### Configure LazyPR ```bash # Set the API key lazypr config set CEREBRAS_API_KEY=your_cerebras_key_here # Switch to Cerebras provider lazypr config set PROVIDER=cerebras ``` ## Switching Providers Change between providers anytime: ```bash lazypr config set PROVIDER=groq ``` ```bash lazypr config set PROVIDER=cerebras ``` Don't forget to set the appropriate API key for your chosen provider (see Getting Started section above). ## Model Selection Configure which AI model to use: ```bash lazypr config set MODEL=llama-3.3-70b ``` **Default model**: `llama-3.3-70b` Different providers support different models. Check your provider's documentation for available options. The default model provides an excellent balance of quality and speed for PR generation. ## Token Usage Tracking Monitor how many tokens your requests consume with the `-u` flag: ```bash lazypr main -u ``` **Output**: ``` Generated PR Content ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ [PR content here] ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Token Usage: 347 tokens ``` This helps you: * Track API costs * Optimize commit message lengths * Stay within rate limits ## Performance Considerations ### Response Time Both providers typically respond in 1-3 seconds for standard PRs. Response time depends on: * Number of commits * Commit message length * Provider load * Network latency ### Quality vs Speed The default model (`llama-3.3-70b`) balances quality and speed. If you need faster responses and don't mind slightly shorter descriptions, you might experiment with smaller models (if your provider supports them). ### Rate Limits Each provider has rate limits: * **Free tiers**: Typically sufficient for individual developers (dozens of PRs per day) * **Paid tiers**: Higher limits for teams and heavy users Check your provider's documentation for specific limits. ## Cost Optimization ### Use Commit Filtering Enable filtering to reduce token usage by excluding irrelevant commits: ```bash lazypr config set FILTER_COMMITS=true # Default ``` Learn more in the [Commit Filtering](/docs/advanced/commit-filtering) guide. ### Write Concise Commit Messages Shorter, clearer commit messages consume fewer tokens while maintaining quality: **Good** (concise): ``` feat: add OAuth login ``` **Less optimal** (verbose): ``` feat: implemented a complete OAuth 2.0 authentication system with support for multiple providers including detailed error handling and logging ``` ### Track Usage Regularly use the `-u` flag to monitor consumption and adjust your usage patterns. ## Troubleshooting **Invalid API Key Error**: Double-check your key is correctly copied and hasn't expired. Generate a new key from your provider's console if needed. **Rate Limiting**: Free tier accounts may have usage limits. Upgrade your plan or wait for the limit to reset. **Slow responses**: Check your network connection. If persistent, try switching providers. **Model not found**: Verify the model name is correct for your chosen provider. Reset to default with: ```bash lazypr config set MODEL=llama-3.3-70b ``` # Settings import { Callout } from 'fumadocs-ui/components/callout'; ## Configuration Options LazyPR stores all settings in `~/.lazypr`. You can modify settings using the config command: ```bash lazypr config set SETTING_NAME=value ``` ## Available Settings ### PROVIDER The AI provider to use for generating PR content. * **Values**: `groq` or `cerebras` * **Default**: `groq` ```bash lazypr config set PROVIDER=groq ``` ### LOCALE Default language for generated PR content. * **Default**: `en` (English) * **Supported**: en, es, pt, fr, de, it, ja, ko, zh, ru, nl, pl, tr ```bash lazypr config set LOCALE=es ``` You can override the locale for a single run using the `-l` flag. ### MODEL The AI model to use for generation. * **Default**: `llama-3.3-70b` * **Provider-specific**: Check your provider's documentation for available models ```bash lazypr config set MODEL=llama-3.3-70b ``` ### MAX\_RETRIES Number of retry attempts if a request fails. * **Default**: `2` * **Range**: 0-5 ```bash lazypr config set MAX_RETRIES=3 ``` ### TIMEOUT Request timeout in milliseconds. * **Default**: `10000` (10 seconds) ```bash lazypr config set TIMEOUT=15000 ``` ### FILTER\_COMMITS Enable or disable automatic commit filtering. * **Default**: `true` * **Values**: `true` or `false` When enabled, LazyPR excludes merge commits, dependency updates, and formatting-only changes. ```bash lazypr config set FILTER_COMMITS=false ``` ### CONTEXT Global style guidance for PR generation (max 200 characters). * **Default**: None * **Example**: "Use conventional commits format and keep descriptions concise" ```bash lazypr config set CONTEXT="Focus on business impact in descriptions" ``` Context helps AI tailor the PR style to your team's preferences. ## Managing Configuration ### View All Settings ```bash lazypr config list ``` ### View Specific Setting ```bash lazypr config get LOCALE ``` ### Reset to Defaults Delete the configuration file to reset all settings: ```bash rm ~/.lazypr ``` Then reconfigure your API key: ```bash lazypr config set GROQ_API_KEY=your_key_here ``` ## Environment-Specific Configurations You can maintain different configurations for different projects or environments by: 1. Storing project-specific settings in a script 2. Setting values before running LazyPR ```bash # Example: Use Spanish for international team lazypr config set LOCALE=es lazypr main # Then switch back lazypr config set LOCALE=en ``` Or use command-line flags for one-time overrides without changing stored config: ```bash lazypr main -l es -c "Keep it brief" ``` # CLI Usage import { Callout } from 'fumadocs-ui/components/callout'; import { Tab, Tabs } from 'fumadocs-ui/components/tabs'; ## Basic Usage The simplest way to use LazyPR is to run it in your repository: ```bash lazypr ``` This analyzes commits between your current branch and main, generates a professional title and description, and offers to copy the result to your clipboard. ### Branch Targeting Specify a different target branch to compare against: ```bash lazypr develop # Compare against develop lazypr production # Compare against production lazypr release-v2 # Compare against release branch ``` ### Using PR Templates LazyPR automatically searches for templates in standard locations: * `.github/pull_request_template.md` * `.github/PULL_REQUEST_TEMPLATE/` Enable template usage with the `--template` flag: ```bash lazypr main --template ``` If multiple templates exist, LazyPR shows an interactive selector. ## Common Workflows Generate and copy to clipboard immediately: ```bash lazypr main # Select "Copy to clipboard" when prompted ``` Save to a file for review before using: ```bash lazypr main > pr-description.txt # Review and edit pr-description.txt # Then create PR manually ``` Create a git alias for faster access: ```bash git config --global alias.pr '!lazypr' # Now use: git pr main ``` ## Advanced Options ### Commit Filtering By default, LazyPR filters out merge commits, dependency updates, and formatting changes to focus on meaningful content: ```bash # Include all commits without filtering lazypr main --no-filter ``` ### Locale Support Generate PR descriptions in multiple languages: ```bash lazypr main -l es # Spanish lazypr main -l fr # French lazypr main -l ja # Japanese lazypr main -l de # German lazypr main -l zh # Chinese lazypr main -l pt # Portuguese lazypr main -l ru # Russian lazypr main -l ko # Korean ``` ### Custom Models Switch between providers and models for different use cases: ```bash # Default model lazypr main --provider groq # Specify model lazypr config set MODEL=llama-3.3-70b-versatile lazypr config set MODEL=llama-3.1-8b-instant # Faster ``` ```bash lazypr main --provider cerebras ``` ### Adding Context Guide the AI with additional context about your PR: ```bash # Explain the purpose lazypr main -c "This PR fixes a critical security vulnerability" # Note breaking changes lazypr main -c "Breaking change: API v1 is deprecated" # Specify audience lazypr main -c "Written for external contributors" ``` Context is limited to 200 characters. Use it for high-level guidance. ## Scripting & Automation ### Output Redirection Save output directly to a file: ```bash lazypr main > pr.txt ``` ### Conditional Generation Only generate if there are commits to process: ```bash if git log main..HEAD --oneline | grep -q .; then lazypr main fi ``` ### Batch Processing Process multiple branches: ```bash for branch in feature/auth feature/api feature/ui; do git checkout "$branch" lazypr main > "pr-${branch##*/}.txt" done ``` ## Multiple Templates Organize templates by PR type in `.github/PULL_REQUEST_TEMPLATE/`: ``` .github/ PULL_REQUEST_TEMPLATE/ feature.md bugfix.md hotfix.md release.md ``` When using `--template`, LazyPR will prompt you to select the appropriate template. ## Git Hooks Integration ### Pre-push Hook Auto-generate PR description before pushing: ```bash # .git/hooks/pre-push #!/bin/bash if [[ $(git rev-parse --abbrev-ref HEAD) != "main" ]]; then lazypr main > .pr-description.txt echo "PR description saved to .pr-description.txt" fi ``` ### Prepare-commit-msg Hook Add PR-ready summaries to commits: ```bash # .git/hooks/prepare-commit-msg #!/bin/bash # Only for feature branches if [[ $(git rev-parse --abbrev-ref HEAD) == feature/* ]]; then # Your hook logic here fi ``` ## Troubleshooting ### "Not a git repository" Make sure you're inside a git repository: ```bash git status # Should not error ``` ### "No commits found" Your branch needs commits that differ from the target: ```bash git log main..HEAD --oneline # Should show commits ``` ### API Key Issues Verify your API key is configured: ```bash lazypr config list # Check GROQ_API_KEY or CEREBRAS_API_KEY ``` ### Rate Limiting If you hit rate limits, wait a few minutes or switch providers: ```bash lazypr main --provider cerebras # Try alternate provider ``` # Configuration import { Callout } from 'fumadocs-ui/components/callout'; import { Tab, Tabs } from 'fumadocs-ui/components/tabs'; ## Configuration File LazyPR stores configuration in `~/.lazypr`. You can edit this file directly or use the `lazypr config` commands. ## Minimal Configuration The simplest setup to get started. Perfect for personal projects and first-time users. ```bash title="~/.lazypr" # LazyPR Minimal Configuration # The only required setting is your API key GROQ_API_KEY=your-groq-api-key-here # Provider defaults to groq if not specified # PROVIDER=groq ``` Get a free API key at [console.groq.com](https://console.groq.com) ### Setting Up Minimal Config ```bash # Set your API key lazypr config set GROQ_API_KEY=gsk_xxxxxxxxxxxxx # Verify configuration lazypr config list ``` ## Team Configuration Standardized configuration for team environments. Ensures consistent PR descriptions across all team members. ```bash title="~/.lazypr" # LazyPR Team Configuration # Recommended settings for team consistency # API Keys GROQ_API_KEY=your-groq-api-key-here CEREBRAS_API_KEY=your-cerebras-api-key-here # Provider Settings PROVIDER=groq MODEL=llama-3.3-70b-versatile # Team Standards DEFAULT_BRANCH=main LOCALE=en FILTER_COMMITS=true # Context for consistent style CONTEXT=Please review this PR carefully and provide feedback # Reliability Settings MAX_RETRIES=3 TIMEOUT=30000 ``` ### Team Setup Instructions Each team member configures their own machine: ```bash # Set required values lazypr config set GROQ_API_KEY=gsk_xxxxxxxxxxxxx lazypr config set PROVIDER=groq lazypr config set MODEL=llama-3.3-70b-versatile lazypr config set DEFAULT_BRANCH=main lazypr config set LOCALE=en lazypr config set FILTER_COMMITS=true lazypr config set MAX_RETRIES=3 lazypr config set TIMEOUT=30000 ``` Distribute a config file to the team: ```bash # Create config file cat > ~/.lazypr << 'EOF' GROQ_API_KEY=YOUR_KEY_HERE PROVIDER=groq MODEL=llama-3.3-70b-versatile DEFAULT_BRANCH=main LOCALE=en FILTER_COMMITS=true MAX_RETRIES=3 TIMEOUT=30000 EOF # Team members replace the API key lazypr config set GROQ_API_KEY=their-actual-key ``` Never commit API keys to version control. Each team member should have their own key. ## Multi-Provider Configuration Configuration supporting multiple AI providers with easy switching. Ideal for production environments and cost optimization. ```bash title="~/.lazypr" # LazyPR Multi-Provider Configuration # Supports multiple providers for flexibility and fallback # Provider API Keys GROQ_API_KEY=your-groq-api-key-here CEREBRAS_API_KEY=your-cerebras-api-key-here # Active Provider (groq or cerebras) PROVIDER=groq # Model Selection MODEL=llama-3.3-70b-versatile # Common Settings DEFAULT_BRANCH=main FILTER_COMMITS=true # Increased reliability for production MAX_RETRIES=5 TIMEOUT=45000 ``` ### Switching Providers ```bash # Switch to Cerebras lazypr config set PROVIDER=cerebras # Or use flag for one-time override lazypr main --provider cerebras # Check current provider lazypr config get PROVIDER ``` ### Manual Fallback Strategy ```bash # Try Groq first, fallback to Cerebras lazypr main --provider groq || lazypr main --provider cerebras ``` ## Configuration Reference ### All Available Settings | Setting | Description | Default | | ------------------ | ---------------------------------- | ---------------- | | `GROQ_API_KEY` | Groq API key | - | | `CEREBRAS_API_KEY` | Cerebras API key | - | | `PROVIDER` | AI provider (`groq` or `cerebras`) | `groq` | | `MODEL` | Model to use | Provider default | | `DEFAULT_BRANCH` | Target branch for comparison | `main` | | `LOCALE` | Output language | `en` | | `FILTER_COMMITS` | Filter merge/dependency commits | `true` | | `CONTEXT` | Custom context for AI | - | | `MAX_RETRIES` | Retry attempts on failure | `3` | | `TIMEOUT` | Request timeout in ms | `30000` | ### Config Commands ```bash # Set a value lazypr config set SETTING=value # Get a value lazypr config get SETTING # List all settings lazypr config list # Remove a setting lazypr config set SETTING= ``` ## Environment Variables You can also configure LazyPR using environment variables. These override config file settings. ```bash # In your shell profile (~/.bashrc, ~/.zshrc) export GROQ_API_KEY=gsk_xxxxxxxxxxxxx export LAZYPR_PROVIDER=groq export LAZYPR_MODEL=llama-3.3-70b-versatile ``` Environment variables take precedence over config file settings. ## Security Best Practices 1. **Never commit API keys** - Use environment variables or local config files 2. **Use separate keys** - Each team member should have their own API key 3. **Rotate keys regularly** - Update keys periodically for security 4. **Limit key permissions** - Use keys with minimal required permissions ## Validation Verify your configuration is correct: ```bash # Check all settings lazypr config list # Test with a dry run lazypr main -u # Shows token usage to verify API connection ``` # GitHub Actions import { Callout } from 'fumadocs-ui/components/callout'; import { Tab, Tabs } from 'fumadocs-ui/components/tabs'; import { Step, Steps } from 'fumadocs-ui/components/steps'; ## Overview LazyPR integrates seamlessly with GitHub Actions to automate PR description generation. These workflows help teams maintain consistent, high-quality PR documentation. ## Setup ### Add API Key Secret Go to your repository **Settings > Secrets and variables > Actions** and add: * `GROQ_API_KEY` - Your Groq API key * `CEREBRAS_API_KEY` - (Optional) For fallback support ### Create Workflow File Copy one of the workflow examples below to `.github/workflows/` in your repository. ### Test the Workflow Create a pull request to trigger the workflow and verify it works correctly. ## Auto-Update PR Updates PR title and description automatically when new commits are pushed. ```yaml title=".github/workflows/auto-update-pr.yml" name: Auto-Update PR on: pull_request: types: [opened, synchronize] permissions: pull-requests: write contents: read jobs: update: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - uses: actions/setup-node@v4 with: node-version: "20" - run: npm install -g lazypr - name: Generate and update PR env: GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }} GH_TOKEN: ${{ github.token }} run: | cat < ~/.lazypr GROQ_API_KEY=${GROQ_API_KEY} PROVIDER=groq EOF lazypr ${{ github.event.pull_request.base.ref }} > pr.txt TITLE=$(head -n 1 pr.txt | sed 's/^# //') BODY=$(tail -n +2 pr.txt) gh pr edit ${{ github.event.pull_request.number }} \ --title "$TITLE" \ --body "$BODY" ``` The `fetch-depth: 0` ensures full git history is available for commit analysis. ## Auto-Create PR Automatically creates pull requests when pushing to feature or fix branches. ```yaml title=".github/workflows/auto-create-pr.yml" name: Auto-Create PR on: push: branches: - 'feature/**' - 'fix/**' permissions: pull-requests: write contents: read jobs: create: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - uses: actions/setup-node@v4 with: node-version: "20" - run: npm install -g lazypr - name: Create PR if needed env: GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }} GH_TOKEN: ${{ github.token }} run: | cat < ~/.lazypr GROQ_API_KEY=${GROQ_API_KEY} PROVIDER=groq EOF # Check if PR already exists EXISTING=$(gh pr list --head "${{ github.ref_name }}" --json number -q '.[0].number') if [ -n "$EXISTING" ]; then echo "PR #$EXISTING already exists" exit 0 fi lazypr main > pr.txt TITLE=$(head -n 1 pr.txt | sed 's/^# //') BODY=$(tail -n +2 pr.txt) gh pr create \ --title "$TITLE" \ --body "$BODY" \ --base main ``` This workflow only triggers on branches matching `feature/**` or `fix/**`. Adjust the pattern to match your branching strategy. ## Multi-Provider Fallback Tries Groq first, falls back to Cerebras if it fails. Provides resilience for production workflows. ```yaml title=".github/workflows/multi-provider-fallback.yml" name: PR with Fallback on: pull_request: types: [opened, synchronize] permissions: pull-requests: write contents: read jobs: update: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - uses: actions/setup-node@v4 with: node-version: "20" - run: npm install -g lazypr - name: Generate with fallback env: GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }} CEREBRAS_API_KEY: ${{ secrets.CEREBRAS_API_KEY }} GH_TOKEN: ${{ github.token }} run: | # Try Groq first cat < ~/.lazypr GROQ_API_KEY=${GROQ_API_KEY} PROVIDER=groq EOF if lazypr ${{ github.event.pull_request.base.ref }} > pr.txt 2>/dev/null; then echo "Generated with Groq" else # Fallback to Cerebras cat < ~/.lazypr CEREBRAS_API_KEY=${CEREBRAS_API_KEY} PROVIDER=cerebras EOF if lazypr ${{ github.event.pull_request.base.ref }} > pr.txt 2>/dev/null; then echo "Generated with Cerebras (fallback)" else echo "Both providers failed" exit 1 fi fi TITLE=$(head -n 1 pr.txt | sed 's/^# //') BODY=$(tail -n +2 pr.txt) gh pr edit ${{ github.event.pull_request.number }} \ --title "$TITLE" \ --body "$BODY" ``` Both `GROQ_API_KEY` and `CEREBRAS_API_KEY` must be configured in repository secrets. ## PR Validation Validates PR description quality and suggests improvements if too short. ```yaml title=".github/workflows/pr-validation.yml" name: PR Validation on: pull_request: types: [opened, edited] permissions: pull-requests: write contents: read jobs: validate: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - uses: actions/setup-node@v4 with: node-version: "20" - run: npm install -g lazypr - name: Validate PR description env: GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }} GH_TOKEN: ${{ github.token }} run: | # Get current PR body BODY=$(gh pr view ${{ github.event.pull_request.number }} --json body -q '.body') # Check minimum length (100 characters) if [ ${#BODY} -lt 100 ]; then echo "PR description is too short" # Generate suggestion cat < ~/.lazypr GROQ_API_KEY=${GROQ_API_KEY} PROVIDER=groq EOF lazypr ${{ github.event.pull_request.base.ref }} > suggestion.txt # Post comment with suggestion gh pr comment ${{ github.event.pull_request.number }} \ --body "## Suggested PR Description Your PR description seems brief. Here's a suggested improvement: --- $(cat suggestion.txt) --- *Generated by LazyPR*" exit 1 fi echo "PR description looks good!" ``` ## Customization Tips ### Adding Context Include project-specific context in your workflows: ```yaml - name: Generate with context run: | lazypr main -c "This is a monorepo with shared packages" > pr.txt ``` ### Using Templates Enable template support for consistent formatting: ```yaml - name: Generate with template run: | lazypr main --template > pr.txt ``` ### Custom Branch Patterns Adjust triggers for your branching strategy: ```yaml on: push: branches: - 'feature/**' - 'bugfix/**' - 'hotfix/**' - 'release/**' ``` ## Troubleshooting ### Workflow Not Triggering * Check branch patterns match your naming convention * Verify the workflow file is in `.github/workflows/` * Ensure the workflow has correct permissions ### API Key Errors * Confirm secrets are added to repository settings * Check secret names match exactly (case-sensitive) * Verify API keys are valid and not expired ### Permission Denied Add required permissions to your workflow: ```yaml permissions: pull-requests: write contents: read ``` ### Empty PR Description * Ensure `fetch-depth: 0` is set for full git history * Check there are commits between branches * Verify the base branch name is correct # Basic Commands import { Callout } from 'fumadocs-ui/components/callout'; ## Command Structure The basic LazyPR command structure: ```bash lazypr [target-branch] [options] ``` Or use the short alias: ```bash lzp [target-branch] [options] ``` ## Target Branch Specify the branch to compare against (typically `main` or `master`): ```bash lazypr main # Compare against main branch (default) lazypr develop # Compare against develop branch lazypr master # Compare against master branch ``` If no branch is specified, LazyPR defaults to `main`: ```bash lazypr # Same as: lazypr main ``` ## Command Options ### `-t, --template` Use a PR template from your `.github` folder. ```bash lazypr main --template ``` If multiple templates exist, LazyPR shows an interactive selector. ### `-l, --locale` Override the language for a single run. ```bash lazypr main -l es # Generate in Spanish lazypr main -l fr # Generate in French lazypr main -l ja # Generate in Japanese ``` Supported languages: en, es, pt, fr, de, it, ja, ko, zh, ru, nl, pl, tr ### `-c, --context` Provide custom style guidance (max 200 characters) for this run only. ```bash lazypr main -c "Focus on security improvements" lazypr main -c "Use bullet points and keep it brief" ``` Context overrides your global CONTEXT setting for this run only. ### `--gh` Generate a GitHub CLI command instead of interactive menu. ```bash lazypr main --gh ``` Outputs a ready-to-run `gh pr create` command that you can copy and execute. ### `--no-filter` Include all commits without filtering. ```bash lazypr main --no-filter ``` By default, LazyPR filters out merge commits, dependency updates, and formatting changes. Use this flag to include everything. ### `-u, --usage` Display token usage statistics after generation. ```bash lazypr main -u ``` Shows the number of tokens consumed by the AI request. ## Combining Options You can combine multiple options: ```bash lazypr main --template -l es -c "Keep descriptions concise" -u ``` This command: * Compares against `main` branch * Uses a PR template * Generates in Spanish * Applies custom context * Shows token usage ## Configuration Commands Manage LazyPR settings: ```bash # Set a configuration value lazypr config set SETTING_NAME=value # View all settings lazypr config list # View specific setting lazypr config get SETTING_NAME ``` ## Help Command View all available commands and options: ```bash lazypr --help ``` ## Examples ```bash # Basic usage with main branch lazypr main # Use template and show token usage lazypr main --template -u # Generate in French with custom guidance lazypr develop -l fr -c "Emphasize performance improvements" # Generate GitHub CLI command without filtering lazypr main --gh --no-filter ``` # GitHub Integration import { Callout } from 'fumadocs-ui/components/callout'; import { Steps, Step } from 'fumadocs-ui/components/steps'; ## Overview LazyPR integrates with GitHub CLI (`gh`) to streamline PR creation. Instead of copying title and description separately, generate a ready-to-execute `gh pr create` command. ## Prerequisites You need GitHub CLI installed and authenticated: ```bash # Install GitHub CLI # macOS brew install gh # Windows winget install GitHub.cli # Linux sudo apt install gh # Authenticate gh auth login ``` ## Using the --gh Flag Generate a GitHub CLI command instead of the interactive menu: ```bash lazypr main --gh ``` **Output**: ```bash gh pr create --title "feat: Add user authentication" --body "## Changes - Implement OAuth 2.0 flow - Add JWT token management - Create authentication middleware ## Testing Verified OAuth integration with Google provider" ``` Copy the generated command and run it directly to create your PR! ## Complete Workflow ### Generate the Command ```bash lazypr main --gh ``` ### Copy and Execute Copy the generated `gh pr create` command and run it: ```bash gh pr create --title "..." --body "..." ``` ### PR Created GitHub CLI creates the pull request and returns the URL: ``` https://github.com/username/repo/pull/123 ``` ## Combining with Templates Use templates with GitHub integration: ```bash lazypr main --gh --template ``` The generated command will include template-structured content in the body. ## Additional gh Options Enhance the generated command with GitHub CLI options: ```bash # Generate base command lazypr main --gh # Then add gh options when running gh pr create --title "..." --body "..." \ --draft \ --assignee @me \ --label enhancement \ --reviewer username ``` LazyPR generates the title and body. You add any extra `gh pr create` options when executing the command. ## Workflow Integration ### Shell Alias Create an alias for instant PR creation: ```bash # Add to ~/.bashrc or ~/.zshrc alias prgh='lazypr main --gh | pbcopy && echo "Command copied to clipboard!"' ``` Usage: ```bash prgh # Generate and copy to clipboard ``` ### CI/CD Integration Automate PR creation in scripts: ```bash #!/bin/bash # Generate PR command PR_CMD=$(lazypr main --gh) # Execute if successful if [ $? -eq 0 ]; then eval $PR_CMD else echo "Failed to generate PR content" exit 1 fi ``` ### GitHub Actions Example ```yaml name: Create PR on: push: branches: - feature/* jobs: create-pr: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: node-version: '20' - name: Install LazyPR run: npm install -g lazypr - name: Configure API Key run: lazypr config set GROQ_API_KEY=${{ secrets.GROQ_API_KEY }} - name: Create PR run: | lazypr main --gh | sh env: GH_TOKEN: ${{ github.token }} ``` ## Benefits **Speed**: Generate and create PRs in one step without switching contexts. **Consistency**: Same AI-generated quality whether using interactive mode or CLI. **Automation**: Perfect for scripts and CI/CD pipelines. ## Troubleshooting **gh command not found**: Install GitHub CLI and ensure it's in your PATH. **Authentication failed**: Run `gh auth login` to authenticate with GitHub. **Permission denied**: Ensure your GitHub token has `repo` and `workflow` permissions. # PR Templates import { Callout } from 'fumadocs-ui/components/callout'; ## What are PR Templates? PR templates are markdown files that define the structure and sections of your pull requests. LazyPR can use your existing templates from the `.github` folder to generate consistent, structured PR descriptions. ## Using Templates Enable template mode with the `-t` or `--template` flag: ```bash lazypr main --template ``` LazyPR will: 1. Look for template files in `.github/` directory 2. Parse the template structure 3. Fill in the sections with AI-generated content based on your commits ## Template Location LazyPR searches for templates in these locations: ``` .github/pull_request_template.md .github/PULL_REQUEST_TEMPLATE.md .github/pull_request_template/ .github/PULL_REQUEST_TEMPLATE/ ``` ## Interactive Selection If you have multiple templates, LazyPR displays an interactive selector: ``` ? Select a PR template: ❯ feature_template.md bugfix_template.md hotfix_template.md ``` Use arrow keys to select and press Enter. ## Template Format Templates typically include sections like: ```markdown ## Description ## Type of Change - [ ] Bug fix - [ ] New feature - [ ] Breaking change ## Testing ## Checklist - [ ] Tests added - [ ] Documentation updated ``` LazyPR understands these sections and generates appropriate content for each. ## Example: Feature Template **Template file** (`.github/pull_request_template.md`): ```markdown ## Summary ## Changes ## Testing ## Screenshots ``` **LazyPR output**: ```markdown ## Summary Implement user authentication with OAuth 2.0 support ## Changes - Add OAuth authentication flow - Implement JWT token management - Create login/logout endpoints - Add session persistence ## Testing Tested with Google and GitHub OAuth providers Verified token refresh mechanism Validated session timeout handling ## Screenshots N/A - Backend changes only ``` ## Template Best Practices ### Keep Sections Clear Use clear section headers that describe the content: ```markdown ## What Changed ## Why These Changes ## How to Test ``` ### Use Comments for Guidance Add HTML comments to guide contributors: ```markdown ## Description ``` LazyPR removes these comments and fills in the content. ### Include Checklists Checklists help ensure PR completeness: ```markdown ## Checklist - [ ] Code follows style guidelines - [ ] Tests pass locally - [ ] Documentation updated ``` LazyPR can intelligently fill in some checklist items based on your commits (e.g., detecting if tests were added). ## Without Templates If you don't use the `--template` flag, LazyPR generates a clean, structured description automatically: ```bash lazypr main # No template ``` Output will still be well-formatted with sections like "Changes", "Summary", and "Testing". ## Troubleshooting **Template Not Found**: Ensure your template is in the `.github` directory and named correctly. Check for typos in the filename. **Empty Sections**: Some template sections may not be relevant to your commits. LazyPR will either fill them with "N/A" or leave them for manual completion.