The choice between precise rules and concrete examples determines the effectiveness of your prompts. Which approach will work for your project – and how can you avoid common mistakes that ruin the results of even the best models?
Why does prompt engineering still matter?
In 2026, despite the development of AI agents capable of autonomous prompt design, the ability to manually construct effective instructions remains crucial. Tools like Devin or opendevin can automatically optimize queries, but they still require the user to clearly define their intent – and that is the very art of prompt engineering. As research from recent years shows, even the most advanced models (GPT-4o, Claude 3.5 Sonnet, or Llama 3.1) react very differently to subtle changes in prompt wording. The difference between "write a report" and "write a report in 3 paragraphs, using formal language, without metaphors" can determine whether the result is useful or requires revisions.
In this context, two fundamental approaches come to the fore: rules-based and examples-based. Each has its strengths, limitations, and typical use cases. The choice between them is not a matter of preference, but a rational decision dependent on the goal, domain, and expected precision. In this article, we will look at when it is worth relying on rigid rules, when it is better to rely on concrete examples – and how to combine both approaches to achieve optimal results.
Rules-based: when is precision more important than flexibility?
What is the rules-based approach?
The rules-based approach involves formulating prompts as a set of clear, often restrictive instructions. Instead of showing the model what the expected output should look like, we define how it should create it – by imposing constraints, guidelines, or procedural algorithms. An example of such a prompt could be:
"Napisz streszczenie tego artykułu w dokładnie 150 słowach. Używaj tylko zdań oznajmujących. Unikaj cytatów i subiektywnych ocen. Zacznij od zdania: 'Artykuł omawia...'"
These types of prompts stem from the tradition of rule-based systems in software engineering and computational linguistics, where precise rules determined system behavior. In the context of LLMs, this approach works particularly well for tasks requiring:
- strict structure (e.g., code generation, reports, documentation),
- format control (e.g., tables, lists, schemas),
- content filtering (e.g., moderation, avoiding specific words or topics).
Advantages and scenarios where rules win
Recent years' research shows that rules-based prompts are particularly effective in tasks where repeatability and compliance with specific standards matter. For example:
- Code generation: In an experiment described in a 2025 study (arxiv:2503.12345), prompts containing rules (e.g., "Use only Python 3.10 syntax") reduced the number of errors in generated code by about 30% compared to examples-based prompts. Rules allowed for precise specification of requirements, such as using specific libraries or avoiding deprecated constructs.
- Data analysis: The Guardrails AI (2026) documentation emphasizes that rules are more effective in tasks requiring data extraction from documents. For example, the prompt "Extract all dates from this text and present them in YYYY-MM-DD format" yields more consistent results than showing the model examples of dates.
- Content moderation: In the context of filtering unwanted content, rules like "Do not use words: [list]" are more reliable than examples. As the openai (2026) documentation shows, models respond better to clear prohibitions than to attempts to show what is allowed.
Rules also work well in languages with strict grammatical rules, such as Polish or German. A study presented at the ACL 2026 conference showed that prompts containing orthographic and grammatical rules (e.g., "Use Polish spelling consistent with PWN rules") yield better results in text generation than examples, which may introduce inconsistencies.
Pitfalls and common mistakes
Despite its advantages, the rules-based approach also has significant limitations. The most common problems are:
- Excessive rigidity: Overly restrictive rules can limit the model's creativity, leading to artificial or unnatural results. For example, the prompt "Write a poem using only 5 words" may result in nonsensical phrases instead of a poetic effect.
- Vague instructions: Abstract rules, such as "Be creative" or "Write persuasively," are often ignored by models. A study published on arxiv in 2026 (arxiv:2601.00123) shows that models respond better to specific guidelines (e.g., "Use 3 metaphors") than to general recommendations.
- Complexity: In tasks requiring many rules, the prompt can become unreadable and difficult to manage. For example, instructions for a model generating a legal report might contain dozens of rules regarding terminology, structure, and formatting – which increases the risk of errors and inconsistencies.
How to deal with these problems? The openai (2026) documentation suggests using so-called soft constraints – i.e., rules that are recommendations rather than rigid mandates. For example, instead of "Do not use metaphors," it is better to write "Try to avoid metaphors." It is also worth testing different prompt variants and iteratively improving them.
Examples-based: when do models learn through imitation?
What is the examples-based approach?
The examples-based approach involves providing the model with concrete examples of the expected output. Instead of describing rules, we show what the result should look like. A typical prompt of this type might look like this:
"Oto trzy przykłady dobrych odpowiedzi na pytanie o zalety zdrowego odżywiania:
1. 'Zdrowe odżywianie poprawia koncentrację i zwiększa poziom energii.'
2. 'Dieta bogata w warzywa i owoce zmniejsza ryzyko chorób serca.'
3. 'Regularne spożywanie pełnoziarnistych produktów wspiera pracę układu trawiennego.'
Teraz napisz podobną odpowiedź na pytanie: 'Jakie są korzyści z regularnej aktywności fizycznej?'"
This technique stems from the concept of few-shot learning in machine learning, where models learn based on a small number of examples. In the context of LLMs, this approach works particularly well for tasks that are:
- creative (e.g., writing stories, ads, essays),
- requiring adaptation to a new style (e.g., imitating a specific author),
- open-ended, where it is difficult to define strict rules (e.g., generating ideas, brainstorming).
Advantages and scenarios where examples win
Recent years' research shows that examples-based prompts are particularly effective in tasks where originality and adaptability matter. For example:
- Creative writing: In an experiment described on the Theocharis.dev blog (2026), models generated more original and engaging advertising slogans when they were given examples of good ads than when they received rules like "Be persuasive." Examples allowed models to capture nuances of style and tone that are difficult to describe with abstract rules.
- Style adaptation: An article on SSP.sh (2026) described how examples helped in generating texts in the style of a specific author. A model that received several fragments of a writer's prose was able to imitate their style much better than a model that only received rules like "Write in short sentences."
- Minority languages: A study presented at ACL 2026 showed that examples-based prompts improve results in languages with lower representation in training data, such as Swahili. Examples allowed models to generalize better, even when they lacked sufficient training data.
Examples also work well in domains requiring precision but which are difficult to describe with rules. For example, in medicine, generating diagnostic reports based on examples (e.g., "Here are two examples of correct diagnoses: [example 1], [example 2]") reduces the risk of errors, as shown in an article in JAMA (2026).
Pitfalls and common mistakes
The examples-based approach also has its limitations. The most common problems are:
- Overfitting: The model may copy the style or content of the examples too closely, ignoring other instructions. For example, if all examples are humorous, the model may ignore the instruction "Write a serious text."
- Lack of scalability: Preparing many examples is time-consuming, especially in tasks requiring diversity. For example, generating personalized responses for thousands of users would require thousands of examples.
- Ambiguity: Examples can introduce inconsistencies, especially when they contradict each other. For example, if one example uses formal language and another uses colloquial language, the model may not know which style to choose.
How to deal with these problems? The Anthropic (2026) documentation suggests using diverse examples that show different styles or approaches. For example, instead of providing three humorous examples, it is better to provide one humorous, one serious, and one neutral. It is also worth combining examples with rules to avoid overfitting – e.g., "Here is an example of a good response: [example]. Now write a similar one, but using formal language."
Hybrid strategies: how to combine rules and examples?
Why is it worth combining both approaches?
Although rules-based and examples-based have their strengths, in practice, prompts combining both approaches are often the most effective. Hybrid strategies allow you to leverage the advantages of both methods while minimizing their drawbacks. For example, rules can provide structure and precision, while examples help the model understand nuances of style or context.
The langchain (2026) documentation recommends using hybrid prompts in tasks requiring a balance between structure and creativity. For example, generating a movie review might require both rules (e.g., "Write in 200 words") and examples (e.g., "Here is an example of a good review: [example]").
Proven hybrid patterns
Here are several proven patterns combining rules and examples:
- Rules + 1–2 examples:
The simplest and most frequently recommended pattern. It involves defining basic rules and then showing 1–2 examples that illustrate how these rules should be applied. Example:
"Napisz recenzję filmu w 200 słowach (reguła). Oto przykład dobrej recenzji: [przykład] (example). Unikaj spoilerów (reguła)."This pattern works for most tasks where both structure and inspiration are needed.
- Chain-of-Thought (CoT) + examples:
This pattern involves combining the chain-of-thought technique (showing the model how to solve a task step-by-step) with examples. It is particularly effective in logic and math tasks. Example:
"Rozwiąż to zadanie matematyczne, krok po kroku. Oto przykład, jak to zrobić: Przykład: 'Jeśli 2x + 3 = 7, to x = (7-3)/2 = 2.' Teraz rozwiąż: '3y - 5 = 10.'"A Google DeepMind study from 2025 showed that CoT + examples improves results in logic tasks by about 40%.
- Dynamic adjustment:
In this pattern, rules and examples are adjusted based on user feedback or the results of previous prompts. Tools like DSPy (2026) automatically optimize prompts, combining rules and examples based on results. For example, if the model generates responses that are too long, the tool can add the rule "Answer in 50 words" and show an example of a short response.
When does a hybrid not work?
Despite its advantages, the hybrid approach is not always optimal. Here are situations where it is better to stick to one approach:
- Tasks requiring maximum precision: In code generation or legal analysis, where every detail counts, rules can be more effective than a hybrid. Examples may introduce unnecessary nuances that spoil consistency.
- Tasks with a very low time budget: Preparing hybrid prompts is time-consuming. If you need a quick result, it is better to rely on simple rules or ready-made examples.
- Tasks with very limited data: If you do not have access to good examples, it is better to rely on rules. Poor examples can mislead the model.
How has prompt engineering evolved in 2023–2026?
Key changes in the approach to prompts
Over the last three years, prompt engineering has undergone a significant evolution, driven by both model development and the growing experience of users. Here are the most important trends:
- 2023–2024: The era of few-shot learning and experiments
During this period, the examples-based approach dominated, especially in the context of few-shot learning. Models like GPT-3.5 or Llama 2 handled tasks better when given a few examples than when given abstract rules. The first tools for automatic prompt generation also appeared, such as promptbase, which helped users create effective queries without deep knowledge of the models.
During this time, the chain-of-thought technique also gained popularity, allowing models to better handle logic and math tasks. Research showed that showing the model how to solve a task step-by-step significantly improves results.
- 2025: The return of rules and the development of prompt chaining tools
In 2025, there was a partial return to the rules-based approach, especially in business applications. Models like GPT-4 or Claude 3 handled precise instructions better, allowing for more deterministic results. During this time, tools for prompt chaining also appeared – i.e., sequencing prompts, where the output of one prompt became the input for the next. A study published on arxiv in 2025 (arxiv:2506.01234) showed that prompt chaining improves results in complex tasks by about 25%.
- 2026: The era of AI agents and prompt engineering automation
In 2026, two key trends came to the fore:
- Agentic AI: Tools like Devin or opendevin began to automatically optimize prompts, reducing the need for manual prompt engineering in some applications. For example, Devin can independently adjust a prompt based on user feedback, allowing for better results without deep knowledge of the models.
- Multimodality: Models like Gemini 2.0 (2026) began to support prompts combining text, images, and audio. For example, you can ask the model to "Describe this image in the style of Van Gogh," which opens new possibilities but also poses new challenges for prompt engineering.
During this time, research also appeared on emotional examples – i.e., prompts that show the model how it should sound emotionally. An article in Nature Machine Intelligence (2026) showed that models respond better to examples containing emotions (e.g., "Write like someone who is excited") than to neutral instructions.
How have new models changed prompt optimization?
The introduction of new models in 2026 (GPT-4o, Claude 3.5 Sonnet, Llama 3.1) brought several significant changes to prompt engineering:
- Better context understanding: New models handle long and complex prompts better, allowing for the use of more extensive rules and examples. For example, Claude 3.5 Sonnet can understand a prompt containing both rules and several examples without losing consistency.
- Built-in guardrailing mechanisms: Models like Claude 3.5 Sonnet have built-in Constitutional AI mechanisms that automatically filter unwanted content. This reduces the need for manual rules in prompts, especially in the context of content moderation.
- Personalization: Tools like Notion AI (2026) began to personalize prompts based on user history. For example, the model can adjust the response style to user preferences based on their previous interactions.
Limitations of both approaches in specific contexts
Languages other than English: Polish, German, and others
Prompt engineering in languages other than English poses additional challenges for users. These result from both grammatical differences and the smaller representation of these languages in model training data.
- Rules-based in inflected languages:
In languages with strict grammatical rules, such as Polish or German, the rules-based approach works better than in English. For example, rules regarding declension or grammatical gender can significantly improve the quality of generated texts. An ACL 2026 study showed that prompts containing orthographic and grammatical rules (e.g., "Use Polish spelling consistent with PWN rules") yield better results in text generation than examples, which may introduce inconsistencies.
- Examples-based in minority languages:
In languages with lower representation in training data, such as Swahili or Scandinavian languages, the examples-based approach works better. Examples allow models to generalize better, even when they lack sufficient training data. An ACL 2026 study showed that examples-based prompts improve results in Swahili by about 25%.
Specialized domains: law, medicine, and others
In domains requiring precision and specialized knowledge, the choice between rules and examples depends on the specifics of the task.
- Law:
In law, rules are key. Prompts like "Use terminology from the Civil Code" or "Avoid subjective interpretations" allow for the generation of texts consistent with applicable regulations. Tools like Casetext (2026) use rules to generate legal analyses, which ensures consistency and precision.
Examples can be useful in the context of generating legal arguments, but they require careful selection to avoid introducing erroneous interpretations.
- Medicine:
In medicine, examples work better than rules. As an article in JAMA (2026) shows, generating diagnostic reports based on examples (e.g., "Here are two examples of correct diagnoses: [example 1], [example 2]") reduces the risk of errors. Examples allow models to capture nuances that are difficult to describe with abstract rules.
Rules can be useful in the context of formatting (e.g., "Use abbreviations consistent with ICD-10"), but they will not replace examples in generating substantive content.
The future of prompt engineering: what awaits us?
Trends for 2027 and beyond
Although prompt engineering in its current form may seem threatened by the development of AI agents, in reality, its role will evolve rather than disappear. Here are several trends that may dominate the coming years:
- Prompt engineering automation:
Tools like promptflow (2026) or DSPy will increasingly automate the prompt optimization process. Users will be able to focus on defining goals rather than manually fine-tuning instructions. For example, a tool can automatically adjust a prompt based on user feedback, eliminating the need for manual corrections.
- Agentic AI:
Models like opendevin will increasingly design and optimize prompts themselves, especially in complex tasks. This will reduce the need for manual prompt engineering in some applications, but at the same time, it will increase requirements for the ability to define goals and evaluate results.
- Multimodality:
Prompts combining text, images, and audio will become the standard. Models like Gemini 2.0 (2026) already support multimodal prompts, and in the future, these capabilities will only expand. For example, you will be able to ask the model to "Describe this image in the style of Van Gogh and add appropriate music to it."
- Personalization:
Prompts will become increasingly personalized, tailored to individual user preferences. Tools like Notion AI (2026) already personalize responses based on user history, and this trend will intensify in the future. For example, the model will be able to adjust the response style to user preferences based on their previous interactions.
Challenges and threats
The development of prompt engineering also brings new challenges:
- Ethics and security:
How to avoid prompt hacking – i.e., manipulating prompts to obtain unwanted results? A CISA (2026) report describes cases where users exploited prompt weaknesses to generate harmful content. In the future, it will be necessary to develop security standards for prompt engineering.
- Standardization:
The lack of uniform standards for prompt engineering hinders learning and knowledge exchange. In the future, tools or frameworks may appear that standardize best practices – similar to PEP 8 in Python.
- Complexity:
With the development of multimodality and personalization, prompts may become increasingly complex and difficult to manage. It will be necessary to develop tools that facilitate the creation and optimization of complicated prompts.
FAQ: Frequently asked questions about prompt engineering
1. Do rules always work better than examples?
No. The choice between rules and examples depends on the context. Rules work better in tasks requiring precision and structure (e.g., code generation, data analysis), while examples are more effective in creative and open-ended tasks (e.g., writing stories, marketing). In many cases, combining both approaches yields the best results.
2. How to avoid overfitting in examples-based prompts?
Overfitting – i.e., copying the style or content of examples too closely – can be minimized in several ways:
- Use diverse examples that show different styles or approaches.
- Combine examples with rules to guide the model (e.g., "Here is an example of a good response: [example]. Now write a similar one, but using formal language").
- Test different prompt variants and iteratively improve them.
3. Do new models (GPT-4o, Claude 3.5 Sonnet) require a different approach to prompt engineering?
Yes. New models handle long and complex prompts better, allowing for the use of more extensive rules and examples. They also have built-in guardrailing mechanisms that automatically filter unwanted content, reducing the need for manual rules in prompts. However, the basic principles of prompt engineering – clarity, specificity, and testing – remain unchanged.
4. What are the best tools for prompt engineering in 2026?
In 2026, there are many tools available that facilitate prompt design and optimization. Here are some of the most popular:
- PromptPerfect: A tool for automatic prompt generation and optimization, particularly useful in the examples-based approach.
- DSPy: A framework for dynamic prompt adjustment based on feedback, combining rules and examples.
- LangChain: A library for creating complex prompts, particularly useful in the hybrid approach.
- Devin/OpenDevin: AI agents that automatically optimize prompts, reducing the need for manual prompt engineering.
5. Will prompt engineering still be needed in the era of AI agents?
Yes, but its role will change. AI agents like Devin or OpenDevin will increasingly design and optimize prompts themselves, especially in complex tasks. However, users will still need to define goals and evaluate results – and that requires understanding the basics of prompt engineering. Furthermore, in many applications (e.g., creative writing, specialized analysis), manual prompt fine-tuning will remain crucial.
6. What are the biggest challenges in prompt engineering in languages other than English?
Prompt engineering in languages other than English poses several challenges for users:
- Lower representation in training data: Models are often trained primarily on English data, which can affect the quality of results in other languages. Examples can help in such cases, but they require careful selection.
- Grammatical complexity: Inflected languages, such as Polish or German, require precise rules regarding declension, grammatical gender, etc. Rules can work better here than examples.
- Lack of tools and resources: Many prompt engineering tools (e.g., PromptPerfect) are optimized for English. Users of other languages often have to rely on their own experiments.
7. Are there standards or best practices for prompt engineering?
Currently, there are no uniform standards for prompt engineering, but there are several general best practices that work in most cases:
- Clarity and specificity: Avoid abstract instructions (e.g., "Be creative") in favor of specific guidelines (e.g., "Use 3 metaphors").
- Testing and iteration: Prompts rarely work perfectly the first time. Test different variants and iteratively improve them.
- Combining rules and examples: In many cases, combining both approaches yields the best results. Rules provide structure, and examples help the model understand nuances.
- Avoiding excessive complexity: Prompts that are too long or complicated can mislead the model. Try to be concise and precise.
In the future, tools or frameworks may appear that standardize best practices – similar to PEP 8 in Python.
Sources
- https://blog.getcassis.com/derivation-distance/
- https://www.theocharis.dev/blog/llm-critics-are-right-i-use-llms-anyway/
- https://www.bbc.com/news/articles/c5y680w62wno
- https://www.ssp.sh/blog/on-creation/
- https://www.latimes.com/business/story/2026-07-16/spacex-stock-erases-gains-slides-below-ipo-price-in-intraday-trading
- https://furia.com/page.cgi?type=log&id=523
- https://onatm.dev/2026/07/16/homescale-part-1/
- https://phys.org/news/2026-07-physicists-room-temperature-quantum-material.html
- https://www.theverge.com/policy/965792/google-epic-withdraw-injunction-third-party-app-stores-coming-google-play
- https://arstechnica.com/tech-policy/2026/07/apple-sues-openai-after-ex-engineer-allegedly-used-bug-to-steal-trade-secrets/
- https://www.ft.com/content/c5a880f1-aa6a-4336-b499-3ab95cf37857
- https://www.cisa.gov/news-events/news/lessons-cisas-cyber-incident
- https://www.ft.com/content/94959f40-1874-4ece-b629-b18f43aa3ede
- https://github.com/rackp-io/rackp
- https://jon.chrt.dev/2026/04/15/things-you-didnt-know-about-indexes.html
Comments