> ## Documentation Index
> Fetch the complete documentation index at: https://docs.talosjs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Running seeds

> Populate the database across every module with talos seed:run.

Populate the database across every module with `talos seed:run`. The command runs each module's `bin/seed/run.ts` script from the module's own directory. Each runner resolves every registered seed, keeps the ones that are active and target the current environment, and runs them in dependency order.

```bash theme={null}
# Run all seeds
talos seed:run

# Clear seeded data first, running in the test environment
talos seed:run --drop --env=test

# Force every seed to run, ignoring the cache
talos seed:run --no-cache
```

| Option       | Description                                      | Default |
| ------------ | ------------------------------------------------ | ------- |
| `--drop`     | Clear seeded data before running seeds.          | `false` |
| `--env`      | Value used for `APP_ENV` when running the seeds. | —       |
| `--no-cache` | Skip reading and writing the seed cache.         | `false` |

## How a run proceeds

The runner loads every registered seed and filters it through `isActive()` and `getEnv()` against the current `APP_ENV`. For each remaining seed it first runs the seed's dependencies — resolving each from the container and collecting their return values — then calls the seed's `run(data)` with those values. A seed that throws stops the run and exits non-zero; the runner closes the registered database connection on the way out.

There is no tracking table: whether a seed has already run is recorded only by the [run cache](/seeds/caching), so a successful, unchanged seed is skipped on the next run and reported as `up to date (cached)`.

## Clearing data

Passing `--drop` clears seeded data before any seed runs by calling `drop()` on the module's registered `database` constant, then re-seeds from scratch. A module without a registered database simply has nothing to drop. `--drop` also bypasses the cache, since the reset must always re-seed.

## Setting the environment

`--env` sets `APP_ENV` for the run, which drives two things: the `getEnv()` filter that selects which seeds run, and the environment folded into each seed's [cache fingerprint](/seeds/caching). Seeding a different environment is therefore always a cache miss.

## Running `run()` directly

Outside the CLI you can call `run()` from `@talosjs/seeds`:

```typescript theme={null}
import { run } from "@talosjs/seeds";

await run();
```

See the [`seed:run` command](/cli/commands/seed-run) for the full reference.

## Next steps

* [Caching](/seeds/caching): how the per-seed run cache skips unchanged seeds.
* [Writing seeds](/seeds/writing): gate a seed by activity, environment, and dependencies.
