Builder API
Methods for defining prompts.
Basics
All methods chain:
prompt("assistant", (p) =>
p
.persona("helpful assistant")
.input("question")
.output("answer")
.do("be concise")
);Identity
.persona(role)
p.persona("senior engineer").input(desc) / .output(desc)
p.input("code to review")
p.output("actionable feedback").context(info)
p.context("user is building a React app")Instructions
.do(instruction) / .dont(instruction)
p.do("explain reasoning")
p.dont("use jargon").constraint(rule)
p.constraint("under 100 words")Nudge levels
Control strength with { nudge: 1-5 }:
| Level | Meaning |
|---|---|
| 1 | Light — "if you'd like" |
| 2 | Soft — "consider" |
| 3 | Default |
| 4 | Strong — "always" |
| 5 | Required — "must" |
p.do("cite sources", { nudge: 4 })
p.dont("fabricate", { nudge: 5 })Extras
.example(input, output)
p.example("2+2?", "4").raw(text)
Include verbatim text:
p.raw("Always respond in JSON.").use(prompt) / .optional(name, builder)
See Reusing Prompts and Optional Blocks.