This document explains how lazypr templates work, how to create custom templates, and how to use the official template collection to customize Pull Request summaries generated by the lazypr AI-powered GitHub Action.


Overview

lazypr generates intelligent Pull Request summaries using predefined or custom templates. Templates act as AI instructions, defining what context is provided and how the summary should be structured.

lazypr supports:


Template Types

1. Built-in Presets

lazypr ships with built-in template presets located at:

packages/config-presets/src/index.ts

These presets are useful for quick setup or standardized workflows.


2. Custom Templates

Custom templates allow full control over:

Custom templates live inside your repository and are automatically detected by lazypr.


Template Variables (Placeholders)

Templates may include the following dynamic placeholders. These are replaced automatically at runtime.

PR Metadata

VariableDescription
{{prTitle}}Title of the Pull Request
{{prAuthor}}GitHub username of the PR author
{{prBody}}Existing PR description

Diff Context

VariableDescription
{{filesChanged}}List of files modified in the PR
{{diff}}Sanitized git diff of the Pull Request

Risk Context (Precomputed)

VariableDescription
{{riskLevel}}Risk classification (Low, Medium, High, Critical)
{{riskScore}}Numerical risk score (0–100)
{{highRiskFiles}}Files flagged as high-risk
{{fileBreakdown}}File-level change analysis

Custom Template Requirements

Every custom template must include the following placeholders:

Templates that omit these required fields will not be processed correctly.


Custom Template Resolution Order

When custom_template is enabled, lazypr searches for templates in the following order (first match wins):

  1. custom_template_path (if explicitly provided)
  2. .github/lazypr-template.md
  3. .lazypr/template.md
  4. lazypr-template.md

This template is suitable for most projects and balances clarity, brevity, and reviewer context.

You are an expert reviewer. Produce a concise Markdown summary.

PR:

- Title: {{prTitle}}
- Author: {{prAuthor}}

Risk:

- {{riskLevel}} ({{riskScore}}/100)
- High-risk files: {{highRiskFiles}}

Files:
{{filesChanged}}

Diff:
{{diff}}

Output format:

### TL;DR

<1-2 sentences>

### Key Changes

- <bullets>

### Notes for Reviewers

- <bullets>

lazypr Summary Templates

This directory contains a curated collection of specialized and generic summary templates for the lazypr GitHub Action.

Each template is designed for a specific workflow, audience, or review style.


GitHub Repository

All templates are publicly available at:

👉 https://github.com/elvis-ndubuisi/lazypr/tree/main/templates


How to Use These Templates

  1. Copy any template file.
  2. Place it at:
.github/lazypr-template.md

lazypr will automatically detect and use it with no additional configuration.


Option 2: Specify Template in Workflow

To select a template per repository or workflow, configure the GitHub Action input:

- uses: elvis-ndubuisi/lazypr@v1
  with:
    api_key: ${{ secrets.GEMINI_API_KEY }}
    provider: gemini
    custom_template: true
    custom_template_path: templates/freelancer.md

Available Templates

Scenario-Specific Templates

TemplatePurpose
Freelancer (freelancer.md)Emphasizes value delivered and requirements completed
Open Source (open-source.md)Highlights community standards, issues, and quality checks
Organization (organization.md)Staff-engineer level review: architecture, security, ops
Personal (personal.md)Reflective summaries with lessons learned and TODOs

Generic Use-Case Templates

TemplatePurpose
Bug Fix (bug-fix.md)Explains root cause and before/after behavior
New Feature (new-feature.md)Focuses on user experience and usage examples
Refactor (refactor.md)Explains motivation and confirms no regressions
Security (security.md)High-urgency vulnerability and risk analysis
Documentation (documentation.md)Tracks clarity, audience, and link correctness
Minimalist (minimalist.md)Ultra-short, 3-bullet summary

Template Placeholders Reference

Required Placeholders

PlaceholderDescription
{{diff}}Required. Sanitized git diff
{{filesChanged}}Required. Modified files

PR Metadata

PlaceholderDescription
{{prTitle}}Pull Request title
{{prAuthor}}PR author
{{prBody}}Existing PR description

Risk Assessment

PlaceholderDescription
{{riskLevel}}Risk classification (Low, Medium, High)
{{riskScore}}Numerical risk score (0–100)
{{highRiskFiles}}Files flagged as high-risk
{{fileBreakdown}}File-level change analysis

Ticket Detection (v1.2.0+)

PlaceholderDescription
{{relatedTickets}}Markdown list of detected tickets

PR Size Metrics (v1.2.0+)

PlaceholderDescription
{{prSizeLines}}Total lines changed
{{prSizeFiles}}Number of files changed
{{prSizeAdditions}}Lines added
{{prSizeDeletions}}Lines deleted
{{prSizeMetrics}}Full metrics as formatted text

Custom Placeholders (v1.2.0+)

Any placeholders defined in custom_placeholders input are also available. See custom placeholders guide.


Template Design Rules

To ensure consistent and reliable output: