@saferun/cli
v0.6.63
Published
AI Safety Middleware - Protect your Git workflows from dangerous AI agent operations
Downloads
3,390
Maintainers
Readme
SafeRun
Strict policy enforcement for your git workflow. SafeRun acts as a middleware between your terminal and GitHub, preventing accidental data loss and enforcing development policies.
Features
Layer 1: Local Protection (Zero Latency)
SafeRun installs git hooks (pre-push, pre-commit) that intercept dangerous commands before they execute.
- Blocks accidental destruction: Prevents
force-push,branch -D,reset --hardon protected branches. - Context-Aware: Settings are isolated per repository. Protecting
developin Project A won't affect Project B. - Smart Caching: Rules are checked locally (0ms latency).
Layer 2: Approval Workflow
Risky operations trigger an interactive approval request in Slack.
- You run
git push --force origin main. - SafeRun blocks the command and sends a notification.
- You (or a team lead) click Approve in Slack.
- The command executes automatically.
Layer 3: One-Click Revert (Webhooks)
If a dangerous operation bypasses local checks (e.g., via GitHub UI or another machine), SafeRun's GitHub App detects it and offers instant recovery.
- 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.
Installation
npm install -g @saferun/cliSetup
Navigate to your git repository and run the interactive wizard:
saferun setupThis command will:
- Link your API Key.
- Connect Slack & GitHub App.
- Install necessary Git Hooks (
pre-push,reference-transaction). - Register the repository in your global config.
CLI Cheat Sheet
SafeRun works silently in the background. Use these commands for configuration and audit:
Essentials
saferun setupInitialize. Sets up SafeRun in the current repository.saferun settings branchesConfigure. Interactively select branches to protect (e.g.,main,production).
Maintenance
saferun syncUpdate. Manually pulls latest settings from the cloud (Auto-sync runs in background).saferun doctorDiagnose. Checks connection, hooks, and configuration status.
Audit
saferun historyAudit. Shows the log of recent intercepted operations and their status.saferun config showInspect. View the current active configuration.saferun uninstallRemove. Cleans up hooks and configuration.
Protected Operations
SafeRun intercepts the following commands on protected branches:
git push --forcegit branch -Dgit 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.
Troubleshooting
"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:
- Run
saferun uninstall --global(removes configs and hooks). - Run
npm uninstall -g @saferun/cli(removes the binary).
