Sub topic 1
Why Templates Matter for Reviews and Triage
Prerequisites
This chapter assumes you already know the following:
- Basic Git and GitHub usage: repositories, branches, pull requests, and issues.
- Markdown syntax, such as headings, lists, and task lists.
- How to read simple YAML. You will not write any yet.
- Write or admin access to a repository you can experiment in.
The problem templates solve
Open a few issues in any busy open-source project and you will see the same pattern. Some reports say "it crashes" and nothing else. Some pull requests have an empty description. A maintainer then spends the first part of every review asking for basics: which version, what steps, what was tested, which issue this closes.
Each round of questions costs a day or more, because the author and the maintainer work in different time zones and on different schedules. A template removes most of those rounds. It puts the questions in front of the author at the moment they write the report, before anyone has to ask.
GitHub offers two kinds of template, and this tutorial covers both:
- Pull request templates pre-fill the description box of a new pull request with text you wrote.
- Issue templates appear in a chooser when someone opens a new issue. They come in two formats: Markdown templates, and YAML issue forms that render as real form fields.
What improves for reviews
A reviewer needs to know what changed, why, and how it was checked. A pull request template can ask for those three things every time.
Consider the template from the Topic Spine. It is saved as .github/pull_request_template.md:
## Summary
<!-- What does this change do, and why? -->
## Related issues
Closes #
## How was this tested?
- [ ] Unit tests added or updated
- [ ] Tested manually
## Checklist
- [ ] Documentation updated
- [ ] No breaking changes, or they are described aboveEach section does a specific job:
| Section | What it gives the reviewer |
|---|---|
| Summary | The intent of the change, so the diff can be judged against it |
| Related issues | A link to the discussion. `Closes #` also closes the issue on merge |
| How was this tested? | Evidence, or a visible gap that the reviewer can point to |
| Checklist | A reminder of the project's conventions, such as docs and breaking changes |
The author can still ignore the template or delete sections. A template does not enforce anything, but it changes the default. Most people fill in what is already in front of them.
What improves for triage
Triage is the work of reading new issues, deciding what each one is, and routing it. Maintainers label it, assign it, ask for more information, or close it as a duplicate.
Issue templates help in three ways:
- Consistent content. Every bug report has a version, an operating system, and steps to reproduce, in the same place.
- Automatic routing. A template can apply labels and assignees when the issue is created. A bug can arrive already labeled
bugandtriage. - Fewer wrong-channel issues. The chooser can send usage questions to Discussions instead of the issue tracker.
Issue forms go further than Markdown templates. They can mark fields as required, so GitHub refuses to submit a report that lacks a version number. Later chapters cover how to configure this.
The diagram below shows where a template sits in the flow.
Limits to keep in mind
Templates are not a cure-all. Keep these points in mind as you design your own:
- A long template discourages people. Ask only for what you will actually use.
- Markdown templates cannot require anything. Only issue forms can.
- Contributors can bypass templates, for example through the API or a blank issue, unless you disable blank issues in
config.yml. - A template that nobody maintains goes stale. Update it when your process changes.
What comes next
The next chapter covers where these files must live and which branch GitHub reads them from. Without the right location, none of the templates above will appear.
Exercise
Name two ways an issue template helps maintainers during triage, and one thing a Markdown issue template cannot do that an issue form can.
Show answer
Any two of: consistent information in every report, labels and assignees applied automatically, and redirecting usage questions away from the issue tracker. A Markdown template cannot require a field to be filled in. An issue form can mark fields as required.
Exercise
Look at the last three pull requests merged in a repository you work on. List which of the four sections from the example template (Summary, Related issues, How was this tested?, Checklist) you had to look up or ask about. What does that suggest about the template you would write?
Show answer
Answers vary. Any section you had to look up elsewhere is a good candidate for the template, because the template is meant to supply exactly the information reviewers otherwise have to request.