/gh-issue — File a GitHub Issue
Create a GitHub issue with the correct native type set (Feature, Bug, or Task).
gh issue create does not support --type — this skill uses the GraphQL API to set it.
When to Use
- Filing a new GitHub issue from a description, ticket, or conversation
- Any time a
type:is specified (Feature, Bug, Task) —gh issue createsilently ignores it
Arguments
$ARGUMENTS — optional repo override in owner/repo format. If omitted, uses current repo via gh repo view.
Process
Gather required fields from context or ask the user:
title— requiredbody— required (write in GitHub-flavored markdown; use## Description,## Why It Matters,## Proposed Changesections as appropriate)type— one ofFeature,Bug,Task(required; defaultTaskif unclear)labels— optional, comma-separatedrepo— from$ARGUMENTSorgh repo view --json nameWithOwner --jq '.nameWithOwner'
Write body to a temp file to avoid shell quoting issues:
cat > /tmp/gh-issue-body.md << 'ENDBODY' <body content> ENDBODYCreate the issue (without type —
gh issue createdoesn't support it):gh issue create \ --title "<title>" \ --body-file /tmp/gh-issue-body.md \ --label "<labels>" \ --repo <owner/repo>Capture the returned issue URL and extract the issue number.
Look up the issue type ID for the target repo:
gh api graphql -f query=' query { repository(owner: "<owner>", name: "<repo>") { issueTypes(first: 10) { nodes { id name } } } }'Match the desired type name (case-insensitive) to get its
id.Get the issue node ID:
gh api graphql -f query=' query { repository(owner: "<owner>", name: "<repo>") { issue(number: <number>) { id } } }' --jq '.data.repository.issue.id'Set the issue type:
gh api graphql -f query=' mutation { updateIssue(input: { id: "<issue-node-id>", issueTypeId: "<type-node-id>" }) { issue { number title issueType { name } } } }'Report:
✓ Filed: <owner/repo>#<number> — <title> Type: <type> Labels: <labels> URL: <url>
Rules
- Always use
--body-file— never inline the body in the shell command. Backticks and special chars in issue bodies break heredoc quoting. - Always set the type — if the user didn't specify, infer from context (bug report → Bug, new capability → Feature, chore/refactor → Task). Confirm if unsure.
- If
issueTypesquery returns empty, the repo may not have types enabled. Warn and skip step 6 — do not abort. - Clean up
/tmp/gh-issue-body.mdafter the issue is filed.