Skip to content

Commit 8618d0a

Browse files
fsilvaortizclaude
andauthored
fix: use global branch numbering instead of per-short-name detection (#1757)
* fix: remove per-short-name number detection from specify prompt The specify.md prompt instructed the AI to search for existing branches filtered by the exact short-name, causing every new feature to start at 001 since no branches matched the new short-name. The underlying create-new-feature.sh script already has correct global numbering logic via check_existing_branches() that searches ALL branches and spec directories. The fix removes the AI's flawed number-detection steps and tells it to NOT pass --number, letting the script auto-detect the next globally available number. Closes #1744 Closes #1468 🤖 Generated with [Claude Code](https://claude.com/code) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: clarify --json flag requirement per Copilot review - Rephrased step 2 to mention both --short-name and --json flags - Added explicit note to always include the JSON flag for reliable output parsing Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 71e6b4d commit 8618d0a

File tree

1 file changed

+5
-24
lines changed

1 file changed

+5
-24
lines changed

templates/commands/specify.md

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -39,33 +39,14 @@ Given that feature description, do this:
3939
- "Create a dashboard for analytics" → "analytics-dashboard"
4040
- "Fix payment processing timeout bug" → "fix-payment-timeout"
4141

42-
2. **Check for existing branches before creating new one**:
42+
2. **Create the feature branch** by running the script with `--short-name` (and `--json`), and do NOT pass `--number` (the script auto-detects the next globally available number across all branches and spec directories):
4343

44-
a. First, fetch all remote branches to ensure we have the latest information:
45-
46-
```bash
47-
git fetch --all --prune
48-
```
49-
50-
b. Find the highest feature number across all sources for the short-name:
51-
- Remote branches: `git ls-remote --heads origin | grep -E 'refs/heads/[0-9]+-<short-name>$'`
52-
- Local branches: `git branch | grep -E '^[* ]*[0-9]+-<short-name>$'`
53-
- Specs directories: Check for directories matching `specs/[0-9]+-<short-name>`
54-
55-
c. Determine the next available number:
56-
- Extract all numbers from all three sources
57-
- Find the highest number N
58-
- Use N+1 for the new branch number
59-
60-
d. Run the script `{SCRIPT}` with the calculated number and short-name:
61-
- Pass `--number N+1` and `--short-name "your-short-name"` along with the feature description
62-
- Bash example: `{SCRIPT} --json --number 5 --short-name "user-auth" "Add user authentication"`
63-
- PowerShell example: `{SCRIPT} -Json -Number 5 -ShortName "user-auth" "Add user authentication"`
44+
- Bash example: `{SCRIPT} --json --short-name "user-auth" "Add user authentication"`
45+
- PowerShell example: `{SCRIPT} -Json -ShortName "user-auth" "Add user authentication"`
6446

6547
**IMPORTANT**:
66-
- Check all three sources (remote branches, local branches, specs directories) to find the highest number
67-
- Only match branches/directories with the exact short-name pattern
68-
- If no existing branches/directories found with this short-name, start with number 1
48+
- Do NOT pass `--number` — the script determines the correct next number automatically
49+
- Always include the JSON flag (`--json` for Bash, `-Json` for PowerShell) so the output can be parsed reliably
6950
- You must only ever run this script once per feature
7051
- The JSON is provided in the terminal as output - always refer to it to get the actual content you're looking for
7152
- The JSON output will contain BRANCH_NAME and SPEC_FILE paths

0 commit comments

Comments
 (0)