Write Prompts Like Code.
String concatenation does not scale.
As your AI features grow, managing large prompt templates with string interpolation becomes a maintenance nightmare. Unescaped characters break JSON outputs, context gets duplicated, and refactoring is impossible.
PromptForge replaces template literals with a structured, strongly-typed compiler designed specifically for Large Language Models.
const systemPrompt = `
You are an expert financial analyst.
Here is the user's portfolio data:
${JSON.stringify(userData)}
Please return a JSON array of... wait what if userData contains quotes?
`;
You are an expert financial analyst.
Here is the user's portfolio data:
${JSON.stringify(userData)}
Please return a JSON array of... wait what if userData contains quotes?
`;
Why PromptForge?
Without PromptForge
With PromptForge
Manual Strings
Type-safe API
No Validation
Compile-time Validation
Provider-specific formatting
Provider Agnostic Compilation
Difficult Maintenance
Composable Prompts
The Prompt Pipeline
Write
Compile
Validate
Analyze
Optimize
Deploy
Code First.
Define your inputs, outputs, and constraints using Zod schemas. PromptForge handles the markdown generation and LLM formatting automatically.
agent.ts
import { pf } from '@promptforgee/core';
export const summarize = pf.define({
input: z.object({ text: z.string() }),
output: z.object({
summary: z.string(),
keywords: z.array(z.string())
}),
messages: (vars) => [
pf.system`You are a strict technical summarizer.`,
pf.user`Summarize this: ${vars.text}`
]
});
export const summarize = pf.define({
input: z.object({ text: z.string() }),
output: z.object({
summary: z.string(),
keywords: z.array(z.string())
}),
messages: (vars) => [
pf.system`You are a strict technical summarizer.`,
pf.user`Summarize this: ${vars.text}`
]
});
COMPILEDOPENAIANTHROPIC
SYSTEM: You are a strict technical summarizer.
USER: Summarize this: {vars.text}
OUTPUT FORMAT:
{ "summary": "string", "keywords": ["string"] }
USER: Summarize this: {vars.text}
OUTPUT FORMAT:
{ "summary": "string", "keywords": ["string"] }
Analyzer
Static analysis and real LLM evaluation grades your prompts before they hit production.
SCORE
95/100
TOKENS
124
Perfect task isolation
Structured output enforced
Optimizer
Run your code through the optimizer to strip filler words and strictly enforce prompt engineering best practices.
BEFORE
"Please somehow summarize this stuff if you can..."
AFTER
"Summarize the provided text."
Saved: 24% TokensRemoved Ambiguity
Production Ready Examples
Developer Experience First.
- TypeScript First
- Tree Shakeable
- ESM & CommonJS
- Zero Dependencies (Core)
- Provider Agnostic