---
name: Deterministic Worktree Management via REST/MCP API
---

# Story 42: Deterministic Worktree Management via REST/MCP API

## User Story

As a developer running multiple agents, I want worktree creation and management handled by the Rust binary through the REST/MCP API, so that worktree locations are deterministic and predictable rather than at the discretion of LLM agents.

## Acceptance Criteria

- [ ] Worktrees are created under `.story_kit/worktrees/` inside the project directory
- [ ] `.story_kit/worktrees/` contents are gitignored
- [ ] Worktree creation is exposed through the REST/MCP API with deterministic naming (e.g. based on story ID)
- [ ] Agents no longer create worktrees themselves — they call the API and receive the worktree path
- [ ] Existing `start_agent` flow uses the new worktree management instead of ad-hoc creation
- [ ] Worktree listing is available via API so users can see what worktrees exist
- [ ] Worktree cleanup/removal is available via API
- [ ] `create_story` API optionally commits the new story file to the current branch

## Out of Scope

- TBD
