CLI and configuration
Commands
| Command | Description |
|---|---|
init | Initialize a TypePrompt project |
gen | Generate code from template files |
format | Format template files |
run | Run playground inference for a .play.tp file |
patch | Initialize a patch project against a base project |
Commands that operate on a project use the current directory by default. Pass -p <path> to point to the directory containing typeprompt.yaml instead.
init
npx @typeprompt/cli init [-p <path>]Creates typeprompt.yaml and a prompts/ directory with a starter template. The target directory is created if it doesn't exist. An existing typeprompt.yaml is left untouched.
gen
npx @typeprompt/cli gen [-p <path>] [--watch]Compiles the project and writes generated code for each language configured under gen. With --watch (-w), regenerates whenever a template file changes. In a patch project, also writes overrides.json.
format
npx @typeprompt/cli format [-p <path>] [--ci]Formats all template files in place. With --ci, checks formatting without modifying files and fails if any file is not properly formatted.
run
npx @typeprompt/cli run <file> [-o <path>]Runs inference on every sample in a playground file and prints the results as JSON, or writes them to the file given by -o. The project is located by searching for typeprompt.yaml in the file's directory and its parents. See playground inference.
patch
npx @typeprompt/cli patch -b <base> -o <output-dir>Creates a patch project for editing prompts against a base project. See template overrides.
Configuration
typeprompt.yaml lives at the root of the project.
include:
- prompts/**/*.tp
gen:
typescript:
file: src/gen/prompts.ts
kotlin:
file: src/main/kotlin/gen/Prompts.kt
package: com.example.promptsinclude
Required. List of glob patterns matching the project's .tp files.
gen
One entry per target language. Each entry requires a file path for the generated code; some languages accept additional options:
| Key | Options | Guide |
|---|---|---|
typescript | file (.ts) | TypeScript |
python | file (.py) | Python |
kotlin | file (.kt), package | Kotlin |
rust | file (.rs) | Rust |
cpp | file (.h), rootNamespace | C++ |
swift | file (.swift), rootNamespace | Swift |
dart | file (.dart) | Dart |
csharp | file (.cs), rootNamespace | C# |
patch
Set by npx @typeprompt/cli patch in patch projects; you don't need to edit it. See template overrides.
API keys
Provider API keys for playground inference are stored separately, in .typeprompt.secrets.yaml. See API keys.