Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIDeepSeekDeepSeekMuseMuse+22 more

    Agent Foreman Git Guard - Stop AI Agents Destroying Work

    1

    Foreman Git Guard makes those mistakes impossible to make by accident.

    $9

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    Agent Foreman Git Guard - Stop AI Agents Destroying Work

    Agent Foreman Git Guard - Stop AI Agents Destroying Work

    Example session with this skill installed

    The tests keep failing, let's start fresh: cd api && git stash && git checkout -- . && git clean -fdx

    • Read your context and instructions
    • Compiled the agent foreman git

    Summary

    The agent proposed one tidy "start fresh" line. Foreman Git Guard parsed every step of the chain and refused the tool call before anything ran, so no uncommitted work was lost.

    Guard verdict: DENY

    Step in the chainVerdictReason
    cd apiallowplain navigation
    git stashdenygit stash is blocked (only stash list / stash show): it hides other people's work in a shared tree, and a failed pop loses it
    git checkout -- .denydiscards uncommitted changes in the working tree
    git clean -fdxdenydeletes untracked and ignored files, including a colleague's fixtures

    Because one step is denied, the whole command is denied - the tool call never executes.

    What the agent does instead

    Following the skill's pre-flight rules, the agent:

    1. Runs git status and git diff --stat (both allowed).
    2. Reports exactly which files it changed in this session.
    3. Asks you whether to revert only its own edits with a new commit, instead of wiping the tree.

    It cannot be wrapped around

    AttemptResult
    forced push inside bash -c inside $( ... )DENY - all three layers parsed
    git commit --no-verify to skip a failing lint hookDENY - "fix what the hook reports"
    recursive delete of a folder named by an unresolved variableDENY - "use a literal path"
    git status, git diff, git push origin feature/x, git checkout -b, deleting node_modulesALLOW - normal work flows untouched

    Next steps

    • In Claude Code, keep the PreToolUse hook installed so every shell call is checked automatically.
    • In Cursor or Codex, have the agent run python foreman_guard.py --check "<command>" first (exit 2 = deny).
    • Add project-specific protected folders or a commit-subject regex in .foreman-guard.json.

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

    About this skill

    Autonomous coding agents are fast, and occasionally they "clean up" by discarding your uncommitted work, force-pushing over a teammate's branch or rewriting history to make a commit look tidy. Foreman Git Guard makes those mistakes impossible to make by accident.

    It ships two layers:

    • Always-on pre-flight rules your agent follows in any tool that reads skills - no installation.
    • foreman_guard.py, a single self-contained Python script (standard library only, no network, never executes what it checks). Install it as a Claude Code PreToolUse hook - the agent writes it into your project only after you say yes - or call it from any agent as --check "<command>".

    The guard does not grep for scary words. It tokenizes the command the way a shell does - quotes, chains, pipes, subshells, command substitution, heredocs - and follows wrappers such as bash -c, pwsh -Command, cmd /c, eval, Invoke-Expression, wsl, env, sudo and xargs. Wrapping a dangerous command does not get it through; mentioning one inside an echo or a heredoc document does not get it blocked. The rule set was validated against a 217-case regression suite.

    Project rules are optional and live in .foreman-guard.json: extra allowed folders, protected folders, temporary worktree locations, push policy, a commit-subject regex and banned patterns for commit messages (internal ticket ids, tool names).

    Key capabilities

    • Real shell parsing for bash, PowerShell and cmd, including nested shells, eval and substitutions
    • Blocks discarding work: reset, clean, checkout/restore/switch discards, stash
    • Blocks history rewrites: rebase, amend, filter-branch, filter-repo, update-ref, reflog expire, gc --prune
    • Blocks forced/deleting pushes and indirect push forms
    • Blocks branch -D/-M/-C/--force, add -A/., commit -a
    • Enforces commit identity and git hooks (--author, user.* config, GIT_AUTHOR_*, --no-verify, hooksPath)
    • Protects drive roots, home, project, repository roots and .git from recursive deletion
    • Restricts file writes to the project, temp and approved folders
    • Commit-message checks: unreadable messages, junk subjects, regex convention, banned patterns
    • Fails open on malformed input so it can never brick a session; --check CLI for any agent

    Who it is for

    Developers and teams who let AI coding agents run shell commands unattended; anyone running several agents on one repository; engineering leads who want a mechanical safety floor before granting auto mode.

    Install / usage

    1. Add the skill to your agent. Ask: "Use foreman-git-guard and install the guard hook in this project."
    2. The agent shows the hook entry, waits for your yes, writes .claude/hooks/foreman_guard.py and merges one PreToolUse entry into .claude/settings.local.json.
    3. It verifies with --check (ALLOW for git status, DENY for a forced push).

    Other agents: run python foreman_guard.py --check "<command>" [--shell bash|ps|cmd] (exit 2 = deny).

    Limitations

    It is not a sandbox. It is a floor for commands the agent types; a script the agent writes and then runs is not inspected. Pair it with your normal permission settings.

    Changelog

    • 1.0.0 - First release: shell-aware guard, hook and CLI modes, .foreman-guard.json configuration, pre-flight rules for any agent.

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

    Not a sandbox: it checks the commands the agent types; a script the agent writes and then runs is not inspected. Pair it with your normal permission settings. The hook and --check CLI need Python 3.8+. On malformed hook input it fails open (allows) and logs to foreman_guard.err so it can never lock a session.

    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

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scan

    Security scan passed 4 days ago

    Software
    Git
    Optional
    Python 3.8+ (for the hook and --check CLI)

    Permissions

    Terminal / Shell
    Read Files
    Write Files
    Environment Variables
    Listed4 days ago

    What's inside

    Frequently Asked Questions

    No. It only reads the command text and returns allow or deny.

    No: status, diff, log, fetch, plain push, commit -m, checkout -b, switch, restore --staged and deleting build folders are allowed.

    It fails open (allows) and logs to foreman_guard.err, so a bad payload can never lock your session.

    Yes - the pre-flight rules work in any skill-aware agent, and the --check CLI works anywhere Python 3.8+ runs.

    No. It is a floor for commands the agent types; a script the agent writes and then runs is not inspected. Pair it with your normal permission settings.

    Yes, optionally, in .foreman-guard.json: extra allowed folders, protected folders, temporary worktree locations, push policy, a commit-subject regex and banned patterns for commit messages.

    New in Security