CtroEnv
ctroenvType-Safe Environment Variables
Getting StartedQuick StartCore Concepts
defineEnv()string()number()boolean()semver()pick()ip(), ipv4(), ipv6()uuid(), guid()Chainable MethodsRefinementsError HandlingSchema CompositionSecurityCustom ValidatorswatchEnv()
CLI Overviewctroenv validatectroenv generatectroenv checkctroenv docsctroenv initCLI Configuration
Node AdapterVite AdapterNext.js Adapter
Migration from t3-envMigration from envalidMigration from dotenv

ctroenv check

CI-friendly command that validates env vars and exits with the appropriate code.

  1. Docs
  2. CLI

ctroenv check

CI-friendly validation command. Designed for continuous integration pipelines.

Usage

ctroenv check [options]

Options

OptionTypeDefaultDescription
--sourcestring.envPath to the env file to check
--strictbooleanfalseValidate values against schema (not just keys)
--jsonbooleanfalseOutput as JSON
--warn-unknownbooleanfalseWarn about keys in source not in schema (with "did you mean?" suggestions)

CI Integration

# .github/workflows/env-check.yml
name: Environment Check
on: [pull_request]
jobs:
  validate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
      - run: npm ci
      - run: npx ctroenv check

Exit Codes

CodeMeaning
0All variables valid
1Validation errors found
2Configuration error

Combine with .env.example in CI:

# Validate against the example file (all required vars present)
ctroenv check --source .env.example

# Strict mode: validate values against schema validators
ctroenv check --source .env --strict

Strict Mode

Without --strict, check only compares key sets — it reports missing and unused keys but does not validate values.

With --strict, each value is validated against its schema validator (same as ctroenv validate). This catches type mismatches, invalid URLs, out-of-range numbers, and other value-level errors.

# Key comparison only (fast)
ctroenv check --source .env

# Key comparison + value validation
ctroenv check --source .env --strict

Unknown Key Warnings

With --warn-unknown, the command reports keys found in the source file that are not defined in the schema. When a close match is detected via Levenshtein distance, a "did you mean?" suggestion is shown:

ctroenv check --source .env --warn-unknown
# ⚠ Unknown key: "DATABSE_URL"
#   → Did you mean "DATABASE_URL"?

JSON output

ctroenv check --source .env --strict --warn-unknown --json
{
  "source": ".env",
  "total": 5,
  "clean": false,
  "summary": {
    "missing": 2,
    "unused": 1,
    "matched": 2
  },
  "missing": ["DATABASE_URL", "JWT_SECRET"],
  "unused": ["OLD_KEY"],
  "matched": ["PORT", "NODE_ENV"],
  "validationErrors": [
    {
      "key": "DATABASE_URL",
      "message": "Invalid URL",
      "code": "invalid_value"
    }
  ],
  "unknownSuggestions": [
    { "key": "DATABSE_URL", "suggestion": "DATABASE_URL" }
  ]
}

How is this guide?

Edit on GitHub

Last updated on Jun 30, 2026

Previousctroenv generateNextctroenv docs

On this page

UsageOptionsCI IntegrationExit CodesStrict ModeUnknown Key WarningsJSON output