audit-env-variables
БесплатноБез исполняемых скриптовНе проверенAnalyze environment variables in JavaScript/TypeScript projects. Identifies unused variables, infers permission scopes, detects specific services (Stripe…
от qdhenry★ 1 360 звёзд на GitHubОб этом скилле
- Discovery - Find all env files and code references
- Usage Analysis - Identify which variables are used vs unused
- Service Detection - Recognize services (Stripe, AWS, Supabase, etc.) and their permission implications
- Code Path Mapping - Document where each variable is used in the codebase
- Report Generation - Output a structured markdown document
- Cleanup (optional) - Safely remove unused variables with user confirmation
- Regression Prevention - Validate no regressions via build/test validation with automatic rollback
With cleanup (--cleanup flag):
6. Check for dynamic access patterns that might hide usage
7. Present unused variables and get user confirmation
8. Create backups, remove confirmed variables
9. Run build/tests to detect regressions
10. Auto-rollback if regressions detected
Find all env-related files:
find . -maxdepth 2 -name ".env*" -o -name "env.d.ts" | grep -v node_modules
Common files:
.env- Local development.env.local- Local overrides.env.development/.env.production- Environment-specific.env.example- Template for required variables
Step 2: Extract Declared Variables
Parse each env file for variable declarations:
Grep pattern: ^[A-Z][A-Z0-9_]+=
Build a list of all declared variables with their source file.
Step 3: Find Code References
Search for environment variable usage patterns:
Direct access:
process.env.VARIABLE_NAME
import.meta.env.VARIABLE_NAME
process.env["VARIABLE_NAME"]
Destructured patterns:
const { API_KEY, DATABASE_URL } = process.env
Framework-specific:
// Next.js public vars
NEXT_PUBLIC_*
// Vite
VITE_*
Use Grep tool with patterns:
process\.env\.([A-Z][A-Z0-9_]+)
import\.meta\.env\.([A-Z][A-Z0-9_]+)
Step 4: Cross-Reference Usage
For each declared variable:
- Used: Found in code references
- Unused: Declared but no code references found
- Undeclared: Referenced in code but not in any env file
Flag potential issues:
- Unused variables (cleanup candidates)
- Undeclared variables (missing from .env.example)
- Variables only in .env but not .env.example (documentation gap)
Step 5: Detect Services and Infer Permissions
Match variable names against known service patterns. See references/service-patterns.md for the complete list.
Categories:
- Database - Connection strings, credentials
- Authentication - JWT secrets, OAuth credentials
- Payment - Stripe, payment processor keys
- Cloud Services - AWS, GCP, Azure credentials
- Third-party APIs - Various service integrations
- Feature Flags - Toggle configurations
- Application Config - URLs, ports, modes
Permission levels:
- Critical - Full account access, billing, admin operations
- High - Read/write access to user data
- Medium - Limited API access, specific operations
- Low - Public keys, non-sensitive configuration
Step 6: Map Code Paths
For each used variable, document:
- File path where it's used
- Function/component context
- Purpose (inferred from surrounding code)
Example:
STRIPE_SECRET_KEY
├── src/lib/stripe.ts:15 - Stripe client initialization
├── src/api/webhooks/stripe.ts:8 - Webhook signature verification
└── src/api/checkout/route.ts:23 - Create checkout session
Step 7: Generate Report
Use the template in templates/env-audit-report.md to generate the final document.
Output to: ENV_AUDIT.md in project root (or user-specified location)
Step 8: Cleanup Unused Variables (Optional)
Trigger: User passes --cleanup flag or explicitly requests cleanup after reviewing the audit report.
8.1 Present Cleanup Candidates
Display unused variables with context:
UNUSED VARIABLES (candidates for removal):
1. OLD_API_KEY (.env, .env.local)
- Last modified: [file date]
- No code references found
2. DEPRECATED_SERVICE_URL (.env)
- Last modified: [file date]
- No code references found
8.2 Dynamic Access Check
Before confirming removal, search for dynamic access patterns that grep may have missed:
// These patterns indicate variables might be used dynamically:
process.env[variableName] // Dynamic key access
process.env[`${prefix}_KEY`] // Template literal access
Object.keys(process.env) // Iteration over all env vars
{ ...process.env } // Spread operator
Use Grep with patterns:
process\
Установить audit-env-variables в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadGrepGlobBashWriteEditAskUserQuestionВложенные файлы
FAQ
Что делает скилл audit-env-variables?
Analyze environment variables in JavaScript/TypeScript projects. Identifies unused variables, infers permission scopes, detects specific services (Stripe, AWS, Supabase), and documents code paths. Includes optional cleanup of unused variables with regression detection. Use when auditing .env files, reviewing security, or documenting project configuration.
Как установить скилл audit-env-variables?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл audit-env-variables запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic