AI Safety Middleware - Protect your Git workflows from dangerous AI agent operations
npm install @saferun/cliStrict policy enforcement for your git workflow.
SafeRun acts as a middleware between your terminal and GitHub, preventing accidental data loss and enforcing development policies.
pre-push, pre-commit) that intercept dangerous commands before they execute.force-push, branch -D, reset --hard on protected branches.develop in Project A won't affect Project B.git push --force origin main.* Force Push: Restores branch to previous commit SHA.
* Delete Branch: Recreates the deleted branch.
* Merge PR: Creates a revert commit.
* Archive Repo: Unarchives the repository.
> ⚠️ Note: Revert capabilities require the SafeRun GitHub App to be installed. CLI-intercepted operations are prevented before they happen, so they don't need reverting.
---
``bash`
npm install -g @saferun/cli
Navigate to your git repository and run the interactive wizard:
`bash`
saferun setup
This command will:
1. Link your API Key.
2. Connect Slack & GitHub App.
3. Install necessary Git Hooks (pre-push, reference-transaction).
4. Register the repository in your global config.
---
SafeRun works silently in the background. Use these commands for configuration and audit:
* saferun setup
Initialize. Sets up SafeRun in the current repository.
* saferun settings branches
Configure. Interactively select branches to protect (e.g., main, production).
* saferun sync
Update. Manually pulls latest settings from the cloud (Auto-sync runs in background).
* saferun doctor
Diagnose. Checks connection, hooks, and configuration status.
* saferun history
Audit. Shows the log of recent intercepted operations and their status.
* saferun config show
Inspect. View the current active configuration.
* saferun uninstall
Remove. Cleans up hooks and configuration.
---
SafeRun intercepts the following commands on protected branches:
* git push --forcegit branch -D
* git reset --hard
* (via hook)git clean -fd
(via hook - requires shell integration*)git rebase
* (via hook)
Bypass:
If you strictly need to bypass SafeRun (e.g., for scripting), you can disable protection temporarily via saferun settings branches or use standard git bypass flags if your policy allows.
---
"Config outdated" message
SafeRun automatically syncs settings in the background. If you see this, run saferun sync to force an update.
Uninstalling
To completely remove SafeRun:
1. Run saferun uninstall --global (removes configs and hooks).npm uninstall -g @saferun/cli` (removes the binary).
2. Run
---
Built for developers who value sleep. 😴