---
url: https://docs.mochiexec.io/reference/cli/mochi_template_generate.md
description: Generate workspace executables and scaffolding from a flowfile template.
---

# mochi template generate

Generate workspace executables and scaffolding from a flowfile template.

## Synopsis

Add rendered executables from a flowfile template to a workspace.

The WORKSPACE\_NAME is the name of the workspace to initialize the flowfile template in.
The FLOWFILE\_NAME is the name to give the flowfile (if applicable) when rendering its template.

One of -f or -t must be provided and must point to a valid flowfile template.
The -d flag can be used to specify an output directory within the workspace to create
the flowfile and its artifacts in.

```shell
mochi template generate FLOWFILE_NAME [-w WORKSPACE ] [-d OUTPUT_DIR] [-f FILE | -t TEMPLATE] [flags]
```

## Options

| Flag | Type | Description |
|------|------|-------------|
| `-d, --dir` | `string` | Output directory (within the workspace) to create the flow file and its artifacts. If the directory does not exist, it will be created. |
| `-f, --file` | `string` | Path to the template file. It must be a valid flow file template. |
| `-h, --help` |  | help for generate |
| `-o, --output` | `string` | Output format. One of: yaml, json, or tui. |
| `-s, --set` | `stringArray` | Set a form field value by key (KEY=value). Repeat for multiple fields. Fields with a matching key will skip the interactive prompt. |
| `-t, --template` | `string` | Registered template name. Templates can be registered in the flow configuration file or with 'flow template add'. |
| `-w, --workspace` | `string` | Workspace to create the flow file and its artifacts. Defaults to the current workspace. |

## Options inherited from parent commands

| Flag | Type | Description |
|------|------|-------------|
| `-L, --log-level` | `string` | Log verbosity level (debug, info, fatal) (default "info") |
| `--sync` |  | Sync flow cache and workspaces |

## See also

* [mochi template](mochi_template.md) — Manage flowfile templates.
