# Direnv

> direnv

- Skill: `comeonoliver/direnv` (Agent Skill)
- Install (CLI): `npx skillmds@latest add comeonoliver/direnv`
- Raw SKILL.md: https://api.skillmd.com/api/skills/comeonoliver/direnv/raw
- Safety review: pending (external: skill-scanner PASS, skillspector CAUTION)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: ComeOnOliver (https://skillmd.com/u/comeonoliver)
- Updated: 2026-09-21
- Page: https://skillmd.com/skills/comeonoliver/direnv

---

# direnv

## Overview
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
```bash
brew install direnv
# Add to .bashrc or .zshrc:
eval "$(direnv hook bash)"
```

### Step 2: Configure
```bash
# .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
```

```bash
direnv allow    # required first time and after changes
```

### Step 3: Per-Project Layouts
```bash
# .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.

