← All videos >THE FULL PICTURE
Take the AI agents course

ai agents / prompt engineering / system prompts

The System Prompt That Changes Everything (Prompt Engineering For AI Agents)

Course walkthrough

AI Agents from Scratch

Lesson 5 of 12

All lessons in this series

  1. 1I'll Teach You How To Build AI Agents From Scratch (10 Billion Tokens Proof)
  2. 2What Is An AI Agent? (ChatGPT Doesn't Count)
  3. 3The ONE Trick That Turns ChatGPT Into An AI Agent (Tools)
  4. 4The ReAct Loop: How Cursor & Claude Code Actually Work
  5. 5The System Prompt That Changes Everything (Prompt Engineering For AI Agents)
  6. 6How To Make Your AI Agent Truly Autonomous (Without It Going Rogue)
  7. 7How To Trigger An AI Agent (5 Different Ways)
  8. 8Subagents Explained: How AI Agents Launch Other AI Agents
  9. 9Simple Memory: How AI Agents Remember Between Runs
  10. 10How AI Agents Actually Remember (Memory + RAG Explained)
  11. 11How To Actually Tell If Your AI Agent Is Good (Evaluation)
  12. 12The Complete Guide To Building AI Agents (10 Lesson Recap)

Prompt engineering got dismissed as a meme after GPT-4 came out. That was a mistake. For AI agents, the system prompt is the single most important thing you'll write — it controls how your agent reasons, which tools it picks, how accurate it is, and how much it costs to run.

In this lesson, I break down the anatomy of a production system prompt and show you exactly why small changes to it can make or break your agent.

You'll learn: → What prompt engineering actually is (and why it's still critical in 2026) → The anatomy of a system prompt — role, context, rules, examples, and tool definitions → Why a good system prompt directly impacts cost, accuracy, and latency → The exact patterns I use for production agents at Oscar Health, Coinbase, and NexusTrade → Common system-prompt mistakes that quietly burn tokens and hallucinate

By the end, you'll understand why the system prompt is the closest thing to "source code" for an AI agent — and how to write one that doesn't waste money or trust.

This is Lesson 5 of "How To Build AI Agents From Scratch" — a free 11-lesson masterclass on building production-ready AI agents.

#AIAgents #PromptEngineering #SystemPrompt #LLM #ProductionAI

Transcript

0:05Welcome back to the course on how to build an AI agent from scratch and I felt like this topic was so important that even though I had finished recording all the videos and even started editing them I went back to record this video because it's super

0:19important I thought it deserves its own dedicated video Today I'm going to be talking about prompt engineering Now first I want to define what exactly is prompt engineering Everyone says prompt engineering

0:32and a prompt engineer What does that actually mean If you take a look at the system prompt here this message gives instructions for how the AI ought to act So you know you can have a very simple

0:46prompt you're a helpful assistant that's just some basic instructions But you might want your AI to respond in a very specific way For example if you're generating SQL queries you

0:59have to give the AI what your schemas are If you don't give the AI your schemas your AI isn't going to know your schemas and you can't create an accurate SQL query You also might have some business logic rules

1:12You might define something which could be a little bit ambiguous and you want to clarify exactly what that means So let me take example right here building a system prompt So when you build a system prompt this is the OpenAI Playground This is my internal

1:26app that I named Nexus Gen AI So when you build a system prompt there are several things that you should take into account Number one is you want to give your AI some sort of role This is a more or less optional statement

1:41It helps your AI have some sort of flavor of how it's actually responding So I'm actually something like you know you are a nice feminine AI agent that offers trading advice You

1:55know it gives your AI some personality Something that it can mimic when it's creating responses So another thing that's really important for creating a system prompt is your actual instructions What

2:09the AI should actually do You give it a list of things The list of constraints that it should follow The output format Anything that's important for the AI to know before

2:24it begins You want to put it all within the system prompt Now if you just have a list of instructions Maybe you have an output schema If you just have that that is called

2:37zero shot prompting and is good for very basic very simple tasks However if you're getting into some more complex tasks like generating SQL queries then you'll find the AI isn't usually good enough at

2:52generating these queries You have to give it examples of what a good query looks like and what a bad query looks like That is the heart of prompt engineering We call this few shot prompting

3:08With few shot prompting we basically want to give the AI a bunch of examples of things that work and doesn't work So you can see in this example I have right here If I click here these are examples These are saved within the system prompts

3:23and just formatted for a nice easy consistency If you actually go here and you click export I'm going to just paste this into a terminal Create a new tab and you can see this is what the actual system prompt is

3:37It's just a very large detailed markdown You can literally think of it copy pasting this putting it over in the playground and putting it right here This is exactly what it is and you can see in my examples

3:49I have these same examples within the system prompt and delineated it I just have code to transform this UI into this markdown format

4:03You notice several things within the system prompt that are really important I've mentioned some One you notice these examples Two I have my AI identity and objective Three I have my JSON formats

4:17Four I have things like my schema My schema is here and it's injected at runtime It tells the AI the valid tables I have within my application

4:29You want to provide detailed rules You'll first start with something simple and then you're just going to inevitably build towards a strong system prompt Another thing that I really want to emphasize

4:43is this system prompt can respond with whatever you want You can tell your system prompt to respond with markdown You can tell your system prompt to respond with JSON You can tell your system prompt to respond with a technically valid SQL query It can really be whatever you want but

4:57you want to make sure it's accomplishing your goal in certain formats The model just has an easier time to generate If you tell your AI to respond with JSON it's going to do a lot better job than asking it to respond with some

5:11proprietary format nobody has ever heard of Finally there are some things that you should keep in mind For example within AI tools within the APIs you can ask it to respond with these formats but also when you

5:26want to create an account and use these APIs you'll see they have these little helper modules You'll see things such as an MCP server An MCP server is just an external API that is basically

5:38telling your AI to respond with a specific JSON so that a JSON object can hit an API That's more or less kind of what an MCP server is

5:53You have things like the output schema You know you might tell your AI to respond in JSON mode and then you might not have the response actually as text but it might be within a different part of the response API But the main point that these

6:08models are all doing is just simply generating text in accordance to the instructions that you give it In this next video I'm going to talk about the way to make your AI agent safe

6:21while still be able to do things automatically It is an extremely important part of building production AI agents I'll see you there

Join the conversation

Loading conversation…