{
"issueNumber": 266,
"branchName": "fix/266-worktree-branch-guard",
"generatedAt": "2026-04-03T12:00:00Z",
"stories": [
{
"id": "S1",
"title": "Add branch guard in createWorktree() — detect current branch, auto-switch to master if on target branch, throw on checkout failure",
"priority": 1,
"dependsOn": [],
"acceptanceCriteria": [
"Before stale-branch cleanup, git rev-parse --abbrev-ref HEAD is called to check current branch",
"If current branch matches target, git checkout master is executed",
"If git checkout master fails, a descriptive error is thrown (not swallowed)",
"Detached HEAD state is treated as not on target branch — no checkout attempted"
],
"passes": false,
"completedAt": null
},
{
"id": "S2",
"title": "Add unit tests for branch guard scenarios",
"priority": 2,
"dependsOn": [
"S1"
],
"acceptanceCriteria": [
"Test: main repo on target branch → auto-switch to master → worktree creation succeeds",
"Test: main repo on target branch → git checkout master fails → typed error thrown",
"Test: git branch -D failure is handled gracefully (existing behavior preserved)",
"All existing tests continue to pass",
"npm run lint passes with zero warnings"
],
"passes": false,
"completedAt": null
}
]
}