tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Generative AI > Prompt Engineering > System Prompts - How to Write Effective Instructions for LLMs

System Prompts - How to Write Effective Instructions for LLMs

Author: Venkata Sudhakar

A system prompt is a special message sent to an LLM before the conversation begins that sets its persona, constraints, output format, and behaviour for the entire session. The user never sees it - it is the developer's backstage instruction to the model. A well-written system prompt is the single most impactful thing you can do to improve LLM output quality and consistency. It tells the model who it is, what it knows, what format to use, and what it should never do - turning a general-purpose LLM into a focused, reliable application component.

System prompts work because LLMs are trained to follow instructions. When you write "You are a data migration expert. Always respond with specific tool names and version numbers", the model brings that context to every answer in the session. Without it, the model behaves as a generic assistant. The key components of a strong system prompt are: role and persona (who the model is), task context (what it is helping with), output format (how to structure responses), constraints (what to avoid), and examples where needed. Keep it focused - a 200-word system prompt that is specific outperforms a 2000-word prompt full of vague instructions.

The below example shows the same user question answered with a weak system prompt vs a strong one, demonstrating the dramatic difference in output quality.


It gives the following output,

=== WEAK SYSTEM PROMPT ===
Migrating stored procedures from MySQL to PostgreSQL can be challenging because
the two databases use different procedural languages. You should review your
stored procedures carefully and make necessary adjustments. Consider using
migration tools to help automate the process.

=== STRONG SYSTEM PROMPT ===
Root cause: MySQL stored procedures use PL/SQL-like syntax incompatible with
PostgreSQL PL/pgSQL - particularly DELIMITER, IF...THEN syntax, and MySQL-specific
functions like NOW() vs CURRENT_TIMESTAMP.

Steps:
1. Run AWS SCT to auto-convert procedures - handles ~70% automatically
2. For remaining failures, use ora2pg --type PROCEDURE to export and manually
   fix DELIMITER, SIGNAL/RESIGNAL -> RAISE EXCEPTION, and IFNULL -> COALESCE
3. Test each procedure with pgTAP unit tests before cutover

Gotcha: PostgreSQL functions must have explicit RETURN types - MySQL does not require this.

It gives the following output,

Risk: CRITICAL
Hours: 480
Blockers: ["2-week timeline is insufficient for 150 stored procedures",
           "Team lacks Oracle migration experience",
           "24/7 availability requirement limits maintenance windows"]
Advice: Extend timeline to 12 weeks, hire an Oracle DBA consultant, and
        implement blue-green deployment for zero-downtime cutover.

System prompt best practices: be specific about output format (JSON, bullet list, paragraph) and the model will follow it reliably. Use explicit constraints ("never say I don't know - always give the closest answer") rather than vague ones ("be helpful"). Include 1-2 examples inline when the output format is unusual. Test your system prompt with edge cases: what happens when the user asks something off-topic? Add a constraint for that. Version control your system prompts as code - they are as important as your application logic.


 
  


  
bl  br