---
name: make-issue
description: Create a new GitHub issue based on the $ARGUMENTS input from the user.
---

You're going to create a new GitHub issue based on the $ARGUMENTS input from the user.

The user has briefly described the issue in the $ARGUMENTS.

## Procedure

### 1. Gather Repository Info

Run these commands in parallel to collect all necessary data upfront:

- Check for issue templates in `.github/ISSUE_TEMPLATE/`
- Get repo metadata: `gh repo view --json owner,name,id`
- Fetch available issue types:
  ```bash
  gh api graphql -f query='
    query($owner: String!, $name: String!) {
      repository(owner: $owner, name: $name) {
        issueTypes(first: 20) {
          nodes {
            id
            name
            description
          }
        }
      }
    }
  ' -f owner='{owner}' -f name='{repo}'
  ```
- Fetch all available labels:
  ```bash
  gh label list --limit 100 --json name,description,color
  ```
  If the repository has more than 100 labels, increase the limit or paginate.

### 2. Template Selection

If issue templates are available, ask the user which template to use.

### 3. Issue Type Selection

If issue types are available, present them using AskUserQuestion and let the user select one.

### 4. Label Selection

Analyze the issue content and auto-suggest relevant labels:
- Group labels by category/prefix (e.g., "type:", "priority:", "area:", "status:")
- For each category, use AskUserQuestion with multiSelect enabled
- Always show your auto-suggested labels and indicate which ones you recommend
- Make sure to cover ALL available labels across multiple questions if needed

### 5. Write the Issue

Write the issue concise and to the point but with enough working information and context.

### 6. Create the Issue

Create the issue in a single request with all selected labels.

**With issue type:**
```bash
gh api graphql -f query='
  mutation($repositoryId: ID!, $title: String!, $body: String!, $issueTypeId: ID!, $labelIds: [ID!]) {
    createIssue(input: {repositoryId: $repositoryId, title: $title, body: $body, issueTypeId: $issueTypeId, labelIds: $labelIds}) {
      issue {
        number
        url
      }
    }
  }
' -f repositoryId='{repoId}' -f title='{title}' -f body='{body}' -f issueTypeId='{selectedIssueTypeId}' -f labelIds='["{labelId1}","{labelId2}"]'
```

**Without issue type:**
```bash
gh issue create --title '{title}' --body '{body}' --label 'label1,label2'
```

### 7. Provide Link

Provide a link to the newly created issue.
