Skip to content

fix(scripts): honor feature.json branch bypass in check-prerequisites (bash + PowerShell)#2888

Open
PascalThuet wants to merge 2 commits into
github:mainfrom
PascalThuet:fix/2887-feature-json-check-prereq
Open

fix(scripts): honor feature.json branch bypass in check-prerequisites (bash + PowerShell)#2888
PascalThuet wants to merge 2 commits into
github:mainfrom
PascalThuet:fix/2887-feature-json-check-prereq

Conversation

@PascalThuet
Copy link
Copy Markdown
Contributor

Fixes #2887

Problem

setup-plan and setup-tasks skip the "must be on a feature branch" check when .specify/feature.json pins an existing feature directory. check-prerequisites did not apply this bypass in its validating modes. So on the same branch with the same feature.json, /speckit.plan and /speckit.tasks succeed while /speckit.checklist, /speckit.analyze, /speckit.implement and /speckit.taskstoissues fail with "Not on a feature branch".

Affected both script sets — check-prerequisites.sh and check-prerequisites.ps1 (the bypass lived only in setup-plan / setup-tasks).

Change

Wrap the branch check in both check-prerequisites.sh and check-prerequisites.ps1 with the same feature_json_matches_feature_dir / Test-FeatureJsonMatchesFeatureDir guard the setup scripts already use. REPO_ROOT / FEATURE_DIR are already in scope. The bypass only skips the branch-name check — the plan.md / tasks.md existence checks still run.

Testing

New tests/test_check_prerequisites_feature_json.py (mirrors test_setup_plan_feature_json.py):

  • bash: passes on a non-feature branch when feature.json is valid (--json, and --require-tasks --include-tasks); fails without feature.json; --paths-only always succeeds.
  • PowerShell: passes with valid feature.json, fails without (skipped when no pwsh).

uv run python -m pytest tests/test_check_prerequisites_feature_json.py tests/test_check_prerequisites_paths_only.py tests/test_setup_plan_feature_json.py tests/test_setup_tasks.py → all green (PowerShell cases skipped locally).

🤖 Generated with Claude Code

setup-plan and setup-tasks skip the feature-branch check when
.specify/feature.json pins an existing feature directory, but
check-prerequisites did not — so on the same branch with the same
feature.json, /speckit.plan and /speckit.tasks succeeded while
/speckit.checklist, /speckit.analyze, /speckit.implement and
/speckit.taskstoissues failed with "Not on a feature branch".

Wrap the branch check in check-prerequisites.sh and check-prerequisites.ps1
with the same feature_json_matches_feature_dir / Test-FeatureJsonMatchesFeatureDir
guard the setup scripts use. The bypass only skips the branch-name check, not
the plan.md / tasks.md existence checks. Add tests covering both languages.

Fixes github#2887

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@PascalThuet PascalThuet requested a review from mnriem as a code owner June 6, 2026 20:56
Self-review fixes:
- The PS "fails without feature.json" test only asserted a non-zero exit, which
  the later "feature dir not found" check also produces — it would stay green
  even if the branch guard were reverted. Assert the "Not on a feature branch"
  message so the branch check is the proven failure cause (matches the bash
  test and the sibling setup-plan/setup-tasks tests).
- Add safety tests: feature.json pinning a non-existent dir, and malformed
  feature.json — both must fail safe (enforce the branch check), pinning the
  property that the bypass only triggers on a real match.
- Align the PS branch call to the space-bound `-HasGit` used by the sibling
  scripts this change mirrors.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

[Bug]: feature.json branch bypass is inconsistent — check-prerequisites ignores it (bash + PowerShell)

1 participant