Summary
In a bare-repo + linked-worktrees layout (.bare/ + main/ + pr/prNNNN.slug/), running wt new from the main worktree in non-interactive mode fails with:
Cannot create PR from a PR worktree in non-interactive mode. Switch to the main worktree first.
— even though the current worktree is the main worktree, and wt list itself identifies it correctly ([main] * … Path main (current)).
Environment
@camaradesuk/git-worktree-tools 1.14.0 (pnpm global install; incidentally wt --version prints unknown)
- Repo layout:
/home/chris/workspace/syrf/.bare (bare) with linked worktrees main/ (branch main) and pr/prNNNN.slug/
.worktreerc: worktreeParent: ".worktrees", worktreePattern: "pr{number}.{slug}"
- Working tree had unstaged changes (2 untracked paths + 1 modified file) at the time
Repro
cd /home/chris/workspace/syrf/main # linked worktree, branch = main
wt new "Some new work" --ready --non-interactive --action=empty_commit --json
Result:
{"success": false, "error": {"code": "INVALID_ARGUMENT",
"message": "Cannot create PR from a PR worktree in non-interactive mode. Switch to the main worktree first."}}
--verbose shows the state analysis contradicting itself — scenario is pr_worktree while branchType/currentBranch are main:
[DEBUG] State analysis complete {"scenario":"pr_worktree","branchType":"main","currentBranch":"main",
"commitRelationship":"same","workingTreeStatus":"unstaged_only","stagedFiles":[],
"unstagedFiles":[".generated-checksums.json",".claude/skills/promote-staging-to-production/",
"src/libs/project-management/SyRF.ProjectManagement.Core.Tests/PartitionAsyncDeadlockRepro.cs"],
"repoRoot":"/home/chris/workspace/syrf/main"}
[ERROR] Cannot create PR from a PR worktree in non-interactive mode. Switch to the main worktree first.
Meanwhile wt list from the same directory is correct:
main worktrees:
[main] *
Branch main
Path main (current)
Hypothesis
Scenario detection appears to treat any linked worktree as a PR worktree. In a bare-repo layout every checkout is a linked worktree (there is no non-linked primary checkout), so the main worktree gets classified pr_worktree. wt list evidently uses different (correct) logic — probably branch/config based.
Suggested direction: derive "main worktree"-ness the way wt list does (current branch == default branch, or an explicitly configured main-worktree path) rather than from worktree linkage; at minimum, trust branchType: "main" over the linkage heuristic in wt new's guard.
Impact / workaround
wt new is unusable non-interactively in bare-repo layouts (the recommended layout for this repo family). Workaround used: manual git worktree add + gh pr create + git worktree move to the pr{number}.{slug} convention.
Summary
In a bare-repo + linked-worktrees layout (
.bare/+main/+pr/prNNNN.slug/), runningwt newfrom the main worktree in non-interactive mode fails with:— even though the current worktree is the main worktree, and
wt listitself identifies it correctly ([main] * … Path main (current)).Environment
@camaradesuk/git-worktree-tools1.14.0 (pnpm global install; incidentallywt --versionprintsunknown)/home/chris/workspace/syrf/.bare(bare) with linked worktreesmain/(branchmain) andpr/prNNNN.slug/.worktreerc:worktreeParent: ".worktrees",worktreePattern: "pr{number}.{slug}"Repro
Result:
{"success": false, "error": {"code": "INVALID_ARGUMENT", "message": "Cannot create PR from a PR worktree in non-interactive mode. Switch to the main worktree first."}}--verboseshows the state analysis contradicting itself — scenario ispr_worktreewhilebranchType/currentBrancharemain:Meanwhile
wt listfrom the same directory is correct:Hypothesis
Scenario detection appears to treat any linked worktree as a PR worktree. In a bare-repo layout every checkout is a linked worktree (there is no non-linked primary checkout), so the main worktree gets classified
pr_worktree.wt listevidently uses different (correct) logic — probably branch/config based.Suggested direction: derive "main worktree"-ness the way
wt listdoes (current branch == default branch, or an explicitly configured main-worktree path) rather than from worktree linkage; at minimum, trustbranchType: "main"over the linkage heuristic inwt new's guard.Impact / workaround
wt newis unusable non-interactively in bare-repo layouts (the recommended layout for this repo family). Workaround used: manualgit worktree add+gh pr create+git worktree moveto thepr{number}.{slug}convention.