agentleFS
timmo001timmo001/skills/git-context/SKILL.md

git-context

Skill1 starsChanged 56 days agoApache-2.0View on GitHub

Patterns for working with git branches, remotes, diffs against the default branch, and rebases. Use when resolving rebase conflicts, continuing interactive rebases, amending commits, or any git operation that would open an interactive editor.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

12 rules. About 0 are common, 8 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈8

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill when working with branches, remotes, or comparing changes.

    line 10
  2. Very specific:

    When <branch-context> is present:

    line 22
  3. Distinctive:

    Use it as the primary source for branch analysis.

    line 24
  4. Very specific:

    Use <work-scope> instead of rebuilding scope with separate git commands.

    line 25
  5. Very specific:

    Avoid re-running git/gh commands unless the user asks for a fresh snapshot.

    line 26
  6. Very specific:

    Prefer upstream as the comparison remote when present, otherwise origin.

    line 44
  7. Distinctive:

    Prefer the installed helpers over rebuilding default-branch operations with ad-hoc shell commands:

    line 48
  8. Distinctive:

    If a PR exists for the branch:

    line 61
  9. Distinctive:

    Read each conflicted file and understand both sides.

    line 85
  10. Distinctive:

    When both sides are additive (independent features touching the same location), keep both.

    line 86
  11. Distinctive:

    After replacing conflict markers, verify full method/function bodies are intact — shared code between conflict markers is easily lost if …

    line 87
  12. Distinctive:

    Use this when a branch is too large and needs to be split into stacked branches with predictable file counts.

    line 100

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Git Context Patterns

Use this skill when working with branches, remotes, or comparing changes.

Plugin-first branch context

BranchContextPlugin precomputes branch and scoped-work context for branch-oriented commands and scoped cleanup/type commands. It injects a <branch-context> block with tagged sections:

  • <branch-metadata> for default remote/branch resolution and base-ref identity
  • <status> for compact git status -sb output
  • <work-scope> for current work scope in this order: unstaged, staged, then branch diff
  • <pull-request> for PR metadata and check output on branch-focused commands when available
  • <warnings> for collection caveats, fallbacks, and missing data

When <branch-context> is present:

  1. Use it as the primary source for branch analysis.
  2. Use <work-scope> instead of rebuilding scope with separate git commands.
  3. Avoid re-running git/gh commands unless the user asks for a fresh snapshot.
  4. For commands that require BranchContextPlugin scope, stop and report a plugin issue if context is missing instead of rebuilding scope.

Command-line context

For ad-hoc work without current injected context, load context-cli and use its repository snapshot workflow. That skill owns Context command options and output handling.

These commands do not replace a required plugin injection. If context is unavailable during ad-hoc work, report that limitation and use only the Git reads needed for the task:

git diff
git diff --cached
git remote
git symbolic-ref refs/remotes/<remote>/HEAD
gh repo view --json defaultBranchRef -q .defaultBranchRef.name
git diff <remote>/<default-branch>...HEAD

Prefer upstream as the comparison remote when present, otherwise origin.

Default branch helpers

Prefer the installed helpers over rebuilding default-branch operations with ad-hoc shell commands:

  • git-default-ref is the guarded resolver used by all helpers. It prefers upstream, falls back to origin, verifies local <remote>/HEAD against the advertised default, and fetches it. A missing or mismatched ref requires human confirmation; under dot is-agent or without a TTY it fails instead of prompting.
  • git-switch-default (gsd) switches to the resolved default branch and fast-forwards it.
  • git-rebase-default (grd) rebases the checked-out branch onto the resolved default with --autostash.
  • git-diff-default (gdd) diffs the resolved default branch's merge base against HEAD.
  • git-log-default (gld) lists commits in HEAD that are not in the resolved default branch.
  • gra prints a status message and runs git rebase --abort.

These commands are stowed from scripts/.local/bin/; the aliases are defined in zsh/.zshrc.

Checking PR Status

If a PR exists for the branch:

gh pr view              # Read description
gh pr checks            # Check CI status, find failing checks
gh pr diff              # See what's in the PR

Rebases and Interactive Editor Operations

Git opens an interactive editor for many operations. Since the agent runs in a non-interactive shell, bypass the editor with GIT_EDITOR=true (which makes the "editor" succeed immediately, accepting defaults).

Commands that need GIT_EDITOR=true

GIT_EDITOR=true git rebase --continue   # After resolving conflicts
GIT_EDITOR=true git merge --continue    # After resolving merge conflicts
GIT_EDITOR=true git revert --continue   # After resolving revert conflicts

For any requested commit amendment, load dot-git-commit and use its dot git-commit --amend gateway flow instead of raw git commit --amend.

Resolving rebase conflicts

  1. Read each conflicted file and understand both sides.
  2. When both sides are additive (independent features touching the same location), keep both.
  3. After replacing conflict markers, verify full method/function bodies are intact — shared code between conflict markers is easily lost if not carefully included in the resolution.
  4. Stage resolved files with git add.
  5. Continue with GIT_EDITOR=true git rebase --continue.

Operations that do NOT need the editor bypass

  • git rebase --abort / git merge --abort (no editor involved)
  • git rebase --skip (no editor involved)

Ordinary commits are outside this skill. Load dot-git-commit after an explicit commit request and use its gateway.

Splitting a branch by changed files

Use this when a branch is too large and needs to be split into stacked branches with predictable file counts.

  • Preferred helper script: git-split-branch-by-files
  • Location: ~/.local/bin/git-split-branch-by-files
  • Naming: always <source-branch>-b1, <source-branch>-b2, and so on

Default behavior:

  • Splits against origin/HEAD (fallback dev, main, then master)
  • Creates 5 branches by default
  • Makes the first 4 branches equal in changed-file count by default (--equal-up-to 4)
  • Puts any remainder into the tail branches

Typical commands:

# Preview only
git-split-branch-by-files --source <branch> --base <base> --branches 5 --equal-up-to 4 --dry-run

# Recreate output branches if they already exist
git-split-branch-by-files --source <branch> --base <base> --branches 5 --equal-up-to 4 --force

Safety notes:

  • Requires a clean worktree for real execution.
  • Uses stacked output branches where each next branch is based on the previous split branch.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.