---
description: Report issues with intelligent type detection and comprehensive documentation
argument-hint: <description of the issue>
---

# /eg:issue

You are tasked with creating comprehensive issue reports from user descriptions, automatically determining issue type and generating well-structured documentation.

Input: `$ARGUMENTS`

## Step 1: Parse Description

Extract the issue description from arguments. If no description provided, prompt the user.

```
!if [ -z "$ARGUMENTS" ]; then
  echo "Please provide an issue description"
  echo "Usage: /eg:issue \"description of the issue\""
  exit 1
fi
```

## Step 2: Initialize Issue Directory

Create a timestamped directory for the issue:

```
!timestamp=$(date +%Y%m%d-%H%M%S)
!mkdir -p .eg/issues/${timestamp}
```

## Step 3: Generate Issue Report

Use the Task tool to create a comprehensive issue report:

```
Task(
  description="Create issue report",
  prompt=`
    Analyze this issue description: $ARGUMENTS
    
    Use the issue report template from .claude/templates/issue-report.template.md
    
    Your tasks:
    1. Determine issue type (bug, feature, improvement) from the description
    2. Create a comprehensive report filling all relevant sections
    3. Auto-populate environment information (git branch, commit, etc.)
    4. Generate appropriate content based on issue type:
       - For bugs: reproduction steps, expected/actual behavior
       - For features: use cases, proposed solutions, alternatives
       - For improvements: current behavior, proposed enhancement, benefits
    5. Use the appropriate emoji (🐛, ✨, 🔧)
    6. Make intelligent inferences when details are unclear
    7. Include relevant technical context from the codebase
    
    Save the report to: .eg/issues/${timestamp}/issue-report.md
  `,
  subagent_type="eg-issue-creator"
)
```

## Step 4: Review Generated Report

Display the generated report for review:

```
!echo "📋 Issue Report Generated"
!echo "========================"
!cat .eg/issues/${timestamp}/issue-report.md
!echo ""
!echo "Report saved to: .eg/issues/${timestamp}/issue-report.md"
```

## Step 5: GitHub Integration (Optional)

Check if GitHub CLI is available and offer to create an issue:

```
!if command -v gh >/dev/null 2>&1; then
  if git rev-parse --git-dir >/dev/null 2>&1; then
    echo ""
    echo "🐙 GitHub Integration Available"
    echo "Would you like to create a GitHub issue from this report? (yes/no)"
    echo ""
    echo "To create manually later, run:"
    echo "gh issue create --title \"<title>\" --body-file .eg/issues/${timestamp}/issue-report.md"
  fi
else
  echo ""
  echo "💡 Tip: Install GitHub CLI (gh) to create issues directly from reports"
fi
```

## Step 6: Quick Actions

Provide helpful next steps based on issue type:

```
!# Extract issue type from the report
!issue_type=$(grep -m1 "^# [🐛✨🔧]" .eg/issues/${timestamp}/issue-report.md | sed 's/.*\([🐛✨🔧]\).*/\1/')

!case "$issue_type" in
  "🐛")
    echo ""
    echo "🐛 Bug Report Created"
    echo "Next steps:"
    echo "1. Debug the issue: /eg:debug bug-${timestamp} @.eg/issues/${timestamp}/issue-report.md"
    echo "2. Create GitHub issue: gh issue create --label bug --body-file .eg/issues/${timestamp}/issue-report.md"
    ;;
  "✨")
    echo ""
    echo "✨ Feature Request Created"
    echo "Next steps:"
    echo "1. Define the feature: /eg:define feature-${timestamp} @.eg/issues/${timestamp}/issue-report.md"
    echo "2. Create GitHub issue: gh issue create --label enhancement --body-file .eg/issues/${timestamp}/issue-report.md"
    ;;
  "🔧")
    echo ""
    echo "🔧 Improvement Request Created"
    echo "Next steps:"
    echo "1. Architect the improvement: /eg:architect improvement-${timestamp} @.eg/issues/${timestamp}/issue-report.md"
    echo "2. Create GitHub issue: gh issue create --label improvement --body-file .eg/issues/${timestamp}/issue-report.md"
    ;;
esac
```

## Step 7: Issue History

Maintain a log of all reported issues:

```
!echo "${timestamp} | ${issue_type} | $ARGUMENTS" >> .eg/issues/history.log
!echo ""
!echo "📂 Recent issues:"
!tail -5 .eg/issues/history.log 2>/dev/null || echo "No previous issues found"
```

## Success Message

The issue has been documented and is ready for action. The report includes all necessary context for developers to understand and address the issue effectively.