jira-to-branch
v1.0.2
Published
π AI-powered CLI tool to create Git branches from Jira tickets
Maintainers
Readme
π Jira to Branch CLI
An AI-powered CLI tool that creates meaningful Git branches from Jira tickets using OpenAI's advanced language models.
β¨ Features
- π OpenAI-Powered Generation: Advanced AI analysis using OpenAI GPT-3.5-turbo for superior branch names
- π Multiple Input Formats: Supports ticket IDs, browse URLs, and project URLs
- π― Smart Analysis: Deep understanding of technical context and business requirements
- β‘ Git Integration: Automatically creates and switches to new branches
- π¨ Beautiful Output: Colorful, informative terminal experience with detailed ticket information
- βοΈ Flexible Configuration: Easy setup with persistent configuration
- π Secure: Proper HTTPS validation and secure credential storage
π¦ Installation
Global Installation (Recommended)
npm install -g jira-to-branchFrom Source
git clone <repository>
cd jira-to-branch
npm install
./install.shLocal Development
git clone <repository>
cd jira-to-branch
npm install
npm run build
npm linkπ οΈ Setup
Before using the tool, configure your credentials:
jira-to-branch setupYou'll be prompted for:
- Jira Host: Your Jira instance (e.g.,
company.atlassian.net) - Jira Email: Your Jira account email
- Jira API Token: Generate one at https://id.atlassian.com/manage-profile/security/api-tokens
- OpenAI API Key: Get one at https://platform.openai.com/api-keys (required)
- Default Branch Prefix: Optional prefix for branches (e.g.,
feature,bugfix) - AI Model: Choose from GPT-3.5-turbo, GPT-4, GPT-4o, etc.
- AI Temperature: Controls randomness (0.0-1.0, lower = more consistent)
- AI Max Tokens: Maximum tokens for AI analysis (1-4000)
π Usage
Basic Usage
# Using ticket ID
jira-to-branch create EH-1234
# Using full Jira URL
jira-to-branch create "https://company.atlassian.net/browse/EH-1234"
# Quick alias
j2b create EH-1234Advanced Options
# Skip confirmation prompt
jira-to-branch create EH-1234 --yes
# Override branch prefix
jira-to-branch create EH-1234 --prefix bugfix
# Show detailed AI analysis
jira-to-branch create EH-1234 --analysis
# Combine options
jira-to-branch create EH-1234 --analysis --prefix feature --yes
# Quick branch command (alias)
jira-to-branch branch EH-1234
# or
jira-to-branch b EH-1234Configuration Commands
# View current configuration
jira-to-branch config
# Configure AI model settings
jira-to-branch ai-config
# Reconfigure all settings
jira-to-branch setup
# Get help
jira-to-branch --helpπΏ Branch Name Format
The tool generates branches in the format: <ticket-id>-<ai-generated-summary>
Examples:
EH-1234+ "Fix user authentication bug" βEH-1234-fix-auth-bugPROJ-567+ "Add payment integration API" βPROJ-567-add-payment-apiBUG-89+ "Update database schema for users" βBUG-89-update-user-schema
π AI-Powered Features:
- π§ Deep Context Understanding: Analyzes technical and business context using configurable AI models
- π― Intelligent Action Detection: Identifies primary intent and priority
- π Semantic Analysis: Understanding beyond keywords with natural language processing
- π Smart Prioritization: AI-driven relevance scoring for optimal branch names
- π¨ Structured Analysis: Clear reasoning and context categorization
- βοΈ Configurable Models: Support for GPT-3.5-turbo, GPT-4, GPT-4o, and more
- π§ Fine-tuning: Adjustable temperature and token limits for optimal results
π Detailed AI Analysis
Use the --analysis flag to see detailed AI reasoning:
jira-to-branch create EH-1234 --analysisThis provides:
- Primary Action: Main action verb (fix, add, update, etc.)
- Technical Context: Relevant technical terms and components
- Business Context: Business-related terms and implications
- Reasoning: AI's explanation for the chosen branch name
π― Workflow
- Input Processing: Accepts Jira ticket ID or URL with format validation
- Repository Validation: Ensures command is run within a Git repository
- Configuration Check: Loads or prompts for required credentials (Jira + OpenAI)
- Ticket Fetching: Retrieves comprehensive ticket information from Jira API
- Rich Display: Shows detailed ticket information (title, type, status, priority, assignee)
- AI Analysis: GPT-3.5-turbo semantic analysis for intelligent branch naming
- Branch Generation: Creates concise, meaningful branch names with AI reasoning
- User Confirmation: Shows current branch and prompts for confirmation (unless
--yes) - Git Integration: Creates and switches to the new branch
- Success Feedback: Confirms successful branch creation
π Supported Input Formats
- Ticket ID:
EH-1234,PROJ-567 - Browse URL:
https://company.atlassian.net/browse/EH-1234 - Project URL:
https://company.atlassian.net/projects/EH/issues/EH-1234 - URL with Parameters: URLs with query parameters and fragments
π§ Configuration
Configuration is stored in ~/.jira-to-branch.json:
{
"jiraHost": "company.atlassian.net",
"jiraEmail": "[email protected]",
"jiraToken": "your-api-token",
"openaiApiKey": "sk-...",
"defaultBranchPrefix": "feature",
"aiModel": "gpt-3.5-turbo",
"aiTemperature": 0.3,
"aiMaxTokens": 500
}AI Model Configuration
Use the dedicated AI configuration command for fine-tuning:
jira-to-branch ai-configAvailable Models:
gpt-3.5-turbo(recommended) - Fast and cost-effectivegpt-4- More accurate but slower and more expensivegpt-4-turbo-preview- Latest GPT-4 with improved performancegpt-4o- Optimized version of GPT-4gpt-4o-mini- Smaller, faster version of GPT-4o
Configuration Options:
- Temperature: Controls creativity vs consistency (0.0 = deterministic, 1.0 = creative)
- Max Tokens: Limits response length (higher = more detailed analysis)
π‘οΈ Security & Reliability
- Secure HTTPS: Proper certificate validation with custom HTTPS agent
- Credential Protection: API tokens stored locally and masked in output
- Error Handling: Comprehensive error handling with specific error messages
- Rate Limiting: Handles Jira API rate limits gracefully
- Timeout Management: 15-second timeout for API requests
- Connection Testing: Built-in connection validation for both Jira and OpenAI
π Troubleshooting
Common Issues:
Authentication Failed (401)
- Verify your Jira email and API token
- Check if your Jira host URL is correct (without https://)
- Ensure your API token is valid and not expired
Access Denied (403)
- Check your permissions for the specific project/ticket
- Verify you have access to the Jira instance
Ticket Not Found (404)
- Verify the ticket ID exists and is accessible
- Check the project key format (e.g., EH-1234)
Rate Limit Exceeded (429)
- Wait a few minutes before retrying
- Consider reducing API call frequency
Git Repository Error
- Run the command from within a Git repository
- Ensure Git is installed and configured
OpenAI API Issues
- Verify your OpenAI API key is valid
- Check your OpenAI account has sufficient credits
- Ensure network connectivity to OpenAI API
Debug Information:
The tool provides detailed error messages and status updates for troubleshooting.
π Technical Details
Dependencies
- axios: HTTP client for Jira API calls
- chalk: Terminal color output
- commander: CLI framework
- inquirer: Interactive prompts
- openai: OpenAI API integration
- TypeScript: Type-safe development
AI Analysis Process
Uses OpenAI GPT-3.5-turbo with structured prompts for semantic analysis:
- Analyzes ticket summary and description
- Identifies primary actions and technical context
- Generates concise, meaningful branch names
- Ensures proper formatting and length constraints
Branch Name Constraints
- Maximum 50 characters total
- Ticket ID case preserved, suffix in lowercase with hyphens
- Ticket ID prefix always preserved
- Meaningful technical terms prioritized
- Action words emphasized
π€ Contributing
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes with proper TypeScript types
- Build and test:
npm run build && npm run dev - Submit a pull request
π License
MIT License - see LICENSE file for details.
π Examples
Real-world Usage:
# AI-powered generation
$ jira-to-branch create AUTH-123
π Starting AI-powered branch creation...
βΉ Detected Jira ticket: AUTH-123
βΉ Connecting to Jira...
βΉ Fetching ticket information...
π Ticket Information:
Title: Fix OAuth token refresh mechanism
Type: Bug
Status: In Progress
Priority: High
Assignee: John Doe
βΉ π€ Generating branch name with OpenAI...
πΏ AI-generated branch: AUTH-123-fix-oauth-token-refresh
π Current branch: main
? Create and switch to this branch? Yes
βΉ Creating new branch...
β Successfully created and switched to branch: AUTH-123-fix-oauth-token-refresh
# Skip confirmation with --yes
$ jira-to-branch create FEAT-456 --yes
π Starting AI-powered branch creation...
βΉ Detected Jira ticket: FEAT-456
βΉ Connecting to Jira...
βΉ Fetching ticket information...
π Ticket Information:
Title: Implement payment gateway integration with Stripe API
Type: Story
Status: To Do
Priority: Medium
Assignee: Jane Smith
βΉ π€ Generating branch name with OpenAI...
πΏ AI-generated branch: FEAT-456-implement-payment-gateway
βΉ Creating new branch...
β Successfully created and switched to branch: FEAT-456-implement-payment-gateway
# With detailed AI analysis
$ jira-to-branch create API-321 --analysis
π Starting AI-powered branch creation...
π Ticket Information:
Title: Implement user authentication API with JWT tokens
Type: Story
Status: To Do
Priority: High
Assignee: Alice Johnson
βΉ π€ Generating branch name with OpenAI...
πΏ AI-generated branch: API-321-implement-user-auth-jwt
π AI Analysis:
Primary Action: implement
Technical Context: authentication, api, jwt, tokens
Business Context: user, security
Reasoning: Focuses on the primary action 'implement' and key technical components 'auth' and 'jwt' for a concise yet descriptive branch name
? Create and switch to this branch? Yes
β Successfully created and switched to branch: API-321-implement-user-auth-jwt
# With custom prefix
$ jira-to-branch create PERF-789 --prefix hotfix
π Starting AI-powered branch creation...
π Ticket Information:
Title: Optimize database query performance for user dashboard
Type: Improvement
Status: Selected for Development
Priority: High
Assignee: Bob Wilson
πΏ AI-generated branch: hotfix/PERF-789-optimize-db-query-performanceHappy branching! πΏ
