Skip to content

fix(scripts): add explicit positional binding to PowerShell create-new-feature params#1885

Open
mvanhorn wants to merge 1 commit intogithub:mainfrom
mvanhorn:osc/1879-fix-ps-positional-param-binding
Open

fix(scripts): add explicit positional binding to PowerShell create-new-feature params#1885
mvanhorn wants to merge 1 commit intogithub:mainfrom
mvanhorn:osc/1879-fix-ps-positional-param-binding

Conversation

@mvanhorn
Copy link

Summary

Fixes PowerShell positional parameter binding in create-new-feature.ps1 that caused ParameterBindingArgumentTransformationException when AI agents passed the feature description as a positional argument.

Why this matters

When an AI agent calls create-new-feature.ps1 'Add user authentication' with positional arguments, PowerShell's implicit binding assigns the string to $Number (Int32) before reaching $FeatureDescription, causing the script to fail on first attempt (#1879). The bash equivalent (create-new-feature.sh) already handles this correctly via explicit --number flag parsing.

Changes

  • Added [Parameter(Position = 0, ValueFromRemainingArguments = $true)] to $FeatureDescription so it binds first positionally
  • Added [Parameter()] (no Position) to $Number so it only binds by name (-Number N)

This matches the invocation pattern documented in specify.md line 45: -Json -ShortName "user-auth" "Add user authentication"

Testing

  • All 382 existing tests pass (uv run pytest)
  • ruff check src/ passes
  • Verified the param block change matches PowerShell positional binding semantics

AI Disclosure

This PR was authored with AI assistance (Claude Code). The fix was identified from the error description in #1879 and verified against PowerShell parameter binding documentation.

Fixes #1879

…w-feature params

The $Number (Int32) parameter was implicitly receiving positional
arguments intended for $FeatureDescription, causing a
ParameterBindingArgumentTransformationException when AI agents
called the script with positional strings.

Add [Parameter(Position = 0)] to $FeatureDescription so it binds
first, and mark $Number with [Parameter()] (no Position) so it
only binds by name (-Number N).

Fixes github#1879

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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 PR fixes PowerShell positional argument binding in create-new-feature.ps1 so a feature description passed positionally (common with AI-agent invocations) binds to the description parameter instead of being incorrectly coerced into the numeric -Number parameter.

Changes:

  • Assigns Position = 0 to $FeatureDescription and keeps ValueFromRemainingArguments = $true so the first positional argument is treated as the description.
  • Adds an explicit [Parameter()] attribute to $Number (leaving it intended for named usage like -Number 3).

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants