Skip to content

Instantly share code, notes, and snippets.

@RoseSecurity
Last active December 2, 2025 17:10
Show Gist options
  • Select an option

  • Save RoseSecurity/58e0ca95dd25da44fedf52a857e8ad85 to your computer and use it in GitHub Desktop.

Select an option

Save RoseSecurity/58e0ca95dd25da44fedf52a857e8ad85 to your computer and use it in GitHub Desktop.
Generate Jira tickets programmatically
#!/usr/bin/env bash
# Generate Jira tickets programmatically with AI-enhanced descriptions
# Requires gum, jira-cli, and claude CLI for interactivity
# Install gum: brew install gum
# Install claude CLI: https://docs.anthropic.com/en/docs/claude-code
if ! command -v gum &>/dev/null; then
echo "Error: Gum is not installed. Install it with 'brew install gum'."
exit 1
fi
if ! command -v claude &>/dev/null; then
echo "Error: Claude CLI is not installed. Visit https://docs.anthropic.com/en/docs/claude-code"
exit 1
fi
# Default to Task if not selected
TYPE="Task"
# Get priority
PRIORITY=$(gum choose --limit=1 --header="Select Priority" "Lowest" "Low" "Medium" "High" "Highest")
# Get title
TITLE=$(gum input --placeholder "Enter Ticket Title")
if [ -z "$TITLE" ]; then
echo "Error: Ticket Title cannot be empty."
exit 1
fi
# Get change category
CHANGE_TYPE=$(gum choose --limit=1 --header="Select Change Category" \
"Feature" "Bugfix" "Documentation" "Refactoring" "Performance" "Security" "Testing" "Infrastructure")
# Get historical context
echo ""
echo "Provide any relevant historical context (prior discussions, related tickets, background):"
HISTORICAL_CONTEXT=$(gum write --placeholder "Optional: Add context about why this work is needed, previous attempts, related issues, etc.")
# Get technical details
echo ""
echo "Provide technical details or initial implementation thoughts:"
TECHNICAL_DETAILS=$(gum write --placeholder "Optional: Add technical considerations, affected components, dependencies, etc.")
# Get acceptance criteria
echo ""
echo "Define acceptance criteria (what does 'done' look like?):"
ACCEPTANCE_CRITERIA=$(gum write --placeholder "Optional: List the specific conditions that must be met")
# Get labels
LABELS=$(gum input --placeholder "Enter labels for this ticket (comma-separated, optional)")
# Get story points
STORY_POINTS=$(gum input --placeholder "Enter story points for this ticket (press Enter for 1)")
if [ -z "$STORY_POINTS" ]; then
STORY_POINTS=1
fi
# Build the prompt for Claude
PROMPT="Generate a concise, well-structured Jira ticket description based on the following information:
Title: ${TITLE}
Type: ${TYPE}
Change Category: ${CHANGE_TYPE}
Priority: ${PRIORITY}
Historical Context:
${HISTORICAL_CONTEXT:-None provided}
Technical Details:
${TECHNICAL_DETAILS:-None provided}
Acceptance Criteria:
${ACCEPTANCE_CRITERIA:-None provided}
Please create a professional Jira ticket description that includes:
1. A brief overview/summary section
2. Background/context (if provided)
3. Technical approach or details (if provided)
4. Clear acceptance criteria formatted as checkable items
5. Any relevant notes or considerations
Keep the description concise but comprehensive. Use markdown formatting appropriate for Jira. Do not add sections that have no information provided."
echo ""
echo "Generating enhanced ticket description with Claude..."
echo ""
# Generate description using Claude
GENERATED_DESCRIPTION=$(claude -p "$PROMPT")
if [ $? -ne 0 ] || [ -z "$GENERATED_DESCRIPTION" ]; then
echo "Warning: Failed to generate AI description. Using manual input instead."
GENERATED_DESCRIPTION="${TECHNICAL_DETAILS}\n\n${ACCEPTANCE_CRITERIA}"
fi
# Display the generated ticket
echo "═══════════════════════════════════════════════════════════════"
echo "Generated Ticket Preview"
echo "═══════════════════════════════════════════════════════════════"
echo "Type: ${TYPE}"
echo "Title: ${TITLE}"
echo "Priority: ${PRIORITY}"
echo "Change Category: ${CHANGE_TYPE}"
echo "Story Points: ${STORY_POINTS}"
echo "Labels: ${LABELS:-None}"
echo ""
echo "Description:"
echo "───────────────────────────────────────────────────────────────"
echo "$GENERATED_DESCRIPTION"
echo "═══════════════════════════════════════════════════════════════"
echo ""
# Confirm and create the ticket
if gum confirm "Do you want to create this ticket?"; then
# Prepare labels with change type
if [ -z "$LABELS" ]; then
FINAL_LABELS="$CHANGE_TYPE"
else
FINAL_LABELS="$LABELS,$CHANGE_TYPE"
fi
jira issue create \
-t "$TYPE" \
-s "$TITLE" \
-y "$PRIORITY" \
-b "$GENERATED_DESCRIPTION" \
-l "$FINAL_LABELS" \
--custom story-points="$STORY_POINTS" \
-a "$(jira me)" \
--no-input
if [ $? -eq 0 ]; then
echo "✓ Ticket created successfully!"
else
echo "✗ Error: Failed to create the ticket."
exit 1
fi
else
echo "Ticket creation cancelled."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment