Skip to content

feat: Add direnv support for automatic API key management#1

Open
jcorbettfrank wants to merge 1 commit intorichawo:masterfrom
jcorbettfrank:feat/add-direnv-support
Open

feat: Add direnv support for automatic API key management#1
jcorbettfrank wants to merge 1 commit intorichawo:masterfrom
jcorbettfrank:feat/add-direnv-support

Conversation

@jcorbettfrank
Copy link
Copy Markdown

@jcorbettfrank jcorbettfrank commented Nov 12, 2025

Summary

This PR adds direnv support for automatic, project-scoped API key management.

Changes

  • .envrc - Automatically creates .env from template on first direnv allow
  • .env.example - Template with all environment variables (GEMINI_API_KEY, OPENAI_API_KEY, BLENDER_PATH)
  • README.md - Updated with direnv as the recommended setup method, with shell RC file as alternative

Benefits

  • Zero manual setup - .envrc auto-creates .env from template
  • Project-scoped - API keys only loaded when in this directory
  • Auto-loading - Variables export/unexport when entering/leaving repo
  • Safer - .env is gitignored, prevents accidental key commits
  • Better DX - Standard pattern used across many projects

User Experience

Before:

# Manual setup
export GEMINI_API_KEY="your-key-here"  # Goes in ~/.bashrc, global scope

After:

# Automatic setup
<one time> direnv allow  # Creates .env from template
# Edit .env with actual keys
(blocksmith) jordan@jordan-desktop:~/repos$ cd blocksmith/
direnv: loading ~/repos/blocksmith/.envrc
direnv: export +GEMINI_API_KEY
(blocksmith) jordan@jordan-desktop:~/repos/blocksmith$ echo $GEMINI_API_KEY
AIz...

Testing

  • Tested that .envrc successfully creates .env from .env.example
  • Verified .env is already in .gitignore
  • Confirmed README instructions are clear

🤖 Generated with Claude Code

jcorbettfrank added a commit to jcorbettfrank/blocksmith that referenced this pull request Nov 12, 2025
Move "Environment Setup" section to the top of DEVELOPMENT.md so
developers configure their environment BEFORE running Quick Start
commands. This prevents the confusing flow where users would follow
export instructions before learning about the recommended direnv approach.

**Changes:**
- Move "Environment Setup (Recommended: direnv)" to position richawo#1
- Update Quick Start sections to reference env setup instead of inline exports
- Add note to BLENDER_PATH section about using direnv
- Add "Alternative (manual export)" inline for quick reference

**New flow:**
1. Environment Setup (direnv recommended, manual export alternative)
2. Quick Start (uv) - references env setup above
3. Alternative (pip/venv) - references env setup above
4. Install Blender - mentions direnv for BLENDER_PATH
5. Rest unchanged

This creates a logical progression: setup → install → test

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@jcorbettfrank jcorbettfrank marked this pull request as ready for review November 12, 2025 00:50
Add direnv configuration with automatic .env setup:
- .envrc automatically creates .env from template on first use
- .env.example provides template with all environment variables
- Update README with direnv as recommended setup method
- Keep shell RC file method as alternative option

Benefits:
- Project-scoped environment variables
- Auto-loads when entering repo directory
- Zero manual file copying required
- Prevents accidental API key commits

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

comment out .env.example values

docs: Improve direnv documentation and add error handling

Comprehensive documentation improvements for direnv support:

**Error Handling:**
- Add safety check to .envrc for missing .env.example
- Provides helpful error message if template is missing
- Prevents silent failures during setup

**DEVELOPMENT.md:**
- Add dedicated "Environment Setup" section for direnv
- Include installation and setup instructions
- Update troubleshooting section with direnv-specific guidance
- Maintain manual export as alternative approach

**examples/README.md:**
- Add direnv as recommended option for API key setup
- Reference main README for detailed setup
- Keep manual export as Option 2

**tests/integration/README.md:**
- Clarify that direnv users don't need `source .env`
- Add note explaining auto-loading behavior
- Prevent confusion about when to use `source .env`

All documentation now consistently promotes direnv as the
recommended approach while maintaining compatibility with
manual environment variable export.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

docs: Restructure DEVELOPMENT.md for better flow

Move "Environment Setup" section to the top of DEVELOPMENT.md so
developers configure their environment BEFORE running Quick Start
commands. This prevents the confusing flow where users would follow
export instructions before learning about the recommended direnv approach.

**Changes:**
- Move "Environment Setup (Recommended: direnv)" to position richawo#1
- Update Quick Start sections to reference env setup instead of inline exports
- Add note to BLENDER_PATH section about using direnv
- Add "Alternative (manual export)" inline for quick reference

**New flow:**
1. Environment Setup (direnv recommended, manual export alternative)
2. Quick Start (uv) - references env setup above
3. Alternative (pip/venv) - references env setup above
4. Install Blender - mentions direnv for BLENDER_PATH
5. Rest unchanged

This creates a logical progression: setup → install → test

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@jcorbettfrank jcorbettfrank force-pushed the feat/add-direnv-support branch from 4454fa6 to 95a4c81 Compare November 12, 2025 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant