Per-directory environment manager for loading approved `.envrc` or `.env` files into shells and commands.
$curl -sfL https://direnv.net/install.sh | bash
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
.envrcor.envfile. - 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 execgives agents a direct non-interactive way to run other CLIs inside the environment a project expects.direnv export jsonandstatus --jsonprovide 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
.envrcor.envfiles must be explicitly approved withdirenv allow, which blocks unattended use until trust is established. .envrcfiles are shell code executed in a bash subprocess, so behavior and safety depend on trusted repo content and shell-compatible setup.