Vercel Environment Sync
Synchronize environment variables between local development and Vercel deployments, ensuring consistency across all environments. Detects changes to .env files and provides options to sync with Vercel, validates environment variable format, and ensures required variables are present. Setup: Export 'export VERCEL_TOKEN=your_token' (get from vercel.com/account/tokens).
$ npx claude-code-templates@latest --hook="automation/vercel-environment-sync" --yesRequires Claude Code. The command adds this hook to your project's .claudedirectory â nothing runs on ToolZip's servers.
What's inside this hook
Component source
{
"description": "Synchronize environment variables between local development and Vercel deployments, ensuring consistency across all environments. Detects changes to .env files and provides options to sync with Vercel, validates environment variable format, and ensures required variables are present. Setup: Export 'export VERCEL_TOKEN=your_token' (get from vercel.com/account/tokens).",
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit|MultiEdit",
"hooks": [
{
"type": "command",
"command": "bash -c 'input=$(cat); FILE_PATH=$(echo \"$input\" | jq -r \".tool_input.file_path // empty\"); SUCCESS=$(echo \"$input\" | jq -r \".tool_response.success // false\"); if [ \"$SUCCESS\" = \"true\" ] && [[ \"$FILE_PATH\" =~ \\.env ]]; then echo \"đ Environment file change detected: $FILE_PATH\"; if [ -n \"$VERCEL_TOKEN\" ]; then echo \"đ Environment Sync available - Vercel token configured\"; ENV_TYPE=\"development\"; if [[ \"$FILE_PATH\" =~ \\.env\\.production ]]; then ENV_TYPE=\"production\"; elif [[ \"$FILE_PATH\" =~ \\.env\\.preview ]] || [[ \"$FILE_PATH\" =~ \\.env\\.staging ]]; then ENV_TYPE=\"preview\"; fi; echo \"đ Environment type detected: $ENV_TYPE\"; if [ -f \"$FILE_PATH\" ]; then echo \"đ Validating environment variables in $FILE_PATH...\"; VALIDATION_ISSUES=0; while IFS= read -r line; do if [[ \"$line\" =~ ^[A-Z_][A-Z0-9_]= ]] && [[ ! \"$line\" =~ ^# ]]; then VAR_NAME=$(echo \"$line\" | cut -d\"=\" -f1); VAR_VALUE=$(echo \"$line\" | cut -d\"=\" -f2-); if [[ \"$VAR_VALUE\" =~ ^[\\\"\\'].[\\\"\\']$ ]]; then echo \"đĄ $VAR_NAME: Quoted value detected (quotes will be included in value)\"; fi; if [[ \"$VAR_NAME\" =~ (SECRET|PRIVATE|KEY|TOKEN) ]] && [ ${#VAR_VALUE} -lt 16 ]; then echo \"â ī¸ $VAR_NAME: Secret appears to be too short (${#VAR_VALUE} chars)\" >&2; ((VALIDATION_ISSUES++)); fi; if [[ \"$VAR_VALUE\" == \"your-\" ]] || [[ \"$VAR_VALUE\" == \"change-me\" ]] || [[ \"$VAR_VALUE\" == \"replace-\" ]]; then echo \"â $VAR_NAME: Placeholder value detected\" >&2; ((VALIDATION_ISSUES++)); fi; elif [[ \"$line\" =~ ^[A-Za-z] ]] && [[ ! \"$line\" =~ ^# ]] && [ -n \"$line\" ]; then echo \"â ī¸ Invalid environment variable format: $line\" >&2; ((VALIDATION_ISSUES++)); fi; done < \"$FILE_PATH\"; if [ $VALIDATION_ISSUES -eq 0 ]; then echo \"â Environment validation passed\"; VAR_COUNT=$(grep -c \"^[A-Z_][A-Z0-9_]=\" \"$FILE_PATH\" 2>/dev/null || echo \"0\"); echo \"đ Found $VAR_COUNT environment variables\"; echo \"đĄ Sync options:\"; echo \" âĸ Manual sync: vercel env pull .env.local\"; echo \" âĸ Push to Vercel: vercel env add [name] [environment]\"; echo \" âĸ Bulk sync: Use vercel-env-sync command if available\"; echo \"đ Security reminder: Never commit secrets to version control\"; else echo \"â Found $VALIDATION_ISSUES validation issues\" >&2; echo \"đ¨ Environment sync blocked due to validation errors\" >&2; exit 2; fi; else echo \"â File $FILE_PATH not found\"; fi; else echo \"â ī¸ VERCEL_TOKEN not configured. Set environment variable to enable sync features.\"; echo \"đĄ Get token from: https://vercel.com/account/tokens\"; echo \"đĄ Export with: export VERCEL_TOKEN=your_token\"; fi; else echo \"âšī¸ Environment sync skipped (not an .env file or failed operation)\"; fi'",
"timeout": 30
}
]
}
],
"SessionStart": [
{
"matcher": "startup|resume",
"hooks": [
{
"type": "command",
"command": "bash -c 'echo \"đ Environment Sync Status Check...\"; if [ -n \"$VERCEL_TOKEN\" ]; then echo \"â Vercel token configured\"; if command -v vercel >/dev/null 2>&1; then echo \"â Vercel CLI available\"; PROJECT_STATUS=$(vercel project ls 2>/dev/null | head -1); if [[ \"$PROJECT_STATUS\" =~ \"No projects found\" ]]; then echo \"â ī¸ No Vercel project linked to current directory\"; echo \"đĄ Run: vercel link\"; else echo \"â Vercel project linked\"; fi; else echo \"â ī¸ Vercel CLI not installed\"; echo \"đĄ Install with: npm i -g vercel\"; fi; if [ -f \".env.example\" ]; then echo \"đ .env.example found - template available\"; fi; ENV_FILES=($(ls .env 2>/dev/null | grep -v .env.example || true)); if [ ${#ENV_FILES[@]} -gt 0 ]; then echo \"đ Environment files found: ${ENV_FILES[]}\"; for file in \"${ENV_FILES[@]}\"; do VAR_COUNT=$(grep -c \"^[A-Z_][A-Z0-9_]*=\" \"$file\" 2>/dev/null || echo \"0\"); echo \" $file: $VAR_COUNT variables\"; done; else echo \"âšī¸ No .env files found\"; fi; else echo \"â ī¸ VERCEL_TOKEN not configured\"; echo \"đĄ Environment sync features disabled\"; fi'",
"timeout": 15
}
]
}
]
}
}
Related Claude Code Hooks
Simple Notifications
Send desktop notifications when Claude Code finishes working or needs user input. Works on macOS and Linux systems.
Dependency Checker
Advanced dependency analysis and security checking. Monitors for outdated packages, security vulnerabilities, and license compatibility.
Build On Change
Automatically trigger build processes when source files change. Detects common build tools and runs appropriate build commands.
Agents Md Loader
Automatically loads AGENTS.md configuration file content at session start to ensure Claude Code follows project-specific agent behavior. Only loads if AGENTS.md exists, otherwise passes empty context. Supports the universal AGENTS.md standard for cross-platform AI assistant compatibility.
Telegram Notifications
Send Telegram notifications when Claude Code finishes working. Requires TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID environment variables. Get bot token from @BotFather, get chat ID by messaging the bot and visiting https://api.telegram.org/bot<TOKEN>/getUpdates
Deployment Health Monitor
Monitor deployment status, error rates, and performance metrics, sending notifications for failed deployments or performance degradation. Tracks Vercel deployment health, monitors build success/failure rates, and provides alerts for deployment issues. Setup: Export 'export VERCEL_TOKEN=your_token' and 'export VERCEL_PROJECT_ID=your_project_id' (get from vercel.com/account/tokens and Vercel dashboard).
Catalog data and component content are sourced from the open-source davila7/claude-code-templates project (MIT license). ToolZip curates the listing and writes original descriptions; every component links back to its original source. Claude Code is a product of Anthropic. ToolZip is an independent catalog and is not affiliated with or endorsed by Anthropic.