[{"data":1,"prerenderedAt":560},["ShallowReactive",2],{"blog-prompts/move-to-env-vars":3},{"id":4,"title":5,"body":6,"category":535,"date":536,"dateModified":537,"description":538,"draft":539,"extension":540,"faq":541,"featured":539,"headerVariant":545,"image":546,"keywords":546,"meta":547,"navigation":548,"ogDescription":549,"ogTitle":546,"path":550,"readTime":546,"schemaOrg":551,"schemaType":552,"seo":553,"sitemap":554,"stem":555,"tags":556,"twitterCard":558,"__hash__":559},"blog/blog/prompts/move-to-env-vars.md","Move Secrets to Environment Variables with AI",{"type":7,"value":8,"toc":518},"minimark",[9,16,21,29,87,91,96,111,153,157,168,224,228,239,284,288,292,295,324,328,343,379,389,393,399,456,465,487,506],[10,11,12],"tldr",{},[13,14,15],"p",{},"These prompts help you properly set up environment variables in your project. They create .env files, configure your framework correctly, add validation, and ensure secrets never get committed to git. The prompts cover Next.js, Node.js, Python, and deployment platforms.",[17,18,20],"h2",{"id":19},"complete-environment-variable-setup","Complete Environment Variable Setup",[13,22,23,24,28],{},"Use this prompt to set up a full environment variable system from scratch. Your AI will create a ",[25,26,27],"code",{},".env.example"," template, a typed config module with startup validation, and clear separation between public and private variables.",[30,31,33,36,39,55,58,73,76],"prompt-box",{"title":32},"Full Env Var Setup",[13,34,35],{},"Set up a complete environment variable system for this project.",[13,37,38],{},"Create:",[40,41,42,46,49,52],"ol",{},[43,44,45],"li",{},".env.example with all required variables and placeholder values",[43,47,48],{},"A typed config module that loads and validates env vars at startup",[43,50,51],{},"Clear error messages when required variables are missing",[43,53,54],{},"Separation between public (client-safe) and private (server-only) variables",[13,56,57],{},"Requirements:",[59,60,61,64,67,70],"ul",{},[43,62,63],{},"Fail fast: app should not start if required env vars are missing",[43,65,66],{},"Type safety: config values should be typed, not just strings",[43,68,69],{},"Documentation: comments explaining what each variable is for",[43,71,72],{},"Defaults: sensible defaults for non-sensitive variables",[13,74,75],{},"Also ensure:",[59,77,78,81,84],{},[43,79,80],{},".env is in .gitignore",[43,82,83],{},".env.local is in .gitignore",[43,85,86],{},"Only .env.example is committed",[17,88,90],{"id":89},"framework-specific-setup","Framework-Specific Setup",[92,93,95],"h3",{"id":94},"nextjs","Next.js",[13,97,98,99,102,103,106,107,110],{},"Copy this prompt to generate a type-safe Next.js env var setup with proper ",[25,100,101],{},"NEXT_PUBLIC_"," separation. Your AI will create a ",[25,104,105],{},"lib/env.ts"," validation module using Zod and a ",[25,108,109],{},".env.local.example"," template.",[30,112,114,117,119,130,133,147,150],{"title":113},"Next.js Env Setup",[13,115,116],{},"Set up environment variables properly for my Next.js project.",[13,118,38],{},[40,120,121,124,127],{},[43,122,123],{},".env.local.example with all variables",[43,125,126],{},"A lib/env.ts file that exports validated, typed env vars",[43,128,129],{},"Proper separation of NEXT_PUBLIC_ vars vs server-only vars",[13,131,132],{},"Rules:",[59,134,135,138,141,144],{},[43,136,137],{},"NEXT_PUBLIC_ prefix only for variables that MUST be in the browser",[43,139,140],{},"Secret keys, API keys, database URLs must NOT have NEXT_PUBLIC_",[43,142,143],{},"Validate at build time, not runtime",[43,145,146],{},"Use zod or similar for validation",[13,148,149],{},"The config should work with both Pages Router and App Router.",[13,151,152],{},"Show me which variables are safe for client-side and which must stay server-only.",[92,154,156],{"id":155},"nodejs-with-typescript","Node.js with TypeScript",[13,158,159,160,163,164,167],{},"Use this prompt to create a Zod-validated config module for Node.js. Your AI will generate ",[25,161,162],{},"config/index.ts"," and ",[25,165,166],{},"config/schema.ts"," with typed exports, environment-specific defaults, and clear startup errors for missing variables.",[30,169,171,174,176,193,196,207,210],{"title":170},"Node.js TypeScript Env",[13,172,173],{},"Create a type-safe environment variable configuration for my Node.js TypeScript project.",[13,175,57],{},[40,177,178,181,184,187,190],{},[43,179,180],{},"Use dotenv to load .env files",[43,182,183],{},"Create a config.ts that validates and exports typed env vars",[43,185,186],{},"Use zod for validation with clear error messages",[43,188,189],{},"Support different environments (development, production, test)",[43,191,192],{},"Throw at startup if required vars are missing",[13,194,195],{},"Structure:",[59,197,198,201,204],{},[43,199,200],{},"config/index.ts (main config export)",[43,202,203],{},"config/schema.ts (zod schema)",[43,205,206],{},".env.example (template with all vars)",[13,208,209],{},"Include:",[59,211,212,215,218,221],{},[43,213,214],{},"DATABASE_URL",[43,216,217],{},"API keys (typed as string, validated as non-empty)",[43,219,220],{},"PORT (with default)",[43,222,223],{},"NODE_ENV (enum: development, production, test)",[92,225,227],{"id":226},"python-with-pydantic","Python with Pydantic",[13,229,230,231,234,235,238],{},"Copy this prompt to set up Pydantic-based environment management for Python. Your AI will create a ",[25,232,233],{},"Settings"," class with type validation, automatic ",[25,236,237],{},".env"," loading, field descriptions, and nested configuration support.",[30,240,242,245,247,261,264,281],{"title":241},"Python Pydantic Env",[13,243,244],{},"Set up environment variable management for my Python project using Pydantic.",[13,246,38],{},[40,248,249,252,255,258],{},[43,250,251],{},"config.py with a Settings class using pydantic-settings",[43,253,254],{},"Proper .env file loading",[43,256,257],{},"Type hints and validation for all settings",[43,259,260],{},"Support for different environments",[13,262,263],{},"The Settings class should:",[59,265,266,269,272,275,278],{},[43,267,268],{},"Load from .env file automatically",[43,270,271],{},"Validate types (strings, integers, booleans)",[43,273,274],{},"Have clear field descriptions",[43,276,277],{},"Raise validation errors with helpful messages",[43,279,280],{},"Support nested settings if needed",[13,282,283],{},"Also create .env.example with all required variables documented.",[17,285,287],{"id":286},"deployment-platform-setup","Deployment Platform Setup",[92,289,291],{"id":290},"vercel","Vercel",[13,293,294],{},"Use this prompt to get a deployment checklist for Vercel environment variables. Your AI will list every variable your app needs, flag which should be marked \"Sensitive,\" and specify preview vs production values.",[30,296,298,301,304,318,321],{"title":297},"Vercel Env Setup",[13,299,300],{},"Help me set up environment variables for Vercel deployment.",[13,302,303],{},"I need:",[40,305,306,309,312,315],{},[43,307,308],{},"List of all env vars my app needs",[43,310,311],{},"Which ones should be marked as \"Sensitive\" in Vercel",[43,313,314],{},"Which ones need different values for Preview vs Production",[43,316,317],{},"How to reference them in my code",[13,319,320],{},"Also create a vercel.json if needed for any special env var configuration.",[13,322,323],{},"Format the output as a checklist I can follow in the Vercel dashboard, with the variable name, which environments it applies to, and whether it's sensitive.",[92,325,327],{"id":326},"railway-render","Railway / Render",[13,329,330,331,334,335,338,339,342],{},"Paste this prompt to generate platform-specific env var configuration for Railway or Render. Your AI will create ",[25,332,333],{},"railway.toml"," or ",[25,336,337],{},"render.yaml"," with variable references, a setup checklist, and notes on platform-provided variables like ",[25,340,341],{},"PORT",".",[30,344,346,349,351,365,368],{"title":345},"Railway/Render Env Setup",[13,347,348],{},"Set up environment variables for Railway (or Render) deployment.",[13,350,38],{},[40,352,353,356,359,362],{},[43,354,355],{},"A railway.toml or render.yaml with env var references",[43,357,358],{},"List of all required env vars I need to set in the dashboard",[43,360,361],{},"Documentation for each variable's purpose",[43,363,364],{},"Any service-specific variables (like PORT for Railway)",[13,366,367],{},"Include platform-specific considerations:",[59,369,370,373,376],{},[43,371,372],{},"Railway provides PORT automatically",[43,374,375],{},"Database URLs from Railway's built-in databases",[43,377,378],{},"Proper health check configuration",[380,381,382],"warning-box",{},[13,383,384,388],{},[385,386,387],"strong",{},"Never commit .env files:"," Even .env files with \"fake\" values can reveal your variable naming scheme and expected configuration. Always use .env.example with clearly placeholder values instead.",[17,390,392],{"id":391},"migration-from-hardcoded-values","Migration from Hardcoded Values",[13,394,395,396,398],{},"Use this prompt to find and migrate every hardcoded secret in your codebase to environment variables. Your AI will scan for URLs, credentials, feature flags, and config values, then generate the code changes, ",[25,397,27],{}," entries, and validation updates.",[30,400,402,405,408,422,425,442,445],{"title":401},"Migrate Hardcoded to Env",[13,403,404],{},"I have hardcoded configuration values throughout my codebase. Help me migrate them to environment variables.",[13,406,407],{},"For each hardcoded value found:",[40,409,410,413,416,419],{},[43,411,412],{},"Create an appropriately named env var",[43,414,415],{},"Update the code to read from env var",[43,417,418],{},"Add to .env.example with a placeholder",[43,420,421],{},"Add to the config validation",[13,423,424],{},"Look for:",[59,426,427,430,433,436,439],{},[43,428,429],{},"URLs (API endpoints, webhooks)",[43,431,432],{},"Credentials and keys",[43,434,435],{},"Feature flags",[43,437,438],{},"Configuration values (timeouts, limits)",[43,440,441],{},"Third-party service IDs",[13,443,444],{},"Group related variables and use consistent naming:",[59,446,447,450,453],{},[43,448,449],{},"DATABASE_URL, DATABASE_POOL_SIZE",[43,451,452],{},"STRIPE_SECRET_KEY, STRIPE_WEBHOOK_SECRET",[43,454,455],{},"FEATURE_NEW_DASHBOARD, FEATURE_BETA_ACCESS",[457,458,459],"tip-box",{},[13,460,461,464],{},[385,462,463],{},"Pro tip:"," Use a consistent naming convention like SERVICE_VARIABLE_NAME. For example: STRIPE_SECRET_KEY, SUPABASE_URL, OPENAI_API_KEY. This makes it easy to find and manage related variables.",[466,467,468,475,481],"faq-section",{},[469,470,472],"faq-item",{"question":471},"What's the difference between .env and .env.local?",[13,473,474],{},".env is typically committed to git with placeholder or default values. .env.local contains your actual secrets and should never be committed. Most frameworks load .env.local with higher priority.",[469,476,478],{"question":477},"Should I use NEXT_PUBLIC_ prefix for all environment variables?",[13,479,480],{},"No. Only use NEXT_PUBLIC_ for variables that must be accessible in the browser. Secret keys, database credentials, and API keys should never have this prefix as they would be exposed to users.",[469,482,484],{"question":483},"How do I set environment variables in production?",[13,485,486],{},"Use your hosting platform's environment variable settings. Vercel, Netlify, Railway, and other platforms have dashboards or CLI commands to set production environment variables securely.",[488,489,490,496,501],"related-articles",{},[491,492],"related-card",{"description":493,"href":494,"title":495},"Secure hardcoded credentials","/blog/prompts/fix-exposed-api-keys","Fix Exposed API Keys",[491,497],{"description":498,"href":499,"title":500},"Prevent accidental commits","/blog/prompts/add-gitignore","Add Proper .gitignore",[491,502],{"description":503,"href":504,"title":505},"Lock down your config","/blog/prompts/secure-config-files","Secure Configuration Files",[507,508,511,515],"cta-box",{"href":509,"label":510},"/","Start Free Scan",[17,512,514],{"id":513},"verify-your-env-setup","Verify Your Env Setup",[13,516,517],{},"Scan your repository to check for exposed secrets and missing .gitignore entries.",{"title":519,"searchDepth":520,"depth":520,"links":521},"",2,[522,523,529,533,534],{"id":19,"depth":520,"text":20},{"id":89,"depth":520,"text":90,"children":524},[525,527,528],{"id":94,"depth":526,"text":95},3,{"id":155,"depth":526,"text":156},{"id":226,"depth":526,"text":227},{"id":286,"depth":520,"text":287,"children":530},[531,532],{"id":290,"depth":526,"text":291},{"id":326,"depth":526,"text":327},{"id":391,"depth":520,"text":392},{"id":513,"depth":520,"text":514},"prompts","2026-02-20","2026-03-06","AI prompts to migrate hardcoded secrets to environment variables. Proper .env setup for Next.js, Node.js, Python, and more frameworks.",false,"md",[542,543,544],{"question":471,"answer":474},{"question":477,"answer":480},{"question":483,"answer":486},"cyan",null,{},true,"AI prompts to migrate hardcoded secrets to environment variables. Proper .env setup for any framework.","/blog/prompts/move-to-env-vars","[object Object]","BlogPosting",{"title":5,"description":538},{"loc":550},"blog/prompts/move-to-env-vars",[557],"Environment Variables","summary_large_image","BSTdy_8bLKQp716vac7hZti-To8hiYLqKPQMPyxiMQI",1775843938465]