home/roleplay/prompt-techniques-2

Prompt Techniques

GPTClaudeGemini··401 copies·updated 2026-07-14
prompt-techniques-2.prompt
# Section 4: Prompting Techniques -- From Zero-Shot to Production Patterns

[Section 3: Prompting](03-prompting.md) covered the anatomy of a good prompt, the
CO-STAR framework, and the 26 principles of effective prompting. This section goes
deeper into **prompting techniques** that control how much guidance you give the
model before it produces output — plus **best practices** for output contracts,
model-specific tuning, anti-patterns, and production patterns.

The first four techniques — zero-shot, one-shot, few-shot, and chain-of-thought —
are foundational. The next three — ask-me-anything, least-to-most, and directional
stimulus — are advanced techniques from recent research. Five more — zero-shot CoT,
self-consistency, tree of thoughts, ReAct, and prompt chaining — cover reasoning
boosts and agent workflows.

Understanding these techniques lets you choose the right level of scaffolding
for every task — from a quick "generate a getter" (zero-shot) to a complex
"debug this N+1 query step by step" (chain-of-thought with few-shot examples)
to a multi-perspective architecture review (ask-me-anything).

All examples in this section use the same Java 21 / Spring Boot 3.5 / Spring
Data JDBC stack described in the course's Target Stack.

| Section | Topic |
|---------|-------|
| [Anatomy of a Prompt](03-prompting.md#anatomy-of-an-effective-prompt) | Role, Task, Context, Format (Section 3) |
| [Five Universal Principles](#five-universal-principles) | Core rules for every prompt |
| [Zero-Shot](#zero-shot-prompting) | Task only, no examples |
| [One-Shot](#one-shot-prompting) | One example to guide format |
| [Few-Shot](#few-shot-prompting) | Multiple examples for pattern |
| [Chain-of-Thought](#chain-of-thought-prompting) | Step-by-step reasoning |
| [Zero-Shot CoT](#zero-shot-cot) | "Think step by step" |
| [Self-Consistency](#self-consistency) | Sample multiple reasoning paths |
| [Tree of Thoughts](#tree-of-thoughts-tot) | Explore multiple reasoning branches |
| [ReAct](#react) | Interleaved reasoning and action |
| [Prompt Chaining](#prompt-chaining) | Output feeds next prompt |
| [Ask-Me-Anything (AMA)](#ask-me-anything-ama-prompting) | Model asks clarifying questions |
| [Least-to-Most](#least-to-most-prompting) | Decompose into sub-problems |
| [Directional Stimulus](#directional-stimulus-prompting) | Hint to guide output direction |
| [Combining Techniques](#combining-techniques-real-world-patterns) | Real-world mix patterns |
| [Generic Technique Combinations](#generic-technique-combinations) | Pairwise technique combos |
| [Choosing the Right Technique](#choosing-the-right-technique) | Decision framework |
| [Output Contracts](#output-contracts) | Structure, XML delimiters, verification |
| [Model-Specific Tips](#model-specific-tips) | Claude, GPT, reasoning models |
| [Anti-Patterns](#anti-patterns-to-avoid) | 7 common mistakes |
| [Advanced Patterns](#advanced-and-production-patterns) | RAG, caching, versioning |
| [Examples](08-prompt-examples.md) | Copy-paste Java prompts (Section 8) |

---

### Why it matters

A poorly written prompt of the same underlying intent can drop accuracy by 30–50% compared to a well-structured one. At scale (production APIs, agent pipelines, automated workflows), this difference directly translates to cost, reliability, and user trust.

> **Context engineering:** At scale, the focus shifts beyond individual prompts to
> assembling the right context — retrieved documents, conversation history, tool
> definitions, and structured examples — at the right moment. See
> [Section 6: Context](06-context.md).

---

Every technique example below uses **Role / Task / Context / Format**.
For the full 4-Block framework, CO-STAR mapping, and worked examples, see
[Section 3: Anatomy of an Effective Prompt](03-prompting.md#anatomy-of-an-effective-prompt).

---



> The **4-Block Framework** complements the CO-STAR mnemonic from
> [Section 3](03-prompting.md). Use both: CO-STAR for structure, 4-Block for
> quick audits.

---

## Five Universal Principles

These principles apply across all major LLMs and task types. They are distilled from the [26 Principles in Section 3](03-prompting.md#the-26-principles-of-effective-prompting): be explicit (not verbose), show don't tell, constrain output format, keep critical instructions at the top, and start simple then expand only to fix gaps.

**Examples:** [08-prompt-examples.md](08-prompt-examples.md#from-section-4-prompt-techniques)

---

## Technique Overview

## Prompting Techniques

| Technique | Best for | Complexity |
|-----------|----------|------------|
| Zero-Shot | Simple tasks, frontier models | Low |
| Few-Shot | Format/pattern consistency | Low |
| Chain-of-Thought | Math, logic, multi-step reasoning | Medium |
| Zero-Shot CoT | Quick reasoning boost | Low |
| Self-Consistency | High-stakes, accuracy-critical answers | Medium |
| Tree of Thoughts | Complex planning, search problems | High |
| ReAct | Agent loops, tool use | High |
| Prompt Chaining | Long multi-step workflows | Medium |


The sections below cover zero-shot through directional stimulus in depth (with Java
examples). [Zero-Shot CoT](#zero-shot-cot), [Self-Consistency](#self-consistency),
[Tree of Thoughts](#tree-of-thoughts-tot), [ReAct](#react), and
[Prompt Chaining](#prompt-chaining) follow after chain-of-thought.

---

## Zero-Shot Prompting

Zero-shot prompting gives the model **only instructions** -- no examples of the
desired output. The model relies entirely on its training data to decide format,
style, and structure.

when to use it

Community prompt sourced from the open-source GitHub repo gzheyts/ai-tools (no explicit license). A "Prompt Techniques" style prompt — adapt the placeholders and specifics to your task. Imported as-is and not independently retested here, so check the output before relying on it.

tags

roleplaycommunitygeneral

source

gzheyts/ai-tools · no explicit license