Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsCommunityBlog
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

Back to skills

Branch Hygiene

ASecurity

Inspect and clean stale branches across multiple repositories using the dotfiles git-hygiene + gh-bootstrap toolchain. Use when the user asks about branch state, stale local branches, or "no ref was fetched" errors.

2 stars
0 votes
0 copies
0 views
Added 9/22/2026
ai-agentspythongoshellbashgit

Works with

claude code

Security Analysis

A100/100

Scanned 9/22/2026

Install to Claude Code

$npx -y skills add jckeen/dotfiles --skill branch-hygiene --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Branch Hygiene?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Branch Hygiene
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/jckeen-branch-hygiene-dotfiles/badge)](https://www.skillsdirectory.com/skills/jckeen-branch-hygiene-dotfiles)

More formats (shields.io, HTML) on the badges page.

Download Zip
Files
SKILL.md
---
name: branch-hygiene
description: Inspect and clean stale branches across multiple repositories using the dotfiles git-hygiene + gh-bootstrap toolchain. Use when the user asks about branch state, stale local branches, or "no ref was fetched" errors.
---

# Branch Hygiene

The user has a three-layer auto-hygiene system in `~/dev/dotfiles/`:

## What's already automatic

1. **GitHub-side settings** (set via `gh-bootstrap.sh`): every repo has
   `delete_branch_on_merge=true`, `allow_auto_merge=true` (Git Pro),
   `allow_update_branch=true`, and a squash-only merge policy with
   `squash_merge_commit_title=PR_TITLE` / `squash_merge_commit_message=PR_BODY`.
2. **Daily systemd timer** (`git-hygiene.timer`, fires 09:30 local) — runs
   `gh-bootstrap.sh --check --all ~/dev`, writes drift state to
   `~/.local/state/hygiene/status.json`, then runs
   `git-hygiene.sh prune ~/dev --yes --gh` to delete safely-dead local
   branches (class below). Every deletion is logged with its SHA to
   `~/.local/state/hygiene/cron.log` and `deletions.tsv` (recover with
   `git branch <name> <sha>`); an ntfy summary is pushed only when something
   was deleted, and it carries counts plus the log path only — repo and
   branch names never leave the local log (ntfy topics are effectively
   public). `NTFY_SERVER` overrides the default `https://ntfy.sh`.
   `HYGIENE_DELETE=0` in the unit's environment disables the prune.
3. **Shell `gh` wrapper** in `.bash_aliases` — when the user runs
   `gh repo create` or `gh repo clone` from their shell, the wrapper auto-runs
   `gh-bootstrap.sh` on the new repo. Note: this only fires from the user's
   interactive shell, not from agent-spawned shells.

## Workflow

When the user asks about hygiene state:

1. Read `~/.local/state/hygiene/status.json` first — it's the cached daily
   check. Use `~/dev/dotfiles/hygiene-status.sh --status` for a one-liner or
   `--text` for a full readout. This is read-only and instant.
2. If the user wants a fresh check, run
   `~/dev/dotfiles/gh-bootstrap.sh --check --all ~/dev`.
3. To clean stale local branches now: `~/dev/dotfiles/git-hygiene.sh prune
   ~/dev --yes --gh` (what the timer runs; add `--dry-run` to preview — it
   writes nothing: no deletions, no `fetch --prune`, no `remote set-head`), or
   the compatibility command `~/dev/dotfiles/git-hygiene.sh clean ~/dev --yes`,
   which uses the same conservative local proof rules.
4. To bootstrap a new or drifted repo:
   `~/dev/dotfiles/gh-bootstrap.sh <owner/repo>` or `--all <dir>`.

## Important: agent-created repos

If you (the Codex agent) run `gh repo create` or `gh repo clone` yourself,
the shell wrapper does not fire — your `gh` invocation goes directly to the
binary. **Run `~/dev/dotfiles/gh-bootstrap.sh <owner/repo>` immediately
after** any successful create/clone you do, so the new repo doesn't drift.

## What "safely deletable" means here

Both `clean` and `prune` require current remote evidence, known branch activity,
and proof that no unique merges or patches remain. Dirty working trees,
current branch, and worktree-checked-out branches are always skipped.
`HYGIENE_MIN_AGE_HOURS` in `git-hygiene.sh` controls the activity window.

`prune --gh` can also verify a squash-merged PR into the default branch when
its head SHA matches the local tip or a fetched descendant. A name or commit
subject match never authorizes deletion. Failed remote refresh, unknown
activity, unique merge commits and unavailable GitHub evidence preserve work.

For task worktrees, inspect `hygiene-status.sh --worktrees` or run
`python3 ~/dev/dotfiles/claude/scripts/worktree-lifecycle.py inventory --repo /path/to/repo`.
The timer reports ownership/disposition separately from settings drift and
never deletes worktrees. Follow the release and authorized-retirement procedure
in `claude/scripts/README.md`, including private evidence archival. A pending
PR retains its worktree with a named owner and follow-up command.

## Output

If the user just asks "is everything clean?":

```
$ ~/dev/dotfiles/hygiene-status.sh --status
settings clean (checked 4h ago)
```

This reports repository settings only; read `--worktrees` for retained or
released task worktrees. If settings drift exists, the same command emits a summary and the user can run
`gh-bootstrap.sh --all ~/dev` to fix it. Be specific about which repos
drifted — they're listed in `drifted_repos` of the JSON.

## Project state cleanup

After archiving or deleting a repo locally, also purge its Claude Code state (transcripts, file history, config entries, tasks):

```bash
# Always dry-run first
claude project purge "$REPO_PATH" --dry-run

# When the dry-run looks right
claude project purge "$REPO_PATH" --yes
```

The `--all` flag purges every project not currently on disk in one pass — useful after a quarterly cleanup.

This is the v2.1.126 primitive. Without it, `~/.claude/projects/` and `~/.claude/file-history/` accumulate state for dead projects forever.

Attribution

jckeenjckeen
View sourceMore from jckeen →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Caveman

Ultra-compressed communication mode that cuts output tokens while keeping technical accuracy. Levels: lite, full, ultra and the wenyan variants. Use for /caveman, "caveman mode", "talk like caveman", "be brief" or "less tokens".

1066601 votes

Hyperplan

Adversarial multi-agent planning skill. Self-orchestrates 5 hostile category members (unspecified-low, unspecified-high, deep, ultrabrain, artistry) via team-mode for ruthless cross-critique debate, distills only the defensible insights, then MANDATORILY hands the distilled insight bundle to the `plan` agent for executable plan formalization. Use when planning needs maximum rigor and surfacing of weak assumptions, blind spots, and over-engineering. Triggers: 'hyperplan', 'hpp', '/hyperplan', ...

686011 votes

Mcp Code Execution

Routes multi-tool workflows through MCP servers for large datasets and pipelines. Use when Bash tool overhead is limiting throughput on data-heavy tasks.

3351 votes

catchup

Recovers the conversation and failed tool calls of a previous Codex, Claude Code, Antigravity, Cline, Copilot CLI, Cursor, DeepSeek Harness, Kimi, OpenCode, Pi Agent, or ZCode session. Use when the user says "catch up", "what did the last session do", "get me up to speed", "I switched agents", asks to recover/summarize a previous session before continuing, or asks to diagnose or report a catchup failure. Do NOT use for the current conversation, git history, or any non-agent log.

651 votes

math-skill

A comprehensive mathematical reasoning skill for AI assistants — handles arithmetic to research-level problems with rigorous step-by-step reasoning, systematic verification, and transparent uncertainty handling

381 votes
View all in ai-agents →