Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIDeepSeekDeepSeekMuseMuse+22 more

    Git Safety Net

    1

    Backs up your work before your agent runs a git command that can lose it (reset --hard, clean, branch -D, stash drop), and knows how to get it back when something is already gone.

    Free

    Security scanned
    Git Safety Net

    Git Safety Net

    Example session with this skill installed

    I messed up my local branch. Throw away all my changes and reset main to origin/main.

    • Read your context and instructions
    • Compiled the git safety net

    Summary

    Reset main to origin/main and discarded local changes, after saving a backup you can restore from.

    What was going to be lost (checked first):

    ItemCount
    Commits on main not on origin/main2 (a41c9e2 WIP parser, 9b03d1f fix tests)
    Modified tracked files3 (1 staged)
    Untracked files2 (notes.md, tmp/sample.json)
    Ignored files.env, left untouched

    Backup saved before the reset:

    backup id: 20261109T183850Z-4211
    reason: before reset --hard origin/main
    saved: HEAD (main at 9b03d1f)
    saved: 3 local branch(es)
    saved: staged and unstaged changes to tracked files
    saved: 2 untracked file(s) -> .git/agent-backup/20261109T183850Z-4211-untracked.tgz
    NOT saved (ignored files, e.g.):
      .env
    

    Then ran:

    git fetch origin
    git reset --hard origin/main
    git clean -fd      # untracked files only; .env and other ignored files kept
    

    main is now at origin/main (c72e0aa) and the working tree is clean.

    Next steps

    • Want the 2 commits back? git branch rescued refs/agent-backup/20261109T183850Z-4211/branches/main
    • Want the uncommitted changes back? git stash apply --index refs/agent-backup/20261109T183850Z-4211/wip
    • Happy with the result? Tell me and I'll delete the backup.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Git is a powerful tool, but one wrong command can permanently delete uncommitted code, untracked files or stashes. This skill gives agents working in your repository a safety net: before a destructive git command, the agent saves a restorable backup, and when work is already lost, it knows how to dig it back out.

    What it does

    • Backups before risky commands: saves every local branch, HEAD, staged and unstaged changes, stash entries and untracked files, without touching your working tree or index.
    • Risk awareness: the agent treats commands like reset --hard, clean -f, branch -D, stash drop and rebase as risky, including inside && chains, sh -c, scripts and aliases.
    • Asks before what can't be backed up: deleting ignored files (.env, local databases), force pushes, and pruning recovery data (gc --prune, reflog expire).
    • Work recovery: exact commands to restore a branch, uncommitted changes, stashes or untracked files from a backup.
    • Recovery without a backup: walks through the reflog, unreachable commits (git fsck) and lost staged blobs, and says plainly when something is truly gone.
    • gitflash integration: if gitflash is installed, the agent uses its snapshots and one-command undo instead.

    How it works

    1. Check the command: the agent recognises a risky git command, and only runs one you actually asked for.
    2. Inspect what's at risk: it runs git status, git clean -n and checks unpushed commits and stashes, so you see what the command would destroy.
    3. Back up: it runs the bundled backup script, which saves the current state under a unique backup ID.
    4. Ask when needed: if the command would delete ignored files, rewrite a remote or delete recovery data, it stops and asks you first.
    5. Run and report: it runs the command and tells you the backup ID and how to restore from it.

    Frameworks & tools

    Requires git, bash and tar. Works on macOS, Linux and Windows via Git Bash. Uses gitflash if it is installed.

    Why this beats prompting it yourself

    Git can't restore uncommitted changes, untracked files or dropped stashes, and ad-hoc prompts rarely cover all of them. This skill gives the agent a tested backup script that captures branches, changes, stashes and untracked files in one step, a clear rule for when to stop and ask, and a step-by-step recovery playbook for when no backup exists.

    Use cases

    • Clearing a workspace with git reset --hard without losing the uncommitted work you might still want.
    • Getting back a stash that was dropped or cleared by mistake.
    • Restoring new, not-yet-committed source files removed by git clean -f.
    • Rescuing commits from a deleted branch that was never pushed.

    Known limitations

    Does not back up ignored files (such as .env) or untracked files over 50 MB. The script lists what it skipped. Uncommitted work inside submodules is not captured unless the script runs in the submodule. Backups are local, stay until you delete them, and cannot undo a force push on a remote.

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for DevOps & Cloud.

    No backup for ignored files or untracked files over 50MB. Requires bash and tar. Does not capture uncommitted work inside submodules automatically.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Free to use

    No account required to browse

    Trust & safety

    Security scan

    Security scan passed 7 days ago

    • Free with an Agensi account

    Software
    GitBashTar
    Optional
    Ruby

    On Windows, run it from Git Bash or WSL. Backups are stored inside your repository's .git folder and never leave your machine.

    Permissions

    Terminal / Shell
    Read Files
    Write Files

    File Scopes

    .git/**

    Runs git and a bundled backup script in your repository. Backups are written only inside .git (refs/agent-backup/* and .git/agent-backup/). It reads your working tree to back up untracked files but never modifies or uploads them. No network access.

    Listed7 days ago

    What's inside

    Frequently Asked Questions

    Before your agent runs a git command that can destroy work (reset --hard, checkout -- ., clean -f, branch -D, stash drop, rebase), it checks what would be lost and saves a backup of branches, uncommitted changes, stashes and untracked files. Afterwards it tells you how to undo. If work is already lost, it walks through recovering it.

    Any agent that follows the SKILL.md standard and can run shell commands: Claude Code, Codex CLI, Cursor, Gemini CLI and others. It needs git, bash and tar.

    Install it in your agent's skills folder. After that it works on its own: whenever the agent is about to run a risky git command, it backs up first. You can also ask directly, for example "back up my repo state", "I lost my changes after git reset, can you get them back?" or "list my git backups".

    No. Ignored files are never saved, so the agent asks you before any command that would delete them (git clean -x, git worktree remove).

    New in DevOps & Cloud

    Free