spec-kit icon indicating copy to clipboard operation
spec-kit copied to clipboard

[Bug]: create-new-feature.ps1 fails in a project whose path contains square brackets

Open adityajai119 opened this issue 2 weeks ago • 0 comments

Bug Description

scripts/powershell/create-new-feature.ps1 passes the project path to Set-Location, Test-Path and Get-ChildItem without -LiteralPath, so PowerShell reads [ and ] in that path as wildcards. In a project such as app [v2] the script stops at Set-Location $repoRoot with "Cannot find path ... because it does not exist". The Python helper creates the feature in the same kind of project.

Two more wildcard calls sit behind that one, so fixing only Set-Location is not enough:

  • Get-HighestNumberFromSpecs (Test-Path $SpecsDir, Get-ChildItem -Path $SpecsDir) sees no existing features and numbers the new one 001 again (001-payment-export next to 001-login-page).
  • $needsSpec = -not (Test-Path -PathType Leaf $specFile) reports an existing spec.md as missing, so -AllowExistingBranch on an existing feature rewrites that spec.md. In my run it was emptied, because the template lookup in common.ps1 has the same wildcard problem (#5396 addresses that part).

#4956 and #4970 fixed bracketed feature directories, and #5396 covers common.ps1. None of them changes create-new-feature.ps1.

Steps to Reproduce

Windows 11, Windows PowerShell 5.1:

uvx --from git+https://github.com/github/[email protected] specify init 'app [v2]' --integration codex --script ps --ignore-agent-tools --non-interactive
Set-Location -LiteralPath 'app [v2]'
mkdir specs\001-login-page | Out-Null
.\.specify\scripts\powershell\create-new-feature.ps1 -Json 'Add payment export'

Expected Behavior

{"BRANCH_NAME":"002-payment-export", ...} and exit 0, as the Python helper prints for the same project layout.

Actual Behavior

Set-Location : Cannot find path '...\app [v2]' because it does not exist.
At ...\app [v2]\.specify\scripts\powershell\create-new-feature.ps1:142 char:1
+ Set-Location $repoRoot

Exit code 1, and no feature directory is created.

Specify CLI Version

v1.4.0. main (979b0a3) has the same create-new-feature.ps1.

AI Agent

Codex integration for the reproduction; the script itself is agent-independent.

Operating System

Windows 11, Windows PowerShell 5.1.26100

Python Version

3.13.5

Error Logs

See Actual Behavior.

Additional Context

I have a fix with a regression test and will open a PR for it right away.

AI Disclosure

Found, reproduced and written up by OpenCode with Claude Opus 5.5 in autonomous agent mode, on behalf of @adityajai119. The example above was run locally.

adityajai119 avatar Nov 12 '26 07:11 adityajai119