Skip to content
Source
Sign inSign up

Get complete issues with templates

Issues and pull requests / Issues

Get complete issues with templates and forms

People open issues with no version, no steps and no logs, and you spend a comment to ask for them. Issue templates and issue forms ask for these facts when the issue is opened. A form can make a field required: then the forge refuses a new issue that leaves the field empty, from the web, src, REST, MCP, bots and agents.

5 min read

You need write access to the repository, because the templates are files on its default branch.

1. Add a Markdown template

A Markdown template gives a new issue a body to start from. Make the file .github/ISSUE_TEMPLATE/question.md:

---
name: Question
about: Ask how to do something
title: "[Question]: "
labels: question
assignees: ana
---

## What I want to do

## What I tried

The front matter between the --- lines sets the template:

  • name and about: the name and the text that the template chooser shows. Both are required.
  • title: the start of the title of a new issue. Optional.
  • labels and assignees: added to each new issue of the template. Give one name, names split by commas, or a YAML list.

2. Add an issue form

An issue form asks for each fact in its own field. Make the file .github/ISSUE_TEMPLATE/bug_report.yml:

name: Bug report
description: Tell us what broke
title: "[Bug]: "
labels: [bug]
body:
  - type: markdown
    attributes:
      value: Thanks for the report. Fill in each field with a star.
  - type: input
    id: version
    attributes:
      label: Version
      placeholder: 1.2.0
    validations:
      required: true
  - type: textarea
    id: what-happened
    attributes:
      label: What happened?
      description: The steps, what you expected, and what you got.
    validations:
      required: true
  - type: textarea
    id: logs
    attributes:
      label: Logs
      render: shell
  - type: dropdown
    id: browsers
    attributes:
      label: Browsers
      multiple: true
      options:
        - Chrome
        - Firefox
        - Safari
  - type: checkboxes
    id: terms
    attributes:
      label: Before you send
      options:
        - label: I searched the open issues
          required: true

The form uses the same format as GitHub:

  • name and description are required. title, labels and assignees work as in a Markdown template.
  • body lists the fields: markdown (text only), input, textarea, dropdown and checkboxes.
  • validations.required: true makes a field required. For checkboxes, set required: true on each option that must be checked.
  • id is the key of the field for src, REST and MCP. A field with no id uses its label as the key.

The body of the new issue has a ### <label> heading for each field, then its value. An empty field shows _No response_.

3. Turn off blank issues

To make every new issue use a template, make the file .github/ISSUE_TEMPLATE/config.yml:

blank_issues_enabled: false
contact_links:
  - name: Ask in the chat
    url: https://example.com/chat
    about: For questions, the chat is faster.
  • blank_issues_enabled: false: each new issue must name a template. The default is true.
  • contact_links: links that the template chooser shows under the templates.

4. Add a pull request template

Make the file .github/PULL_REQUEST_TEMPLATE.md (or pull_request_template.md) with the text that each new pull request starts with:

## What changed

## How I tested it

Fixes #

5. Push the files to the default branch

Commit the files and push them to the default branch. The forge reads the templates from the tip of that branch only.

Note

The forge also reads the same files from .source/ in the place of .github/. When a file name is in both folders, the file in .source/ wins.

Done

  • New issue opens the template chooser, with your templates and contact links.
  • An issue from the bug form gets the bug label, and its title starts with [Bug]:.
  • A new issue that leaves Version empty is refused.
  • A new pull request on the compare page starts with the text of your pull request template.

When a template does not show

The forge leaves out a file that it cannot use, and the other templates still work. Admins see each left-out file and the reason above the template chooser, on the new issue page. A file is left out when:

  • Its YAML or its front matter is not valid, or a required key is missing.
  • It is larger than 64 KiB.
  • It is after the first 40 templates, by file name.

What reporters and agents see

On the web

  1. Open the Issues tab, then click New issue.
  2. In Choose a template, click Get started next to a template. When blank issues are on, Open a blank issue is under the list.
  3. Fill in the form. A required field has a red star.
  4. Click Create.

When a required field is empty, the page shows the refusal above the title and keeps what you typed.

In a terminal

List the templates and the keys of their required fields:

src issue templates
NAME          FILE              KIND      REQUIRED FIELDS
Bug report    bug_report.yml    form      version, what-happened
Question      question.md       markdown

Open an issue from a form. Give each field with --field key=value. To pick more than one option, give the key again:

src issue create --template bug_report --title "Login fails" \
  --field version=1.2.0 \
  --field what-happened="The login button does nothing." \
  --field browsers=Chrome --field browsers=Firefox \
  --field "terms=I searched the open issues"
  • --template takes the file name, the file name without its extension, or the name of the template.
  • With a Markdown template, --body is optional: the template's text is the body.
  • src issue templates --json name,file,kind,fields gives each field with its key and options.

With REST or MCP

You want toRESTMCP tool
List the templates and the configGET /api/v1/repos/{owner}/{repo}/issue-templateslist_issue_templates
Open an issue from a templatePOST /api/v1/repos/{owner}/{repo}/issues, with template and fieldscreate_issue, with template and fields

fields maps each key to a text, or to a list of texts for a dropdown or checkboxes:

{
  "title": "Login fails",
  "template": "bug_report",
  "fields": { "version": "1.2.0", "what-happened": "The login button does nothing.", "browsers": ["Chrome"] }
}

You can send a body in the format of the form in the place of fields, but not both. The answer of list_issue_templates also has blankIssuesEnabled and contactLinks.

When the forge refuses the issue

The refusal names the template and what is missing. REST answers 422 with the text, and 400 when fields is not a map of texts. For example:

The issue form "Bug report" (bug_report.yml) needs these fields: Version (version)

Send the field with the key in the parentheses, here --field version=1.2.0. When blank issues are off and you name no template, the refusal lists the templates:

New issues of acme/app need a template. Name one of: Bug report (bug_report.yml), Question (question.md)

Name one of them with --template, or template in REST and MCP.

What the rules do not check

  • Issues that a GitHub import or GitHub sync brings in. They were opened on GitHub.
  • An issue that moves from another repository.

On a repository that syncs with GitHub, the template's labels and assignees go to GitHub with the issue. To start a new repository with a .gitignore and a license, see Start a repository with a .gitignore and a license.