Skip to content

skystate diff

Show differences between two environments.

Synopsis

skystate diff --from <env> --to <env> [--keys <keys>] [--format <format>]

Description

Compares the latest config versions of two environments for the linked project and outputs the differences. If the configs are identical, the command exits silently with code 0. If differences are found, they are printed and the command exits with code 1.

This non-zero exit on differences makes diff suitable for use in CI pipelines that should fail when environments are out of sync.

The repo must already be linked via skystate init.

Options

OptionDescription
--from <env>(Required) Source environment. Accepts development, staging, production, or aliases dev, stg, prod.
--to <env>(Required) Target environment. Accepts the same values as --from.
--keys <keys>Comma-separated list of top-level keys to compare. Other keys are ignored.
--format <format>Output format. json outputs raw hunk data to stdout. Default is ANSI-coloured diff to stdout.

Global options (--verbose, --api-url) are also accepted. See global options.

Environment aliases

AliasFull name
devdevelopment
stgstaging
prodproduction

Exit codes

CodeMeaning
0No differences found (environments are identical)
1Differences found (or an error occurred)

Examples

sh
# Compare development to staging
skystate diff --from development --to staging

# Use environment aliases
skystate diff --from dev --to prod

# Compare only specific keys
skystate diff --from dev --to prod --keys featureFlags,limits

# JSON output for scripting
skystate diff --from dev --to staging --format json

# Use in CI — fail if dev and staging differ
skystate diff --from dev --to staging && echo "In sync" || echo "Out of sync"

Output (default ANSI format)

Each changed key is shown as a numbered hunk:

[1/2] featureFlags (replace)
  source (development v1.2.0):
    darkMode: false
    newCheckout: false
  target (staging v1.1.0):
    darkMode: true
    newCheckout: false

[2/2] limits.maxRetries (replace)
  source (development v1.2.0): 5
  target (staging v1.1.0): 3

Hunk types:

TypeMeaning
addKey exists in source, missing in target
removeKey exists in target, missing in source
replaceKey exists in both but values differ

If there are no differences, the command produces no output and exits with code 0.

Output (JSON format, --format json)

json
[
  {
    "key": "featureFlags",
    "type": "replace",
    "sourceValue": { "darkMode": false, "newCheckout": false },
    "targetValue": { "darkMode": true, "newCheckout": false }
  },
  {
    "key": "limits.maxRetries",
    "type": "replace",
    "sourceValue": 5,
    "targetValue": 3
  }
]

--keys filtering

When --keys is provided, only the listed top-level keys appear in the diff. Keys in --keys that are not present in the diff produce a warning on stderr:

Warning: key "nonexistent" not found in diff.

Errors

SituationExit CodeMessage
--from not specifiederrorCommander required option error
--to not specifiederrorCommander required option error
Invalid source environment1Error: Invalid source environment "xyz". Must be one of: dev, stg, prod (or development, staging, production)
Invalid target environment1Error: Invalid target environment "xyz". Must be one of: ...
--from and --to are the same1Error: Source and target environments must be different.
Source has no config1Error: No config found in source environment "development". with hint Push config to development first via the dashboard.
No project linked1Error: No project linked. with hint Run: skystate init
Not authenticated2Not authenticated. Run: skystate login
Network error1Error: Network error -- check your connection and try again

Note: if the target environment has no config, it is treated as an empty object {}. All source keys appear as add hunks.

Dashboard equivalent

The Remote Config tab in the dashboard at https://app.skystate.io includes a visual diff view that compares environments side by side.

Built with VitePress