Skip to main content
AI/MLWaterplanAI

ac-git-branch

Creates new git branch with corresponding spec directory structure. Triggers on keywords: create branch, new branch, branch with spec

Stars
31
Source
WaterplanAI/agentic-config
Updated
2026-05-25
Slug
WaterplanAI--agentic-config--ac-git-branch
View on GitHubRaw SKILL.md

// install — copy + paste into any project

mkdir -p .claude/skills && curl -fsSL https://raw.githubusercontent.com/WaterplanAI/agentic-config/HEAD/packages/pi-ac-git/skills/ac-git-branch/SKILL.md -o .claude/skills/ac-git-branch.md

Drops the SKILL.md into .claude/skills/ac-git-branch.md. Works with Claude Code, Cursor, and any agent that loads SKILL.md files from .claude/skills/.

Create Branch with Spec Directory

Create a new git branch and its corresponding spec directory.

Pre-Flight Checks

  1. Verify clean git state:

    • If dirty: STOP and list uncommitted changes
  2. Validate branch name:

    • Must be provided as argument
    • If empty: STOP with "Branch name required"

Execution

  1. Create and checkout branch:

    git checkout -b $ARGUMENTS
    
  2. Resolve and create spec directory:

    # Source the bundled spec resolver from this pi package
    source "../../assets/scripts/spec-resolver.sh"
    
    # Resolve spec path (handles external vs local)
    RELATIVE_PATH="$(date +%Y)/$(date +%m)/$ARGUMENTS/000-backlog.md"
    SPEC_FILE=$(resolve_spec_path "$RELATIVE_PATH")
    SPEC_DIR="${SPEC_FILE%/*}"  # Pure bash dirname equivalent
    
    # Create backlog file
    touch "$SPEC_FILE"
    
    • Path: Auto-resolved based on .env configuration
      • External: .specs/specs/<YYYY>/<MM>/<branch-name>/
      • Local: specs/<YYYY>/<MM>/<branch-name>/
    • Creates 000-backlog.md (empty file)
  3. Commit spec directory:

    # Extract NNN and title for commit_spec_changes
    # For backlog, use "000" and "backlog"
    commit_spec_changes "$SPEC_FILE" "CREATE" "000" "backlog"
    
    • CRITICAL: Must commit BEFORE creating worktree, otherwise spec files are lost
  4. Confirm:

    - Branch: $ARGUMENTS
    - Spec dir: <resolved-path>
    - Backlog: 000-backlog.md (committed)
    

Conditional Documentation

When configuring external specs repository or modifying spec path resolution, read:

  • ../../assets/scripts/spec-resolver.sh
  • ../../assets/scripts/external-specs.sh
  • ../../assets/scripts/lib/config-loader.sh