# Branch

> Create Development Branch Skill

- Skill: `valasubramanian-kr/branch` (Agent Skill)
- Install (CLI): `npx skillmds@latest add valasubramanian-kr/branch`
- Raw SKILL.md: https://api.skillmd.com/api/skills/valasubramanian-kr/branch/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: valasubramanian-kr (https://skillmd.com/u/valasubramanian-kr)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/valasubramanian-kr/branch

---


# Create Development Branch Skill

## Purpose

Create a development branch with standardized naming convention (`dcppay-<JIRA-number>-<short-title>`) after implementation plan is approved.

## Usage

```bash
/branch
```

(Must be run after `/plan`)

## What This Skill Does

1. **Load Implementation Plan**: Reads `implementation-plan.md` to understand the work
2. **Extract JIRA Number**: Gets JIRA number from workflow directory
3. **Generate Branch Name**: Creates branch name in format `dcppay-<number>-<short-title>`
4. **Validate Branch**: Checks if branch already exists
5. **Create Branch**: Creates new branch from main for the current project repo
6. **Save Branch Details**: Outputs to `dev-branch.md`

## Implementation Plan Context

The implementation plan should be located in the most recent directory under `workflow/jira-to-github/*/implementation-plan.md`. You will need to find and read this file in Step 1.

## Instructions

You are creating a development branch for a JIRA issue. Follow these steps:

### Step 1: Validate Prerequisites and Load Context

First, find the most recent JIRA workflow directory and load the repo profile for branch naming:
```bash
ls -td workflow/jira-to-github/*/ | head -1
```

If no directory exists, display error:
```
❌ No JIRA issue found

Please run the following commands first:
1. /pull <JIRA-KEY>
2. /plan

Then try again.
```

If directory exists:
1. Read `workflow/jira-to-github/<JIRA-NUMBER>/target-repo.md` to get the profile path
2. Read the repo profile (e.g., `context/repos/esperanto.md`) to get the `Branch Naming` convention
3. Read the implementation plan from `workflow/jira-to-github/<JIRA-NUMBER>/implementation-plan.md` to understand the work
4. Use the branch naming format from the profile (default: `dcppay-<JIRA-number>-<short-title>` if no profile found)

### Step 2: Extract JIRA Information

From the workflow directory path, extract:
- JIRA number (e.g., DRT-17270 → 17270)
- JIRA key (e.g., DRT-17270)
- JIRA title (e.g., Web - WHPP - Develop UI - New card type)

### Step 3: Generate Short Title

Create a short, hyphenated title from the issue summary:
- Convert to lowercase
- Remove special characters
- Replace spaces with hyphens
- Limit to 2-3 meaningful words
- Max 20 characters

**Examples**:
- "Add eProtect error code handling" → "eprotect-error-code"
- "Fix wallet card deletion bug" → "fix-card-deletion"
- "Implement analytics tracking for checkout" → "analytics-checkout-tracking"

### Step 4: Generate Branch Name

Create branch name in format:
```
dcppay-<JIRA-number>-<short-title>
```

**Examples**:
- DRT-17270 → `dcppay-17270-eprotect-error-code`
- DRT-17345 → `dcppay-17345-fix-card-deletion`
- DRT-17410 → `dcppay-17410-analytics-checkout-tracking`

### Step 5: Validate Branch Doesn't Exist

Check if branch already exists locally or remotely:

```bash
# Check local branches
git branch --list "dcppay-<number>-*"

# Check remote branches
git fetch origin
git branch -r --list "origin/dcppay-<number>-*"
```

If branch exists:
- Display existing branch name
- Ask user if they want to:
  - A) Checkout existing branch
  - B) Create new branch with different name
  - C) Delete existing and create fresh

### Step 6: Get Latest from Main

Ensure working from latest main:

```bash
# Determine if repo uses main
DEFAULT_BRANCH=main

# Fetch latest
git fetch origin

# Switch to default branch
git checkout $DEFAULT_BRANCH

# Pull latest changes
git pull origin $DEFAULT_BRANCH
```

### Step 7: Create Development Branch

Create and checkout the new branch:

```bash
git checkout -b dcppay-<JIRA-number>-<short-title>
```

### Step 8: Save Branch Details

Create a branch details document:

```markdown
# Development Branch: dcppay-<JIRA-number>-<short-title>

## Branch Information

- **Branch Name**: `dcppay-<JIRA-number>-<short-title>`
- **JIRA Issue**: <JIRA-KEY>
- **Created From**: <DEFAULT_BRANCH>
- **Created At**: <timestamp>
```

Save to:
```
workflow/jira-to-github/<JIRA-NUMBER>/dev-branch.md
```

### Step 9: Display Summary

Display a concise summary to the user:

```
✓ Development Branch Created

Branch: dcppay-<JIRA-number>-<short-title>
JIRA: <JIRA-KEY>
Base: <DEFAULT_BRANCH>

Branch details saved to: workflow/jira-to-github/<JIRA-NUMBER>/dev-branch.md

Next step: Run /code to implement the changes
```

## Error Handling

If errors occur:
1. Log error to `workflow/jira-to-github/<JIRA-NUMBER>/errors.log`
2. Display user-friendly message
3. Suggest recovery action

Common errors:
- **No implementation plan found**: Run `/plan` first
- **Branch already exists**:
  - Display: `Branch dcppay-<number>-<title> already exists`
  - Options:
    - Checkout existing: `git checkout dcppay-<number>-<title>`
    - Rename: Suggest alternative name
    - Delete and recreate: `git branch -D dcppay-<number>-<title>` (confirm first)
- **Not on a git repository**: Ensure you're in the correct project directory
- **Uncommitted changes**: Stash or commit changes before creating branch
- **Network errors**: Check connectivity to git remote

## Examples

Example 1: Standard feature branch
```bash
/branch
# → dcppay-17270-eprotect-error-code
```

Example 2: Bug fix branch
```bash
/branch
# → dcppay-17345-fix-card-deletion
```

Example 3: Branch already exists
```bash
/branch
# → Branch already exists. Checkout existing? (Y/n)
```

