Index of every page on this site: llms.txt
All skills
kartikkabadi avatar

/git-branch-worktree-discipline

@02a497f
by Kartikkartikkabadi/skills10 stars
Run it yourself

Disciplined Git workflows for Codex: branch/worktree safety, preflight checks, destructive-command boundaries, conflict handling, PR readiness, and parallel-agent isolation.

Use this Skill: https://skilld.dev/gh/kartikkabadi/skills/git-branch-worktree-discipline

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈51 tokens for metadata: the name and description. ≈590 when used: this file.

Description uses 2.6% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈206 characters, or 2.6%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

Git Branch And Worktree Discipline

Git is shared mutable state. Inspect before writes, checkpoint before risk, and never rewrite or delete work without explicit approval.

Use When

  • Starting code work in a git repo.
  • Creating, switching, merging, rebasing, deleting, or pushing branches.
  • Running parallel agents or model variants in the same repo.
  • Using git worktree.
  • Preparing a PR, resolving conflicts, or cleaning up after merge.

Non-Negotiable Safety

Before changing git state:

git status --short
git branch --show-current
git diff --stat
git log --oneline --decorate -5

Require explicit user confirmation before:

  • git reset --hard, git clean -f*, git branch -D, git worktree remove -f, git reflog expire, git filter-branch, git filter-repo
  • git push --force or git push --force-with-lease
  • rebasing, amending, deleting, or force-updating commits that may be shared
  • changing remotes, Git credentials, global Git identity, auth, config, or security settings
  • deleting branches/worktrees with uncommitted or unmerged work

Prefer safer alternatives:

  • undo one file: inspect diff, then git restore <file>
  • undo staged file: git restore --staged <file>
  • undo public commit: git revert <sha>
  • delete branch: git branch -d <branch> first
  • clean files: git clean -nfd before any execution
  • parallel work: separate worktree plus branch per agent

Worktree Workflow

Use a separate worktree when multiple agents, variants, or tasks need to edit concurrently.

git worktree add -b agent/<task-slug> ../repo-agent-<task-slug> main

Each worker must know:

  • exact working directory
  • exact branch
  • allowed files/scope
  • forbidden side effects
  • verification commands
  • that other agents may be editing elsewhere

After completion, inspect before integrating:

git status --short
git log --oneline --decorate -5
git diff --stat main..HEAD

Never delete worktree directories with rm -rf; use git worktree remove.

PR-Ready Loop

Before opening or handing off:

git fetch origin
git status --short
git diff --stat origin/main..HEAD
git log --oneline origin/main..HEAD

Run the project’s real checks. Review that only intended files changed, no secrets/debug junk were added, and the working tree is clean if a commit/PR is being handed off.

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts3mo3 checks · Risk SAFE
  • Gen Agent Trust Hub3mo

    The skill provides a set of disciplined Git workflow instructions, focusing on safety, preflight checks, and preventing accidental data loss. No security issues were detected.

  • Socket3mo

    No alerts

  • Snyk3mo

    Risk: LOW · No issues

Signed by skilld at 02a497f. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Steadyupdated 4 months ago
version
1.0.0-codex
author
Hermes Agent, adapted for Codex

README badge

README badge for kartikkabadi/skills/git-branch-worktree-discipline