Barefoot AI HubTHE BAREFOOT FREELANCER
Start learning
◆ AI Foundations · Lesson 5 of 5

05Advanced Prompting Techniques

Few-shot examples, step-by-step reasoning, prompt chaining, structured JSON output, system prompts and simple evaluations — the techniques behind reliable AI systems.

⏱ 25 min📶 Intermediate🧪 3-question check

What you'll learn

  • Use few-shot examples to lock in style and format
  • Get reliable structured (JSON) output for automations
  • Break big jobs into prompt chains
  • Write strong system prompts for bots and agents
  • Evaluate prompts with a small test set

Few-shot prompting: teach by example

“Few-shot” means including a few input → output examples in the prompt. It's the fastest way to get a consistent style, format or classification scheme.

few-shot-classifier.txtprompt
Classify each customer message as BOOKING, COMPLAINT, QUESTION or SPAM.
Respond with only the label.

<examples>
Message: "Can I reserve a table for 6 on Saturday night?"
Label: BOOKING

Message: "My latte was cold and the staff ignored me."
Label: COMPLAINT

Message: "Do you have oat milk?"
Label: QUESTION

Message: "Congrats!! You won an iPhone, click here"
Label: SPAM
</examples>

Message: "{{new message}}"
Label:

Step-by-step reasoning

For analysis, math, planning or decisions, ask the model to reason before answering. Separating the reasoning from the final answer also makes the output easy to parse.

reasoning.txtprompt
A client wants a 5-page website, a booking system and 3 months of support.
My rates: ₱1,800/hr design, ₱2,200/hr development, support ₱6,000/month.

Estimate hours per component, then the total price.
Think it through step by step inside <thinking> tags,
then give the client-ready quote inside <quote> tags.

Many models also offer a built-in extended thinking or reasoning mode. When available, it usually beats manual “think step by step” instructions for hard problems.

Structured output: JSON for automations

When AI output feeds another system — a spreadsheet, CRM, n8n workflow or your code — you need a strict, parseable structure. Describe the schema exactly and give an example.

extract-lead.txtprompt
Extract lead details from the inquiry below.
Return ONLY valid JSON matching this schema — no commentary, no markdown fences:

{
  "name": string,
  "email": string | null,
  "service": "website" | "branding" | "seo" | "other",
  "budget_php": number | null,
  "deadline": string | null,        // ISO date, or null if not stated
  "urgency": "low" | "medium" | "high",
  "summary": string                 // one sentence
}

If a field isn't stated, use null. Do not guess budgets.

<inquiry>
{{inquiry text}}
</inquiry>

Prompt chaining: split big jobs

One giant prompt that researches, outlines, writes, edits and formats will be mediocre at all of them. Chain smaller prompts where each step's output feeds the next — and you can check or fix things between steps.

STEP 1Research brieffacts & angles
STEP 2Outlinestructure
CHECKYou approveedit outline
STEP 3Draftsection by section
STEP 4Critique & fixvs. checklist
OUTFinalformatted
A content chain. Each step is simpler, easier to debug and easier to improve.

System prompts: the constitution of your bot or agent

A system prompt sets persistent behavior for a chatbot or agent — identity, knowledge, rules, tone and escalation. It's the most important piece of any AI product you build. A solid structure:

system-prompt.txtprompt
<identity>
You are Kapé, the virtual assistant for Barefoot Café in Iloilo City.
You help customers with hours, menu, reservations and delivery.
</identity>

<knowledge>
{{hours, menu with prices, policies — or retrieved via RAG}}
</knowledge>

<behavior>
- Friendly, concise (2–4 sentences), light Taglish is fine if the customer uses it.
- Only answer using the knowledge above. If unsure, say so and offer to
  connect the customer with the team.
- To book a table, collect name, party size, date and time, then call
  the create_reservation tool.
</behavior>

<escalation>
Hand off to a human (call the escalate tool) when the customer is upset,
asks for a refund, reports a food safety issue, or asks something
outside café topics twice.
</escalation>

<never>
Never invent prices, promos or policies. Never collect payment details in chat.
</never>

Self-critique and verification

Ask the model to check its own work against explicit criteria — or better, use a second call as a reviewer:

reviewer.txtprompt
Review the draft below against this checklist. For each item answer
PASS or FAIL with a one-line reason, then output a corrected draft.

Checklist:
1. Under 150 words
2. Mentions the new date (Oct 10) exactly once
3. No blame language ("you were late", "your fault")
4. Ends with a clear next step

<draft>{{draft}}</draft>

Evaluate prompts with a tiny test set

Before you rely on a prompt in a business process, build a quick evaluation:

  1. Collect 10–20 real inputs

    Include typical cases and the weird ones: long, short, angry, mixed-language, missing info.

  2. Write the expected result for each

    For classification that's the correct label; for drafts, a short checklist of must-haves.

  3. Run the prompt on all of them

    A spreadsheet works: input column, output column, pass/fail column.

  4. Fix and re-run

    Every time you change the prompt or the model, re-run the whole set. This is how you avoid breaking things that used to work.

Key takeaways

  • Few-shot examples are the fastest route to consistent style and labels — include edge cases.
  • Separate reasoning from the final answer; use built-in thinking modes for hard problems.
  • For automations, demand strict JSON — and use native schema enforcement when available.
  • Chain prompts for complex work; a system prompt is the constitution of any bot or agent.
  • Test prompts on a small, realistic set before trusting them — and re-test after every change.

Knowledge check

0 / 3

Q1What is few-shot prompting?

Q2Why chain prompts instead of using one huge prompt?

Q3Your chatbot sometimes promises refunds. Where should the fix go?

Finished this lesson?Your progress is saved in this browser.