---
title: Quickstart
description: Get started with Specdiff and Envlock. Install, import, and validate in minutes.
url: https://pr-1-8289d63b6330.thally.app/quickstart
---

# Quickstart

Get started with Specdiff and Envlock. Install, import, and validate in minutes.

## Specdiff

Detect breaking changes in your JSON Schema and OpenAPI documents.

### Install

```sh
npm install @specdiff/core
```

### Usage

Create a simple comparison of two documents:

```js
import { diffDocuments, formatText } from "@specdiff/core";

const before = {
  type: "object",
  properties: {
    id: { type: "integer" },
    name: { type: "string" }
  },
  required: ["id", "name"]
};

const after = {
  type: "object",
  properties: {
    id: { type: "integer" },
    email: { type: "string" }
  },
  required: ["id", "email"]
};

const result = diffDocuments(before, after);
console.log(formatText(result));
```

Specdiff reports every change with its severity, rule code, and JSON pointer path. In this example it detects that the `name` property was removed (breaking) and a new required property `email` was added (breaking).

### CLI

Compare YAML or JSON files from the command line:

```sh
npx @specdiff/cli before.yaml after.yaml
```

Pass `--format markdown` for a detailed report, or `--fail-on warning` to exit with code 1 on warnings or above.

---

## Envlock

Validate environment variables against a typed contract.

### Install

```sh
npm install @envlock/core
```

### Usage

Define your environment contract and load variables:

```js
import { defineEnv, env, loadEnv } from "@envlock/core";

const schema = defineEnv({
  NODE_ENV: env.enum(["development", "production"]).default("development"),
  PORT: env.port().default(3000),
  DATABASE_URL: env.url({ protocols: ["postgres:"] }).secret(),
});

const config = loadEnv(schema);
// TypeScript infers:
// config: { NODE_ENV: "development" | "production"; PORT: number; DATABASE_URL: string }
```

Set variables and run:

```sh
DATABASE_URL=postgres://user:pass@localhost/db node app.mjs
```

If any required variable is missing or invalid, `loadEnv()` throws `EnvValidationError` with a detailed message.

### CLI

Check if your environment satisfies the contract:

```sh
npx @envlock/cli check
```

Generate an `.env.example` file from your schema:

```sh
npx @envlock/cli example --out .env.example
```

Inspect the full schema as a table:

```sh
npx @envlock/cli inspect
```