@saferun/cli
v0.6.26
Published
AI Safety Middleware - Protect your Git workflows from dangerous AI agent operations
Maintainers
Readme
SafeRun CLI
🛡️ Human approval layer for AI agent Git operations
SafeRun protects your Git repositories from dangerous operations executed by AI agents (Cursor, Claude Code, Copilot) and automation tools. It intercepts risky commands and requires human approval via Slack before execution.
Installation
npm install -g @saferun/cliQuick Start
cd your-repo
saferun setup # Complete setup wizardThe wizard guides you through:
- API Key — Get from saferun.dev
- Slack — Bot token + webhook for notifications
- GitHub App — Install SafeRun GitHub App
- Shell Wrapper — Intercepts dangerous commands
Protected Operations
git push --force/git push -fgit reset --hardgit branch -D/git branch --delete --forcegit clean -fdgit commit --no-verify- Direct commits to
mainormaster
Commands
saferun setup # Complete setup wizard
saferun init # Initialize protection in current repo
saferun status # Show protection status
saferun status -n 20 # Show last 20 operations
saferun doctor # Health check
saferun uninstall # Remove from current repo
saferun uninstall --global # Remove completelyHow It Works
SafeRun uses multiple layers of protection:
- Shell Wrapper — Intercepts
gitcommands in interactive shells - Git Hooks —
pre-commit,pre-push,post-checkout - reference-transaction Hook — Intercepts ALL ref changes at Git core level (Git 2.29+)
The reference-transaction hook is the most reliable layer — it catches operations even when AI agents call /usr/bin/git directly, bypassing shell aliases and PATH wrappers.
AI Agent → /usr/bin/git reset --hard → Git internals → reference-transaction hook → SafeRun blocks!When a dangerous operation is detected:
- SafeRun calculates risk score and detects AI agent
- Slack notification sent with Approve/Reject buttons
- You approve → command executes. You reject → command blocked.
Approval timeout: 2 hours.
Requirements
- Node.js 18+
- Git 2.29+ (for
reference-transactionhook) - Slack workspace with bot token
Known Limitations (Help Wanted! 🙏)
SafeRun protects Git ref-changing operations. Some operations are outside our scope:
✅ Protected Operations (ref-changing):
git reset --hard— changes branch refgit branch -D— deletes branch refgit push --force— changes remote refgit rebase— rewrites branch refgit checkoutto different branch — updates HEAD ref
❌ Not Protected (no ref change):
git clean -fd— deletes untracked files only → use.gitignorerm -rf .git— filesystem operation → use Docker/sandbox- Deleting
.git/hooks/— filesystem operation → use Docker/sandbox
Why can't we protect git clean?
Git's reference-transaction hook only fires when refs change. git clean deletes untracked files without touching refs.
Community contributions welcome! If you know how to intercept these operations, please open an issue or PR.
Documentation
Full documentation: github.com/Cocabadger/saferun-api
License
MIT © SafeRun Team
