fix: validate prefix uniqueness when --number option is used#1340
Open
ggeutzzang wants to merge 1 commit intogithub:mainfrom
Open
fix: validate prefix uniqueness when --number option is used#1340ggeutzzang wants to merge 1 commit intogithub:mainfrom
ggeutzzang wants to merge 1 commit intogithub:mainfrom
Conversation
When --number is explicitly provided, validate that the specified prefix number is not already in use by another spec directory. This prevents collisions like: - Existing: 001-feature-a - New with --number 1: 001-feature-b (COLLISION!) The validation allows retrying the same feature (same suffix) but blocks creating different features with duplicate prefixes. Error message guides users to remove --number for auto-detection. Related to github#1332
Author
|
@copilot review |
nsalvacao
added a commit
to nsalvacao/spec-kit
that referenced
this pull request
Feb 19, 2026
When the user passes --number N (bash) / -Number N (PS1) explicitly, the chosen prefix (e.g. '003') might already be used by a different feature directory in specs/. Without this check the collision is silently accepted and two specs share the same prefix, causing ambiguity in branch names and spec lookups. Added a validation loop (bash) / foreach block (PS1) immediately after FEATURE_NUM is computed: - Iterates existing directories in specs/ - Extracts the 3-digit prefix of each - If a match is found AND the suffix differs, aborts with an error message and a hint to use auto-detection instead - If same suffix (idempotent retry), silently continues Upstream fix: github#1340 Closes #55 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
nsalvacao
added a commit
to nsalvacao/spec-kit
that referenced
this pull request
Feb 19, 2026
Adds the PS1 parity for bash commit 5745025 (cherry-picked from upstream github/spec-kit PR github#1340 by Hyungjoo Song). The bash change validates prefix collisions when --number is explicitly provided. This commit adds the equivalent logic to the PowerShell script. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
--numberis explicitly provided tocreate-new-feature.sh, this PR adds validation to ensure the specified prefix number is not already in use by another spec directory.Problem
Even after PR #1237 fixed the auto-detection logic, users can still create collisions by explicitly using the
--numberoption:Solution
Added validation after
FEATURE_NUMis calculated:Test
Related
Related to #1332 - This addresses a remaining edge case not covered by #1237
🤖 Generated with Claude Code