Skip to content

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

Description

@PascalThuet

Bug Description

The "must be on a feature branch" check can be bypassed when .specify/feature.json pins an existing feature directory (feature_json_matches_feature_dir / Test-FeatureJsonMatchesFeatureDir). setup-plan and setup-tasks apply this bypass; check-prerequisites does not in its validating modes. So with the same feature.json on the same branch, half the spec-kit commands succeed and half fail.

This affects both the bash and PowerShell script sets.

Evidence (main @ 7106858)

The helper is called from only two of the three scripts, in each language:

scripts/bash/common.sh:191            feature_json_matches_feature_dir()
scripts/bash/setup-plan.sh:36         guarded ✅
scripts/bash/setup-tasks.sh:32        guarded ✅
scripts/bash/check-prerequisites.sh:115   check_feature_branch — UNGUARDED ❌

scripts/powershell/common.ps1:169     Test-FeatureJsonMatchesFeatureDir
scripts/powershell/setup-plan.ps1:27  guarded ✅
scripts/powershell/setup-tasks.ps1:23 guarded ✅
scripts/powershell/check-prerequisites.ps1:85   Test-FeatureBranch — UNGUARDED ❌

--paths-only / -PathsOnly exits before the branch check, which is why only that mode happens to work.

Command → script mapping

Command Script call Honors feature.json?
/speckit.plan setup-plan
/speckit.tasks setup-tasks
/speckit.clarify check-prerequisites --paths-only ➖ exits before check
/speckit.checklist check-prerequisites --json ❌ fails
/speckit.analyze check-prerequisites --require-tasks --include-tasks ❌ fails
/speckit.implement check-prerequisites --require-tasks --include-tasks ❌ fails
/speckit.taskstoissues check-prerequisites --require-tasks --include-tasks ❌ fails

Steps to Reproduce

On a branch whose name is not a feature pattern, with feature.json pinning a valid populated feature dir:

bash .specify/scripts/bash/setup-plan.sh --json                  # EXIT=0
bash .specify/scripts/bash/check-prerequisites.sh --json --paths-only  # EXIT=0
bash .specify/scripts/bash/check-prerequisites.sh --json         # EXIT=1  "Not on a feature branch"
bash .specify/scripts/bash/check-prerequisites.sh --json --require-tasks --include-tasks  # EXIT=1

Expected Behavior

check-prerequisites honors feature.json the same way setup-plan / setup-tasks do, so the whole command set behaves consistently. The bypass only skips the branch-name check, not the file-existence checks (plan.md, tasks.md).

Actual Behavior

check-prerequisites fails with "Not on a feature branch" even though feature.json pins a valid feature dir, blocking /speckit.checklist, /speckit.analyze, /speckit.implement, /speckit.taskstoissues.

Specify CLI Version

main @ 7106858 (reported on 0.9.3)

AI Agent

Codex CLI

Suggested Fix

Wrap the branch check in both check-prerequisites.sh and check-prerequisites.ps1 with the same guard the setup scripts use:

if ! feature_json_matches_feature_dir "$REPO_ROOT" "$FEATURE_DIR"; then
    check_feature_branch "$CURRENT_BRANCH" "$HAS_GIT" || exit 1
fi

REPO_ROOT / FEATURE_DIR are already in scope at that point. PR incoming.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions