> ## 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.

# Prompting Basics

> Guide to practical prompt engineering explaining roles, specificity, few shot examples, positive phrasing, chain of thought, and API message design to steer large language model behavior

The context window is the model's working memory — everything the model can see at once. What you place inside that window directly determines the quality, format, and usefulness of the model's output.

Many people assume prompting is only about being specific: give a clear instruction, add context, and you're done. That helps, but there's a deeper mechanism at work: prompts shape which internal patterns the model activates. Small wording differences can prime different behaviors and produce measurably different results.

Consider these two instructions:

* Don't use bullet points.
* Write in paragraphs only.

They mean the same thing, but the second is more reliable. Why? The phrase "don't use bullet points" activates the bullet-point pattern (because it mentions it) and then asks the model to suppress it. The suppression can fail or produce mixed results. By contrast, "Write in paragraphs only" directly activates the paragraph-writing pattern you want.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/z7NmHsFQN9LCEiD0/images/AI-Agents-for-Beginners-OpenClaw-Case-Study/LLM-Fundamentals/Prompting-Basics/same-meaning-different-result-bullet-suppression.jpg?fit=max&auto=format&n=z7NmHsFQN9LCEiD0&q=85&s=1946978d4270bf2315b071834f0b96a4" alt="A poster-style graphic titled &#x22;Same Meaning, Different Result&#x22; showing two instruction boxes: a red &#x22;NEGATIVE&#x22; box that says &#x22;Don't use bullet points.&#x22; and a green &#x22;POSITIVE&#x22; box that says &#x22;Write in paragraphs only.&#x22; Below is text explaining that the model activates the &#x22;bullet-point&#x22; pattern first then tries to suppress it, and that &#x22;The suppression doesn't always win.&#x22;" width="1920" height="1080" data-path="images/AI-Agents-for-Beginners-OpenClaw-Case-Study/LLM-Fundamentals/Prompting-Basics/same-meaning-different-result-bullet-suppression.jpg" />
</Frame>

Prompting is therefore less about a single instruction and more about steering which patterns the model should follow. Once you think of prompts as pattern selectors, several practical techniques become obvious and consistently effective.

## Roles and the messages array

When you use the API, messages are not plain text — each message has a role that activates a cluster of patterns learned during training. The three canonical roles are:

| Role | Purpose | Example / Behavior |
| - | - | - |
| `system` | Establishes the assistant's behavior, rules, tone, and constraints | `You are a personal assistant that prioritizes upcoming meetings.` |
| `user` | The end user's question or request (what the model should respond to) | `What's on my calendar today?` |
| `assistant` | Example outputs from the model; used for few-shot examples and desired formats | `9:00 — Team standup; 11:00 — Client call` |

Example messages array (system sets the behavior; user asks the question):

```json theme={null}
[
  {
    "role": "system",
    "content": "You are a personal assistant that helps manage schedules and tasks."
  },
  {
    "role": "user",
    "content": "What's on my calendar today?"
  }
]
```

When building an app you control this entire messages array. That control is a major reason the API is more powerful than a simple chat UI: you decide what the model sees and in what order.

## Why prompt specificity matters

Changes in phrasing and added constraints shape the model's output format and content. For example:

* "Help me with my schedule" → may return general advice or suggestions.
* "List my meetings for today in bullet points with times" → returns short, structured, useful output.

Adding task-specific instructions, priority rules, or constraints further increases usefulness:

"You are a personal assistant. The user has a busy day. Summarize their calendar, flag any conflicts, and suggest which meeting to reschedule if they're double-booked."

More context and explicit constraints typically yield more practical, actionable responses.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/z7NmHsFQN9LCEiD0/images/AI-Agents-for-Beginners-OpenClaw-Case-Study/LLM-Fundamentals/Prompting-Basics/why-prompts-matter-vague-specific-detailed.jpg?fit=max&auto=format&n=z7NmHsFQN9LCEiD0&q=85&s=d47c70962190848fcce3fb3c4b0f3138" alt="An infographic titled &#x22;Why Prompts Matter&#x22; that compares three prompt levels—Vague, Specific, and Detailed—showing example prompts and their resulting outputs. The design uses a retro pixel-style font and dark grid background." width="1920" height="1080" data-path="images/AI-Agents-for-Beginners-OpenClaw-Case-Study/LLM-Fundamentals/Prompting-Basics/why-prompts-matter-vague-specific-detailed.jpg" />
</Frame>

Quick comparison: prompt specificity levels

| Level | Example prompt | Likely result |
| - | - | - |
| Vague | "Help me schedule my day." | High-level advice, potentially verbose |
| Specific | "List today's meetings with start times." | Structured list with times |
| Detailed | "Summarize today's meetings, flag overlaps, and recommend one meeting to reschedule." | Actionable summary with conflict resolution |

## Few-shot prompting (show, don't just tell)

Including examples of the exact input/output format you want is often far more effective than only describing it. This technique — few-shot prompting — demonstrates both the expected input and the required reply format.

Example: without examples, the model might produce an essay-style sentiment analysis. Provide one assistant example and the model reliably follows that concise label format.

```json theme={null}
[
  {
    "role": "system",
    "content": "Classify sentiment: positive, negative, or neutral."
  },
  {
    "role": "user",
    "content": "The food was amazing!"
  },
  {
    "role": "assistant",
    "content": "positive"
  },
  {
    "role": "user",
    "content": "It took 2 hours to get our order."
  }
]
```

Because you demonstrated the desired single-word reply, the model learns the response format and repeats it for new inputs.

## Assigning a role changes style and assumptions

When you add a role such as "You are a senior Python developer" versus "You are a beginner-friendly coding tutor," you activate different vocabularies, reasoning styles, and expectations. Use roles intentionally to align tone, level of detail, and approach with user needs.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/z7NmHsFQN9LCEiD0/images/AI-Agents-for-Beginners-OpenClaw-Case-Study/LLM-Fundamentals/Prompting-Basics/assign-role-senior-python-beginner-tutor.jpg?fit=max&auto=format&n=z7NmHsFQN9LCEiD0&q=85&s=854d6a77e142b8292d0fea61d8a916cd" alt="A presentation slide titled &#x22;TECHNIQUE 3: ASSIGN A ROLE&#x22; showing two role cards. Role A says &#x22;You are a senior Python developer&#x22; and Role B says &#x22;You are a beginner-friendly coding tutor,&#x22; with a footer noting it &#x22;Activates patterns from training — vocabulary, reasoning style, priorities.&#x22;" width="1920" height="1080" data-path="images/AI-Agents-for-Beginners-OpenClaw-Case-Study/LLM-Fundamentals/Prompting-Basics/assign-role-senior-python-beginner-tutor.jpg" />
</Frame>

## Phrase positively to avoid priming unwanted behaviors

Negative instructions can accidentally prime the very behavior you want to avoid. Instead, prefer positive, direct statements that activate the desired pattern.

Examples:

* Instead of "Don't be verbose" → "Be concise; one sentence per point."
* Instead of "Avoid jargon" → "Use simple words a high school student would understand."

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/z7NmHsFQN9LCEiD0/images/AI-Agents-for-Beginners-OpenClaw-Case-Study/LLM-Fundamentals/Prompting-Basics/technique-4-phrase-positively-instead-use.jpg?fit=max&auto=format&n=z7NmHsFQN9LCEiD0&q=85&s=42917dd79518b0f5706581a42ed47eb2" alt="A dark-themed infographic titled &#x22;Technique 4: Phrase Positively&#x22; with two columns (&#x22;Instead of...&#x22; and &#x22;Use...&#x22;) showing negative instructions on the left and positive rephrasings on the right (e.g., &#x22;Don't use bullet points&#x22; → &#x22;Write in paragraphs only&#x22;)." width="1920" height="1080" data-path="images/AI-Agents-for-Beginners-OpenClaw-Case-Study/LLM-Fundamentals/Prompting-Basics/technique-4-phrase-positively-instead-use.jpg" />
</Frame>

<Callout icon="lightbulb" color="#1CB2FE">
  Phrase instructions positively whenever possible — it reduces ambiguity and avoids priming unwanted patterns.
</Callout>

## Chain-of-thought prompting for multi-step tasks

For complex tasks, break the problem into ordered steps so the model reasons sequentially. Each step conditions the next, improving the final answer.

Example stepwise plan for travel planning:

1. Check calendar for travel dates.
2. Search for flights within budget.
3. Find hotels near meeting location.
4. Summarize the best option.

This decomposition reduces guesswork and encourages the model to build the solution step-by-step.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/z7NmHsFQN9LCEiD0/images/AI-Agents-for-Beginners-OpenClaw-Case-Study/LLM-Fundamentals/Prompting-Basics/chain-of-thought-trip-plan.jpg?fit=max&auto=format&n=z7NmHsFQN9LCEiD0&q=85&s=85029c4f42067c11d1e527ad73034d0d" alt="An infographic titled &#x22;TECHNIQUE 5: CHAIN OF THOUGHT&#x22; showing a numbered four-step plan for &#x22;Plan my trip&#x22; (check my calendar, search for flights within budget, find hotels near meeting location, summarize the best options). A banner at the bottom reads &#x22;EACH STEP CONDITIONS THE NEXT ONE.&#x22;" width="1920" height="1080" data-path="images/AI-Agents-for-Beginners-OpenClaw-Case-Study/LLM-Fundamentals/Prompting-Basics/chain-of-thought-trip-plan.jpg" />
</Frame>

## API vs ChatGPT: control and responsibility

* ChatGPT: you type a message; system behavior is preconfigured and hidden. Good for quick interactions and experimentation.
* OpenAI API: you compose the messages array (system, user, assistant examples) and control every token the model sees. This gives you more power — and more responsibility — to design clear system messages, include examples, and manage token budgets.

Keep these practical tips in mind:

* Put role, behavior rules, and priorities in the `system` message.
* Add few-shot `assistant` examples to lock in output format.
* Use chain-of-thought steps in `user` messages for multi-step reasoning.
* Monitor token usage and plan prompts to fit the model's context window.

<Callout icon="warning" color="#FF6B6B">
  Be mindful of token limits: every system, user, and assistant message consumes tokens. Long multi-example system prompts can exhaust the context window and increase cost.
</Callout>

## Why these techniques work (brief)

Research and practical experience explain the mechanics:

* Larger models are sensitive to negative instructions and priming.
* Prompt ordering influences attention and which context tokens the model prioritizes.
* Production systems often assemble multi-part system prompts programmatically (e.g., a long system message composed of role, safety filters, and behavior rules).

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/z7NmHsFQN9LCEiD0/images/AI-Agents-for-Beginners-OpenClaw-Case-Study/LLM-Fundamentals/Prompting-Basics/whats-next-section4-negative-instructions-openclaw19.jpg?fit=max&auto=format&n=z7NmHsFQN9LCEiD0&q=85&s=cb9350de9df90719804738d172892363" alt="A dark slide titled &#x22;WHAT'S NEXT&#x22; that lists Section 4 topics: &#x22;Why these techniques work,&#x22; &#x22;Negative instructions + model size,&#x22; &#x22;Prompt ordering effects,&#x22; and &#x22;OpenClaw's 19-section system prompt.&#x22;" width="1920" height="1080" data-path="images/AI-Agents-for-Beginners-OpenClaw-Case-Study/LLM-Fundamentals/Prompting-Basics/whats-next-section4-negative-instructions-openclaw19.jpg" />
</Frame>

## References and further reading

* [ChatGPT](https://chat.openai.com) — conversational playground.
* [OpenAI API docs](https://platform.openai.com/docs) — messages, roles, and examples.
* For deeper reading on prompt engineering and behavior shaping, search for terms like "few-shot prompting", "chain-of-thought", and "system prompt design".

The following sections dig into the research and practical patterns that explain and extend these prompting techniques.

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/ai-agents-for-beginner-openclaw-case-study/module/13d4f7ad-29e5-4bc0-b026-47c4ae43c31c/lesson/11b4c053-2280-4211-9909-e5a77b74a241" />
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.