direnv

direnv is a skill for Claude Code, Codex 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 CodeCodex

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.

agentmods
npx agentmods add skills/aaronsb/claude-code-config/direnv
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, Codex.

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.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.svg" alt="Measured on agentmods" 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. Scan, not verified.
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 $0.00064 $0.01117
Opus 5 $0.00032 $0.00558
Sonnet 5 $0.00013 $0.00223
Haiku 4.5 $0.00006 $0.00112

Measured 4d ago against content hash fe330844727d, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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 4d 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. 4d 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 5mo ago), licensed MIT. It adds 64 tokens to every session and 1,117 once invoked, about $0.0003 per session on Opus 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

Other skills, from other repositories

achieving-cmmc-level-2-compliance

Prepare a defense-contractor environment for CMMC Level 2 certification: scope CUI and FCI, implement the 110 NIST SP 800-171 Rev 2 security requirements across 14 families, compute the SPRS score with the DoD Assessment Methodology, manage a compliant POA&M, and ready the organization for a C3PAO assessment. Use when…

mukul975/Anthropic-Cybersecurity-Skills · 255 tokens

task-planning-arch

计算任务 gap 并产出下一步可执行子任务 List[TaskSpec];gap 已闭返回空数组。对齐 arch 场景(架构师名册/技术栈概览/双视角分析)确定式分解——按根目标交付物集合 + donechildren 查表(参照 task-planning storage 特例,非自由 LLM 分解)。.

inclusionAI/Avernet · 89 tokens

task-search

在框架预查的候选 bot 集里决出执行者(who)与协作方式(how),返回 4 态 SearchResult(HITSINGLE/HITGROUP/HITMULTIBOTS/MISS)。对齐案例剧本确定式映射。.

inclusionAI/Avernet · 59 tokens

escalation-governance

Assess whether to escalate models. Use when evaluating reasoning depth.

athola/claude-night-market · 19 tokens

agt-policy-authoring

Create and validate a minimal AGT Copilot CLI policy tailored to the repository being inspected.

microsoft/agent-governance-toolkit · 23 tokens

workflow

工作流引擎核心命令。管理工作流生命周期(创建、确认、拒绝、跳过、重试、提交、恢复),以及在人工节点等待时通过 workflowchoice 工具解读用户自然语言意图。.

inclusionAI/Avernet · 52 tokens