---
layout: doc
title: How kubb-lock.json works
description: Kubb 5.27 writes kubb-lock.json next to your config. It lets kubb generate skip a build when nothing changed, and lets --check verify formatted output without running the formatter.
outline: deep
image: /blog/kubb-lock/cover.svg
date: 2026-11-26
---

> Index of every page on this site: [llms.txt](https://kubb.dev/llms.txt)

![How kubb-lock.json works](/blog/kubb-lock/cover.svg)

# How kubb-lock.json works

Kubb 5.27 writes `kubb-lock.json` to your project root. Commit it with your generated code. With it, `kubb generate` skips the build when nothing changed, and `kubb generate --check` verifies formatted output without running your formatter.

## Why it exists

`output.format`, `output.lint`, and `output.postGenerate` rewrite the files Kubb generates, so the generated text rarely matches the file on disk. Before 5.27, `--check` ran the formatter and linter again in a temporary folder to compare them. That was slow, and it broke when an ignore rule skipped that folder.

## What it holds

Only hashes. Each generated file gets two: `source` for the code Kubb generated, and `output` for the file after formatting. Each config also gets one hash of everything the build read.

```json [kubb-lock.json]
{
  "lockfileVersion": 1,
  "inputs": {
    "src/gen": { "hash": "0c3bf1dc…", "sources": ["openapi.yaml"] }
  },
  "files": {
    "src/gen/types/Pet.ts": { "source": "647596c2…", "output": "002220b7…" }
  }
}
```

## Faster checks and skipped builds

`--check` generates in memory. When a file's `source` hash matches the new code and its `output` hash matches the disk, the formatter already did its work, so Kubb skips it. A fresh CI checkout gets the answer without running a formatter.

`kubb generate` prints "Up to date" and exits when the config, the spec, the installed package versions, and the generated files all match. Pass `--force` to build anyway, for example after you change your formatter config, which Kubb does not track.

## Merge conflicts

Don't merge the lockfile by hand. Run `kubb generate`, then commit the result. Kubb treats a lockfile it cannot parse as missing, so one full run rewrites it.

To turn the lockfile off, pass `--no-lockfile`.

## Try it

Update to Kubb 5.27. The [`kubb generate` reference](/docs/5.x/reference/commands/generate#kubb-lock) has every rule, and [Check generated code in CI](/docs/5.x/how-to/recipes#check-generated-code-in-ci) has example workflows.

## Sitemap

See the full [sitemap](https://kubb.dev/sitemap.md) for all pages.
