Techniques

Prompt Engineering

Kỹ thuật Prompt

The practice of crafting inputs to an AI model to reliably elicit desired outputs.

Prompt engineering is the discipline of designing, structuring, and iterating on the text you send to an AI model to get more accurate, useful, or consistent results. Think of it as learning the model's "dialect."

**Why it's a real skill**

The same underlying model can produce mediocre results with a vague prompt and excellent results with a well-structured one. Small changes — adding "think step by step," providing examples, specifying format — can dramatically shift output quality.

**Core techniques**

*Role assignment*: "You are a senior TypeScript engineer reviewing a pull request." Framing the model's persona anchors its style and knowledge domain.

*Instruction clarity*: Be explicit about format, length, tone, and constraints. "Write a 3-sentence summary in plain English for a non-technical audience" beats "summarize this."

*Few-shot examples*: Provide 2–3 input/output pairs before your actual request. The model infers the pattern. This is particularly powerful for classification or formatting tasks.

*Chain of thought*: Ask the model to reason through steps before answering. "Let's think step by step" or structured scratchpads reduce errors on multi-step problems.

*Constraints and negative instructions*: "Do not use jargon" or "avoid bullet points" can be as useful as positive instructions.

**When it matters most**

Prompt engineering pays dividends in production systems where you're calling the API programmatically and need reliable, parseable output. For casual chat use, it matters less.

**Pitfalls**

Over-engineered prompts become brittle. Model updates can break carefully tuned prompts. And prompts are not a security boundary — jailbreak and injection attacks bypass them.