System Prompts: Common Pitfalls and Better Practices
What a system prompt actually does
A system prompt sets the assistant’s high-level role, rules, priorities, and operating context. It is usually sent separately from the user’s request, so the model can distinguish application instructions from task-specific input. For example, a customer-support assistant might be told to answer only about billing, use a concise tone, and ask for an account number when necessary.
However, a system prompt is not a guaranteed security boundary or a replacement for application logic. Models can misunderstand vague instructions, encounter conflicting messages, or be exposed to prompt injection through user-controlled content. Treat the prompt as one part of your system, alongside permissions, validation, logging, and output checks.
Common pitfall 1: Writing a vague role
“You are a helpful assistant” provides little operational guidance. It does not define what the assistant should prioritize, what it must refuse, or how its answer should be structured. Replace broad personality claims with observable behavior.
- State the assistant’s job and audience.
- Define what information it may use.
- Specify the desired format, tone, length, and language.
- Explain what to do when information is missing or uncertain.
A stronger instruction might say: “Answer product questions using the supplied documentation. If the documentation does not contain the answer, say that you cannot verify it and suggest contacting support. Use three short paragraphs at most.”
Common pitfall 2: Mixing permanent rules with changing data
Putting today’s inventory, user profile, or entire knowledge base into a permanent system prompt makes prompts expensive and difficult to maintain. Keep stable behavior in the system message, then pass changing facts in a clearly labeled user or context message. This also makes caching, debugging, and prompt versioning easier.
Do not place passwords, API keys, private tokens, or other secrets in a prompt. A model may reproduce or transform text that it receives. Use server-side access controls and tools that expose only the minimum data required for the task.
Common pitfall 3: Assuming instructions cannot be overridden
User input can contain text such as “ignore previous instructions” or disguised instructions inside a document, webpage, email, or search result. This is prompt injection. Tell the model how to treat retrieved or user-provided content: as data to analyze, not as instructions to follow.
For higher-risk workflows, separate untrusted content from control instructions, label it clearly, and require the model to quote or summarize it rather than execute commands found inside it. Enforce important decisions in code. For example, never rely on a model alone to authorize a refund, send an email, or grant access.
Common pitfall 4: Overloading the prompt with contradictory rules
Long prompts are not automatically better. Repeated requirements and exceptions can create ambiguity, consume context, and increase cost. Organize instructions in a predictable order: purpose, priorities, workflow, constraints, output format, and examples. If two rules can conflict, state which one wins.
Use positive, testable directions where possible. “Return valid JSON with the keys answer and confidence” is more useful than “Do not produce messy output.” Still validate the response in your application, because formatting instructions are not a substitute for a JSON parser or schema check.
Common pitfall 5: Failing to test across models
Claude Opus, Sonnet, Haiku, Fable, and GPT models can interpret the same wording differently. Before production, create a small evaluation set covering normal requests, ambiguous requests, malicious inputs, long context, missing data, and requests outside the assistant’s scope. Record accuracy, refusal quality, format compliance, latency, and token usage.
Version system prompts like code. Store the text in source control, review changes, and compare evaluation results before deployment. If you change the model, SDK, tools, or temperature, rerun the tests rather than assuming equivalent behavior.
Using system prompts cost-effectively
Keep the prompt concise, remove duplicated examples, and avoid sending irrelevant history. When building with Claude or GPT through an API, choose a smaller model for classification, extraction, and routine support, reserving more capable models for complex reasoning. 59API offers pay-as-you-go access to native Claude Opus, Sonnet, Haiku, Fable, and GPT models without a model downgrade, making it a practical low-cost option for testing and production traffic.
Its API base URL is https://api.59api.com, and it works with Claude Code, Codex, and OpenAI SDK-compatible applications. Developers can also use its referral rebate. If you want to try a cheaper relay while keeping access to official-quality models, sign up for 59API and start with a small evaluation workload.
¿Listo para empezar?
Conecta Claude y GPT en minutos a los precios más bajos, sin recortes. Regístrate para obtener tu clave API.
Registro gratis