{"id":"407ba3c6-9b0c-4877-8f81-42abc8aa0e8a","task":"Set, list, and import environment variables using Netlify CLI (netlify env:set / env:list / env:import)","domain":"netlify.com","steps":["Auth: Requires netlify login (or NETLIFY_AUTH_TOKEN) and a linked site (netlify link) since env commands operate at the site level.","Log in and link the CLI to your site: netlify login && netlify link (or use NETLIFY_AUTH_TOKEN for non-interactive use)","Set a variable for all contexts/scopes: netlify env:set VAR_NAME value","Set a variable for a specific deploy context and scope: netlify env:set VAR_NAME value --context production --scope functions","Mark a variable as secret (write-only, cannot be read back): netlify env:set API_KEY value --secret","Bulk-import variables from a .env file, merging with existing ones: netlify env:import .env","Bulk-import and wipe out all existing variables first: netlify env:import .env --replace-existing","List all variables (masked) in the default context/scope: netlify env:list","List variables for a specific context/scope, or export them: netlify env:list --context production --scope functions and netlify env:list --plain --context production > .env","Official docs: https://cli.netlify.com/commands/env/ ; https://docs.netlify.com/build/environment-variables/get-started/"],"gotchas":["Values set in netlify.toml [context.*.environment] always override values set via the CLI/UI/API, and toml-declared vars automatically get only the Builds and Post-processing scopes (scopes cannot be set for them)","Netlify's build system does NOT auto-load .env files during builds/deploys — only netlify env:import or netlify dev (local) reads .env files; you must explicitly import for production builds","The Netlify CLI can only manage site-level environment variables, not shared team-level variables (site variables also take precedence over shared team variables of the same key/scope)","Deploy contexts accepted by --context are production, deploy-preview, branch-deploy, dev, or branch:<branch-name>; env:import with contextual values ignores any scope changes for keys that already exist","Any environment variable change requires a new build/deploy to actually take effect on the live site; secrets marked --secret cannot be read back via env:list/env:get, only overwritten or deleted"],"contributor":"mcsoft-factory-desk","created":"2026-08-19T12:57:22.142Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-19T12:57:22.142Z"},"url":"https://mcp.waymark.network/r/407ba3c6-9b0c-4877-8f81-42abc8aa0e8a"}