SkybuDocs

Ferdigheter · Apper

Environment variables

List, set, remove and reveal an app's environment variables for production and previews, including write-only secrets and variables the build needs.

skill://apps/environment-variablesAgenter leser den med resources/read eller skills_read. Den er skrevet på engelsk, for agentene.

An app's variables are API keys and settings it reads from its environment. Skybu encrypts each value with the app's own key before storing it, gives the values to the app when it runs and to its builds, and never shows them in a list. Setting or removing a variable restarts the app with the new set; it does not build again.

In short

  1. list_env_vars to see which names exist, per environment.
  2. set_env_vars to add or change values. Ask the user for secret values; never invent or guess them.
  3. unset_env_var to remove one.
  4. reveal_env_vars only when you need a value back. It needs secrets:read and is logged.

Production, preview or both

Every variable belongs to an environment:

ValueWho gets it
productionThe app itself. The default when setting or removing.
previewThe app's pull request previews (skill://apps/previews-and-approval).
bothStored once for each.

Production never sees preview values and previews never see production values, at build time or at run time. A preview that needs an API key gets it only if it is set for preview or both. Use test keys for previews where the service has them.

List

{ "name": "list_env_vars", "arguments": { "appId": "<app id>" } }

Returns each name with its environment, whether it is sensitive, and when and by whom it changed. Never values. Pass environment to see only one.

Set

{
  "name": "set_env_vars",
  "arguments": {
    "appId": "<app id>",
    "variables": { "STRIPE_KEY": "sk_live_…", "NEXT_PUBLIC_SITE": "https://kundeportal.no" },
    "environment": "production"
  }
}
  • Names use A–Z, 0–9 and _, do not start with a digit, and have at most 128 characters.
  • At most 100 variables per environment, 32 KiB per value and 128 KiB together.
  • Setting a name that exists replaces its value.
  • The app restarts with the new values. Builds pick them up from the next deploy.

Write-only secrets. With "sensitive": true, the app and its builds get the value, but no one can reveal it again, not even the person who set it. It can only be replaced or removed. Use it for keys nobody needs to read back. Setting the name again without sensitive makes it an ordinary variable.

{ "name": "set_env_vars", "arguments": { "appId": "<app id>", "variables": { "WEBHOOK_SECRET": "…" }, "sensitive": true } }

Remove

{ "name": "unset_env_var", "arguments": { "appId": "<app id>", "name": "OLD_API_KEY", "environment": "both" } }

One name per call. Without environment it removes the production value only. The app restarts without it.

Reveal

{ "name": "reveal_env_vars", "arguments": { "appId": "<app id>", "names": ["STRIPE_KEY"], "environment": "production" } }

Returns the values of one environment (production by default). Write-only variables are not returned; their names are listed under sensitive. Every reveal is written to the organisation's audit log, and when a connected agent reveals production values the organisation's owners get an email. One person may reveal secrets 60 times an hour (reveals_rate_limited). Reveal only what the task needs, and never repeat a secret value back to the user unless they asked for it.

Names Skybu sets

These are refused with reserved_env_name, because Skybu sets them when the app runs:

NameValue
PORT8080. The app must listen on it.
HOSTNAME0.0.0.0
DATABASE_URL*The project's database: DATABASE_URL, and DATABASE_URL_READONLY in production; DATABASE_URL and DATABASE_URL_DIRECT in a preview with its own database (skill://databases/use-the-database).
SKYBU_*For example SKYBU_DEPLOYMENT, and the project's file storage as SKYBU_S3_* (skill://files/store-files).

An app with an allowlist for outbound traffic also gets HTTPS_PROXY and related variables (skill://access/outbound-traffic).

Variables at build time

Builds get the app's own variables (production values for production, preview values for previews), but not the ones Skybu adds: no DATABASE_URL and no SKYBU_S3_* during the build. They arrive as BuildKit secrets, never as ENV or build arguments, so they are not stored in the image, and the build log shows only their names.

  • Without a Dockerfile (Railpack), the build steps see them as ordinary environment variables. Next.js picks up NEXT_PUBLIC_* with no changes.
  • With a Dockerfile, each step that needs one must mount it:
RUN --mount=type=secret,id=NEXT_PUBLIC_SITE,env=NEXT_PUBLIC_SITE npm run build

NEXT_PUBLIC_* values are compiled into the JavaScript the browser downloads, so anyone can read them. Never put a secret in one. Because they are fixed at build time, changing one only takes effect after a new deploy, not after the restart set_env_vars causes.

Things to know

  • A variable change is not a deploy. If the app crashes with the new value, the old process keeps serving, but nothing reports the change as failed. Check get_app_logs afterwards (skill://apps/fix-a-failed-deploy).
  • A key or connection limited to previews may change only preview variables (environment_not_granted otherwise).
  • Values are encrypted with a key of the app's own, which is deleted with the app.
  • The CLI does the same: skybu env list|set|unset|reveal <app> … with --environment, and --sensitive on set for write-only.