environment-setup
Skill6 starsChanged 8 months agoMITView on GitHub
Eliminates the number one blocker for non-technical users — environment variable configuration. Explains what .env files are, auto-generates .env.example, provides step-by-step guides for getting API keys, and validates setup at startup.
- Reads credentials
5 other projects use a version of this.
Adopted by
Most recently taken up by
- aidless/research-writing-skilltheir own version, first seen Oct 4, 2026
- WalrusQuant/sports-analytic-skillstheir own version, first seen Aug 24, 2026
- 200iqlabs/shared-skillstheir own version, first seen Aug 22, 2026
- kienbui1995/magic-powerstheir own version, first seen Apr 10, 2026
- autohandai/community-skillstheir own version, first seen Mar 9, 2026
Other versions5 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 5
- WalrusQuant/sports-analytic-skills★ 50same name
- autohandai/community-skills★ 11same name
- 200iqlabs/shared-skills★ 4same name
- aidless/research-writing-skill★ 0same name
- kienbui1995/magic-powers★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository64 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- api-backward-compatibilitySkill
- api-design-standardsSkill
- api-versioningSkill
- database-designSkill
- distributed-systemsSkill
- observability-by-defaultSkill
- performance-budgetsSkill
- resilience-patternsSkill
- twelve-factor-appSkill
- codex-cross-reviewSkill
- dispatching-parallel-agentsSkill
- receiving-code-reviewSkill
- requesting-code-reviewSkill
- subagent-driven-developmentSkill
- architecture-awarenessSkill
- intent-to-specSkill
- project-diagnosisSkill
- using-shipworthySkill
- systematic-debuggingSkill
- documentation-as-codeSkill
- accessibilitySkill
- frontend-standardsSkill
- retrospectiveSkill
- writing-skillsSkill
- ci-cd-awarenessSkill
- context-managerSkill
- feature-flag-disciplineSkill
- finishing-a-development-branchSkill
- guardrail-audit-logSkill
- incident-responseSkill
- mcp-integrationSkill
- migration-strategiesSkill
- production-readinessSkill
- scope-creep-detectionSkill
- session-memorySkill
- slo-sli-definitionSkill
- tech-debt-trackingSkill
- using-git-worktreesSkill
- zero-downtime-migrationsSkill
- brainstormingSkill
- decision-frameworksSkill
- design-documentsSkill
- executing-plansSkill
- writing-plansSkill
- code-complexitySkill
- confidence-based-strictnessSkill
- error-handling-patternsSkill
- feedback-driven-adaptationSkill
- quality-gatesSkill
- response-schema-validationSkill
- test-driven-developmentSkill
- verification-before-completionSkill
- adaptive-securitySkill
- bias-detectionSkill
- compliance-awarenessSkill
- container-securitySkill
- dependency-managementSkill
- pii-detectionSkill
- secrets-managementSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
22 rules. 0 are common, 10 are distinctive, and 12 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
10
Distinctive
This author's own choices. Worth a look.
12
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 13
Security: If your code is on GitHub, anyone can see your secrets
- Very specific: line 34
Every project MUST have a .env.example file.
- Very specific: line 38
When setting up a project or adding a new service, always create or update .env.example:
- Distinctive: line 95
Every variable that the app needs MUST be listed
- Distinctive: line 97
Use placeholder values, never real secrets
- Distinctive: line 109
Wait about 2 minutes for the project to be created
- Distinctive: line 120
Make sure you're in Test mode (toggle in the top-right says "Test mode")
- Very specific: line 128
After creating, click the endpoint and find "Signing secret" — this is your STRIPE_WEBHOOK_SECRET
- Distinctive: line 140
Create a new project (or select existing)
- Very specific: line 144
Add authorized redirect URI: http://localhost:3000/api/auth/callback/google
- Very specific: line 181
The Rule: If someone with this value could do something harmful (charge money, read private data, send emails, access your database), it …
- Very specific: line 206
Never copy production secrets to your local .env unless you have a specific reason
- Distinctive: line 212
Every project should crash immediately with a clear message if required environment variables are missing.
- Very specific: line 216
Add this to your project's startup (e.g., lib/env.ts or config/env.ts):
- Very specific: line 262
Every time you set up or modify environment configuration, verify that .gitignore includes:
- Distinctive: line 289
When a user starts a new project, run through this checklist:
- Very specific: line 291
Create .env.example with all required variables and plain-language comments
- Very specific: line 292
Create .env by copying .env.example
- Very specific: line 293
Verify .env is in .gitignore
- Very specific: line 295
Add startup validation (lib/env.ts)
- Distinctive: line 296
Test that the app starts successfully with all variables set
- Distinctive: line 297
Test that the app crashes clearly when a required variable is missing
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Environment Setup
What Are .env Files? (Plain Language)
Your app needs secret information to work — database passwords, API keys, service credentials. You can't put these directly in your code because:
- Security: If your code is on GitHub, anyone can see your secrets
- Flexibility: Different environments (your laptop vs the live site) need different values
- Team safety: Each developer has their own keys; you don't share secrets in code
A .env file is a simple text file that sits on your computer (and ONLY your computer) containing these secrets. It looks like this:
# Database connection
DATABASE_URL=postgresql://user:password@localhost:5432/mydb
# Stripe payment processing
STRIPE_SECRET_KEY=sk_test_abc123
STRIPE_PUBLISHABLE_KEY=pk_test_xyz789Your app reads these values when it starts up. The .env file is listed in .gitignore so it never gets uploaded to GitHub.
The .env.example File
Every project MUST have a .env.example file. This is a template that shows what variables are needed WITHOUT revealing actual secret values.
Auto-Generate Template
When setting up a project or adding a new service, always create or update .env.example:
# =============================================================
# Environment Variables
# Copy this file to .env and fill in your values:
# cp .env.example .env
# =============================================================
# ----- DATABASE -----
# Your Supabase database connection string
# Get it: Supabase Dashboard > Project Settings > Database > Connection string
DATABASE_URL=postgresql://postgres:[YOUR-PASSWORD]@db.[YOUR-PROJECT-REF].supabase.co:5432/postgres
# Supabase anonymous (public) key — safe to expose in the browser
# Get it: Supabase Dashboard > Project Settings > API > anon/public key
NEXT_PUBLIC_SUPABASE_URL=https://[YOUR-PROJECT-REF].supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key-here
# Supabase service role key — NEVER expose this in the browser
# Get it: Supabase Dashboard > Project Settings > API > service_role key
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key-here
# ----- AUTHENTICATION -----
# NextAuth secret — random string for encrypting session tokens
# Generate one: openssl rand -base64 32
NEXTAUTH_SECRET=generate-a-random-string-here
NEXTAUTH_URL=http://localhost:3000
# Google OAuth (optional — for "Sign in with Google")
# Get it: https://console.cloud.google.com/apis/credentials
# Create OAuth 2.0 Client ID, set redirect URI to http://localhost:3000/api/auth/callback/google
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
# ----- PAYMENTS -----
# Stripe API keys
# Get it: https://dashboard.stripe.com/test/apikeys
# Use TEST keys during development (start with sk_test_ and pk_test_)
STRIPE_SECRET_KEY=sk_test_your-key-here
STRIPE_PUBLISHABLE_KEY=pk_test_your-key-here
# Stripe webhook secret for verifying webhook signatures
# Get it: https://dashboard.stripe.com/test/webhooks — click your endpoint, reveal signing secret
STRIPE_WEBHOOK_SECRET=whsec_your-webhook-secret-here
# ----- EMAIL -----
# Resend API key for sending emails
# Get it: https://resend.com/api-keys — create a new key
RESEND_API_KEY=re_your-api-key-here
# ----- APP CONFIG -----
# Your app's public URL (no trailing slash)
NEXT_PUBLIC_APP_URL=http://localhost:3000Rules for .env.example:
- Every variable that the app needs MUST be listed
- Include a comment explaining what it is and where to get the value
- Use placeholder values, never real secrets
- Group related variables with section headers
- Mark which variables are safe for the browser (NEXT_PUBLIC_) vs secret
Where to Get Common API Keys
Supabase (Database + Auth)
- Go to supabase.com and sign in (or create an account — it's free)
- Click "New Project" and give it a name
- Set a database password (save this somewhere — you'll need it)
- Wait about 2 minutes for the project to be created
- Go to Project Settings (gear icon in the left sidebar)
- Click API in the settings menu
- You'll see:
- Project URL — this is your
NEXT_PUBLIC_SUPABASE_URL - anon/public key — this is your
NEXT_PUBLIC_SUPABASE_ANON_KEY(safe for browsers) - service_role key — this is your
SUPABASE_SERVICE_ROLE_KEY(keep secret!)
- Project URL — this is your
- Click Database in the settings menu for your
DATABASE_URL
Stripe (Payments)
- Go to dashboard.stripe.com and sign in (or create an account)
- Make sure you're in Test mode (toggle in the top-right says "Test mode")
- Go to Developers > API keys
- You'll see:
- Publishable key (starts with
pk_test_) — this is yourSTRIPE_PUBLISHABLE_KEY - Secret key (starts with
sk_test_) — click "Reveal" — this is yourSTRIPE_SECRET_KEY
- Publishable key (starts with
- For webhooks: Go to Developers > Webhooks > Add endpoint
- URL:
https://your-domain.com/api/webhooks/stripe(for local dev, use Stripe CLI) - Select events you want to listen for
- After creating, click the endpoint and find "Signing secret" — this is your
STRIPE_WEBHOOK_SECRET
- URL:
Resend (Email)
- Go to resend.com and sign in (or create an account)
- Go to API Keys in the sidebar
- Click Create API Key
- Give it a name (like "my-app-dev") and choose permissions (Full access for development)
- Copy the key (starts with
re_) — this is yourRESEND_API_KEY - Important: you can only see the key once. If you lose it, create a new one.
Google OAuth (Sign in with Google)
- Go to console.cloud.google.com
- Create a new project (or select existing)
- Go to APIs & Services > Credentials
- Click Create Credentials > OAuth 2.0 Client ID
- Application type: Web application
- Add authorized redirect URI:
http://localhost:3000/api/auth/callback/google - Click Create
- You'll see your Client ID and Client Secret — these are your
GOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRET - For production, add your real domain to the redirect URIs
NextAuth Secret
This isn't an API key — it's a random string your app uses to encrypt session data. Generate one:
openssl rand -base64 32Copy the output and use it as your NEXTAUTH_SECRET. Any random string works, but make it long and unpredictable.
NEXT_PUBLIC_ Prefix Explained
In Next.js, environment variables are SECRET by default — they only exist on the server.
To make a variable available in the browser (client-side), prefix it with NEXT_PUBLIC_.
What's SAFE to Expose (Use NEXT_PUBLIC_)
- Supabase anon key (
NEXT_PUBLIC_SUPABASE_ANON_KEY) — designed to be public, Row Level Security protects your data - Supabase project URL (
NEXT_PUBLIC_SUPABASE_URL) — just a URL, not a secret - Stripe publishable key (
STRIPE_PUBLISHABLE_KEY) — designed to be public - Your app's URL (
NEXT_PUBLIC_APP_URL) — obviously public - Analytics IDs (Google Analytics, Plausible) — public tracking codes
- Feature flags that are non-sensitive
What MUST Stay Secret (NO NEXT_PUBLIC_ Prefix)
- Database URLs (
DATABASE_URL) — contains password - Supabase service role key (
SUPABASE_SERVICE_ROLE_KEY) — bypasses Row Level Security - Stripe secret key (
STRIPE_SECRET_KEY) — can charge cards - Stripe webhook secret (
STRIPE_WEBHOOK_SECRET) — verifies webhook authenticity - Resend API key (
RESEND_API_KEY) — can send emails as you - NextAuth secret (
NEXTAUTH_SECRET) — encrypts sessions - Any password, token, or secret key
The Rule: If someone with this value could do something harmful (charge money, read private data, send emails, access your database), it MUST NOT have NEXT_PUBLIC_ prefix.
Development vs Production Variables
You'll have at least two sets of values:
Development (Your Computer)
DATABASE_URL=postgresql://postgres:localpassword@localhost:5432/mydb
STRIPE_SECRET_KEY=sk_test_... # Test key — no real charges
NEXT_PUBLIC_APP_URL=http://localhost:3000Production (Live Site)
DATABASE_URL=postgresql://postgres:prodpassword@db.abc123.supabase.co:5432/postgres
STRIPE_SECRET_KEY=sk_live_... # Live key — real charges!
NEXT_PUBLIC_APP_URL=https://myapp.comHow to manage this:
.envor.env.local— your local development values (never committed to git)- Production values — set in your hosting provider's dashboard (Vercel > Settings > Environment Variables)
- Never copy production secrets to your local
.envunless you have a specific reason
Startup Validation
Every project should crash immediately with a clear message if required environment variables are missing. This saves hours of debugging mysterious errors.
Implementation
Add this to your project's startup (e.g., lib/env.ts or config/env.ts):
// lib/env.ts — Validate environment variables at startup
function requireEnv(name: string): string {
const value = process.env[name];
if (!value) {
throw new Error(
`Missing required environment variable: ${name}\n` +
`Check your .env file. See .env.example for setup instructions.`
);
}
return value;
}
function optionalEnv(name: string, defaultValue: string = ''): string {
return process.env[name] || defaultValue;
}
// Required — app won't start without these
export const env = {
DATABASE_URL: requireEnv('DATABASE_URL'),
NEXTAUTH_SECRET: requireEnv('NEXTAUTH_SECRET'),
// Required for payments (only if payments are enabled)
// STRIPE_SECRET_KEY: requireEnv('STRIPE_SECRET_KEY'),
// Optional with defaults
APP_URL: optionalEnv('NEXT_PUBLIC_APP_URL', 'http://localhost:3000'),
};Then import env instead of using process.env directly throughout your app. If any required variable is missing, the app crashes on startup with a message like:
Error: Missing required environment variable: DATABASE_URL
Check your .env file. See .env.example for setup instructions.This is infinitely better than discovering 10 minutes into debugging that your database URL is undefined.
.gitignore Check
Every time you set up or modify environment configuration, verify that .gitignore includes:
# Environment variables
.env
.env.local
.env.development.local
.env.test.local
.env.production.localIf .env is NOT in .gitignore, add it immediately. This is a security-critical step. If .env was ever committed to git history, consider all secrets in it compromised — rotate every key.
How to Check
# Check if .env is in .gitignore
grep -q "^\.env$" .gitignore && echo "OK: .env is in .gitignore" || echo "WARNING: .env is NOT in .gitignore — add it now!"
# Check if .env was ever committed
git log --all --oneline -- .env
# If this shows any results, those secrets may be compromisedQuick Start for New Projects
When a user starts a new project, run through this checklist:
- Create
.env.examplewith all required variables and plain-language comments - Create
.envby copying.env.example - Verify
.envis in.gitignore - Help the user get each API key (link to the service, step-by-step)
- Add startup validation (
lib/env.ts) - Test that the app starts successfully with all variables set
- Test that the app crashes clearly when a required variable is missing
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

