Injecting Nix Dev Environments into Claude Code

Claude Code runs each Bash command in its own process. Environment variables don’t persist between them — an export in one invocation is gone by the next. If your project uses a Nix devShell, this is a problem. Running nix develop inside a Claude session is messy, and running outside it requires restarting the devShell and Claude for any new dependency added to flake.nix. CLAUDE_ENV_FILE Claude Code has a CLAUDE_ENV_FILE environment variable. Set it to a shell script path before launching, and Claude will source that script before every Bash command it runs. ...