# Next Steps Branch: `claude/investigate-git-clone-failures-mlHGo` ## Done this session - Fixed critical `sandboxDir` variable shadowing bug in `internal/executor/claude.go` (lines 119, 131) — changed `:=` to `=`. This was the root cause of git clone failures: sandboxes were never torn down, changes were never pushed back to origin, `/tmp` accumulated orphaned dirs. - Fixed hardcoded `master` branch in `teardownSandbox` — now detects current branch from HEAD. - Rewrote `CLAUDE.md` with accurate architecture, correct YAML key (`agent:` not `claude:`), complete state machine, all packages documented, known bugs and design debt called out. - Created `docs/IMPROVEMENT_PLAN.md` with 20 prioritized issues, each with root cause, file location, and concrete fix. ## Immediate next steps 1. **Delete or implement GeminiRunner** (`internal/executor/gemini.go`) — it silently returns hardcoded fake output. Any task with `agent.type: gemini` produces wrong results in production. Deleting it is the safe path. 2. **Wrap execution creation in a transaction** — `execute()` calls `CreateExecution` then `UpdateTaskState(RUNNING)` as separate writes. Add `storage.CreateExecutionAndSetRunning()`. 3. **Fix `context.Background()` in resume path** — `handleAnswerQuestion()` in `api/server.go` submits with `context.Background()` instead of the server's root context. 4. **Add `Pool.Shutdown(ctx)`** — `dispatch()` goroutine leaks on server shutdown; `workCh` is never closed. 5. **Remove dead code: `QuestionRegistry`** — created in `NewPool`, stored on `Pool.Questions`, never read. Remove along with `QuestionHandler` interface. 6. **Fix `parseStream` ignoring `scanner.Err()`** — silent data loss if stdout read fails mid-stream. 7. **Remove changestats extraction from `api.Server.processResult()`** — pool already does it; the second extraction is idempotent but confusing. ## To dogfood (run tasks through claudomator itself) - Build: `go build -o claudomator ./cmd/claudomator/` - Init + serve: `./claudomator init && ./claudomator serve` - Set `project_dir` in tasks to point at the canonical repo (`/workspace/claudomator` per CLAUDE.md) - The sandbox fix means agent work will now actually be committed and pushed back