Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
224 changes: 122 additions & 102 deletions .cursor/commands/create-issue.md
Original file line number Diff line number Diff line change
@@ -1,151 +1,171 @@
# Create Issue Command

This command helps you create issues in GitHub repositories using the GitHub CLI.
**CREATES GITHUB ISSUES - REQUIRES USER CONFIRMATION**

## ⚠️ CRITICAL WORKFLOW - MUST FOLLOW
Execute `/create-issue` to create issues following project standards.

When creating an issue, **ALWAYS** follow these steps in order:
## EXECUTION PROTOCOL

### 1. Determine the target repository
### STEP 1: DETERMINE TARGET REPOSITORY

- If user specifies a repo (e.g., "ORG/REPO"), use that
- Otherwise, detect current repo with: `gh repo view --json nameWithOwner --jq .nameWithOwner`
```bash
# If user specifies repo: use "ORG/REPO"
# Otherwise detect current:
REPO=$(gh repo view --json nameWithOwner --jq .nameWithOwner)
```

### 2. Verify the repository exists
### STEP 2: VERIFY REPOSITORY ACCESS

```bash
gh repo view ORG/REPO --json nameWithOwner,description
gh repo view $REPO --json nameWithOwner,description
```

- If successful, show repo name and description
- If failed, inform user the repo doesn't exist or isn't accessible
**IF fails:**
→ Display: "❌ Repository not found or not accessible: $REPO"
→ ABORT

### 3. **⚠️ CONFIRM WITH USER FIRST** (MANDATORY)
**IF succeeds:**
→ Display repo name and description
→ PROCEED to STEP 3

**DO NOT create the issue yet!** Show the user:
- ✓ Target repository: `ORG/REPO`
- ✓ Issue type: `Bug` / `Feature` / `Task`
- ✓ Issue title: `"Your title here"`
- ✓ Preview of issue body (first 20 lines)
- ❓ **Ask:** "Create this issue? (yes/no)"
### STEP 3: GATHER ISSUE DETAILS

### 4. Create the issue ONLY after user confirms "yes"
**Determine from user input:**
- Issue type: Bug / Feature / Task
- Title (clear, descriptive)
- Body (structured with headings)
- Assignees (optional)

GitHub will automatically assign the next available issue number. **DO NOT** specify the issue number yourself!
**Format body based on type:**

## Quick Reference
**Bug:**
```markdown
## Description
[What's wrong]

### Create a Bug Issue
## Steps to Reproduce
1. [Step 1]
2. [Step 2]

```bash
gh api \
--method POST \
/repos/ORG/REPO/issues \
--field title="Brief description of the problem" \
--field body="<your issue body>" \
--field type="Bug"
## Expected Behavior
[What should happen]

## Actual Behavior
[What actually happens]

## Environment
- OS:
- Version:
```

### Create a Feature Issue
**Feature:**
```markdown
## Feature Request
[What feature is needed]

```bash
gh api \
--method POST \
/repos/ORG/REPO/issues \
--field title="Feature title" \
--field body="<your issue body>" \
--field type="Feature"
## Use Case
[Why it's needed]

## Proposed Solution
[How it could work]

## Alternatives Considered
[Other approaches]
```

### Create a Task Issue
**Task:**
```markdown
## Task Description
[What needs to be done]

```bash
gh api \
--method POST \
/repos/ORG/REPO/issues \
--field title="Task: Brief description" \
--field body="<your issue body>" \
--field type="Task" \
--field assignees[]="username"
## Acceptance Criteria
- [ ] [Criterion 1]
- [ ] [Criterion 2]

## Related Issues
- Related to #X
```

**Important Notes:**
- GitHub automatically assigns the next available issue number
- **DO NOT add labels** unless explicitly requested by user
- Only use: `title`, `body`, `type`, and optionally `assignees[]`
### STEP 4: CONFIRM WITH USER (MANDATORY)

## Utility Commands
**MUST display preview and wait for confirmation:**

### Get Current Repo
```text
📋 Issue Preview

```bash
gh repo view --json nameWithOwner --jq .nameWithOwner
```
Target: ORG/REPO
Type: Bug/Feature/Task
Title: "Your title here"

### Verify Repo Exists
Body:
[First 20 lines of body...]

```bash
gh repo view ORG/REPO --json nameWithOwner,description
❓ Create this issue? (yes/no)
```

Example output:
**WAIT for user response.**

```json
{
"description": "Repository description",
"nameWithOwner": "ORG/REPO"
}
```
**IF user says "no" or anything other than "yes":**
→ Display: "Issue creation cancelled"
→ ABORT

**IF user says "yes":**
→ PROCEED to STEP 5

### Check Repo Access
### STEP 5: CREATE ISSUE

**GitHub auto-assigns issue number - DO NOT specify it yourself:**

```bash
gh repo view ORG/REPO --json nameWithOwner,description,viewerPermission
gh api --method POST /repos/$REPO/issues \
--field title="$TITLE" \
--field body="$BODY"
```

---
**IF assignees requested:**
```bash
gh api --method POST /repos/$REPO/issues \
--field title="$TITLE" \
--field body="$BODY" \
--field assignees[]="$USERNAME"
```

## Examples
**DO NOT add labels unless user explicitly requests them.**

### Example 1: Bug Report
### STEP 6: CONFIRM CREATION

```bash
# 1. Get repo
REPO=$(gh repo view --json nameWithOwner --jq .nameWithOwner)
```text
✅ Issue created successfully

# 2. Show user what will be created
echo "Creating bug report in $REPO"
echo "Type: Bug"
echo "Title: Login button doesn't work on mobile"
echo ""
echo "Create this issue? (yes/no)"
read -r confirm

# 3. Create only if confirmed
if [ "$confirm" = "yes" ]; then
gh api --method POST /repos/$REPO/issues \
--field title="Login button doesn't work on mobile" \
--field body="## Description
Login button is not responsive on mobile devices..." \
--field type="Bug"
fi
Issue: #<number>
Title: <title>
URL: https://github.com/ORG/REPO/issues/<number>
```

### Example 2: Feature Request
## ERROR HANDLING

```bash
gh api --method POST /repos/ORG/REPO/issues \
--field title="Add dark mode support" \
--field body="## Feature Request\n\nWe should add dark mode..." \
--field type="Feature"
```
**Repository not found:**
→ "❌ Repository not accessible: ORG/REPO"
→ Verify repo exists and you have access

**Authentication failure:**
→ Run `gh auth status`
→ Run `gh auth login` if not authenticated

**API error:**
→ Check error message from gh CLI
→ Verify user has write access to repo

---
## CRITICAL RULES

## Common Mistakes
**NEVER:**
- ❌ Specify issue number (GitHub auto-assigns)
- ❌ Add labels without explicit user request
- ❌ Create without user confirmation
- ❌ Use fields other than: title, body, assignees

❌ **Specifying issue number** - GitHub assigns this automatically
❌ **Adding labels** - DO NOT add `labels[]` unless user explicitly asks
❌ **Creating without confirmation** - Always ask user first
❌ **Wrong type values** - Must be exactly: `Bug`, `Feature`, or `Task`
❌ **Assuming what user wants** - Only add fields user explicitly requests
**ALWAYS:**
- ✅ Show preview before creating
- ✅ Wait for explicit "yes" confirmation
- ✅ Let GitHub assign issue number
- ✅ Use structured body format
Loading
Loading