Files
holocron/plugins/git/skills/git-branches/SKILL.md
Defame1297 6cfc3577e2 docs: trim repeated boilerplate in git, gitea, and bin skills
Finding 13: five blocks of near-identical wording were repeated across
skills within a plugin — the gitea "resolve owner and repo" step (5
skills), the 404-masks-403 note (6 files), the manual pagination
explanation (8 files), the git plugin's main/master force-push refusal
(7 files, some with multiple internal restatements), and the bin
skills' domain-glossary/ADR paragraph (5 skills). Tightened each
instance in place — same meaning, fewer words — rather than extracting
to a shared file, which ADR-0014's one-file-per-skill install
constraint rules out. Left the three git skills' structured-result
JSON shapes alone (coupled to the separate, out-of-scope git-orchestrate
merge candidate, finding 19).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YR2CjVumUbEGWcMikcoXBD
2026-09-12 19:48:31 +00:00

3.7 KiB

name, description, metadata
name description metadata
git-branches Use when creating, switching, deleting, renaming, tracking, merging, or comparing local git branches under GitHub Flow or Gitflow. Not writing or rewriting commits -> `git-commits`. Not history inspection -> `git-history`. Not a Gitea remote's branches -> `gitea-branches`.
version category source_keys
1.0.4 git
context7-git-htmldocs
nvie-gitflow-post
atlassian-gitflow-tutorial
gitflow-cheatsheet

Gotchas

  • Uncommitted changes abort a switch. git switch refuses rather than clobbering conflicting local edits. Offer to stash and retry — forcing the checkout past it is how work disappears.
  • A branch and a tag can carry the same name. Detect it before acting — git branch --list <name> (bare, not rtk: rtk prints a phantom * line even on no match, which reports every name as ambiguous) and rtk git tag --list <name>; output from both means the name is ambiguous. Prefer git switch over git checkout, and where a command accepts either ref, disambiguate with refs/heads/<name> or refs/tags/<name>.
  • main/master are a refusal, not a gate. Force-pushing, force-deleting, or renaming either is rejected even with confirm: true — no flag recovers the remote's history. Offer a new branch instead.

Step 1 — Determine the branching pattern

Infer the branching pattern from the repo: Gitflow if a develop or release/* branch exists, GitHub Flow otherwise (the default).

The two patterns are not mixable, and the wrong merge rule silently damages history. If the action touches a base branch, a name prefix, or a merge rule, read references/branch-patterns.md.

Step 2 — Dispatch on the action

Action Reference
create, switch, delete, rename, track, list, get-intent, stash references/branch-operations.md
merge a branch, resolve merge conflicts references/merging.md
compare two branches, find their divergence references/comparing-branches.md

Load only the file the action needs. A destructive action still passes Step 3 first.

Step 3 — Gate destructive operations

Before any delete or force-delete that loses history:

  • Does the branch track a remote? Warn if so.
  • Are there unpushed commits on it? Warn if so.
  • Did the caller pass confirm: true? Fail if not — for a human caller, prompt interactively instead of failing.

These gates are passable. The main/master refusal in Gotchas is not.

Step 4 — Set tracking

A new branch's first push must be rtk git push -u origin <branch>. The push itself is git-remotes' — every remote-side gate lives there, which is why Step 2's remote-delete row hands off the same way — but the upstream requirement originates here, so carry it in the handoff. Without an upstream, later pushes and pulls either fail or silently target the wrong remote branch, and the caller has no way to tell which happened.

Step 5 — Return a structured result

Return every operation in this shape rather than prose, including failures — a calling agent chains its next operation on the result and cannot parse a sentence.

{
  "success": true,
  "action": "create|switch|delete|rename|track|list|get-intent",
  "branch": "<name>",
  "message": "descriptive message",
  "intent": "<intent if tracked>",
  "tracking": "origin/<branch, if set>",
  "error": "<error message if success=false>",
  "suggestion": "<recovery suggestion if applicable>"
}

When the failure is uncommitted local changes, set "suggestion": "stash changes and retry" so the caller can offer recovery rather than surfacing a dead end.

When a calling agent supplies a structured request rather than prose, read references/orchestrator-contract.md for the request schema.