ghs-guardrails-demo repository. A PR template helps contributors provide consistent context, testing information, and a checklist when opening pull requests for the small Node.js application in this repo.
Why add a PR template?
- Ensures reviewers get consistent information.
- Speeds up reviews by highlighting tests, breaking changes, and required checklist items.
- Encourages contributors to follow project standards.
Prerequisites
- Push access to the repository (or create a branch and open a PR).
- Basic Git knowledge (creating branches, committing, pushing).
Steps
-
Create the template file
Create a file at.github/pull_request_template.mdin the repository root. GitHub recognizes files in the.githubfolder as repository-level templates. -
Add the PR template contents
Paste the following content into.github/pull_request_template.md. This example covers description, change type, testing, and a checklist that your maintainers can adapt to the project’s workflow.
- Commit the change
You can commit directly via the GitHub web UI (if allowed) or use the command line. Example workflow using a branch:
- Open a pull request (if you pushed a branch) or confirm the template is applied (if you committed to
main)
When a contributor opens a new PR, GitHub will pre-populate the PR description with the template contents. Note that the template does not create a PR automatically; it only populates the PR description when one is opened.
Tip: Keep the template concise and specific to your repository’s review requirements. Consider adding links to CI status pages or contributing guidelines to make it easier for contributors to follow the process.
Template sections explained
Verifying the template
- Open a new PR in the repository to confirm that the template content appears in the PR description.
- Update the template over time as review requirements change (e.g., add automated checklist items linked to CI jobs or test results).
- The PR template file serves as the default content for new PR descriptions; it does not open PRs automatically.
- If you have multiple templates, consider using GitHub’s issue and PR template chooser (see links below).
If branch protection rules are in place, you may not be able to commit directly to
main. Some environments have bypass rules that allow privileged users to bypass protection; use such bypasses sparingly and only when appropriate.Links and references
- GitHub: Pull request template docs — https://docs.github.com/en/github/building-a-strong-community/creating-a-pull-request-template
- GitHub: About issue and pull request templates — https://docs.github.com/en/github/building-a-strong-community/about-issue-and-pull-request-templates