npx claudepluginhub edtrackai/claude-code-guardrails-litePattern-based checks that deny .env reads, git force pushes and rm -rf on / or your home folder before Claude Code runs them.
A small Claude Code plugin (a mod, Claude Code 2.1.287+) that checks each tool call and denies three kinds of call before they run:
.env files: Read, Grep and Glob on .env, .env.local, .env.production and similar, plus Bash readers such as cat, head, grep, cp, source and base64 on those files. .env.example, .env.sample and .env.template are allowed.git push -f, --force, --force-with-lease, combined short flags like -uf, and +refspec pushes. A plain git push runs.rm on /, ~ or $HOME: for example rm -rf ~, rm -fr /, rm -Rf $HOME/*. rm -rf node_modules runs.It is pattern-based and about 75 lines of dependency-free JavaScript (hooks/lite-core.mjs). Read it before you install it.
claude plugin marketplace add edtrackai/claude-code-guardrails-lite
claude plugin install guardrails-lite@guardrails-lite
Or inside a session: /plugin marketplace add edtrackai/claude-code-guardrails-lite, then /plugin install guardrails-lite@guardrails-lite. Run /reload-plugins or start a new session.
To try it for one session without installing: clone the repo and run claude --plugin-dir ./claude-code-guardrails-lite.
Output from the core check (node against hooks/lite-core.mjs, captured from this repo's tests):
{"file_path":"/app/.env.local"} -> {"decision":"deny","reason":"Guardrails Lite: reading /app/.env.local is blocked because .env files hold secrets. Use .env.example for variable names, or ask the user for the specific value."}
{"command":"git push --force origin main"} -> {"decision":"deny","reason":"Guardrails Lite: force push needs the user's explicit approval. Ask the user to run it."}
{"command":"rm -rf ~"} -> {"decision":"deny","reason":"Guardrails Lite: recursive rm on /, ~ or $HOME is blocked. Ask the user to run it."}
{"command":"git push origin main"} -> null
In the mod, the reason is returned to Claude Code as { deny: reason } and the tool does not run (checked by the a refused call never reaches the tool plugin test).
claude plugin validate --strict .: passes (Claude Code 2.1.300).claude plugin test .: 13 of 13 pass (tests/register.test.ts, synthetic tool-call events).node --test tests/: 36 of 36 pass (tests/core.test.mjs), including checks of the internal-error deny and of the .catch handler and a timing check that runs 60 adversarial inputs near the 64 K size cap and requires each to finish in under 50 ms.It has not been tested in a live interactive Claude Code session.
.env, git -C dir push -f variants it doesn't parse, shell variables or aliases, find / -delete, or rm -rf on other important folders.Read, Grep, Glob and Bash tool calls. MCP tools, other file tools and anything outside Claude Code aren't checked.Guardrails Lite: internal error ... to stderr (checked by a unit test in tests/core.test.mjs). Ask the user to run the call, or report the error..catch handler is skipped, and the call goes ahead. From 0.1.2 the hook has an on(...).catch(...) handler; per the same docs, Claude Code calls it when the hook throws or times out, and it denies the call if the hook had not yet passed it on. Unit tests check that the handler is attached and how it answers a simulated timeout; a real timeout has not been triggered in a live Claude Code session. If the handler itself fails, the docs say Claude Code skips the hook and the call goes ahead.--safe-mode, --bare or "disableAllHooks": true, or where your organization blocks user mods. Another mod that approves tool calls can approve a call before this one sees it.See CHANGELOG.md.
MIT. See LICENSE.
Ad (paid, from the same author): the Guardrails Pack ($24 plus VAT where applicable) has the full rule set (Supabase, Stripe, deploy and secret-egress checks, settings hooks, Cursor hooks).
Claude and Claude Code are trademarks of Anthropic. This plugin is not affiliated with or endorsed by Anthropic.
7-day visitors to each marketplace page
Anthropic example skills
Anthropic's Claude Code plugins, installed from the claude-plugins-official repository
Ultra-compressed communication mode. Shortens prose while preserving technical terms, code, commands, and exact errors.