generate-gh-issue
Generates detailed, architect-quality GitHub issues from short instructions. Analyzes the project's actual stack, architecture, and codebase before writing. Detects duplicate issues with intelligent multi-strategy search, validates and creates labels, enforces title conventions, controls scope, and publishes via `gh` CLI with robust error handling. Use this skill whenever the user wants to create a GitHub issue, report a bug, propose a feature, request a refactor, or file any kind of technical issue — even if they just say something brief like "we need to fix the auth flow" or "create an issue for X". Also triggers on: "open an issue", "file a bug", "I want to propose...", "add this to the backlog", "gh issue", or any request that implies creating a trackable work item on GitHub.
NPX Install
npx skill4agent add fabioassuncao/agent-skills generate-gh-issueTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Generate GitHub Issue
Core Principles
- Evidence over assumption. Never guess the stack. Read the repo first.
- Depth over speed. A shallow issue wastes more time than it saves. Analyze thoroughly, write clearly.
- No duplicates. Always check existing issues before creating. When in doubt, ask the user.
- Minimal output. Return only the issue URL (or a decision message). No logs, no issue body echo, no explanations.
- Scope discipline. One issue = one actionable unit of work. If it can't be done in a single PR, it's too big.
- Consistency. Titles, labels, and language follow strict conventions.
Workflow
Step 0 — Validate Environment
ghgh auth status 2>&1ghYou are not authenticated with GitHub. Runto authenticate.gh auth login
This directory is not linked to a GitHub repository. Make sure you are inside a git repo with a GitHub remote.
Step 1 — Discover the Project
- Languages: Check file extensions, ,
package.json,composer.json,Cargo.toml,go.mod,requirements.txt,Gemfile,mix.exs,build.gradle, etc.pom.xml - Frameworks: Look at dependencies, directory structure, config files (e.g., = Laravel,
artisan= Next.js,next.config= Django).manage.py - Architecture: Monorepo? Microservices? MVC? Module-based? Check top-level directories.
- Build tools: Vite, Webpack, esbuild, Make, Docker, etc.
- Key integrations: Payment gateways, auth providers, CDNs, queues, etc.
- Existing patterns: How are things organized? What conventions does the team follow?
Step 2 — Detect Project Language
- Check the last 10 issue titles (if any exist):
bash
gh issue list --limit 10 --state all --json title --jq '.[].title' 2>/dev/null - Check the README language if available.
- Check commit messages:
bash
git log --oneline -10 2>/dev/null
- If the user's request is in a specific language, use that language for the issue body.
- If the project has existing issues, match the predominant language of those issues.
- If no existing issues, match the README language.
- Fallback: use the language the user wrote their request in.
Step 3 — Analyze the Request
- What exactly is the problem or opportunity?
- Which parts of the codebase are affected?
- What are the downstream impacts?
- Are there related concerns the user might not have mentioned?
- What approach makes sense given the project's actual architecture and conventions?
Infer Issue Metadata
- Type: ,
bug,enhancement,refactor, orinvestigationarchitecture - Priority: ,
low, ormedium— based on:high- : security issues, data loss risks, broken core functionality, production outages
high - : degraded functionality, performance issues, developer experience problems
medium - : cosmetic issues, minor improvements, nice-to-haves
low
- Area: ,
backend,frontend,infra,database,api,auth,storage,i18n,integrations,docs,testing,ci-cd(pick all that apply, max 2)monitoring
Step 4 — Scope Control
- It touches 3+ unrelated areas of the codebase
- It requires multiple independent PRs that could be reviewed separately
- It contains both architectural decisions AND implementation work
- The execution plan would have 8+ steps with no logical grouping
-
Identify the logical sub-issues (2-4 pieces).
-
Ask the user:This request covers multiple independent concerns. I recommend splitting into separate issues:
- [Brief description of issue 1]
- [Brief description of issue 2]
- [Brief description of issue 3]
Should I create them separately, or do you prefer a single combined issue? -
Wait for the user's response before proceeding.
-
If creating multiple issues, each one follows this full workflow independently. Add cross-references between them usingafter creation.
#number
Step 5 — Write the Issue
## Context and Motivation
[Why does this matter? What business or technical need drives this?]
## Current State Diagnosis
[What exists today? How does the current implementation work? Be specific — reference files, patterns, and architecture.]
## Identified Problems
[Concrete problems with the current state. Use a numbered or bulleted list.]
## Objectives
[What should be true when this is done? Clear, measurable goals.]
## Proposed Solution
[The recommended approach. Be specific about what to change, where, and how. Reference actual files/modules when possible.]
## Alternatives Considered
[At least one alternative approach and why it was not chosen.]
## Pros and Cons
### Pros
[Benefits of the proposed solution]
### Cons
[Tradeoffs, costs, or downsides]
## Execution Plan
[Step-by-step implementation plan. Order matters — list dependencies between steps. Use checkboxes.]
- [ ] Step 1
- [ ] Step 2
- [ ] ...
## Risks and Precautions
[What could go wrong? Migration risks, breaking changes, performance concerns, data loss scenarios.]
## Acceptance Criteria
[How do we know this is done? Specific, testable criteria.]
- [ ] Criterion 1
- [ ] Criterion 2
## Expected Outcome
[Paint the picture of success. What does the system look like after this is complete?]
## Related Issues / Notes
[Links to related issues, PRs, or external references. Use `#number` for cross-references. If none, say "None."]src/auth/middleware.tsStep 6 — Check for Duplicates
Strategy 1 — Keyword Search
gh issue list --search "<keyword1> <keyword2>" --state all --limit 30 --json number,title,state,url,labels 2>&1Strategy 2 — Area Search
gh issue list --search "<area-term>" --state all --limit 30 --json number,title,state,url,labels 2>&1Strategy 3 — Label Search (if applicable)
gh issue list --label "<relevant-label>" --state all --limit 20 --json number,title,state,url 2>&1Similarity Evaluation
| Dimension | Question | Weight |
|---|---|---|
| Intent | Do both issues aim to solve the same underlying problem? | High |
| Domain | Do they affect the same area/module of the codebase? | Medium |
| Approach | Do they propose similar solutions? | Low |
- High similarity (intent + domain match): Treat as duplicate.
- Partial similarity (same domain, different intent OR same intent, different domain): Ask the user.
- Low similarity (only superficial textual overlap): Not a duplicate — proceed.
- Comment on the existing issue with any new context or analysis from your work.
- Include a summary of what new information you're adding.
- Tell the user what you did and provide the existing issue URL.
A similar issue was previously addressed and closed: #[number] — [title]. Should I reopen it, create a new issue referencing it, or skip?
Step 7 — Validate and Prepare Labels
gh label list --limit 100 --json name --jq '.[].name' 2>&1-
If the label exists: Use it as-is (respect exact casing).
-
If the label does NOT exist: Create it before using it:bash
gh label create "<label-name>" --description "<brief description>" --color "<hex-color>" 2>&1Use these standard colors:Label Color bugd73a4aenhancementa2eeefrefactore4e669investigationd4c5f9architecture1d76dbhighb60205mediumfbca04low0e8a16backend5319e7frontendbfd4f2infraf9d0c4databasec2e0c6api006b75authe99695storaged4c5f9i18nfef2c0integrationsc5def5docs0075catestingbfdadcci-cdf9d0c4monitoringd93f0bIf label creation fails (e.g., insufficient permissions): Proceed without that label. Do NOT fail the entire issue creation. Log which labels could not be created and mention it to the user at the end.
Step 8 — Standardize the Title
[<Type>] <concise description>- Prefix is mandatory and must be one of: ,
[Bug],[Refactor],[Enhancement],[Investigation][Architecture] - Description must be concise, clear, and scannable
- Max length: 80 characters total (including prefix)
- Language: Same language chosen in Step 2
- No trailing punctuation
- No redundant words (avoid "Implement implementation of...", "Fix the fix for...")
[Bug] Login fails silently when session token expires[Refactor] Extract payment processing into dedicated service[Enhancement] Add bulk export for user analytics[Investigation] Intermittent 502 errors on /api/webhooks[Architecture] Migrate queue system from Redis to SQS
Step 9 — Create the Issue
-
Write the issue body to a temporary file:bash
ISSUE_FILE=$(mktemp /tmp/gh-issue-XXXXXX.md) -
Create the issue with error handling:bash
gh issue create \ --title "<standardized title>" \ --body-file "$ISSUE_FILE" \ --label "label1,label2" 2>&1 -
Handle errors:
Error Action gh: Not Found (HTTP 404)Repository not found or no access. Tell user to check repo permissions. gh: Validation FailedUsually invalid labels or title. Retry without labels, then report. gh: auth login requiredTell user to run .gh auth logingh: Resource not accessible by integrationInsufficient permissions (common with fine-grained tokens). Tell user to check token scopes. SAML enforcementOrganization requires SAML SSO. Tell user to authorize their token for the org. Any other error Capture the full error message, present it to the user, and save the issue body to so nothing is lost./tmp/gh-issue-draft.md -
Clean up the temporary file after successful creation:bash
rm -f "$ISSUE_FILE"
Step 10 — Post-Creation Cross-References
-
Comment on each related open issue with a cross-reference:bash
gh issue comment <related-issue-number> --body "Related: #<new-issue-number> — <brief description of relationship>" 2>&1 -
This ensures bidirectional traceability. Only do this for issues with partial similarity or clear topical relationship — not for every issue found during search.
Step 11 — Return the Result
- The URL of the created issue (and URLs of any additional issues if scope was split)
- A message that you commented on an existing issue (with the issue URL)
- A question to the user (if duplicate ambiguity or scope needs resolution)
- A note about any labels that could not be created (if applicable)
Edge Cases
- Ambiguous request: If the user's instruction is too vague to write a quality issue, ask one focused clarifying question before proceeding. Don't guess.
- Multiple issues needed: If the request clearly contains multiple distinct concerns, follow the Scope Control step (Step 4).
- Private repos: handles auth automatically. Errors are caught in Step 9.
gh - No CLI: Caught in Step 0. Tell the user to install it and provide the issue content in a temporary file they can use manually.
gh - No existing issues in repo: Skip language detection from issues, rely on README/commit messages/user language. Skip label search during deduplication.
- Rate limiting: If returns HTTP 429 or rate limit errors, tell the user to wait and retry. Do not retry automatically.
gh - Very large repos with many issues: The multi-strategy search in Step 6 uses targeted keyword queries instead of fetching all issues, so it scales to repositories of any size.
- Conflicting labels: If the repo already has labels with different naming conventions (e.g., instead of
type: bug), prefer the repo's existing convention. Map your intended labels to their equivalents.bug