Skip to content

create-new-feature.ps1 missing git branch creation #3050

Description

@AhmedEssa1

Bug Description

The /specify command (via create-new-feature.ps1) generates a branch name and creates the feature directory structure, but does not create the actual git branch.

Expected Behavior

When running /specify add user authentication, the script should:

  1. ✅ Generate branch name (e.g., 001-user-authentication)
  2. ✅ Create specs/001-user-authentication/ directory
  3. ✅ Create specs/001-user-authentication/spec.md
  4. ✅ Save to .specify/feature.json
  5. MISSING: Create and checkout git branch with git checkout -b 001-user-authentication

Actual Behavior

Only steps 1-4 happen. The git branch is never created. Users remain on their current branch (e.g., master or main).

Environment

  • Spec Kit version: 0.11.0
  • OS: Windows 11
  • Script: .specify/scripts/powershell/create-new-feature.ps1

Root Cause

In create-new-feature.ps1 (line 212), after Save-FeatureJson is called, there is no git checkout -b invocation. The Get-CurrentBranch function in common.ps1 only reads from environment variables or .specify/feature.json — it's a virtual branch, not a real git branch.

Suggested Fix

Add after Save-FeatureJson call (around line 212):

# Create git branch for the new feature
try {
    $existingBranches = & git branch --list $branchName 2>$null
    if ($existingBranches) {
        Write-Warning "[specify] Git branch '$branchName' already exists. Checking it out..."
        & git checkout $branchName 2>$null | Out-Null
    } else {
        & git checkout -b $branchName 2>$null | Out-Null
        Write-Output "[specify] Created and checked out git branch: $branchName"
    }
} catch {
    Write-Warning "[specify] Failed to create git branch: $_"
}

This handles:

  • New branch creation
  • Existing branch checkout (idempotent)
  • Error handling if git is unavailable

Impact

Users following Spec-Driven Development workflows expect each feature to be isolated in its own git branch. Without automatic branch creation, users must manually run git checkout -b <branch-name> after every /specify command, which is error-prone and breaks the expected workflow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions