direnv

direnv is a skill for Claude Code from aaronsb/claude-code-config. It costs 64 tokens per session (1,117 once invoked), scanned A, original, MIT.

A setup for direnv, a tool that loads environment variables when you enter a project directory, for configuring Claude Code separately in each project.

In plain words
What is it for?
Use it to switch automatically between Claude accounts, Anthropic, AWS Bedrock, or Google Vertex AI settings based on the directory you enter.
Why use it?
It prevents API keys, providers, models, and feature flags from being mixed between projects or changed manually each time.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: mentions subagents; mentions Claude Code.

Good fit Use it to switch automatically between Claude accounts, Anthropic, AWS Bedrock, or Google Vertex AI settings based on the directory you enter.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/aaronsb/claude-code-config/direnv
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add aaronsb/claude-code-config --skill direnv
Clone the repo
git clone --depth 1 https://github.com/aaronsb/claude-code-config

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for direnv

README.md
[![agentmods](https://agentmods.dev/badge/skills/aaronsb/claude-code-config/direnv/github.svg)](https://agentmods.dev/skills/aaronsb/claude-code-config/direnv)
Your own site
<a href="https://agentmods.dev/skills/aaronsb/claude-code-config/direnv"><img src="https://agentmods.dev/badge/skills/aaronsb/claude-code-config/direnv/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for direnv

Your own site · 80×15
<a href="https://agentmods.dev/skills/aaronsb/claude-code-config/direnv"><img src="https://agentmods.dev/badge/skills/aaronsb/claude-code-config/direnv.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 64 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,117 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00064 $0.01117
Opus 5.5 $0.00026 $0.00447
Sonnet 5.5 $0.00013 $0.00223
Haiku 4.5 $0.00006 $0.00112

Measured 3mo ago against content hash fe330844727d, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

direnv scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/direnv/SKILL.md · 142 lines

How it starts

The opening of the file, as written. The whole thing — 142 lines — stays where its author put it; the contents beside it link to each section on GitHub.

direnv — Per-Project Claude Code Environments

Set up .envrc files so Claude Code automatically loads the right API keys, provider, model, and feature flags when you cd into a project directory.

Prerequisites

Check that direnv is installed and hooked into the shell:

which direnv && direnv version
# If missing: suggest installation for their platform

Check the shell hook is active:

grep -q 'direnv' ~/.zshrc ~/.bashrc 2>/dev/null && echo "hook found" || echo "hook missing"

If the hook is missing, add it:

  • zsh: echo 'eval "$(direnv hook zsh)"' >> ~/.zshrc
  • bash: echo 'eval "$(direnv hook bash)"' >> ~/.bashrc

Creating a .envrc

Ask the user which scenario they need, then generate the .envrc:

Direct API Key (personal/hobby)

# .envrc
export ANTHROPIC_API_KEY="sk-ant-..."

AWS Bedrock

# .envrc
export CLAUDE_CODE_USE_BEDROCK=1
export AWS_PROFILE=my-bedrock-profile
export AWS_REGION=us-east-1
# Optional: override model
# export ANTHROPIC_MODEL="us.anthropic.claude-sonnet-4-20250514-v1:0"

Google Vertex AI

# .envrc
export CLAUDE_CODE_USE_VERTEX=1
export CLOUD_ML_REGION=us-east5
export ANTHROPIC_VERTEX_PROJECT_ID=my-project-id

Microsoft Azure Foundry

# .envrc
export CLAUDE_CODE_USE_FOUNDRY=1
export ANTHROPIC_FOUNDRY_BASE_URL="https://my-resource.services.ai.azure.com/api"
export ANTHROPIC_FOUNDRY_API_KEY="..."

Feature Flags / Tuning

# .envrc — append to any of the above
export ANTHROPIC_MODEL="claude-opus-4-6"
export CLAUDE_CODE_MAX_OUTPUT_TOKENS=64000
export CLAUDE_CODE_EFFORT_LEVEL=high
export CLAUDE_CODE_AUTOCOMPACT_PCT_OVERRIDE=99

Security Checklist

After creating the .envrc:

  1. Allow it: direnv allow (required after every edit)
  2. Gitignore it: Verify .envrc is in .gitignore — it may contain secrets
grep -q '.envrc' .gitignore 2>/dev/null || echo '.envrc' >> .gitignore
  1. Never commit API keys — if the project is shared, use direnv allow locally and keep .envrc out of version control.

Read the full file on GitHub · 142 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3mo ago First seen · 142 lines · 64 tokens per session scan A fe330844727d

Subscribe to this mod's changes

direnv is a skill published in the GitHub repository aaronsb/claude-code-config (18 stars, last pushed 7mo ago), licensed MIT. It adds 64 tokens to every session and 1,117 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

direnv compared with skills from other repositories

direnv next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
direnvaaronsb/claude-code-configSkill187mo agoMITA64Claude Code
review-offered-taskdesplega-ai/agent-swarmSkill1.1ktodayMITA33Claude Code
close-issuedesplega-ai/agent-swarmSkill1.1ktodayMITA16Claude Code
session-file-publishinclusionAI/AvernetSkill611todayApache-2.0A69Claude Code, Codex
clawbench-bcninclusionAI/AvernetSkill611todayApache-2.0A66Claude Code, Codex
motion-design-replicationdesplega-ai/agent-swarmSkill1.1ktodayMITA95Claude Code
create-prdesplega-ai/agent-swarmSkill1.1ktodayMITA22Claude Code