safety-dotenv-guard

Block unauthorized Read, Bash, Grep, and Glob calls targeting .env files.

7|Updated May 28, 2026
One-click install
npx skills add https://github.com/zcaceres/skills --skill safety-dotenv-guard
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: safety-dotenv-guard
Source: https://github.com/zcaceres/skills/tree/main/skills/safety-dotenv-guard
Command: npx skills add https://github.com/zcaceres/skills --skill safety-dotenv-guard

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires jq, and includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

This skill prevents accidental exposure of sensitive environment variables by intercepting and blocking unauthorized attempts to read or manipulate .env files within the Claude Code environment.

Core Features & Use Cases

  • Proactive Blocking: Automatically blocks Read, Bash, Grep, and Glob tool calls that target .env files.
  • Smart Allowlisting: Explicitly permits common template files like .env.example and .env.template to ensure standard development workflows remain uninterrupted.
  • Defense in Depth: Provides a robust security layer that catches direct file access, subshell bypass attempts, and wildcard expansion tricks.

Quick Start

Run the install script from the skill directory to wire the security hook into your Claude Code settings for always-on protection.

Frequently Asked Questions about safety-dotenv-guard

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent Claude Code from reading .env files?

This security hook intercepts Read, Bash, Grep, and Glob tool calls in Claude Code, blocking unauthorized access to .env files to prevent production secrets from entering the agent's context.

Can I still access .env.example templates when secret blocking is enabled?

Yes, standard template files like .env.example and .env.template are explicitly allowlisted, ensuring standard development workflows remain uninterrupted while blocking actual secret files.

Does this .env protection stop subshell bypass attempts and wildcard expansion?

Yes, the defense-in-depth mechanism validates file paths and command arguments against a strict blocklist, catching direct file access, subshell bypass attempts, and wildcard expansion tricks.

What do I need to install to block environment variable access in Claude Code?

You need the jq dependency installed on your system. Run the provided install script from the skill directory to wire the PreToolUse security hook into your Claude Code settings for always-on protection.

Why are my environment variables leaking into the agent context during development?

Environment variables leak when standard tool calls read .env files directly. Intercepting these tool calls with a strict blocklist prevents sensitive production secrets from entering the agent's context.