home / dev-tools / direnv

direnv

15k

Per-directory environment manager for loading approved `.envrc` or `.env` files into shells and commands.

$curl -sfL https://direnv.net/install.sh | bash
Language
Go
Stars
14,757
Category
Dev Tools
Agent
Ready
Agent Compatibility
JSON Output
Agent Skill
MCP Support
AI Analysis

direnv manages per-directory environment state by evaluating approved .envrc or .env files and exporting the resulting diff to your shell or a child process. It is mainly used to keep project-specific variables, PATH changes, secrets, and toolchain setup tied to a repo instead of a global shell profile.

What It Enables
  • Load project-specific environment variables, PATH changes, and secrets automatically when you enter a repo after approving its .envrc or .env file.
  • Run build, test, deploy, or utility commands inside a directory's configured environment with direnv exec, without manually sourcing activation scripts.
  • Export environment diffs for shell hooks, JSON consumers, or GitHub Actions environment files so the same env definition can drive local and CI workflows.
Agent Fit
  • direnv exec gives agents a direct non-interactive way to run other CLIs inside the environment a project expects.
  • direnv export json and status --json provide structured state, but most day-to-day use still revolves around shell hooks rather than a broad standalone command surface.
  • Best used as infrastructure around repo workflows and other CLIs, not as the main action primitive itself.
Caveats
  • New or changed .envrc or .env files must be explicitly approved with direnv allow, which blocks unattended use until trust is established.
  • .envrc files are shell code executed in a bash subprocess, so behavior and safety depend on trusted repo content and shell-compatible setup.