julianobarbosa/claude-code-skills/direnv
Claude Code and agent skill by julianobarbosa/claude-code-skills
- community
Checking that the SKILL.md file is still in the repository.
Guide for using direnv - a shell extension for loading directory-specific environment variables. Use when setting up project environments, creating .envrc files, configuring per-project environment variables, integrating with Python/Node/Ruby/Go layouts, working with Nix flakes, or troubleshooting environment loading issues on macOS and Linux.
Install
npx vskill@latest install julianobarbosa/claude-code-skills/direnvSKILL.md
direnv Skill
This skill provides comprehensive guidance for working with direnv, covering installation, configuration, stdlib functions, and best practices for per-project environment management.
When to Use This Skill
Use this skill when:
- Installing and configuring direnv on macOS or Linux
- Creating or modifying
.envrcfiles for projects - Setting up per-project environment variables
- Configuring language-specific layouts (Python, Node.js, Ruby, Go, Perl)
- Integrating direnv with Nix or Nix Flakes
- Managing secrets and environment configuration for teams
- Troubleshooting environment loading issues
- Creating custom direnv extensions
Core Concepts
What is direnv?
direnv is a shell extension that loads and unloads environment variables based on the current directory. When you cd into a directory with a .envrc file, direnv automatically loads the environment. When you leave, it unloads the changes.
Security Model
direnv uses an allowlist-based security approach:
- New or modified
.envrcfiles must be explicitly allowed withdirenv allow - Prevents automatic execution of untrusted scripts
- Use
direnv denyto revoke access
How It Works
- Shell hook intercepts directory changes
- Checks for
.envrcfile in current or parent directories - If allowed, executes
.envrcin a bash subshell - Captures exported variables and applies them to current shell
Installation
macOS (Homebrew - Recommended)
Linux
Verify Installation
Shell Configuration
Add the hook to your shell's config file. This is required for direnv to function.
Zsh (~/.zshrc)
With Oh My Zsh:
Bash (~/.bashrc)
Important: Place after rvm, git-prompt, and other prompt-modifying extensions.
Fish (~/.config/fish/config.fish)
After Configuration
Restart your shell:
.envrc File Basics
Creating an .envrc
Basic Syntax
Allowing the .envrc
Standard Library Functions
direnv includes a powerful stdlib. Always prefer stdlib functions over manual exports.
PATH Management
Environment File Loading
Language Layouts
Node.js:
Python:
Ruby:
Go:
Perl:
Nix Integration
For better Nix Flakes support, install nix-direnv:
Version Managers
Validation
File Watching
Utility Functions
Best Practices
Recommended .envrc Template
Git Configuration
.gitignore:
Commit to repository:
.envrc(base configuration, no secrets).env.example(template for team members)
Secrets Management
Never commit secrets. Use environment variable fallbacks:
Layered Configuration
Project Structure
Custom Extensions
Create ~/.config/direnv/direnvrc for custom functions:
Usage in .envrc:
Commands Reference
| Command | Description | |
|---|---|---|
direnv allow | Allow the current .envrc | |
direnv deny | Revoke .envrc access | |
direnv reload | Force reload environment | |
direnv status | Show current status | |
direnv dump | Dump current environment | |
direnv edit | Open .envrc in editor | |
direnv version | Show direnv version |
Troubleshooting
Environment Not Loading
Shell Hook Issues
- Verify hook is in shell config file
- Ensure it's at the END of the file
- Restart shell completely:
exec $SHELL - Check for errors:
direnv hook zsh
Performance Issues
Debugging
IDE Integration
VS Code
Install direnv extension for automatic environment loading in integrated terminal.
JetBrains
Install direnv integration plugin.
Neovim
Use direnv.vim or configure with lua.
Common Patterns
Development vs Production
Multi-Service Projects (Monorepo)
Docker Integration
References
- Official Documentation
- Installation Guide
- Shell Hook Setup
- Standard Library Reference
- nix-direnv
- Homebrew Formula
Gotchas
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/direnv/SKILL.md
Popularity
- Repository stars
- 84
- Repository forks
- 18
- 7-day trend score
- 22
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/julianobarbosa/claude-code-skills/direnv)