live-writer-branch-cleanup-guard
Guardrails for multi-repo sync and branch cleanup when workspace-hub or another shared repo has active writer sessions, worktree-backed branches, or unrelated-history branches.
Best use case
live-writer-branch-cleanup-guard is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Guardrails for multi-repo sync and branch cleanup when workspace-hub or another shared repo has active writer sessions, worktree-backed branches, or unrelated-history branches.
Teams using live-writer-branch-cleanup-guard should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/live-writer-branch-cleanup-guard/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How live-writer-branch-cleanup-guard Compares
| Feature / Agent | live-writer-branch-cleanup-guard | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Guardrails for multi-repo sync and branch cleanup when workspace-hub or another shared repo has active writer sessions, worktree-backed branches, or unrelated-history branches.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Live-Writer Branch Cleanup Guard Use when: - doing repo-wide sync + branch cleanup across workspace-hub repos - a shared repo keeps becoming dirty between checks - many branches are worktree-backed or created by overnight agents ## Core pattern 1. Commit and push dirty repos first. 2. Before mass branch cleanup, check for active writer sessions: - `ps -ef | grep Codex` - `ps -ef | grep '[g]it'` - repeated `git status --short` 3. If a repo becomes dirty again between checks, classify it as a live-writer repo. 4. Do not do broad merge/delete passes on live-writer repos until the writers stop. 5. Use temporary worktrees for branch-to-default merge attempts when the main working tree is dirty or on a non-default branch. ## Branch triage rules ### Safe to delete - already merged branches with shared history - stale worktree-agent branches not attached to active worktrees - old local aliases like `master` in a `main`-default repo once confirmed merged ### Do not auto-merge - branches that fail with `fatal: refusing to merge unrelated histories` - branches with real content conflicts - branches currently attached to active worktrees - branches in repos with active concurrent writer sessions ## Interpretation of common failures - `fatal: refusing to merge unrelated histories` - Treat as separate lineage/import branch. - Do not auto-merge to main. - Report for manual triage. - `error: cannot delete branch '<name>' used by worktree` - Branch is active. - Skip deletion. - Clean the worktree first, then retry later. - repo gets dirty again right after commit/push - Usually another agent/process is still writing. - Stop mass cleanup in that repo and finish other repos first. ## Practical order of operations 1. Audit repos: default branch, dirty state, ahead/behind, branch inventory. 2. Commit/push all dirty repos. 3. Prune obviously merged branches in quiet repos. 4. Attempt merges only for branches with shared history and no active worktree attachment. 5. Leave shared-control repos like workspace-hub for a dedicated quiet window. ## Why this exists A large multi-repo cleanup run showed that the biggest blocker was not git itself but active background Codex/worktree activity. Treating live-writer repos as a special case avoids false cleanup attempts, repeated dirty-state churn, and unsafe branch operations.
Related Skills
mnt-analysis-cleanup
Survey, classify, and clean up `/mnt/local-analysis/` (or any sibling-to-workspace-hub directory holding orphan worktrees, codex-burn artifacts, agent log accumulations, and outer-clone duplicates) without losing useful code/work. Surfaces a tiered approval menu rather than baking decisions; defers all destructive ops until user confirms.
pre-completion-cleanup-audit
Audit and dispose of session residue (orphan files, scratch dirs, sibling-repo state, locks, trash-stages) BEFORE claiming a task complete. Required gate before any agent says "all done", "task complete", or hands work back to user/orchestrator.
worktree-branch-sync-hygiene
Class-level branch, worktree, dirty-main, stash, sync, and hook hygiene for workspace-hub style multi-repo work.
multi-repo-branch-hygiene-at-scale
Systematic approach to cleaning stale branches, resolving merge conflicts, and syncing multiple repos
git-worktree-cleanup-at-scale
Identify and remove stale git worktrees blocking branch deletion in multi-repo environments
git-worktree-cleanup-and-branch-reconciliation
Systematic process for cleaning up stale git worktrees, resolving merge conflicts in diverged branches, and reconciling branch state across multiple repositories.
git-worktree-cleanup-and-branch-hygiene
Systematic approach to cleaning up stale git worktrees, orphan branches, and branch hygiene at scale across multiple repos
git-blob-size-filter-cleanup
Strip oversized blobs from unpushed commits using git filter-branch when GitHub's 100 MB limit blocks push
workspace-hub-sync-concurrent-writer-blocks
Handle repository_sync cleanup when workspace-hub root is being mutated by concurrent Codex/Codex/Gemini sessions.
repo-sync-deleted-remote-branch-and-unrelated-history-recovery
Recover multi-repo sync failures caused by deleted upstream branches, stale git index locks, and local branches with unrelated history to the remote default branch.
overnight-worktree-uv-warmup-and-log-path-guardrails
Prevent false stalls and missing-log failures in overnight Codex worktree batches by pre-warming uv environments, using exact log-path directory creation, and interpreting buffered logs correctly.
live-state-aware-overnight-implementation-prompts
Design overnight implementation prompts that begin with a live repo/CI precheck so workers continue from partial progress instead of replaying stale handoffs.