> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Prompt Engineering Techniques

> Guide to crafting prompts for TechCorp's AI assistant covering techniques, role and format specification, examples, and best practices to improve output quality and consistency

Prompt engineering is the practice of designing inputs to an AI assistant so the responses are accurate, concise, and formatted for your needs. Here we focus on how to craft prompts for TechCorp’s AI Document Assistant — not how to build LangChain apps — because small prompt changes (scope, role, format) dramatically affect output quality.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/zrm8HSwMCH5tF427/images/AI-Agents-Fundamentals/AI-Agents-Part-1/Prompt-Engineering-Techniques/tech-corp-ai-application-diagram.jpg?fit=max&auto=format&n=zrm8HSwMCH5tF427&q=85&s=e28638cb0b9efe1ade96e6a6e68dc27c" alt="A hand-drawn diagram on a black background showing &#x22;Tech Corp's AI Application&#x22; in the center with arrows to surrounding components like a large language model, LangChain, R.A.G., a vector/database, server/stack icons, and a chat UI. The sketch maps how different AI building blocks connect into the central application." width="1920" height="1080" data-path="images/AI-Agents-Fundamentals/AI-Agents-Part-1/Prompt-Engineering-Techniques/tech-corp-ai-application-diagram.jpg" />
</Frame>

Why prompt engineering matters

* Vague prompts force the model to guess intent, leading to longer, noisier, or off-topic responses.
* Adding minimal constraints (audience, region, format) narrows results and improves relevance.
* Explicit roles and format instructions help the assistant maintain consistent tone and structure.

Example of a vague prompt:

```text theme={null}
what is the policy?
```

More specific and actionable:

```text theme={null}
what's the company's remote work policy for international employees?
```

<Callout icon="lightbulb" color="#1CB2FE">
  Be explicit about scope, audience, and desired output format. Small additions — like region, role, or format — often produce substantially better answers.
</Callout>

Define role and output format
Telling the model “who it is” and “how to present the answer” controls voice and structure. For example:

```text theme={null}
You are a TechCorp customer support expert. When asked about company policy, always respond with bullet points for readability.
```

This simple role + format instruction reduces ambiguity and yields predictable outputs across multiple prompts.

Prompting techniques overview
Choose the appropriate technique based on how much guidance you provide: zero-shot, one-shot, few-shot, or chain-of-thought.

Zero-shot prompting
Zero-shot asks the model to perform a task without examples. It relies on the model’s internal knowledge and generalization.

Example:

```text theme={null}
Write a data privacy policy for our European customers.
```

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/zrm8HSwMCH5tF427/images/AI-Agents-Fundamentals/AI-Agents-Part-1/Prompt-Engineering-Techniques/zero-shot-prompting-agent-diagram.jpg?fit=max&auto=format&n=zrm8HSwMCH5tF427&q=85&s=53cbd2ad1c2d31ac78cc45523be32427" alt="A hand-drawn diagram titled &#x22;zero-shot prompting&#x22; showing a prompt bubble (example text: &#x22;Write a data privacy policy for our European customers&#x22;) feeding into an &#x22;Agent&#x22; drawn as a neural‑network node cluster. Arrows indicate the agent's existing knowledge and an output direction." width="1920" height="1080" data-path="images/AI-Agents-Fundamentals/AI-Agents-Part-1/Prompt-Engineering-Techniques/zero-shot-prompting-agent-diagram.jpg" />
</Frame>

One-shot and few-shot prompting
One-shot and few-shot prompts include one or several examples in the prompt to demonstrate the desired output format, tone, or structure. This helps the model pattern-match and produce consistent results.

Workflow example:

* Provide a template or single example of the policy structure.
* Ask the model to “Write a data privacy policy following the same structure.”

Few-shot is similar but supplies multiple samples to cover edge cases and formatting variations.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/zrm8HSwMCH5tF427/images/AI-Agents-Fundamentals/AI-Agents-Part-1/Prompt-Engineering-Techniques/oneshot-prompt-template-agent-output-diagram.jpg?fit=max&auto=format&n=zrm8HSwMCH5tF427&q=85&s=333f23f592693d85b1182b26d2b7322a" alt="A hand-drawn diagram illustrating one-shot prompting: a prompt template on the left feeds into an &#x22;Agent&#x22; (a neural network) in the center, producing output with a specified format and style. Arrows and labels like &#x22;template&#x22; and &#x22;format/style&#x22; annotate the process." width="1920" height="1080" data-path="images/AI-Agents-Fundamentals/AI-Agents-Part-1/Prompt-Engineering-Techniques/oneshot-prompt-template-agent-output-diagram.jpg" />
</Frame>

Chain-of-thought prompting
Chain-of-thought (CoT) prompts ask the model to show or follow intermediate reasoning steps. Instead of only requesting a final output, you specify the stepwise process the assistant should use.

Example steps:

* Review current GDPR requirements for data retention periods.
* Analyze the existing policy to identify gaps.
* Research industry best practices for similar companies.
* Draft specific, implementable recommendations.

<Callout icon="warning" color="#FF6B6B">
  Chain-of-thought prompts can improve analytic depth but may increase verbosity and expose intermediate reasoning. In production, avoid revealing sensitive internal reasoning or use post-processing to extract only final action items.
</Callout>

Comparison table: choosing a technique

| Technique        | When to use                              |                                Strengths | Limitations                            |
| ---------------- | ---------------------------------------- | ---------------------------------------: | -------------------------------------- |
| Zero-shot        | Quick tasks with standard formats        |                       Fast, minimal prep | May be too generic                     |
| One-shot         | You have one clear example/template      |            Low prep, improved formatting | Limited coverage                       |
| Few-shot         | You can provide multiple examples        | Better generalization, covers edge cases | More prompt length                     |
| Chain-of-thought | Complex reasoning or multi-step analysis |                 Higher-quality reasoning | Verbose; may reveal intermediate steps |

Actionable prompt template
Use this scaffold to compose consistent, reusable prompts. Replace each bracketed section with your specifics.

```text theme={null}
Role: You are a [role], e.g., "TechCorp policy expert".
Context: [Provide relevant context or background].
Examples: [Optional — paste 1–3 examples or a single template].
Task: [Clear instruction of what to do].
Constraints: [e.g., length, regulations, audience region].
Format: [e.g., bullet points, numbered steps, markdown, JSON].
```

Example using the template:

```text theme={null}
Role: You are a TechCorp legal analyst.
Context: Our European engineering teams process customer IDs and logs.
Examples: See the provided policy template below.
Task: Draft a GDPR-compliant data retention policy focused on logs and temporary IDs.
Constraints: Max 600 words; include retention periods and deletion processes.
Format: Use numbered sections and a short executive summary.
```

Prompt-engineering best practices

* Start with a clear role and targeted context.
* Specify the desired output format (bullets, sections, JSON).
* Supply examples or templates for consistent formatting.
* Limit scope (audience, region, timeframe) to avoid irrelevant detail.
* Test iteratively — refine prompts based on actual outputs.
* Use chain-of-thought only when you need the model’s intermediate reasoning, and sanitize outputs before exposing them.

Examples: bad vs. improved prompts

* Bad: what is the policy?
* Improved: You are a TechCorp HR expert. Summarize the remote-work policy for international employees in 5 bullet points, highlighting eligibility, timezone expectations, and tax considerations.

References and further reading

* [LangChain — KodeKloud course](https://learn.kodekloud.com/user/courses/langchain)
* [OpenAI Prompting Guide](https://platform.openai.com/docs/guides/completion/prompt-design)
* [Retrieval-Augmented Generation (RAG) overview](https://en.wikipedia.org/wiki/Retrieval-augmented_generation)

Putting it together
Prompt engineering is selecting the right method (zero-/one-/few-shot, or chain-of-thought) and composing a prompt with clear role, context, examples, and format. Thoughtful prompts act like precise instructions for the agent, improving relevance, consistency, and usefulness of the assistant’s responses.

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/ai-agents-fundamentals/module/dd5e8998-51f1-4352-82a5-3414cdc3299c/lesson/ae14e196-126f-4d3e-8ede-d3b09fca7ce0" />
</CardGroup>
