new-feature-branch

Create isolated git worktrees for new feature branches from the latest remote default branch.

Updated Sep 9, 2024
One-click install
npx skills add https://github.com/axel-kaliff/dotfiles --skill new-feature-branch
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: new-feature-branch
Source: https://github.com/axel-kaliff/dotfiles/tree/main/claude/.claude/skills/new-feature-branch
Command: npx skills add https://github.com/axel-kaliff/dotfiles --skill new-feature-branch

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Creating a new feature branch can accidentally start from stale local state, modify the main checkout, or leave untracked worktrees that clutter the repository. This Skill ensures new work begins from the latest remote main/master in an isolated worktree so the primary checkout remains untouched and safe.

Core Features & Use Cases

  • Repo layout detection: Detects normal working trees versus bare repositories and adapts git invocations accordingly.
  • Safe branching workflow: Fetches the remote default branch, updates the local reference, checks for uncommitted changes (skip for bare repos), and prevents branching from dirty worktrees.
  • Isolated worktrees: Creates branches as worktrees under $PROJECT_ROOT/.worktrees, ensures the directory exists and is ignored in normal repos, and changes the working directory into the new worktree.
  • Use Case: Ideal when starting a new feature, bugfix, or experimental change where you want an isolated, up-to-date branch without touching the main checkout.

Quick Start

Create a new feature worktree named feature/auth-flow from the latest main and switch into it.

Frequently Asked Questions about new-feature-branch

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a git worktree for a new feature branch from the latest remote main?

To create a git worktree for a new feature branch, this Skill fetches the latest remote default branch and creates an isolated worktree under your project's .worktrees directory, keeping the main checkout untouched. It then switches you into the new worktree automatically.

Can I create isolated git worktrees in a bare repository?

Yes, you can create isolated git worktrees in a bare repository. The Skill detects bare versus normal working tree layouts and adapts its git commands accordingly, skipping dirty state checks for bare repos while safely managing the worktree creation process.

What is the safest way to start a new feature branch without modifying my main checkout?

Using isolated git worktrees is the safest way to start a new feature branch without modifying your main checkout. This Skill fetches the updated default branch, prevents operations on dirty working trees, and builds the new branch in a separate directory.

Why does my git worktree creation fail when I have uncommitted changes?

Git worktree creation fails on uncommitted changes because this Skill intentionally prevents branching from dirty working trees to avoid losing work or mixing states. It checks for uncommitted changes in normal repos before fetching and creating the isolated worktree.

Does git worktree workflow support keeping the .worktrees directory ignored in version control?

Yes, the git worktree workflow ensures the .worktrees directory is ignored in version control. When creating a new feature worktree in normal repositories, the Skill automatically ensures the directory exists and is added to ignored paths to prevent clutter.

How do I ensure my new feature branch starts from the updated remote default branch instead of stale local state?

To ensure a new feature branch starts from the updated remote default branch instead of stale local state, this Skill fetches the remote main or master, updates the local reference, and creates the worktree directly from that fresh state.