| name | varlock |
| description | Secure environment variable management with Varlock. Use when handling secrets, API keys, credentials, or any sensitive configuration. Ensures secrets are never exposed in terminals, logs, traces, or Claude's context. Trigger phrases include "environment variables", "secrets", ".env", "API key", "credentials", "sensitive", "Varlock". |
| version | 1.0.0 |
Varlock Security Skill
Secure-by-default environment variable management for Claude Code sessions.
Repository: https://github.com/dmno-dev/varlock
Documentation: https://varlock.dev
Core Principle: Secrets Never Exposed
When working with Claude, secrets must NEVER appear in:
- Terminal output
- Claude's input/output context
- Log files or traces
- Git commits or diffs
- Error messages
This skill ensures all sensitive data is properly protected.
CRITICAL: Security Rules for Claude
Rule 1: Never Echo Secrets
echo $CLERK_SECRET_KEY
cat .env | grep SECRET
printenv | grep API
varlock load --quiet && echo "✓ Secrets validated"
Rule 2: Never Read .env Directly
cat .env
less .env
Read tool on .env file
cat .env.schema
varlock load
Rule 3: Use Varlock for Validation
test -n "$API_KEY" && echo "Key: $API_KEY"
varlock load
Rule 4: Never Include Secrets in Commands
curl -H "Authorization: Bearer sk_live_xxx" https://api.example.com
curl -H "Authorization: Bearer $API_KEY" https://api.example.com
Quick Start
Installation
curl -sSfL https://varlock.dev/install.sh | sh -s -- --force-no-brew
export PATH="$HOME/.varlock/bin:$PATH"
varlock --version
Initialize Project
varlock init
touch .env.schema
Schema File: .env.schema
The schema defines types, validation, and sensitivity for each variable.
Basic Structure
NODE_ENV=development
PORT=3000
DATABASE_URL=
DATABASE_PASSWORD=
STRIPE_SECRET_KEY=
STRIPE_PUBLISHABLE_KEY=
Security Annotations
| Annotation | Effect | Use For |
|---|
@sensitive | Redacted in all output | API keys, passwords, tokens |
@sensitive=false | Shown in logs | Public keys, non-secret config |
@defaultSensitive=true | All vars sensitive by default | High-security projects |
Type Annotations
| Type | Validates | Example |
|---|
string | Any string | @type=string |
string(startsWith=X) | Prefix validation | @type=string(startsWith=sk_) |
string(contains=X) | Substring validation | @type=string(contains=+clerk_test) |
url | Valid URL | @type=url |
port | 1-65535 | @type=port |
boolean | true/false | @type=boolean |
enum(a,b,c) | One of values | @type=enum(dev,prod) |
Safe Commands for Claude
Validating Environment
varlock load
varlock load --quiet
varlock load --env=production
Running Commands with Secrets
varlock run -- npm start
varlock run -- node script.js
varlock run -- pytest
Checking Schema (Safe)
cat .env.schema
grep "^[A-Z]" .env.schema
Common Patterns
Pattern 1: Validate Before Operations
varlock load --quiet || {
echo "❌ Environment validation failed"
exit 1
}
npm run build
Pattern 2: Safe Secret Rotation
varlock load
./scripts/update-github-secrets.sh
Pattern 3: CI/CD Integration
- name: Validate environment
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
API_KEY: ${{ secrets.API_KEY }}
run: varlock load --quiet
Pattern 4: Docker Integration
# Install Varlock in container
RUN curl -sSfL https://varlock.dev/install.sh | sh -s -- --force-no-brew \
&& ln -s /root/.varlock/bin/varlock /usr/local/bin/varlock
# Validate at container start
CMD ["varlock", "run", "--", "npm", "start"]
Handling Secret-Related Tasks
When User Asks to "Check if API key is set"
varlock load 2>&1 | grep "API_KEY"
echo $API_KEY
When User Asks to "Debug authentication"
varlock load
varlock load 2>&1 | grep -E "(CLERK|AUTH)"
printenv | grep KEY
When User Asks to "Update a secret"
Claude should respond:
"I cannot directly modify secrets for security reasons. Please:
1. Update the value in your .env file manually
2. Or update in your secrets manager (1Password, AWS, etc.)
3. Then run `varlock load` to validate
I can help you update the .env.schema if you need to add new variables."
When User Asks to "Show me the .env file"
Claude should respond:
"I won't read .env files directly as they contain secrets. Instead:
- Run `varlock load` to see masked values
- Run `cat .env.schema` to see the schema (safe)
- I can help you modify .env.schema if needed"
External Secret Sources
1Password Integration
API_KEY=exec('op read "op://vault/item/field"')
AWS Secrets Manager
DB_PASSWORD=exec('aws secretsmanager get-secret-value --secret-id prod/db')
Environment-Specific Values
API_URL=env('API_URL_${NODE_ENV}', 'http://localhost:3000')
Troubleshooting
"varlock: command not found"
ls ~/.varlock/bin/varlock
export PATH="$HOME/.varlock/bin:$PATH"
~/.varlock/bin/varlock load
"Schema validation failed"
varlock load
"Sensitive value exposed in logs"
npm Scripts
Add these to your package.json:
{
"scripts": {
"env:validate": "varlock load",
"env:check": "varlock load --quiet || echo 'Environment validation failed'",
"prestart": "varlock load --quiet",
"start": "varlock run -- node server.js"
}
}
Security Checklist for New Projects
Quick Reference Card
| Task | Safe Command |
|---|
| Validate all env vars | varlock load |
| Quiet validation | varlock load --quiet |
| Run with env | varlock run -- <cmd> |
| View schema | cat .env.schema |
| Check specific var | varlock load | grep VAR_NAME |
| Never Do | Why |
|---|
cat .env | Exposes all secrets |
echo $SECRET | Exposes to Claude context |
printenv | grep | Exposes matching secrets |
| Read .env with tools | Secrets in Claude's context |
| Hardcode in commands | In shell history |
Integration with Other Skills
Clerk Skill
- Test user passwords are
@sensitive
- Test emails are
@sensitive=false (contain +clerk_test, not secret)
- See:
~/.claude/skills/clerk/SKILL.md
Docker Skill
- Mount
.env file, never copy secrets to image
- Use
varlock run as entrypoint
- See:
~/.claude/skills/docker/SKILL.md
Last updated: December 22, 2025
Secure-by-default environment management for Claude Code