@funkai/prompts
v0.4.1
Published
Prompt SDK with LiquidJS templating and Zod validation
Maintainers
Readme
Features
- :pencil2: built-in templating — Write prompts as Liquid templates (in
.promptformat) with YAML frontmatter. - :shield: Zod validation — Schema variables are validated at render time.
- :package: Codegen — Generate typed TypeScript modules from
.promptfiles. - :jigsaw: Partials — Reusable prompt fragments with
{% render %}tags, flattened at build time. - :file_folder: Groups — Organize prompts into nested namespaces via the
groupfield.
Install
npm install @funkai/promptsUsage
Define a prompt
Create a .prompt file with YAML frontmatter and a Liquid template body:
---
name: writer
schema:
tone: string
---
You are a {{ tone }} writer.Generate typed modules
npx funkai prompts generate --out .prompts/client --includes "src/agents/**"Consume prompts
Add the ~prompts alias to your tsconfig.json:
{
"compilerOptions": {
"paths": {
"~prompts": ["./.prompts/client/index.ts"]
}
}
}Then import and use:
import { prompts } from "~prompts";
const instructions = prompts.agents.writer.render({ tone: "concise" });Frontmatter
| Field | Required | Description |
| --------- | -------- | --------------------------------- |
| name | Yes | Unique kebab-case identifier |
| group | No | Namespace path for grouping |
| version | No | Version number |
| schema | No | Variable declarations (see below) |
Schema variables
Each key under schema declares a template variable:
| Field | Default | Description |
| ------------- | -------- | --------------------------------------- |
| type | string | Variable type (only string supported) |
| required | true | Whether the variable must be provided |
| description | — | Human-readable description |
Shorthand: tone: string is equivalent to tone: { type: string, required: true }.
Partials
Use {% render 'name', key: 'value' %} to include shared partials. Partials resolve from:
- Custom partials —
.prompts/partials/in your project (takes precedence) - Built-in partials — SDK's bundled
identity,constraints,tools
Documentation
For comprehensive documentation, see the Prompts concept and Prompts CLI reference.
