npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

agent-git-guard

v1.0.0

Published

Never let your AI coding agents destroy your git repository. Zero-dependency safety guardrails for Claude Code, Cursor, Windsurf, Aider, and local CLI agents.

Readme

🛡️ agent-git-guard

Never let your AI coding agents destroy your git repository again.
Zero-dependency, ultra-lightweight (<50KB, ~3ms) safety guardrails for Claude Code, Cursor, Windsurf, Aider, and local CLI agents.

License: MIT Node: >=18 Zero Dependencies Speed: ~3ms


💥 The Problem

Autonomous AI coding agents (Claude Code, Cursor Agent, Windsurf, Aider, OpenDevin) are extraordinarily capable, but they lack instinctual risk boundaries. A single hallucinated command can cause irreversible disasters:

  • git push -f origin main overwriting months of team commits.
  • git reset --hard silently discarding uncommitted user files.
  • git clean -fd permanently deleting untracked assets and newly created files.
  • git checkout . or git restore . wiping unstaged work.
  • git add .env accidentally committing production database credentials and API keys.

agent-git-guard intercepts and neutralizes these destructive actions before they execute.


⚡ Quick Start (1-Second Install)

In your project root, run:

npx agent-git-guard init

That's it! agent-git-guard automatically configures:

  1. Claude Code (.claude/settings.json PreToolUse hook)
  2. Git Native Hooks (.git/hooks/pre-push & pre-commit)
  3. Cursor (.cursor/rules/agent-git-guard.mdc)

🎯 What Gets Blocked?

| Risk Level | Target Action | Why it's Blocked | |---|---|---| | CRITICAL | git push -f / --force | Permanently overwrites remote history | | CRITICAL | git reset --hard | Destroys uncommitted and committed work | | CRITICAL | git clean -f / -fd | Irreversibly deletes untracked files | | CRITICAL | rm -rf .git / rm -rf * | Wipes repository and workspace | | HIGH | git push (direct) | Requires explicit human review before remote sync | | HIGH | git branch -D | Force deletes branches without merge verification | | HIGH | git checkout . / restore . | Discards all uncommitted file modifications | | HIGH | git add .env / id_rsa / *.pem | Prevents staging secrets and private keys |

🧠 Intelligent Parsing (Zero False Positives)

agent-git-guard parses compound shell commands (&&, ||, ;, subshells like bash -c '...'), while strictly preserving benign operations:

  • ✅ git commit -m "fix: resolve git push remote issue" (Allowed: quoted string)
  • ✅ echo "git reset --hard should be avoided" (Allowed: echo / print)
  • 🛑 npm test && git push origin main (Blocked: chained destructive push)
  • 🛑 bash -c "git reset --hard" (Blocked: nested subshell)

🛠️ CLI Usage

1. Manual Command Check

Test if any command violates guard rules:

npx agent-git-guard check "git push origin main"
# Output:
# 🛑 Command VIOLATES safety guardrails:
#    🚨 [HIGH] git-push
#       Reason: Direct git push by AI agent without explicit human permission
#       Advice: Do not push directly to remote. Ask the human user to review and push.

2. Inspect Protection Status

Check which agent layers are currently protected in your workspace:

npx agent-git-guard status

3. Granular Installation Options

# Global install for Claude Code (protects all projects)
npx agent-git-guard init --global

# Install Git native hooks only
npx agent-git-guard init --git-hooks

# Install Claude hook only
npx agent-git-guard init --claude

# Install Cursor rules only
npx agent-git-guard init --cursor

🔓 Bypassing When Intended (Human Override)

When a human legitimately needs to push from an agent session, simply set:

ALLOW_AGENT_PUSH=1 git push origin main

📦 Programmatic SDK

You can also use agent-git-guard directly inside your own Node.js or TypeScript agent orchestrator:

import { checkCommand } from 'agent-git-guard';

const result = checkCommand('npm test && git push');

if (!result.allowed) {
  console.log(`Action blocked: ${result.violations[0].rule.description}`);
}

📜 License

MIT © OIYO Lab