Prompt engineering

Prompt engineering is not magic words. It is specification writing: the clearer you state the job, the inputs, the limits and the output shape, the more reliably a model delivers. Most "the model is bad at this" complaints are under-specified prompts.

The six parts of a strong prompt

Role, task, context, constraints, output format, examples. Put them in that order, and mark each part with a delimiter so the model can tell your instructions from your data.

You are a senior data analyst for a mid-sized FMCG distributor in Nagpur.

<task>Summarise the monthly sales data below for the CEO.</task>

<data>
Region, Units, Revenue_INR
Vidarbha, 12400, 3120000
Marathwada, 9800, 2450000
</data>

<requirements>
- Exactly 5 bullet points, each under 20 words
- Quote figures in INR lakhs, one decimal
- Final bullet must name the single biggest risk
- No preamble, no closing line
</requirements>

The AI Prompt Generator will scaffold this structure for you.

Techniques worth knowing

Technique What it does When to reach for it
Zero-shot Instruction only Simple, common tasks
Few-shot Two to five worked examples Fixed format, house tone, tricky edge cases
Role prompt Sets vocabulary and depth Domain writing, audience matching
Delimiters Separates instructions from data Any time user text is interpolated
Step-by-step Asks for reasoning before the answer Multi-step arithmetic or policy checks
Output schema Names the exact keys and types Anything a program will parse
Decomposition Splits into several small prompts Long documents, multi-stage workflows

Few-shot examples do more work than any adjective. Three labelled samples teach the format faster than a paragraph describing it:

SYSTEM = "Classify each customer message as delivery, product, payment or other. Reply with one word."

SHOTS = [
    ("parcel still not delivered", "delivery"),
    ("kurta colour faded after one wash", "product"),
    ("upi debited but order not placed", "payment"),
]

def build_prompt(message):
    lines = [f"Message: {m}" + chr(10) + f"Label: {label}" for m, label in SHOTS]
    lines.append(f"Message: {message}" + chr(10) + "Label:")
    return SYSTEM + chr(10) + chr(10) + (chr(10) + chr(10)).join(lines)

print(build_prompt("refund not credited since 10 days"))

Write constraints as positives

"Do not be verbose" is weak; "Maximum 60 words" is checkable. Models follow measurable limits far better than vague prohibitions. The same goes for tone: "polite Hinglish, no slang, address the customer as aap" beats "be friendly".

Iterate like an engineer

Keep 15–20 real inputs with the answer you would accept, in a file. Change one thing in the prompt, re-run all of them, and compare. Without that set you are tuning on the last example you happened to look at, and you will never notice the change that fixed case 3 while breaking case 11. Version prompts in git alongside code.

Common mistakes

  • Pasting user text straight into the instruction block, so a customer sentence becomes an order to the model.
  • Asking for JSON in prose but never validating the reply.
  • Piling on adjectives ("very detailed yet concise") instead of a number.
  • Editing a prompt in production without a before-and-after on the test set.
  • Reusing one giant prompt for four different jobs, so every change breaks something else.

Practice

Take a task you do by hand — writing delivery-delay apologies, say. Write a zero-shot prompt and a few-shot version with three examples. Run both over 10 real cases and count how many outputs you would send without editing.

B

Written by Bablu Kumar Jha

Founder, BeeProton AI · Mumbai, Maharashtra, India