Skip to content

CLI and configuration ​

Commands ​

CommandDescription
initInitialize a TypePrompt project
genGenerate code from template files
formatFormat template files
runRun playground inference for a .play.tp file
patchInitialize 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 ​

bash
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 ​

bash
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 ​

bash
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 ​

bash
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 ​

bash
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.

yaml
include:
  - prompts/**/*.tp

gen:
  typescript:
    file: src/gen/prompts.ts
  kotlin:
    file: src/main/kotlin/gen/Prompts.kt
    package: com.example.prompts

include ​

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:

KeyOptionsGuide
typescriptfile (.ts)TypeScript
pythonfile (.py)Python
kotlinfile (.kt), packageKotlin
rustfile (.rs)Rust
cppfile (.h), rootNamespaceC++
swiftfile (.swift), rootNamespaceSwift
dartfile (.dart)Dart
csharpfile (.cs), rootNamespaceC#

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.

Made with 🩷 in New York and outer space