---
name: "Add test coverage for worktree.rs (65% -> 80%+)"
---

# Story 128: Add test coverage for worktree.rs

Currently at 65% line coverage (330 lines, 124 missed). Worktree management is core infrastructure — creating, removing, and managing git worktrees for agent isolation.

## What to test

- `worktree_path` construction
- `create_worktree` — branch naming, git worktree add, setup command execution
- `remove_worktree_by_story_id` — cleanup, branch deletion
- Setup command runner (pnpm install, pnpm build, cargo check)
- Error paths: git failures, setup failures, missing directories
- Edge cases: worktree already exists, branch already exists

## Notes

- Use temp git repos for integration tests
- Mock expensive operations (pnpm install, cargo check) where possible
- The setup command failure path is especially important (this was the root cause of bug 118)

## Acceptance Criteria

- [ ] Line coverage for `worktree.rs` reaches 80%+
- [ ] Tests pass with `cargo test`
- [ ] `cargo clippy` clean
