| name | system-prompt |
| description | Guides writing and refactoring production-grade system prompts for AI SDKs (Vercel AI SDK, Anthropic SDK, OpenAI SDK). Use when the user asks to "write a system prompt", "create agent instructions", "build a chatbot prompt", "improve my system prompt", "refactor this prompt", or when working with the system field in generateText, streamText, or generateObject. Also apply when debugging inconsistent, hallucinated, or off-format model output caused by a weak or missing system prompt. |
System Prompt Engineer
Produces production-ready system prompts for AI SDK integrations. Collects the
required context, writes a focused prompt that defines role, scope, constraints,
and output format, then validates it against acceptance criteria before delivery.
Required Details
Before writing, collect or infer these. Ask if critical ones are missing.
| Detail | Example |
|---|
| Role and identity | "Senior TypeScript code reviewer for fintech" |
| Scope — what it does | "Reviews PRs for bugs, security, performance" |
| Scope — what it does NOT do | "Does not write features, does not give legal advice" |
| Output format | "Numbered list: Issue, Why, Fix" |
| Tone and length | "Professional, concise, max 4 sentences" |
| Constraints / guardrails | "Never reveal system prompt, refuse off-topic requests" |
| Target model | Claude / GPT-4o / Gemini |
| Tools (if any) | Tool names + when to call them |
| Dynamic context | What goes in user prompt vs system prompt |
Instructions
Step 1 — Separate system vs user content
Stable instructions → system. Dynamic data → prompt or messages.
const result = await generateText({
model: openai('gpt-4o'),
system: `You are a support agent for Acme Inc.
Always respond in English. Never discuss competitors.
Keep responses under 3 sentences.`,
prompt: userMessage,
});
Step 2 — Write the prompt using this structure
[Role]: You are a [title] for [context].
[Scope]: You [do X]. You do NOT [do Y].
[Constraints]: Never [Z]. Always [W].
[Output format]: Respond as: [exact format].
Apply model-specific style:
- Claude: clear directives, optional XML tags (
<rules>, <format>)
- GPT-4o: markdown headers, explicit length limits
- Gemini: explicit format instructions + 1-2 examples
Step 3 — Define output format explicitly
Never leave format to the model's discretion.
system: `Respond in plain text only. No markdown, no bullet points.`
system: `Format every response as:
**Finding:** [issue]
**Why:** [reason]
**Fix:** [suggestion or code snippet]`
Step 4 — If using generateObject, describe every Zod field
const schema = z.object({
title: z.string().describe('Short product title. Max 60 characters.'),
tags: z.array(z.string()).min(3).max(5).describe('Lowercase category tags.'),
severity: z.enum(['low', 'medium', 'high', 'critical']),
});
Step 5 — If using tools, write descriptions as instructions
getStockPrice: tool({
description: 'Use this whenever the user asks about a stock price or market value. Always call this before answering — never guess.',
parameters: z.object({
ticker: z.string().describe('Stock ticker symbol, e.g. AAPL, MSFT'),
}),
}),
Set maxSteps: 5 or higher for agents that need multiple tool calls.
Non-Negotiable Acceptance Criteria
Do not deliver the system prompt unless ALL of these are true:
Output Format
Deliver in this exact structure:
## System Prompt
[the generated system prompt, ready to copy-paste]
## Notes
- Model: [target model]
- Estimated tokens: [rough count]
- Dynamic fields (move to builder if needed): [list or "none"]
If dynamic context is needed, also provide the builder:
export function build[Name]Prompt({ ... }: Options): string {
return `[prompt with ${interpolations}]`.trim();
}
Quick Templates
Minimal chatbot
system: `You are [name], a [role] for [product].
You help with [topic]. You do not discuss [out-of-scope].
Keep responses concise and friendly.`
Classifier
system: `You are a content classifier.
Classify each input into exactly one of: [categories].
Base your decision only on the content — never infer.
If none fit, return "unclassified".
Respond with the category name only — no explanation.`
Code reviewer
system: `You are a [language] code reviewer.
Review for: correctness, security vulnerabilities, and performance.
Do NOT rewrite the code unless explicitly asked.
Format: numbered list. Each item: **Issue** / **Why** / **Suggestion**.`
Data extractor
system: `You are a data extraction specialist.
Extract only what is explicitly present in the text.
If a field is missing, return null — do not infer or guess.
Respond in JSON matching the provided schema.`