Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Configure and optimize Turborepo monorepo build pipelines with correct task structure, caching, and CI setup.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/environment/RULE.md
1# Environment Variables in Turborepo23Turborepo provides fine-grained control over which environment variables affect task hashing and runtime availability.45## Configuration Keys67### `env` - Task-Specific Variables89Variables that affect a specific task's hash. When these change, only that task rebuilds.1011```json12{13"tasks": {14"build": {15"env": ["DATABASE_URL", "API_KEY"]16}17}18}19```2021### `globalEnv` - Variables Affecting All Tasks2223Variables that affect EVERY task's hash. When these change, all tasks rebuild.2425```json26{27"globalEnv": ["CI", "NODE_ENV"]28}29```3031### `passThroughEnv` - Runtime-Only Variables (Not Hashed)3233Variables available at runtime but NOT included in hash. **Use with caution** - changes won't trigger rebuilds.3435```json36{37"tasks": {38"deploy": {39"passThroughEnv": ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY"]40}41}42}43```4445### `globalPassThroughEnv` - Global Runtime Variables4647Same as `passThroughEnv` but for all tasks.4849```json50{51"globalPassThroughEnv": ["GITHUB_TOKEN"]52}53```5455## Wildcards and Negation5657### Wildcards5859Match multiple variables with `*`:6061```json62{63"env": ["MY_API_*", "FEATURE_FLAG_*"]64}65```6667This matches `MY_API_URL`, `MY_API_KEY`, `FEATURE_FLAG_DARK_MODE`, etc.6869### Negation7071Exclude variables (useful with framework inference):7273```json74{75"env": ["!NEXT_PUBLIC_ANALYTICS_ID"]76}77```7879## With `futureFlags.globalConfiguration`8081When the `globalConfiguration` future flag is enabled, global environment keys move under the `global` key with cleaner names:8283| Old (top-level) | New (`global.`) |84| ---------------------- | ---------------- |85| `globalEnv` | `env` |86| `globalPassThroughEnv` | `passThroughEnv` |8788`global.env` and `global.passThroughEnv` behave identically to their top-level counterparts — they affect the global hash and all tasks, respectively. The rename is purely organizational.8990```json91{92"futureFlags": { "globalConfiguration": true },93"global": {94"env": ["CI", "NODE_ENV"],95"passThroughEnv": ["GITHUB_TOKEN", "NPM_TOKEN"]96},97"tasks": {98"build": {99"env": ["DATABASE_URL", "API_*"],100"passThroughEnv": ["SENTRY_AUTH_TOKEN"]101}102}103}104```105106## Complete Example107108```json109{110"$schema": "https://v2-9-12.turborepo.dev/schema.json",111"globalEnv": ["CI", "NODE_ENV"],112"globalPassThroughEnv": ["GITHUB_TOKEN", "NPM_TOKEN"],113"tasks": {114"build": {115"env": ["DATABASE_URL", "API_*"],116"passThroughEnv": ["SENTRY_AUTH_TOKEN"]117},118"test": {119"env": ["TEST_DATABASE_URL"]120}121}122}123```124