Works with the AI Agents you already use
Agent Foreman Git Guard - Stop AI Agents Destroying Work
Foreman Git Guard makes those mistakes impossible to make by accident.
$9
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 chain | Verdict | Reason |
|---|---|---|
cd api | allow | plain navigation |
git stash | deny | git 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 -- . | deny | discards uncommitted changes in the working tree |
git clean -fdx | deny | deletes 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:
- Runs
git statusandgit diff --stat(both allowed). - Reports exactly which files it changed in this session.
- Asks you whether to revert only its own edits with a new commit, instead of wiping the tree.
It cannot be wrapped around
| Attempt | Result |
|---|---|
forced push inside bash -c inside $( ... ) | DENY - all three layers parsed |
git commit --no-verify to skip a failing lint hook | DENY - "fix what the hook reports" |
| recursive delete of a folder named by an unresolved variable | DENY - "use a literal path" |
git status, git diff, git push origin feature/x, git checkout -b, deleting node_modules | ALLOW - normal work flows untouched |
Next steps
- In Claude Code, keep the
PreToolUsehook 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 CodePreToolUsehook - 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;
--checkCLI 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
- Add the skill to your agent. Ask: "Use foreman-git-guard and install the guard hook in this project."
- The agent shows the hook entry, waits for your yes, writes
.claude/hooks/foreman_guard.pyand merges onePreToolUseentry into.claude/settings.local.json. - It verifies with
--check(ALLOW forgit 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.jsonconfiguration, pre-flight rules for any agent.
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
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
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
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
Requires