git-workspace-cleanup

git-workspace-cleanup is a skill for Claude Code, Codex from hon454/grimoire. It costs 41 tokens per session (804 once invoked), scanned A, original, MIT.

A destructive Git workflow that reduces a repository to one main worktree and local main branch, then updates main from its remote. A worktree is another checked-out working folder connected to the same repository.

In plain words
What is it for?
Use it only when explicitly requested to remove non-main worktrees and branches and fast-forward the local main branch.
Why use it?
It removes extra local worktrees and branches that may contain work, so it can permanently discard local repository state. It previews the proposed cleanup before changes are made.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/hon454/grimoire/git-workspace-cleanup
Any agent
npx skills add hon454/grimoire --skill git-workspace-cleanup
Clone the repo
git clone --depth 1 https://github.com/hon454/grimoire

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for git-workspace-cleanup

README.md
[![agentmods](https://agentmods.dev/badge/skills/hon454/grimoire/git-workspace-cleanup.svg)](https://agentmods.dev/skills/hon454/grimoire/git-workspace-cleanup)
Your own site
<a href="https://agentmods.dev/skills/hon454/grimoire/git-workspace-cleanup"><img src="https://agentmods.dev/badge/skills/hon454/grimoire/git-workspace-cleanup.svg" alt="Measured on agentmods" height="20"></a>
Per session 41 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 804 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00041 $0.00804
Opus 5 $0.00020 $0.00402
Sonnet 5 $0.00008 $0.00161
Haiku 4.5 $0.00004 $0.00080

Measured 4d ago against content hash d15e2a7a7e25, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

git-workspace-cleanup scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/git_workspace_cleanup.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/grimoire/skills/git-workspace-cleanup/SKILL.md · 78 lines

How it starts

The opening of the file, as written. The whole thing — 78 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Git Workspace Cleanup

Return a Git repository to a single clean main worktree: remove every non-main worktree, delete every local branch except main, and fast-forward main from its remote.

This is destructive. Never run it implicitly.

Invocation

Use this skill only when the user explicitly invokes it as $git-workspace-cleanup.

Required Flow

  1. State that the workflow can delete local worktrees and branches.

  2. Resolve the bundled script relative to this SKILL.md:

    scripts/git_workspace_cleanup.py
    
  3. Choose the Python 3 launcher available in the user's shell and call it <python> in the commands below:

    • POSIX shells commonly use python3.
    • Windows PowerShell or cmd.exe commonly use py -3 or python.
  4. Run the bundled script in dry-run mode from any path inside the repository. The dry run fetches the remote and verifies the preserved branch can fast-forward before reporting the destructive plan:

    <python> <skill-dir>/scripts/git_workspace_cleanup.py --repo . --dry-run
    
  5. Show the user the main worktree path and the worktrees and branches that would be removed.

  6. Ask for explicit approval before mutating the repository. Use the host's native user-input or approval UI when it is available; in Codex, use request_user_input when the current mode exposes it. Offer a destructive approval choice and a cancel choice. If no native choice UI is available, ask for a short typed approval phrase instead.

  7. After approval, run:

    <python> <skill-dir>/scripts/git_workspace_cleanup.py --repo . --yes
    
  8. Continue subsequent repository work from the printed main worktree path.

  9. Verify the final state with:

    git worktree list
    git branch --format="%(refname:short)"
    git status --short --branch
    git pull --ff-only
    

Use --repo <path> when the current shell is not inside the target repository.

Safety Rules

  • Do not remove the worktree checked out on main.
  • Do not delete the local main branch.
  • Do not mutate anything unless the user approves the dry-run result.
  • Stop if the main worktree is dirty.
  • Stop if an extra worktree is dirty. Use --force-worktrees only when the user explicitly approves discarding files in those dirty extra worktrees. Prefer the host's native user-input or approval UI for this approval when available; otherwise require a typed approval phrase.
  • Treat fast-forward failure as a blocker before removing worktrees or deleting branches. Do not merge, rebase, reset, or force-push as part of this skill.
  • If the repository uses a preserved branch other than main, rerun the script with --main-branch <branch> only after the user confirms that branch name.

Read the full file on GitHub · 78 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 78 lines · 41 tokens per session scan A d15e2a7a7e25

Subscribe to this mod's changes

git-workspace-cleanup is a skill published in the GitHub repository hon454/grimoire (2 stars, last pushed 16d ago), licensed MIT. It adds 41 tokens to every session and 804 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.