direnv automatically loads/unloads environment variables when you cd into a directory. No more source .env — enter the project folder and variables are set.
Instructions
Step 1: Install
brew install direnv
# Add to .bashrc or .zshrc:
eval "$(direnv hook bash)"
Step 2: Configure
# .envrc — Auto-loaded when entering directory
export DATABASE_URL="postgresql://localhost:5432/myapp"
export API_KEY="sk-dev-key-123"
export NODE_ENV="development"
dotenv .env
PATH_add bin
PATH_add node_modules/.bin
direnv allow # required first time and after changes
Step 3: Per-Project Layouts
# .envrc — Use specific versions
use nvm 20
layout python3
Guidelines
Always add .envrc to .gitignore — it contains secrets.
Use .envrc.example (committed) as template.
direnv unloads vars when you leave the directory — no env pollution.
1---2name: direnv3description: direnv4---5# direnv67## Overview8direnv automatically loads/unloads environment variables when you cd into a directory. No more source .env — enter the project folder and variables are set.910## Instructions1112### Step 1: Install13```bash14brew install direnv15# Add to .bashrc or .zshrc:16eval "$(direnv hook bash)"17```1819### Step 2: Configure20```bash21# .envrc — Auto-loaded when entering directory22export DATABASE_URL="postgresql://localhost:5432/myapp"23export API_KEY="sk-dev-key-123"24export NODE_ENV="development"25dotenv .env26PATH_add bin27PATH_add node_modules/.bin28```2930```bash31direnv allow # required first time and after changes32```3334### Step 3: Per-Project Layouts35```bash36# .envrc — Use specific versions37use nvm 2038layout python339```4041## Guidelines42- Always add .envrc to .gitignore — it contains secrets.43- Use .envrc.example (committed) as template.44- direnv unloads vars when you leave the directory — no env pollution.
Run npx skillmds@latest add comeonoliver/direnv in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
direnv It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: CAUTION, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
ComeOnOliver (@comeonoliver) published this skill. Their other Agent Skills are listed on their SkillMD profile.