Large language models are only as good as the prompts you feed them. That sentence should hit different when you consider that developers are dropping serious cash on API calls to models like GPT-4, Claude, and Gemini—yet many are leaving massive performance gains on the table because they never learned how to actually talk to these systems. A practical rundown of eight core prompting techniques has been making the rounds among devs on DEV.to this week, and it's a reminder that prompt engineering isn't just for AI researchers anymore—it's a foundational skill for anyone shipping products with LLMs.

Zero-Shot Prompting: The Starting Point

Zero-shot prompting is the most basic approach: you give the model a task without any examples. You ask it to translate text, write code, or answer a question—and that's it. For straightforward tasks where the model's training data already covers what you need, zero-shot works fine. But here's where devs get burned: they assume this technique should handle everything. It won't. Zero-shot fails spectacularly when tasks require specific formats, domain knowledge, or nuanced reasoning that isn't obvious from the prompt alone.

Few-Shot Prompting: Teaching Through Examples

Few-shot prompting (also called in-context learning) solves the zero-shot limitation by including a handful of examples in your prompt. Instead of just asking 'Classify this review as positive or negative,' you show the model three or four labeled examples first. The model learns the pattern from those examples and applies it to your actual input. This technique is where most developers see their first meaningful performance jump—but there's a catch. More shots don't always help. After five to eight examples, you often hit diminishing returns, and sometimes you confuse the model with contradictory patterns.

Chain-of-Thought Prompting: Making Models Show Their Work

Chain-of-thought (CoT) prompting is where things get interesting for complex reasoning tasks. The technique involves adding 'let's think step by step' to your prompt, which nudges the model into breaking down its reasoning process rather than jumping straight to an answer. For math problems, logical puzzles, and multi-step analysis, CoT can dramatically improve accuracy. Researchers found that simply including those magic words—'let's think step by step'—unlocked better performance without any changes to the underlying model.

Zero-Shot Chain-of-Thought: Simpler Than It Sounds

Zero-shot CoT combines the simplicity of zero-shot with the reasoning power of chain-of-thought. You don't need examples; you just add a phrase like 'Think step by step' or ask it to 'Explain your reasoning.' The model generates intermediate steps that lead to a more considered answer. This is one of those techniques that's stupidly easy to implement but delivers outsized returns, especially for tasks where the right answer depends on following a logical sequence.

Self-Consistency: Voting on Better Answers

Self-consistency takes CoT a step further by generating multiple reasoning paths and then picking the most common final answer. You essentially ask the same question several times with slight variations, collect all the answers, and go with whatever the model converged on. It's like running a mini election among the model's own thought processes. This technique is computationally expensive—you're making multiple API calls—but for high-stakes applications where accuracy matters more than speed, it's worth considering.

Generated Knowledge: Feed Models Information They Might Be Missing

LLMs have knowledge cutoffs and can hallucinate when asked about niche topics. Generated knowledge prompting addresses this by having the model first produce relevant facts or context before answering your main question. You might ask it to 'list three key facts about PostgreSQL's query optimizer, then answer whether it handles subqueries efficiently.' The first step grounds the model's response in specific information rather than vague training data patterns.

Tree of Thoughts: Exploring Branching Reasoning Paths

For complex decision-making or creative problem-solving, tree of thoughts (ToT) prompting structures the model's exploration of different solution branches. Rather than a linear chain of reasoning, you encourage the model to consider multiple paths, evaluate each one, and backtrack when a path looks promising. This is more advanced and typically requires custom prompt templates, but it's powerful for applications like strategic planning or code architecture decisions where there's no single obvious answer.

Key Takeaways

  • Start with zero-shot for simple tasks—don't overcomplicate things unnecessarily
  • Use few-shot prompting when you need consistent formatting or domain-specific output patterns
  • Add 'step by step' reasoning phrases to any prompt involving multi-step analysis or math
  • Reserve self-consistency and tree of thoughts for high-value decisions where accuracy justifies the extra computation cost

The Bottom Line

Eight techniques sounds like a lot, but most developers will live in zero-shot, few-shot, and chain-of-thought for 90% of their work. The real insight here isn't that these methods exist—it's recognizing that prompt engineering is a legitimate skill with measurable impact on model performance. Stop treating your LLM calls as magic boxes and start treating them like APIs that need proper documentation: in this case, the docs are how you phrase your questions.