Sub topic 3
Categorizing Work with Labels
This chapter assumes you can create an issue, work in a repository on GitHub, and run commands in a terminal. Labels are the first way to sort issues. Later chapters on search, templates, and triage build on them.
What labels do
A label is a short, colored tag attached to an issue or pull request. One item can have many labels. Labels answer questions such as "what kind of work is this?" and "how urgent is it?"
Labels belong to the repository. Anyone with triage access or higher can apply them. Anyone with write access can create and edit them.
Default labels
New repositories start with a set of labels:
| Label | Typical meaning |
|---|---|
| bug | Something is not working |
| enhancement | A new feature or improvement |
| documentation | Changes to docs |
| duplicate | The issue already exists |
| good first issue | Suitable for new contributors |
| help wanted | The maintainers want outside help |
| question | More information is needed |
| wontfix | The work will not be done |
Create and apply labels
To create a label, open the Issues tab, choose Labels, then choose New label. Give it a name, a color, and an optional description. To apply a label, open an issue and select the gear icon beside Labels in the sidebar.
You can also use the GitHub CLI:
gh label create "needs-triage" --color FBCA04 --description "Not yet reviewed"
gh issue edit 42 --add-label "needs-triage"
gh issue edit 42 --remove-label "needs-triage"
gh label listThe first command creates the label. The next two add and remove it on issue 42. The last lists every label in the repository.
Design a label set that works
A small, consistent set works better than a long one. A common approach is to group labels by prefix, so each group answers one question.
| Group | Example labels |
|---|---|
| type | `type: bug`, `type: feature`, `type: docs` |
| priority | `priority: high`, `priority: low` |
| status | `status: needs-triage`, `status: blocked` |
| area | `area: api`, `area: ui` |
Prefixes keep related labels together in the label picker and make search easier. Pick a color for each group, for example red shades for priority.
How labels are used in search
Labels become powerful when you filter by them. This query lists open bugs:
is:issue is:open label:bugAdding several label: qualifiers requires all of them. To match either of two labels, put them in one qualifier separated by a comma, as in label:bug,enhancement. To exclude a label, use -label:wontfix. The Searching chapter covers these qualifiers in more detail.
Common errors
- Too many labels. If people cannot remember them, they stop using them. Delete labels nobody applies.
- Overlapping meanings. If
buganddefectboth exist, searches miss half the items. Rename or merge them. Renaming a label keeps it on existing issues. - No owner for the label set. Without someone responsible, the set drifts. Review it when you triage.
- Using labels for people or dates. Use assignees and milestones for those. They have their own fields and filters.
Exercise
Your repository has both a bug label and a defect label, and a search for label:bug misses some problem reports. What should you do, and why?
Show answer
Pick one name, such as bug. Apply it to the issues that carry defect, then delete defect (or rename it to bug if bug does not yet exist). Overlapping labels split the same kind of work across two names, so any single label search finds only part of it.
Exercise
Write a gh command that adds the label priority: high to issue 17.
Show answer
gh issue edit 17 --add-label "priority: high"