create-branch
Create and checkout a new git branch with smart validation and GitHub issue integration
What this skill does
## Language Conventions
**Infer language style from the project:**
- Analyze existing branches, commit messages, and documentation to detect the project's language variant (US English, UK English, etc.)
- Match the spelling conventions found in the project (e.g., "synchronize" vs "synchronise", "center" vs "centre")
- Maintain consistency with the project's established language style throughout branch names and command outputs
---
# Create Branch Command
This command creates and checks out a new git branch with intelligent validation and GitHub issue integration.
## Priority: GitHub Issue Integration
**IMPORTANT**: If the user provides an issue number (e.g., "#123", "123", or "issue 123"), ALWAYS prioritise using GitHub CLI's issue development workflow:
1. **Check for GitHub CLI availability**:
```bash
gh --version
```
If not available, inform the user and fall back to manual branch creation.
2. **Verify the issue exists**:
```bash
gh issue view <issue-number>
```
Display issue title and status to confirm.
3. **Create branch linked to issue**:
```bash
gh issue develop <issue-number> -c
```
- The `-c` flag automatically checks out the newly created branch
- GitHub automatically generates an appropriate branch name from the issue title
- The branch is linked to the issue for better project tracking
4. **Skip to remote push step** (step 8 below)
## Manual Branch Creation Workflow
If no issue number is provided, follow this workflow:
### 1. Check Repository Status
```bash
git status
```
Verify:
- Clean working directory or acceptable uncommitted changes
- Current branch information
- Whether we're in a git repository
### 2. Get Branch Name Input
Ask the user for the desired branch name. Accept input in any format - the command will handle formatting and validation.
### 3. Auto-Detect and Apply Prefix
Analyse the branch name input for keywords and automatically add appropriate prefixes:
- **feature/** - Keywords: "add", "implement", "create", "new", "feature"
- **bugfix/** - Keywords: "fix", "bug", "resolve", "patch", "repair"
- **hotfix/** - Keywords: "hotfix", "urgent", "critical", "emergency"
- **chore/** - Keywords: "chore", "refactor", "update", "upgrade", "maintain"
- **docs/** - Keywords: "docs", "documentation", "readme", "guide"
If the user's input already starts with a recognised prefix (feature/, bugfix/, etc.), keep it as-is.
### 4. Validate Branch Name
Apply comprehensive validation:
#### Kebab-Case Enforcement
- Convert to lowercase
- Replace spaces and underscores with hyphens
- Ensure format is: `prefix/kebab-case-name`
#### Character Validation
Reject branch names containing:
- Spaces (convert to hyphens)
- Special characters: `~`, `^`, `:`, `?`, `*`, `[`, `]`, `\`, `@{`, `..`
- Control characters or non-ASCII (except hyphens and slashes)
- Leading or trailing slashes or hyphens
#### Length Validation
- Minimum: 3 characters (excluding prefix)
- Maximum: 100 characters (total)
### 5. Check for Duplicates
Check both local and remote branches:
```bash
# Check local branches
git branch --list "<branch-name>"
# Check remote branches
git ls-remote --heads origin "<branch-name>"
```
If branch exists:
- **Locally**: Offer to checkout existing branch instead
- **Remotely**: Warn user and suggest alternative name
- **Both**: Inform user and ask if they want to checkout or choose different name
### 6. Determine Base Branch
Use smart defaulting:
1. Check if `main` exists:
```bash
git rev-parse --verify main
```
2. If not, check if `master` exists:
```bash
git rev-parse --verify master
```
3. If neither exists, use current HEAD
4. Allow user to specify different base branch if needed (ask before creating)
### 7. Create and Checkout Branch
```bash
git checkout -b <validated-branch-name> <base-branch>
```
Confirm successful creation with a message showing:
- Branch name
- Base branch used
- Current status
### 8. Remote Push Recommendation
Ask the user: "Would you like to push this branch to remote and set up tracking?"
If yes:
```bash
git push -u origin <branch-name>
```
This enables:
- Remote backup of the branch
- Collaboration with team members
- GitHub PR creation workflow
- Branch visibility in GitHub UI
## Error Handling
Provide clear, actionable error messages:
- **Not a git repository**: "This directory is not a git repository. Initialise one with `git init` or navigate to a repository."
- **GitHub CLI not available**: "GitHub CLI (`gh`) is not installed. Install it from https://cli.github.com or use manual branch creation."
- **Issue not found**: "Issue #123 not found. Check the issue number or create a branch manually."
- **Invalid branch name**: "Branch name contains invalid characters. Suggested: `feature/valid-branch-name`"
- **Branch exists**: "Branch `feature/existing` already exists. Switch to it with `git checkout feature/existing` or choose a different name."
- **Network issues**: "Unable to check remote branches. Proceeding with local creation only."
## Examples
### Example 1: GitHub Issue Integration
```
User: "Create a branch for issue #456"
Command: gh issue view 456
Output: #456 - Add user authentication (open)
Command: gh issue develop 456 -c
Output: Created and checked out branch: feature/456-add-user-authentication
```
### Example 2: Manual with Auto-Prefix
```
User: "Create branch: fix login bug"
Analysis: Contains "fix" → apply "bugfix/" prefix
Validated: "bugfix/login-bug"
Command: git checkout -b bugfix/login-bug main
```
### Example 3: Custom Prefix
```
User: "Create branch: docs/update readme"
Analysis: Already has "docs/" prefix → keep as-is
Validated: "docs/update-readme"
Command: git checkout -b docs/update-readme main
```
## Best Practises
1. **Always prioritise GitHub issue workflow** when issue numbers are mentioned
2. **Validate thoroughly** before creating branches to avoid git errors
3. **Use descriptive names** that clearly indicate the purpose
4. **Follow team conventions** - check existing branch names for patterns
5. **Push to remote early** for backup and collaboration
6. **Link branches to issues** whenever possible for better project tracking
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.