with one click
safe-git-ops
// Perform Git operations safely with sandbox-aware failure handling. Use for commit, push, merge, rebase, stash, worktree, conflicts, lock files, permission errors, or Git state diagnosis.
// Perform Git operations safely with sandbox-aware failure handling. Use for commit, push, merge, rebase, stash, worktree, conflicts, lock files, permission errors, or Git state diagnosis.
[HINT] Download the complete skill directory including SKILL.md and all related files
| name | safe-git-ops |
| description | Perform Git operations safely with sandbox-aware failure handling. Use for commit, push, merge, rebase, stash, worktree, conflicts, lock files, permission errors, or Git state diagnosis. |
| allowed-tools | Read, Write, Edit, Bash, Glob |
Help the user perform common Git operations without confusing sandbox failures, repository state issues, and real content conflicts.
<installed-skill-dir>/
āāā SKILL.md
āāā references/
āāā failure-modes.md
āāā commit-paths.md
āāā worktrees.md
references/failure-modes.mdreferences/commit-paths.md when the user asks to commit, push, speed up closeout, or choose validation/reinstall scopereferences/worktrees.md when the repo uses git worktree, when .git points to another directory, or when the user mentions multiple worktreesreset --hard, checkout --, deleting branches, or dropping stashessidecar-task-runner precommit classification for non-trivial closeouts when it can run read-only and reduce main-agent decision timeUse this skill immediately when any of these show up:
git cherry-pick, merge, rebase, commit, stash, switch, checkout, branch, or worktreeCONFLICTindex.lockoperation not permittedpermission deniedCould not resolve hostCould not read from remote repositoryConnection timed outNetwork is unreachable.git/worktrees/ORIG_HEADCHERRY_PICK_HEADbranch is already checked outDo not wait until after a failed write to load this skill if the task is obviously Git-heavy.
Never say any of the following unless Git actually proved it:
Before any meaningful Git action, inspect the repository shape:
git rev-parse --show-toplevel
git rev-parse --git-dir
git branch --show-current
git status --short
If the user mentions worktrees or .git is a file rather than a directory, also inspect:
git worktree list
git rev-parse --git-common-dir
Summarize:
Handle the request as one of these categories:
inspect: status, log, diff, branch list, remotes, worktree layoutnetwork_inspect: fetch, pull, push dry checks, ls-remote, submodule update, or any Git operation that contacts a Git remotesafe_write: add, commit, cherry-pick, merge, rebase, stash, branch creation, worktree creationdestructive_write: reset, checkout over local changes, clean, branch deletion, stash drop, force pushFor inspect, run the command directly if sandbox rules allow it.
For network_inspect, expect sandboxed runtimes to block DNS or outbound connections unless network permission is granted.
For safe_write, do a preflight check first. For commit/push closeouts, classify the change as Fast Path, Skill Path, Code Path, or Risk Path using references/commit-paths.md, then run the smallest validation set that matches the path.
For destructive_write, require explicit user confirmation before executing.
Before safe_write or destructive_write, gather enough context to avoid sloppy failure handling:
git status --short
git branch --show-current
git rev-parse --short HEAD
For ordinary commit/push closeout, avoid full orientation unless Risk Path applies. A Fast Path closeout may use only git status --short, git diff --check, explicit git add <files>, and git diff --cached --stat before commit.
For cherry-pick, merge, or rebase, also inspect the target commit or branch first:
git log --oneline --decorate -n 5
git show --stat --summary <target>
For worktrees, inspect the shared metadata location:
git rev-parse --git-common-dir
If the command will likely write to shared Git metadata outside the sandboxed writable root, tell the user this before running it and be ready to request escalation.
If the user specifically asked for a worktree-scoped write operation such as cherry-pick, merge, or commit, explicitly mention before running it that worktrees may require writes under the common git dir rather than only the visible worktree path.
When a Git write fails, classify the failure before telling the user what happened.
Use the guidance in references/failure-modes.md. The high-level rule is:
CONFLICT, conflict markers, or asks to resolve files, this is a code conflictoperation not permitted, permission denied, failure to create lock files, or inability to update refs or worktree metadata, this is a sandbox or permission problemfetch, pull, push, ls-remote, or submodule operations, this is network/sandbox access until rerun with network permissionDo not tell the user "there is a conflict" unless Git actually reported one.
Do not tell the user "authentication failed", "SSH key is wrong", or "the remote repo is missing" when Git never reached the host because of DNS/network/sandbox restrictions.
If a write command is important and fails because of sandbox restrictions:
.git/index.lock.git/worktrees/...Use wording like:
This
git cherry-pickfailure looks like a sandbox write restriction, not a merge conflict. Git needs to update shared worktree metadata, so I should rerun it with elevated permissions.
If a network Git command is important and fails because DNS, API, or host connection is blocked:
git fetch, git push, or git ls-remoteUse wording like:
This
git ls-remotefailure did not reach GitHub; it looks like sandboxed network access, not a missing repo or bad SSH key. I should rerun it with network permission before diagnosing credentials.
When the repo uses worktrees:
commit, cherry-pick, merge, rebase, and similar commands may write outside the current worktree directorygit worktree list and git rev-parse --git-common-dir earlyRead references/worktrees.md for the detailed handling rules.
When you finish, report one of these outcomes clearly:
For each case, give the user the next action, not a vague Git dump.
Good example:
git cherry-pick <commit>did not reach merge resolution. Git was blocked from writing shared worktree metadata under the common git dir, so this is a sandbox issue. The next step is to rerun the same command with elevated permissions.
Bad example:
cherry-pick failed, probably a conflict
When the user asked "what happened?" or "why did this fail?", report in this structure:
Operation: <git command>
Classification: success | content conflict | sandbox restriction | network/sandbox restriction | repository state problem
Evidence: <the key git message or state observation>
Why it happened: <short explanation>
Next step: <single concrete next action>
Keep the classification line explicit. That is the main protection against sloppy Git diagnoses.
git status, log, diff, show, branch, remotegit fetch, pull, push, ls-remotegit add, commit, stashgit cherry-pickgit mergegit rebasegit switch, checkout, checkout -bgit worktree list, git worktree addgit reset --hardgit checkout -- <path>git clean -fdgit branch -Dgit stash drop or cleargit push --forceDo not run these without explicit user approval.