agentleFS
scott2bscott2b/claude-skills/env-manager/SKILL.md

env-manager

Skill1 starsChanged 13 months agoApache-2.0View on GitHub

PROACTIVELY use when environment variables are missing, scripts fail with "environment" or "variable not set" errors, or tasks require configuration (testing, API calls, deployment). Intelligently detects missing variables, finds .env files in project, analyzes formats (shell/simple/fish), and provides exact shell-specific commands to load configuration. Supports bash, zsh, fish. Use automatically at task start for any work requiring environment setup.

  • Reads credentials

3 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Respect user's shell choice: - don't assume bash

    line 140
  2. Distinctive:

    Don't modify environment files: - only read and suggest

    line 141

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Environment Manager

This skill provides intelligent environment variable management for Claude Code. It handles detection of missing variables, parsing of various .env file formats, and provides appropriate commands for different shells.

When to Use This Skill

AUTOMATICALLY use this skill when:

  • User asks to test anything (web pages, APIs, etc.) - testing ALWAYS needs environment
  • User asks to run tests, check functionality, or verify pages work
  • Starting tasks that need configuration (deployment, API integration, database work)
  • Any script or command fails with environment-related errors
  • You detect phrases like "missing", "not set", "required", "environment" in error messages
  • User mentions specific pages to test (e.g., "test the billing page", "check the login form")
  • Beginning work on web applications, APIs, or services

CRITICAL: If the user says "test the X page" or similar, invoke this skill FIRST before writing any test code.

DO NOT wait for the user to ask - proactively invoke this skill when environment issues are likely. DO NOT check for .env files or write environment loading code - that's what THIS skill does.

Key Features

  • Shell Detection: Automatically detects user's shell (bash, zsh, fish)
  • Format Recognition: Understands multiple .env file formats:
    • Shell format: export VAR=value
    • Simple format: VAR=value
    • Commented files with # comments
  • Smart Loading: Recommends the right tool for the job:
    • source for shell-formatted files
    • export for inline variable setting
    • dotenv command for simple format files (if available)
  • Project Awareness: Searches project directory for .env files
  • Frictionless UX: Provides copy-paste commands for users

Helper Scripts

  • scripts/check_env.py - Check if required environment variables are set
  • scripts/detect_env_files.py - Find and analyze .env files in project
  • scripts/load_env.sh - Shell script to load environment variables

Usage Patterns

Pattern 1: Check for Required Variables

import subprocess
import json

result = subprocess.run(
    ['python', '~/.claude/skills/env-manager/scripts/check_env.py',
     '--required', 'VAR1,VAR2,VAR3'],
    capture_output=True,
    text=True
)
info = json.loads(result.stdout)

if not info['all_present']:
    # Handle missing variables
    print(f"Missing: {info['missing']}")

Pattern 2: Find and Suggest .env Files

result = subprocess.run(
    ['python', '~/.claude/skills/env-manager/scripts/detect_env_files.py'],
    capture_output=True,
    text=True
)
files = json.loads(result.stdout)

for file_info in files:
    print(f"Found: {file_info['path']}")
    print(f"Format: {file_info['format']}")
    print(f"Load command: {file_info['load_command']}")

Environment File Formats

Shell Format (Recommended)

# .env file
export DATABASE_URL=postgres://localhost/db
export API_KEY=secret123
export DEBUG=true

Load with: source .env

Simple Format

# .env file
DATABASE_URL=postgres://localhost/db
API_KEY=secret123
DEBUG=true

Load with: dotenv command or manually set with export

Fish Shell Format

# .env.fish file
set -x DATABASE_URL postgres://localhost/db
set -x API_KEY secret123
set -x DEBUG true

Load with: source .env.fish

Integration with Other Skills

Other skills should delegate environment management to this skill:

# In another skill's script
from pathlib import Path
import subprocess
import sys

# Check for required environment variables
check_cmd = [
    'python',
    str(Path.home() / '.claude/skills/env-manager/scripts/check_env.py'),
    '--required', 'VAR1,VAR2',
    '--role', 'user'
]

result = subprocess.run(check_cmd, capture_output=True, text=True)
if result.returncode != 0:
    print("Environment not configured. Run env-manager skill first.")
    sys.exit(1)

Best Practices

  1. Always check environment before running tasks that require specific variables
  2. Provide clear feedback about which variables are missing
  3. Suggest concrete commands for users to run
  4. Respect user's shell choice - don't assume bash
  5. Don't modify environment files - only read and suggest

Shell Compatibility

ShellDetection.env LoadingVariable Setting
bash✓sourceexport VAR=val
zsh✓sourceexport VAR=val
fish✓sourceset -x VAR val
sh✓.export VAR=val

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.