v0.37.0 — agent worktree cleanup and push cadence

Consumers act once: run claude plugin update marvin, follow the update procedure the SessionStart notice prints (upgrades/v0.37.0.md). Upgrade promptly: the personas and the sweep ship with the plugin, so they act as soon as it updates, even before /marvin:upgrade-agent-os installs worktrees.md.

The sweep and its guards. A plugin hook now removes finished agent worktrees under .claude/worktrees/ at every session start, and /marvin:clean-worktrees [--check] does the same on demand. It keeps a worktree unless all seven guards hold: it is unlocked, no session stands in it, no other worktree or git repository lies inside it, nothing changed in it for 15 minutes, no merge or rebase is in progress, it is clean, and its commits are in a branch other than its own. Prunable entries are reported and left untouched. The local branch is deleted only when origin's copy contains the worktree's commits; otherwise it is kept and reported, and remote branches are never deleted. One accepted limit: a quiet interactive --worktree or desktop session standing in a clean, merged worktree under .claude/worktrees/ can be swept by another session's sweep.

Push cadence. Every sub-agent that commits work, the documenter and ponytail included, pushes its own branch before its final message and never force-pushes or pushes main, develop or a tag. The orchestrator merges a passing branch into its parent and pushes the parent at once. main and tags still move only in the release cut. With no remote configured, or a push refused, the push is skipped and said so.

The handover line. A committing sub-agent ends its final message with a WORKTREE: line: pushed and safe to delete once merged, not pushed with the reason, or none. The orchestrator's handoff in .marvin/MEMORY.md lists every worktree it leaves as safe to delete or not safe with the reason, so the next orchestrator and the sweep act on facts. The rules live in the new .marvin/agents/worktrees.md, and .claude/worktrees/ joins .gitignore.

This note's scope: was derived over v0.36.1..HEAD, non-merge commits only; the container epic AOS-195 is excluded.

Upgrade

Consumer-facing: finished agent worktrees are removed automatically, and agents push done work often so no cleanup can lose it. Rules: the new .marvin/agents/worktrees.md.

  • Update with the procedure the SessionStart notice prints. No file moves, so no migration script. Upgrade promptly: the personas and the sweep ship with the plugin, so they act as soon as it updates, even before worktrees.md is installed.
  • The upgrade adds .marvin/agents/worktrees.md and refreshes git-strategy.md, briefing.md, guardrails.md and the kit core .marvin/CLAUDE.marvin.md (customised copies are backed up first). It also adds .claude/worktrees/ to .gitignore.
  • New plugin hook: at session start the sweep removes a worktree under .claude/worktrees/ only when seven guards hold: unlocked, not in use, nothing else inside it, idle 15 minutes, no merge or rebase in progress, clean, and merged into another branch. Prunable entries are reported, never touched.
  • It deletes the local branch only when origin's copy contains the worktree's commits; otherwise the branch is kept and reported. /marvin:clean-worktrees [--check] runs it on demand.
  • Every sub-agent that commits work, the documenter and ponytail included, pushes its own branch and ends with a WORKTREE: line; the orchestrator pushes the parent after each merge. With no remote configured, pushes are skipped and reported.
  • Accepted limit: a quiet interactive --worktree or desktop session standing in a clean, merged worktree under .claude/worktrees/ can be swept by another session's sweep.
  • Start a new session after the upgrade so the hook, the skill and the rules load.

Changes

Added

  • Finished agent worktrees under .claude/worktrees/ are removed at session start and by /marvin:clean-worktrees, and only when seven guards all hold.
  • The sweep keeps any worktree that is locked, in use, holding another worktree or repository, active in the last 15 minutes, mid-merge or rebase, dirty, or not yet merged into another branch.
  • A local branch is deleted only when origin's copy contains the worktree's commits; otherwise it is kept and reported.
  • Every sub-agent that commits work ends with a WORKTREE: line saying whether its worktree is safe to delete; the session handoff lists the ones left.

Changed

  • Agents push done work often: each committing sub-agent pushes its own branch, the orchestrator merges it and pushes the parent at once; main and tags still move only at a release.
  • .gitignore now also ignores .claude/worktrees/.

Action needed

  • Update promptly: the personas and the sweep ship with the plugin and act at once, before /marvin:upgrade-agent-os installs worktrees.md.
  • After /marvin:upgrade-agent-os, start a new session so the new hook, skill and rules load.