Skip to content

Conversation

@danieldekay
Copy link

The /specify command was always creating branches starting at 001, ignoring existing feature branches with different short-names.

Problem

Given existing branches 001-user-auth, 002-payment-flow, 003-dashboard, creating a new feature would incorrectly produce 001-admin-panel instead of 004-admin-panel.

Root Cause

The check_existing_branches() (bash) and Get-NextBranchNumber() (PowerShell) functions filtered by exact short-name match:

# Before: Only finds branches matching the specific short-name
grep -E "refs/heads/[0-9]+-${short_name}$"

# After: Finds all feature branches
grep -E "refs/heads/[0-9]+-"

This meant each unique short-name started its numbering from 001, rather than continuing the global sequence.

Changes

Bash (scripts/bash/create-new-feature.sh)

  • Changed remote, local, and specs directory searches to match pattern [0-9]+-* instead of [0-9]+-${short_name}
  • Added octal-to-decimal conversion (10#$num) to handle leading zeros correctly

PowerShell (scripts/powershell/create-new-feature.ps1)

  • Applied equivalent regex changes to match all feature branches
  • Maintains parity with bash implementation

Documentation (templates/commands/specify.md)

  • Updated instructions to clarify branch numbers increment globally across all features

Behavior

Branch numbers now increment sequentially regardless of short-name:

  • 001-user-auth002-payment-flow003-dashboard004-admin-panel
Original prompt

Fix the branch numbering issue with /specify command. Currently, when creating a new branch with /specify, it doesn't correctly find the right branch number and always starts at 001. The command should properly detect existing branches and increment the branch number correctly based on the highest existing branch number.

This pull request was created as a result of the following prompt from Copilot chat.

Fix the branch numbering issue with /specify command. Currently, when creating a new branch with /specify, it doesn't correctly find the right branch number and always starts at 001. The command should properly detect existing branches and increment the branch number correctly based on the highest existing branch number.

Copilot AI and others added 3 commits November 15, 2025 14:24
Copilot AI review requested due to automatic review settings November 15, 2025 15:32
Copilot finished reviewing on behalf of danieldekay November 15, 2025 15:38
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request fixes a branch numbering issue where the /specify command was incorrectly restarting numbering at 001 for each unique short-name instead of incrementing globally across all features.

Summary:

  • Modified branch number detection logic to check ALL feature branches regardless of short-name
  • Updated regex patterns in both Bash and PowerShell scripts to match the pattern [0-9]+-* instead of filtering by specific short-name
  • Updated documentation to clarify that branch numbers increment globally

Key Changes:

  • Changed branch detection from short-name-specific filtering to global feature branch scanning
  • Added octal-to-decimal conversion in Bash script to handle leading zeros correctly
  • Updated PowerShell script with equivalent changes to maintain parity

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
templates/commands/specify.md Updated documentation to clarify that branch numbers increment globally across all features, not per short-name
scripts/bash/create-new-feature.sh Modified regex patterns to match all feature branches and added octal-to-decimal conversion for branch numbers
scripts/powershell/create-new-feature.ps1 Applied equivalent regex pattern changes to match all feature branches instead of filtering by short-name

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

m1chalz added a commit to m1chalz/AI-First that referenced this pull request Nov 17, 2025
The /specify command was creating branches starting at 001 for each unique
short-name, ignoring existing feature branches with different names. This
caused branch numbers to reset instead of incrementing globally.

Changes:
- Modified check_existing_branches() to search ALL feature branches (pattern [0-9]+-*)
  instead of filtering by exact short-name match
- Added octal-to-decimal conversion (10#$num) to handle leading zeros correctly
- Updated documentation to clarify branch numbers increment globally across all features

Behavior after fix:
Branch numbers now increment sequentially regardless of short-name:
001-user-auth → 002-payment-flow → 003-dashboard → 004-admin-panel

Based on upstream PR: github/spec-kit#1198
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant