Auto-Load Your Dev Environment When Changing Directories
If you use direnv to manage per-project environment variables, Claude Code won't automatically pick up those environments when you switch directories. The CwdChanged hook fixes this by running a command every time Claude changes its working directory.
Add this to your .claude/settings.json:
{
"hooks": {
"CwdChanged": [
{
"hooks": [
{
"type": "command",
"command": "eval \"$(direnv export bash)\" && if [ -n \"$CLAUDE_ENV_FILE\" ]; then direnv export bash | grep 'export' >> \"$CLAUDE_ENV_FILE\"; fi"
}
]
}
]
}
}
The CLAUDE_ENV_FILE variable is a special file Claude Code provides in hooks. Anything you write to it as export VAR=value lines gets loaded into Claude's environment for the rest of the session.
You can also watch .envrc files directly with the FileChanged hook so Claude reloads the environment whenever that file changes — without you needing to switch directories:
{
"hooks": {
"FileChanged": [
{
"matcher": ".envrc",
"hooks": [
{
"type": "command",
"command": "eval \"$(direnv export bash)\" && if [ -n \"$CLAUDE_ENV_FILE\" ]; then direnv export bash | grep 'export' >> \"$CLAUDE_ENV_FILE\"; fi"
}
]
}
]
}
}
Keep Claude's environment in sync with your project without ever thinking about it.
Log in to leave a comment.
When Claude writes error messages, button labels, validation text, or onboarding flows, it defaults to generic developer-speak. Add a "Users" section to your CLAUDE.md describing who your actual users are — their technical level, industry jargon, and what they care about — so Claude writes copy that makes sense to THEM, not to developers.
Use the --agent flag with custom markdown files in .claude/agents/ to launch purpose-built Claude sessions with restricted tools and scoped system prompts.
Every project has traps — the billing module that silently fails if you forget to queue the job, the legacy table with column names that don't match the model, the config value that must be set before tests run. Document these gotchas in your CLAUDE.md so Claude avoids the same mistakes your team spent days debugging.