# amfelt sql generate

Write out the generated SQL for this project.

Renders warehouse SQL for your selected objects and writes it under your
project's configured SQL directory (sql/ by default), nested
`<namespace>/<object>/` so an object's SQL moves as one unit. An object with no
primary key, or a job scoped to a layer that renders no SQL at all, contributes
nothing — this matches what the pipeline actually runs, not just what was
selected.

Rendering asks the target plugin this project is pinned to, so the result
matches what actually runs, including any template you have customized. Doing so
connects to your target using its configured connection details — nothing is
executed against it, but the connection itself is real, not simulated.

A file carrying Amfelt's marker is Amfelt's: overwritten if this run still emits
it, removed if it does not — even if you edited it in place, since editing a
file does not remove its marker. Any other .sql file under your SQL directory is
not ignored: it stops the command, because this generator cannot tell your
unmarked file from one safe to write over. Only a file that is not .sql at all —
a `.gitkeep`, a `.DS_Store` — is genuinely left alone.

Generation is opt-in: add a sql: block with enabled: true to your project file
before running this command.

## Usage

```text
amfelt sql generate [flags]
```

## Examples

```text
sql generate
Writes the generated SQL for the project in the current directory.

sql generate --path pcf/PCF-duckdb.yaml
Writes it for the project defined by the given project file.
```

## Flags

| Flag | Type | Default | Description |
| --- | --- | --- | --- |
| `--path` | `string` | `amfelt.yaml` | path of the Amfelt project file |
{.clidoc-flags-table}

## Global flags

| Flag | Type | Default | Description |
| --- | --- | --- | --- |
| `--amfelt-dir` | `string` | `.amfelt` | directory for workspace files (such as plugins); does not move agent identity (controlled by AMFELT_DIR) |
| `--config` | `string` | — | directory or filename of the application configuration |
| `-f`, `--format` | `string` | `default` | log format to use; either default, pretty, or json |
| `-l`, `--level` | `string` | `info` | minimum log level to display; either error, warn, info, or debug |
| `-v`, `--verbose` | `bool` | `false` | trigger to use verbose logging |
{.clidoc-flags-table}

## See also

- [`sql`](/docs/reference/command-line/sql/) — the parent command

---

Generated from `amfelt` v5.6.3.
