File contents Environment Variables
This is how we add environment variables to the project:
Add to .env.example:
NEW_VARIABLE=value_example
Add to apps/web/env.ts:
// For server-only variables
server: {
NEW_VARIABLE: z.string(),
}
// For client-side variables
client: {
NEXT_PUBLIC_NEW_VARIABLE: z.string(),
}
experimental__runtimeEnv: {
NEXT_PUBLIC_NEW_VARIABLE: process.env.NEXT_PUBLIC_NEW_VARIABLE,
}
For client-side variables:
Must be prefixed with NEXT_PUBLIC_
Add to both client and experimental__runtimeEnv sections
Add to turbo.json under globalDependencies:
{
"tasks": {
"build": {
"env": [
"NEW_VARIABLE"
]
}
}
}
examples:
input: |
Adding a server-side API key
.env.example
API_KEY=your_api_key_here
env.ts
server: {
API_KEY: z.string(),
}
turbo.json
"build": {
"env": ["API_KEY"]
}
output: "Server-side environment variable properly added"
input: |
Adding a client-side feature flag
.env.example
NEXT_PUBLIC_FEATURE_ENABLED=false
env.ts
client: {
NEXT_PUBLIC_FEATURE_ENABLED: z.coerce.boolean().default(false),
},
experimental__runtimeEnv: {
NEXT_PUBLIC_FEATURE_ENABLED: process.env.NEXT_PUBLIC_FEATURE_ENABLED,
}
turbo.json
"build": {
"env": ["NEXT_PUBLIC_FEATURE_ENABLED"]
}
output: "Client-side environment variable properly added"
references:
apps/web/env.ts
apps/web/.env.example
turbo.json
1 --- 2 name: environment-variables 3 description: Add environment variable 4 --- 5 # Environment Variables 6 7 This is how we add environment variables to the project: 8 9 1. Add to `.env.example`: 10 ```bash 11 NEW_VARIABLE=value_example 12 ``` 13 14 2. Add to `apps/web/env.ts`: 15 ```typescript 16 // For server-only variables 17 server: { 18 NEW_VARIABLE: z.string(), 19 } 20 // For client-side variables 21 client: { 22 NEXT_PUBLIC_NEW_VARIABLE: z.string(), 23 } 24 experimental__runtimeEnv: { 25 NEXT_PUBLIC_NEW_VARIABLE: process.env.NEXT_PUBLIC_NEW_VARIABLE, 26 } 27 ``` 28 29 3. For client-side variables: 30 - Must be prefixed with `NEXT_PUBLIC_` 31 - Add to both `client` and `experimental__runtimeEnv` sections 32 33 4. Add to `turbo.json` under `globalDependencies`: 34 ```json 35 { 36 "tasks": { 37 "build": { 38 "env": [ 39 "NEW_VARIABLE" 40 ] 41 } 42 } 43 } 44 ``` 45 46 examples: 47 - input: | 48 # Adding a server-side API key 49 # .env.example 50 API_KEY=your_api_key_here 51 52 # env.ts 53 server: { 54 API_KEY: z.string(), 55 } 56 57 # turbo.json 58 "build": { 59 "env": ["API_KEY"] 60 } 61 output: "Server-side environment variable properly added" 62 63 - input: | 64 # Adding a client-side feature flag 65 # .env.example 66 NEXT_PUBLIC_FEATURE_ENABLED=false 67 68 # env.ts 69 client: { 70 NEXT_PUBLIC_FEATURE_ENABLED: z.coerce.boolean().default(false), 71 }, 72 experimental__runtimeEnv: { 73 NEXT_PUBLIC_FEATURE_ENABLED: process.env.NEXT_PUBLIC_FEATURE_ENABLED, 74 } 75 76 # turbo.json 77 "build": { 78 "env": ["NEXT_PUBLIC_FEATURE_ENABLED"] 79 } 80 output: "Client-side environment variable properly added" 81 82 references: 83 - apps/web/env.ts 84 - apps/web/.env.example 85 - turbo.json
elie222/inbox-zero commit 5f200a55bb
Frequently asked questions How do I install the Environment Variables skill? Run npx get-skill add elie222/environment-variables in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
What does the Environment Variables skill do? Add environment variable It is listed under Coding & Dev Tools on SkillMD.
Is Environment Variables safe to use? This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
Which AI agents work with Environment Variables? This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Is Environment Variables free to use? Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
Who published Environment Variables? elie222 (@elie222) published this skill. Their other Agent Skills are listed on their SkillMD profile.