Skip to content

Prompt Engineering

All You Need To Know About Prompt Engineering

1. Be precise and explicit

Don’t assume hidden meaning. You must spell out every detail: format, tone, constraints.

2. Structure your prompts carefully

  • Start with clear roles: "You are a Technical Writing Assistant…"
  • Define objective, format, and negative constraints explicitly: *“List 3 best-performing Q1 2025 products, then give 5 strategic bullets, don’t use paragraphs.”.

3. Use agentic workflows

Turn your LLM into an autonomous agent:

  • Remind it it's a multi‑message agent (“don’t stop until fully solved”).
  • Encourage planning + reflection between tool/API calls.
  • Insist on tool‑calls, not guesses

4. Utilize context adeptly

  • Feed long inputs and place essential prompts at beginning and end.
  • Remind it of its role mid‑doc to maintain context.

5. Guide reasoning with chain-of-thought

Despite not being a pure reasoning model, LLMs performs better when asked to "think step‑by‑step." Phrasing like “First X, then Y” yields better accuracy on logical tasks.

6. Few-shot / examples

Show desired output patterns. Including examples, that helps ensure structure, tone, and format are followed.

7. Iterate empirically

Treat prompt tuning like debugging:

  1. Try basic version
  2. Evaluate
  3. Adjust one element
  4. Repeat Empirical tweaks are key.

Sample Prompt Template

Markdown
1
2
3
4
5
6
7
8
9
You are a data extractor.
Extract the following fields:
- Title
- Author
- Date
- Summary

Output in JSON.
[TEXT]
Markdown
1
2
3
You are a math tutor.
Solve the problem step by step and explain your reasoning.
Problem: [PROBLEM]

Types of Prompting

✦ Zero-shot

✦ Few-shot

✦ Chain-of-Thought (CoT)

✦ ReAct Prompting

✦ Tree of Thoughts (ToT)

LLM Tuning

✅ Use temperature:

0 for deterministic answers

>0.7 for creativity

ReAct Prompting Example

Markdown
You are an intelligent agent that reasons step by step and uses tools.

Question: What is 23 * 47?

Thought: I should calculate step by step.
Action: Multiply(23, 47)

Observation: 1081

Answer: 1081

Tree of Thoughts (ToT) Example

Markdown
You are solving: How to reduce energy consumption in a data center by 30% in 6 months.

Generate 3 different high-level strategies.
For each, list pros and cons.
Then pick the most promising one to elaborate.

Strategies:
1. Migrate to cloud.
2. Optimize cooling.
3. Use renewable energy.

...

[Model continues]

Role Prompting:

"You are a senior full-stack developer and technical architect..."

Zero-shot instructions:

Clear goals for each part of the system.

Few-shot examples:

Provide a sample output example.

Chain-of-Thought:

"Explain your reasoning step by step."

ReAct:

"Thought → Action → Observation."

Tree of Thoughts:

"Generate multiple alternatives and evaluate them."

Constraints:

Next.js 15, Tailwind.

Format Control:

Markdown and code blocks.

Proactive Edge-Case Handling:

"Highlight edge cases, scalability concerns, and performance optimizations."

Summery

🔹 Clarity: Be precise and explicit. Vague prompts = vague answers.

🔹 Context: Give the model everything it needs to know: background, tone, examples.

🔹 Constraints: Specify format, length, style, and detail level.

🔹 Examples: Provide examples if you want structure or style imitation.

🔹 Iteration: Tweak, test, and compare variations.