varlock – Coding skill for AI agents
Secure-by-default environment variable management for Claude Code sessions.
Install the varlock skill with one command
Pick the tool you use, copy the command and paste it in your terminal. The skill lands in that tool's skills folder and is ready in your next session.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/varlock-22820.tgz | tar xz -C ~/.claude/skills
Call it in Claude Code: /varlock – then describe the task you want done.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/varlock-22820.tgz | tar xz -C ~/.codex/skills
Call it in Codex: $varlock – then describe the task you want done.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/varlock-22820.tgz | tar xz -C ~/.hermes/skills
Call it in Hermes Agent: /varlock – then describe the task you want done.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/varlock-22820.tgz | tar xz -C ~/.deepcode/skills
Call it in DeepSeek: /varlock – then describe the task you want done.
SKILL.md content
Varlock Security Skill
Secure-by-default environment variable management for Claude Code sessions.
> Repository: https://github.com/dmno-dev/varlock
> Documentation: https://varlock.dev
When to Use
- You need to work with environment variables or secrets in a Claude Code session without exposing their values.
- The task involves validating, loading, or auditing secrets while keeping them out of logs, diffs, and assistant context.
- You want a secure-by-default workflow built around Varlock instead of direct
.envinspection.
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 workflow reduces exposure only when sensitivity annotations and the invoked programs are correct; it cannot guarantee that child processes, errors or rendered application output never disclose secrets.
---
CRITICAL: Security Rules for Claude
Rule 1: Never Echo Secrets
# ❌ NEVER DO THIS - exposes secret to Claude's context
echo $CLERK_SECRET_KEY
cat .env | grep SECRET
printenv | grep API
# ✅ DO THIS - validates without exposing
varlock load --quiet && echo "✓ Secrets validated"Rule 2: Never Read .env Directly
# ❌ NEVER DO THIS - exposes all secrets
cat .env
less .env
Read tool on .env file
# ✅ DO THIS - read schema (safe) not values
cat .env.schema
varlock load # Shows masked valuesRule 3: Use Varlock for Validation
# ❌ NEVER DO THIS - exposes secret in error
test -n "$API_KEY" && echo "Key: $API_KEY"
# ✅ DO THIS - Varlock validates and masks
varlock load
# Output shows: API_KEY 🔐sensitive └ ▒▒▒▒▒Rule 4: Never Include Secrets in Commands
# ❌ NEVER DO THIS - secret in command history
curl -H "Authorization: Bearer sk_live_xxx" https://api.example.com
# ✅ DO THIS - use environment variable
# Expanding a secret into curl arguments can expose it to process inspection.
# Prefer an application/HTTP client that reads credentials internally from the environment.
# Or better: varlock run -- curl ...---
Quick Start
Installation
# Install Varlock CLI
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT
curl -sSfL https://varlock.dev/install.sh -o "$tmpdir/varlock-install.sh"
cat "$tmpdir/varlock-install.sh" # review the full installer before executing
sh "$tmpdir/varlock-install.sh" --force-no-brew
# Add to PATH (add to ~/.zshrc or ~/.bashrc)
export PATH="$HOME/.varlock/bin:$PATH"
# Verify
varlock --versionInitialize Project
# Create .env.schema from existing .env
varlock init
# Or create manually
touch .env.schema---
Schema File: .env.schema
The schema defines types, validation, and sensitivity for each variable.
Basic Structure
# Global defaults
# @defaultSensitive=true @defaultRequired=infer
# Application
# @type=enum(development,staging,production) @sensitive=false
NODE_ENV=development
# @type=port @sensitive=false
PORT=3000
# Database - SENSITIVE
# @type=url @required
DATABASE_URL=
# @type=string @required @sensitive
DATABASE_PASSWORD=
# API Keys - SENSITIVE
# @type=string(startsWith=sk_) @required @sensitive
STRIPE_SECRET_KEY=
# @type=string(startsWith=pk_) @sensitive=false
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) |
---
A schema may contain default values or executable expressions and is not automatically safe to print. Inspect metadata through a redacting workflow before exposing file contents. varlock load does not export variables into the parent shell: use varlock run -- npm run build when the build needs them. Validate actual CLI syntax against the pinned version; the rotation helper and external skill paths below are examples, not bundled files. Installer output in a Docker build is not a human review gate: pin and review the installer before the build.
Safe Commands for Claude
Validating Environment
# Check all variables (safe - masks sensitive values)
varlock load
# Quiet mode (no output on success)
varlock load --quiet
# Check specific environment
varlock load --env=productionRunning Commands with Secrets
# Inject validated env into command
varlock run -- npm start
varlock run -- node script.js
varlock run -- pytest
# Child commands receive secrets and may print them; audit their logging and disable tracingChecking Schema (Safe)
# Schema is safe to read - contains no values
cat .env.schema
# List expected variables
grep "^[A-Z]" .env.schema---
Common Patterns
Pattern 1: Validate Before Operations
# Always validate environment first
varlock load --quiet || {
echo "❌ Environment validation failed"
exit 1
}
# Then proceed with operation
npm run buildPattern 2: Safe Secret Rotation
# 1. Update secret in external source (1Password, AWS, etc.)
# 2. Update .env file manually (don't use Claude for this)
# 3. Validate new value works
varlock load
# 4. If using GitHub Secrets, sync (values not shown)
./scripts/update-github-secrets.shPattern 3: CI/CD Integration
# GitHub Actions - secrets from GitHub Secrets
- name: Validate environment
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
API_KEY: ${{ secrets.API_KEY }}
run: varlock load --quietPattern 4: Docker Integration
# Install Varlock in container
RUN tmpdir="$(mktemp -d)" \
&& curl -sSfL https://varlock.dev/install.sh -o "$tmpdir/varlock-install.sh" \
&& cat "$tmpdir/varlock-install.sh" \
&& sh "$tmpdir/varlock-install.sh" --force-no-brew \
&& rm -rf "$tmpdir" \
&& 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"
# ✅ Safe approach
varlock load 2>&1 | grep "API_KEY"
# Shows: ✅ API_KEY 🔐sensitive └ ▒▒▒▒▒
# ❌ Never do
echo $API_KEYWhen User Asks to "Debug authentication"
# ✅ Safe approach - check presence and format
varlock load # Validates types and required fields
# Check if key has correct prefix (without showing value)
varlock load 2>&1 | grep -E "(CLERK|AUTH)"
# ❌ Never do
printenv | grep KEYWhen 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
# In .env.schema
# @type=string @sensitive
API_KEY=exec('op read "op://vault/item/field"')AWS Secrets Manager
# In .env.schema
# @type=string @sensitive
DB_PASSWORD=exec('aws secretsmanager get-secret-value --secret-id prod/db --query SecretString --output text')Environment-Specific Values
# In .env.schema
# @type=url
API_URL=env('API_URL_${NODE_ENV}', 'http://localhost:3000')---
Troubleshooting
"varlock: command not found"
# Check installation
ls ~/.varlock/bin/varlock
# Add to PATH
export PATH="$HOME/.varlock/bin:$PATH"
# Or use full path
~/.varlock/bin/varlock load"Schema validation failed"
# Check which variables are missing/invalid
varlock load # Shows detailed errors
# Common fixes:
# - Add missing required variables to .env
# - Fix type mismatches (port must be number)
# - Check string prefixes match schema"Sensitive value exposed in logs"
# 1. Rotate the exposed secret immediately
# 2. Check .env.schema has @sensitive annotation
# 3. Ensure using varlock commands, not echo/cat
# Add missing sensitivity:
# Before: API_KEY=… (full content is in the download package)
Related skills
- varlock-claude-skill – Secure environment variable management with explicit checks to reduce secret exposure in…
- vercel-ai-sdk-expert – Expert in the Vercel AI SDK. Covers Core API (generateText, streamText), UI hooks…
- vercel-cli-with-tokens – Deploy and manage projects on Vercel using token-based authentication. Use when working…
- vercel-react-view-transitions – Guide React and Next.js view transitions, shared element animations, route transitions…
- vexor – Vector-powered CLI for semantic file search with a Claude/Codex skill
- vexor-cli – Semantic file discovery via `vexor`. Use whenever locating where something is…
- vibe-code-auditor – Audit rapidly generated or AI-produced code for structural flaws, fragility, and…
- vibe-code-cleanup – Safe production cleanup and hardening for vibe-coded fullstack apps (Next.js, React…