AI Foundations
Prompt Engineering: A Practical Guide to Writing Effective Prompts
What prompt engineering is and why it matters
A large language model predicts the most likely next word based on your input. The prompt is therefore the main control: it determines which slice of learned knowledge the model activates and in what form it answers. Prompt engineering is the systematic practice of shaping those inputs so the output becomes useful, consistent and verifiable.
The payoff is concrete: depending on wording, the same question can yield a vague general answer or a directly usable work product. Good prompting is therefore not niche expertise but a core skill for anyone working with tools such as ChatGPT, Claude or Gemini.
The anatomy of an effective prompt
Most strong prompts can be broken into six building blocks. Not all are needed every time, but the more demanding the task, the more of them pay off.
- Role: assign the model a perspective, e.g. 'You are an experienced Swiss tax advisor.' This sharpens vocabulary and level of detail.
- Context: supply background, audience and purpose. 'For new clients of an SME who have never worked with AI.'
- Task: state the goal as a clear verb. 'Summarise', 'compare', 'draft' rather than a vague question.
- Examples: show one or two samples of the desired output (few-shot). Examples often work better than explanations.
- Constraints: set limits on length, tone, language or what to avoid. 'Max 150 words, neutral tone, no jargon.'
- Output format: request a concrete structure, e.g. table, bullet list, JSON or a fixed section layout. This makes answers easy to reuse.
Proven patterns for stronger prompts
Beyond the building blocks, a few patterns have become established and demonstrably help depending on the task.
- Zero-shot vs. few-shot: no example (zero-shot) often suffices for simple tasks; two or three examples (few-shot) markedly improve consistency for formats and classification.
- Step-by-step reasoning (chain-of-thought): ask the model to structure its reasoning before giving the answer. This helps with logic, arithmetic and multi-step tasks.
- System and role prompt: many tools let you set a persistent system prompt that fixes tone and rules for the whole session, saving repetition.
- Decompose the task: instead of one giant prompt, run several smaller steps in sequence. Intermediate results can be checked and corrected.
- Provide a reference text: for factual answers, paste the source into the prompt and instruct the model to answer only from it. This principle also underlies retrieval-augmented generation (RAG).
Common mistakes and how to avoid them
- Too vague: 'Write something about marketing' yields anything. State audience, purpose, scope and format.
- Multiple goals in one sentence: mixed tasks produce muddled answers. Separate subtasks clearly or number them.
- No output format: without a spec you get prose one time, a list the next. Ask for structure explicitly.
- Taking hallucinations as fact: models can invent convincing falsehoods. Ask for sources and verify key facts independently.
- Overrating negations: 'Don't write too long' is weaker than 'max 120 words.' Phrase limits positively and measurably.
- Pasting sensitive data: personal data or trade secrets belong in a prompt only if the legal basis and provider terms allow it.
A practical workflow: iterate toward a good prompt
Treat prompting as a loop, not a one-shot attempt. A reliable routine looks like this:
- 1. Write a base prompt with role, task and format. 2. Review the output critically: what is missing or wrong? 3. Change exactly one thing per round so you can see its effect. 4. Save working versions as templates and reuse them.
- Use the model as a partner: have it critique your prompt or ask clarifying questions before answering ('Ask me if anything is unclear').
Data protection and the Swiss context
Prompts are inputs to an external service. In Switzerland the revised Data Protection Act (revDSG/nFADP) applies, supervised by the FDPIC (EDÖB). Anyone entering personal data into an AI tool needs a legal basis, must know the processing purpose, and should check whether inputs are used for training or transferred abroad.
Practical rule of thumb: anonymise or pseudonymise data before entry, prefer business accounts with a contractual no-training guarantee where possible, and document internal prompting guidelines. That keeps prompt engineering both productive and legally sound.
Frequently asked questions
What is the difference between zero-shot and few-shot prompting?
Zero-shot gives only the instruction with no example; that suffices for simple, unambiguous tasks. Few-shot adds two or three examples of the desired input and output. This noticeably improves consistency, especially for fixed formats, classification or a specific style.
How do I stop the model from making things up?
Hallucinations cannot be fully eliminated but can be greatly reduced: provide a reference text and instruct the model to answer only from it. Explicitly allow an 'I don't know' answer. Ask for sources and verify key facts independently before relying on them.
Do I need a different prompt for each AI model?
The core principles, role, context, clear task, examples and format, apply across models. Details differ, however: context window, handling of system prompts and format instructions vary between ChatGPT, Claude, Gemini and others. Test important prompts per model and adjust the details.
What is a system prompt and when should I use it?
A system prompt sets persistent rules, role and tone for an entire session or application, before the actual user question arrives. Use it when the framing repeats, such as a customer-service assistant with a fixed tone, fixed limits and a consistent output format.
May I enter customer data into a prompt?
Only under conditions. In Switzerland the revDSG requires a legal basis and a clear purpose, supervised by the FDPIC (EDÖB). Check the provider terms on whether inputs are used for training or transferred abroad. Anonymise data where possible and use business accounts with a contractual no-training clause.
How long should a good prompt be?
As short as possible, as long as necessary. Simple tasks need one or two sentences. Demanding tasks benefit from more structure: role, context, examples and format. What matters is precision, not word count. Avoid filler and contradictory instructions that confuse the model.
Key terms in the glossary
Practical AI for your business
From idea to implementation – we show you what is concretely possible in your case.
Request a demo