Skip to content
Back to skills

Branch

ASecurity

Create a working branch from what you're working on. Description: $ARGUMENTS

  • 280 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added May 27, 2026
developmentgobashrefactoringgitfrontend

Security analysis

A100/100

Scanned May 27, 2026

npx -y skills add egregore-labs/egregore --skill branch --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Branch?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Branch
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/egregore-labs-branch/badge)](https://www.skillsdirectory.com/skills/egregore-labs-branch)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
Create a working branch from what you're working on.

Description: $ARGUMENTS

## What to do

1. Derive a topic slug from the description (lowercase, hyphens, no special chars, max 40 chars)
2. Determine branch type from description:
   - `dev/{author}/{topic-slug}` — default for session work
   - `feature/{topic-slug}` — explicit feature work
   - `bugfix/{topic-slug}` — bug fixes
3. Call `EnterWorktree` with `name` set to the topic slug

The WorktreeCreate hook handles everything: fetches develop, creates the branch, creates the worktree, sets up symlinks.

**Fallback:** If `EnterWorktree` fails, fall back to: `git checkout -b {branch-name} origin/develop`

## Deriving the topic slug

Extract the essence of what the user said into a short, meaningful slug:
- "auth flow in frontend" → `auth-flow`
- "fix the payment endpoint bug" → `fix-payment-endpoint`
- "refactoring the token store" → `refactor-token-store`
- "working on oauth implementation" → `oauth-implementation`

If no description is given, use today's date: `YYYY-MM-DD`

## Branch type detection

- Description mentions "fix", "bug", "broken", "crash" → `bugfix/`
- Description mentions "feature", "add", "implement", "new" → `feature/`
- Otherwise → `dev/{author}/` (general session work)

## Resuming existing branches

Before creating, check if a matching branch already exists:
```bash
git branch --list "dev/$AUTHOR/*$SLUG*" "feature/*$SLUG*" "bugfix/*$SLUG*"
```

If a match is found, offer to resume it instead of creating a new one.

## Reusing current worktree

If already in a worktree and the user needs a new branch (e.g., after their PR was merged):
1. Do NOT exit the worktree or create a new one
2. Create the new branch and checkout within the existing worktree:
   ```bash
   git fetch origin develop --quiet
   git checkout -b dev/$AUTHOR/$NEW_SLUG origin/develop
   ```
3. The worktree directory stays the same — only the branch changes
4. Confirm: `Switched to dev/$AUTHOR/$NEW_SLUG (same worktree).`

## Example

```
> /branch auth flow

Creating branch...

  git fetch origin develop --quiet
  git branch dev/alice/auth-flow origin/develop
  EnterWorktree → .claude/worktrees/auth-flow/
  git checkout dev/alice/auth-flow
  bash <main-dir>/bin/worktree.sh setup "$(pwd)" "<main-dir>"
  ✓ Created dev/alice/auth-flow (worktree, from develop)

Ready to work. /save when done.
```

```
> /branch fix payment endpoint bug

Creating branch...

  git fetch origin develop --quiet
  git branch bugfix/fix-payment-endpoint origin/develop
  EnterWorktree → .claude/worktrees/fix-payment-endpoint/
  git checkout bugfix/fix-payment-endpoint
  ✓ Created bugfix/fix-payment-endpoint (worktree, from develop)

Ready to work. /save when done.
```

```
> /branch

No description given. Using today's date.

  git branch dev/alice/2026-02-12 origin/develop
  EnterWorktree → .claude/worktrees/2026-02-12/
  git checkout dev/alice/2026-02-12
  ✓ Created dev/alice/2026-02-12 (worktree, from develop)

Ready to work. /save when done.
```

## Managed repos

If the user's description references a managed repo (listed in `egregore.json` → `repos[]`), create the branch in that repo's sibling directory instead of the hub.

Resolve the repo's base branch first:
```bash
BASE_BRANCH=$(jq -r --arg name "$REPO" '(.repos[]? // empty) | select((if type == "object" then .name else . end) == $name) | if type == "object" then .base_branch // "develop" else "develop" end' egregore.json)
REPO_DIR="$(cd .. && pwd)/$REPO"
git -C "$REPO_DIR" fetch origin "$BASE_BRANCH" --quiet
git -C "$REPO_DIR" checkout -b dev/$AUTHOR/$TOPIC_SLUG "origin/$BASE_BRANCH"
```

Use `git -C` with absolute paths — never `cd` into the repo.

```
> /branch auth flow in frontend

Creating branch in frontend...

  git -C ../frontend fetch origin main --quiet
  git -C ../frontend checkout -b dev/alice/auth-flow origin/main
  ✓ Created dev/alice/auth-flow in frontend (from main)

Ready to work. /save when done.
```

## Next

Make your changes, then `/commit` or `/save` when ready.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.