Skip to content

JPeetz/agent-skills / skills/ai-agent-engineering/prompt-engineering-concepts

prompt-engineering-concepts

Verified

Use this skill when choosing or fixing a prompt — the 20 core techniques (zero-shot, few-shot, chain-of-thought, role, instruction, output formatting, temperature, chaining, self-consistency, RAG, templates, guardrails, dynamic, ReAct, tree-of-thought, compression, multi-modal, JSON mode, evaluation, optimization) mapped to when each earns its tokens, with the exact prompt move, a selection path for time-pressured cases, and the eight pitfalls that make prompts fail.

Prompt Engineering — The 20 Core Concepts

Which prompting technique to reach for, why, and the exact move — as a selection table rather than an essay. This skill is the choosing layer; it does not cover production hardening (5-layer prompt anatomy, quality scoring, A/B discipline, injection defense, per-platform delimiter conventions) or judge calibration — that is agentic-eval's and prompt-injection-defense's territory.

When to Use

  • Writing or rewriting a system prompt, skill body, or long task prompt
  • A prompt produces vague, unreliable, or unusable output and you need a specific fix
  • Choosing between zero-shot, few-shot, chain-of-thought, tree-of-thought, or ReAct
  • Designing tool-use loops or multi-stage agent workflows
  • Debugging inconsistent output, runaway token cost, or broken JSON output
  • Don't use for: single-turn factual questions, injection/safety hardening (prompt-injection-defense), or judge design and eval harnesses (agentic-eval)
  • Don't use as a substitute for running the prompt and inspecting the output

The 20 Concepts (selection table)

#TechniqueReach for it whenThe move
1Zero-shotTask is common, unambiguous, one-shot answerState the task plainly: "Explain quantum computing simply." No examples.
2Few-shotFormat or judgment is easier to show than describeGive 1–5 input→output pairs, then the real input. Match their pattern exactly.
3Chain-of-ThoughtMath, logic, multi-step reasoning, planning"Let's think step by step. Plan → Reason → Answer."
4Role promptingOutput tone/register or domain expertise matters"You are a senior data scientist…" then the constraints.
5Instruction promptingOutput is vague because the ask is vagueBe explicit: length, format, audience, what to exclude. "Summarize in 3 bullets."
6Output formattingOutput gets parsed, or must be consistentGive a schema/shape, not a label: {"summary": …, "key_points": [...]}
7Temperature controlInconsistent vs. creative — you're tuning the wrong knobExtraction/deterministic: low temp (≈0.0–0.3). Ideation: high (≈0.7–1.0).
8Prompt chainingTask has distinct phases with different goalsSplit: Plan → Research → Write. Each stage's output feeds the next as input.
9Self-consistencyOne sample is unreliable on reasoning tasksSample N answers at higher temp, take the majority/consensus. Costs N×.
10RAGThe answer must come from specific documents, not memoryRetrieve relevant chunks first, put them in context, instruct: answer only from these.
11Prompt templatesThe same shape is reused across inputsParameterize role + task + {input} + format. Keep tone stable across instances.
12GuardrailsAnything user-facing, untrusted input, or with side effectsExplicit never-list (no harm, no PII, no secret leakage), placed before the instructions.
13Dynamic promptingOne prompt must serve beginner/expert/pro usersBranch on user type: adjust vocabulary, depth and examples per segment.
14ReActReal tasks needing tools, search, or environment feedbackThought → Action (tool call) → Observation, repeat.
15Tree-of-ThoughtMany plausible paths, one-shot CoT gets stuckGenerate 2–3 candidate paths, evaluate each, commit to the best.
16Prompt compressionLong context, repeated calls, token billsStrip redundancy and hedges; keep constraints + the ask. Same behavior, fewer tokens.
17Multi-modalThe answer depends on an image/diagram/screenshotAttach the image AND say what to look at: "What is this? Focus on the wiring."
18JSON modeOutput feeds codeConstrain to JSON, parse safely (schema validation / try-except, never blind eval).
19Prompt evaluationYou can't tell if a change helpedScore quality/relevance, track success rate over N runs, iterate on data not vibes.
20Prompt optimizationThe prompt works but isn't good enoughVary one element at a time, measure, keep the winner. Iterative, not one-pass.

Choosing under time pressure

  • Simple, common task → 1 (zero-shot) + 5 (instruction) + 6 (format).
  • Output must match a shape (code, parser, table) → 2 (few-shot) + 6 (format) + 18 (JSON mode).
  • Reasoning / math / planning → 3 (CoT); if still unreliable, 9 (self-consistency) or 15 (ToT).
  • Needs tools or live data → 14 (ReAct); if the data is documents, 10 (RAG).
  • Multi-stage work → 8 (chaining), not one giant prompt.
  • Production / user-facing → 12 (guardrails) + 19 (evaluation), always.
  • Several user levels in one product → 13 (dynamic) or separate 11 (templates) per level.
  • Cost or latency pain → 16 (compression) + 7 (temperature) before adding more prompt.

Procedure

  1. Name the failure mode — vague output, wrong format, unreliable reasoning, wrong tone, token bloat, or unparsed JSON. Each maps to a different row above.
  2. Pick the smallest technique set from the selection path. One or two concepts, not six; each added technique costs tokens and hides the cause of a regression.
  3. Write the prompt with the task stated before the constraints where the technique allows it, and all never-rules grouped together.
  4. Run it on ≥3 real inputs — not a hypothetical one — and read the outputs.
  5. Change one variable, re-run, keep the better version (concept 20). Record what changed and why.
  6. Lock the shape for anything machine-read: validate the JSON/schema in code, not by eye (concept 18).

Pitfalls

  1. Few-shot examples that disagree with the instructions — the examples win. Audit them (wrong label, wrong format) before blaming the model.
  2. CoT on tasks that don't need it — costs latency and tokens on lookups and translation, and flattens creative voice. Apply the table, not CoT-by-default.
  3. Guardrails buried at the bottom — constraints must precede the task instructions, or later content overrides them.
  4. "Output JSON" with no schema — models invent keys. Ship the exact shape plus one example.
  5. Self-consistency on a non-reasoning task — N× the cost for noise. It only pays where independent samples can genuinely disagree.
  6. Chaining without a contract between stages — each stage needs a defined output shape, or errors compound silently.
  7. Changing several prompt elements at once — no attribution, no learning.
  8. Trusting a "better" prompt without running it — a prompt is a hypothesis until outputs are scored on real inputs.

Verification

A prompt change is done when:

  • It ran on ≥3 real inputs
  • Parsed output validated programmatically (JSON parses, schema matches)
  • Format compliance checked against the requested spec
  • Token cost compared to the previous version if you compressed (16) or chained (8)
  • Where reliability matters: N runs, success rate recorded (19), one variable changed per pass (20)

References

  • references/20-concepts-cheatsheet.md — verbatim transcription of the source poster (Akhil Meesala, "20 Prompt Engineering Concepts: A Compact Cheatsheet with Ideas, Use Cases and Visualizations"), including every use case and diagram note.
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 470kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall