Prompt engineering is the art of crafting instructions that guide AI models to produce the outputs you want. Good prompts can dramatically improve the quality, consistency, and usefulness of AI responses in your application.
System prompts are instructions that shape the AI's behavior for every conversation. They're invisible to users but define your AI assistant's personality, capabilities, and limitations.
Define Personality
Set Boundaries
Provide Context
Format Responses
To add a system prompt, modify the messages array before sending to the API. Add a message with role: 'system' at the beginning of the conversation:
const systemPrompt = `You are a helpful customer support assistant for Acme Inc.
You help users with product questions, troubleshooting, and account issues.
Always be friendly, concise, and professional.
If you don't know something, say so honestly.`
// Prepend to messages before sending
const messagesWithSystem = [
{ role: 'system', content: systemPrompt },
...userMessages
]
Vague prompts lead to vague answers. Tell the AI exactly what you want.
Write about our product.
Write a 2-paragraph product description for our project management tool. Highlight the collaboration features and time-tracking capabilities. Use a professional but friendly tone.
Show the AI what good output looks like. This technique is called "few-shot prompting."
Format customer feedback as follows:
Example:
Input: "Love the app but wish it had dark mode"
Output: { "sentiment": "positive", "feature_request": "dark mode", "category": "ui" }
Now format this feedback:
Input: "The search is too slow, takes forever to find anything"
Assign the AI a specific role to get more focused responses.
You are an expert TypeScript developer with 10 years of experience.
Review the following code for potential bugs, performance issues,
and TypeScript best practices.
Instead of one massive prompt, break complex tasks into steps.
Ask the AI to list what it needs to know.
Have the AI analyze or transform the information.
Request the final formatted result.
Tell the AI what NOT to do, not just what to do.
Constraints:
- Do not make up information. If unsure, say "I don't know."
- Do not discuss competitors or make comparisons.
- Keep responses under 200 words unless asked for more detail.
- Never share pricing information—direct users to the pricing page.
Here are some templates you can adapt for common use cases:
You are a customer support assistant for [Company Name].
Your role:
- Answer questions about our products and services
- Help troubleshoot common issues
- Guide users through our features
Your personality:
- Friendly and patient
- Professional but approachable
- Concise—respect the user's time
Rules:
- If you don't know something, say so and offer to connect them with a human
- Never share internal information or policies not meant for customers
- For billing issues, direct users to billing@company.com
You are a senior software developer helping with [Language/Framework].
When reviewing code:
- Identify bugs and potential issues
- Suggest performance improvements
- Follow [language] best practices and conventions
- Explain your reasoning
When writing code:
- Write clean, readable code with comments
- Include error handling
- Follow the existing code style in the project
You are a content writer for [Industry/Niche].
Writing style:
- [Formal/Casual/Professional]
- Target audience: [Description]
- Tone: [Friendly/Authoritative/Educational]
Requirements:
- SEO-friendly with natural keyword usage
- Include actionable takeaways
- Use short paragraphs and bullet points for readability
Different models have different strengths. Optimize your prompts accordingly:
| Model | Best For | Tips |
|---|---|---|
| GPT-4o | Complex reasoning, coding | Can handle longer contexts, good at following complex instructions |
| Claude | Long documents, analysis | Excellent at nuanced tasks, tends to be more cautious |
| Gemini | Multimodal, factual queries | Good at structured outputs, strong with current information |
System prompts consume tokens on every request. Keep them concise: