跳到正文
Skillpedia
安全48k · #6094

varlock

它能做什么

Varlock 是一款帮助你在编程项目中管理敏感信息(比如密码和 API 密钥)的工具。它能确保这些信息不会在日志或命令历史记录中意外显示,从而让你的代码更安全。

适用场景

  • ✓当你需要在项目中使用密码或 API 密钥时。
  • ✓当你要与他人分享代码或命令历史记录时。
  • ✓当你想确保机密信息不会在错误日志中泄露时。

技能链接

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/varlock/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/varlock/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“在不泄露 API 密钥的前提下,我该如何检查它是否设置正确?”

每周 5 个新技能,1 分钟读完。

工作原理

Varlock 的工作方式是为敏感信息的处理设定规则。它可以验证必要的信息是否已经存在,并在任何输出中对实际的值进行遮蔽,防止它们被看到。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

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 .env inspection.

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

# ❌ 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 values

Rule 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
curl -H "Authorization: Bearer $API_KEY" https://api.example.com
# 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 --version

Initialize 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)

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=production

Running Commands with Secrets

# Inject validated env into command
varlock run -- npm start
varlock run -- node script.js
varlock run -- pytest

# Secrets are available to the command but never printed

Checking Schema (Safe)

# Schema is safe to read - contains no values
cat .env.schema


…
常见问题

什么是“环境变量”?

你可以把它们想象成程序的“便利贴”,用来存放密码或 API 密钥等信息,而不必直接写在代码里。Varlock 可以帮你安全地管理这些“便利贴”。

为什么不能展示我的密码或 API 密钥?

展示这些信息可能让恶意用户窃取你账号或数据的访问权限。这就像把家门钥匙放在显眼的地方,任何人都能拿到。

什么是 `.env.schema` 文件?

它是一个描述项目需要哪些敏感信息,以及这些信息应该是什么样子(例如是密码还是 URL)的文件。它不包含实际的值,只包含规则,因此可以放心查看。

详情

作者的原始描述

Secure-by-default environment variable management for Claude Code sessions.

repo: sickn33/agentic-awesome-skills

热度

GitHub 星标
48k
排名
#6094
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能