# Generate

> worklens generate — recipe → data. Read from the CLI’s own header, with every option it accepts.

Section: CLI · Type: guide · Last updated: 2026-09-13

worklens generate <recipe.wl.json> [opts] turns a recipe into data, locally. With no options it writes CSV to stdout with the recipe’s row counts; --format picks json, sql or nested, -o writes a file, --seed pins the bytes, --scenario picks a named condition and --slice pulls a referential subset. The same recipe and seed give the same bytes on every machine.

## The picture

recipe.wl.json → worklens generate (--seed · --format) → Data (csv · json · sql · nested)

## Usage

```bash
node packages/sdk-node/bin/worklens.js generate <recipe.wl.json> [opts]
```

## Options

- --seed N — deterministic seed
- --format F — csv | json | sql | nested (default csv)
- -o FILE — write to FILE (else stdout)
- --rows N — DEFAULT rows, used only for entities that declare no rows of their own (default 100). A recipe stating its own counts keeps them.
- --scenario S — named scenario (e.g. nulls, boundary)
- --pack FILE — load a pack before generating; repeatable. Packs are process-local, so CI must pass them on every run — commit the pack next to the recipe and repeat the flag.
- --root E — root entity for nested/slice (default first entity)
- --slice N — extract a referential slice of N root rows

## Examples

```bash
# CSV to stdout, recipe row counts
node packages/sdk-node/bin/worklens.js generate examples/homepage-demo.wl.json

# JSON file, pinned seed
node packages/sdk-node/bin/worklens.js generate examples/homepage-demo.wl.json --seed 42 --format json -o data.json

# a referential slice of 20 root rows
node packages/sdk-node/bin/worklens.js generate examples/whole-company.wl.json --root Customer --slice 20 --format nested
```

> **Not on npm yet** — The package is not published, so npx worklens does not work today. Run the script from a checkout of the repository as node packages/sdk-node/bin/worklens.js; when it is published, the commands are the same with worklens in place of the path.

## Common questions

**Why does --rows not change my row counts?**

--rows is a default, used only for entities that declare no rows of their own. A recipe that states its counts keeps them. Change the recipe if you want different counts for those tables.

**How do I get a small, consistent subset?**

--slice N with --root E pulls N rows of the root entity and every row they reference, so the subset is referentially whole. Useful for a fixture that must stay small.

## Related

- [Installation](https://theworklens.com/docs/cli/installation): How to run the WorkLens CLI today — from a checkout, with Node.js 18 or newer and no build step — and what changes when it is published.
- [Configuration](https://theworklens.com/docs/cli/configuration): Every option the generate, prove and bundle commands accept, and what each one changes about a run. There is no config file.
- [Seeds & determinism](https://theworklens.com/docs/generate/seeds): Same recipe, same seed, same bytes — on any machine. What that guarantee covers, and the three things that change the output.
- [Output formats](https://theworklens.com/docs/generate/output-formats): What a run can write: CSV, JSON, SQL and nested documents from the CLI and SDK, plus fixed-width files for recipes that declare a layout.

_← Previous: [Installation](https://theworklens.com/docs/cli/installation) · Next: [Check](https://theworklens.com/docs/cli/check) →_

_The command line and its options come from the CLI file’s own header comment. Source: packages/sdk-node/bin/worklens.js._

_Canonical: https://theworklens.com/docs/cli/generate · This copy: https://theworklens.com/docs/cli/generate.md_
