branch
Scannednpx machina-cli add skill nmoinvaz/speedy-gonzales/branch-name --openclawFiles (1)
SKILL.md
1.6 KB
Create a new branch following the repository's naming conventions:
-
Determine branch type:
- Use AskUserQuestion with options:
- "Feature branch"
- "Bug fix branch"
- "Cleanup branch"
- Use AskUserQuestion with options:
-
Analyze repository branch naming conventions:
- Get recent branch names:
git for-each-ref --sort=-committerdate refs/heads/ --format='%(refname:short)' --count=20 - Look for patterns like:
feature/TICKET-123-descriptionbugfix/TICKET-123-descriptionusername/feature/TICKET-123-descriptionTICKET-123-description
- Get recent branch names:
-
Search for ticket IDs:
- Check the conversation history for any mentioned ticket IDs (patterns like PROJ-123, etc.)
- If there are staged changes, search them for ticket IDs
- If no ticket ID found, ask the user for a ticket ID or description
-
Generate branch name:
- Follow the repository's detected convention
- For bug fix branches, add incremental suffix:
- Check for existing branches matching the base name pattern:
git branch --list '<base-branch-name>*' - If no matches exist, append
/1to the branch name - If matches exist (e.g.,
bugfix/PROJ-123/1,bugfix/PROJ-123/2), use the next number - Example: if
bugfix/PROJ-123/1andbugfix/PROJ-123/2exist, createbugfix/PROJ-123/3
- Check for existing branches matching the base name pattern:
-
Confirm and create:
- Present the suggested name and ask for confirmation or modification
- Create the branch:
git checkout -b <branch-name>
Source
git clone https://github.com/nmoinvaz/speedy-gonzales/blob/main/skills/branch-name/SKILL.mdView on GitHub Overview
Creates a new git branch following the repository's naming conventions. It guides you through selecting a branch type, detects ticket IDs, and applies incremented suffixes for bug fixes to ensure unique, consistent branches.
How This Skill Works
It prompts for branch type, analyzes existing naming conventions using git for-each-ref to infer patterns, searches for ticket IDs in history or staged changes, builds a base name per the detected convention, and prompts for confirmation before executing git checkout -b.
When to Use It
- Starting a new feature and you want the branch to match repo naming patterns
- Fixing a bug tied to a ticket and needing a unique bugfix branch with proper suffixes
- Cleaning up or refactoring where naming consistency matters
- When a ticket ID is mentioned in conversations or changes and should be reflected in the branch name
- You want to confirm the final branch name before creating it
Quick Start
- Step 1: Determine branch type with user prompt and inspect repo naming conventions using recent branches
- Step 2: Search for ticket IDs in history and staged changes, then generate a base name; for bug fixes, compute the next incremental suffix
- Step 3: Confirm the suggested branch name or modify it, then run git checkout -b <branch-name>
Best Practices
- Always determine the branch type from the user and align with repo conventions
- Check recent branches to understand current naming patterns before naming
- Incorporate ticket IDs when possible to improve traceability
- For bug fixes, rely on the incremental suffix to avoid naming collisions
- Verify the final suggested name during confirmation and adjust if needed
Example Use Cases
- feature/PROJ-123-add-login
- bugfix/PROJ-123/1-fix-auth-token
- username/feature/PROJ-124-improve-perf
- PROJ-77-improve-logging
- bugfix/PROJ-305/2-fix-crash-on-startup
Frequently Asked Questions
Add this skill to your agents