Skip to content

Building with agents, lesson 1.3

How coding agents structure system prompts and tools

Before a coding agent reads your request, it has been handed a system prompt, a set of tool definitions and your project rules. This lesson takes that text apart, and shows how to write a tool the model will use well.

What do you run?

Every example below changes to fit what you pick. The businesses are made up for teaching.

The picture, one step at a time

Each box is one stage. The picture lights up as you scroll.

Step 1 of 6

Your request arrives last

In lesson 1.2 the agent searched, read, edited and ran. But before the model sees a word of your request, the agent has already sent it a lot of text. That text shapes how it behaves as much as the model itself does.

Step 2 of 6

The system prompt: who and how

The system prompt comes first. It sets the agent's role, how it should use its tools, and its safety rules. In Claude Code, Anthropic writes it. If you build an order-lookup agent for your shop, you write it yourself.

Anthropic's Agent SDK docs describe the Claude Code system prompt as carrying tool instructions and safety instructions. You can keep it and add to the end, or replace it, and if you replace it, the tool guidance and safety rules are yours to write (as of November 2026).

Step 3 of 6

A tool definition: name, description, inputs

Each tool is defined by three things: a name, a plain description of what it does and when to use it, and a schema, which is the list of inputs it takes and what kind each one is. The model never sees your code, only these words.

Anthropic's docs say the API builds a special system prompt from your tool definitions. Tool descriptions can carry rules too: Claude Code's instructions for writing commits sit inside its shell tool's description, not in the system prompt.

Step 4 of 6

The description does most of the work

A good description says what the tool does, when to use it and when not to, what each input means, and what it does not return. Name inputs plainly: customer_id, not customer. When an agent picks the wrong tool, the description is the first place to look.

Anthropic's tool docs call detailed descriptions "by far the most important factor in tool performance" and suggest at least three or four sentences each. Its September 2025 post says precise refinements to tool descriptions helped Claude Sonnet 3.5 reach a top score on SWE-bench Verified, a coding test.

Your agent keeps calling search_orders when it should call get_order. Where do you start?

Step 5 of 6

Project rules ride in the conversation

Your CLAUDE.md or AGENTS.md holds the rules of this repo. Claude Code does not put it in the system prompt. It adds it to the conversation, with a line saying it overrides default behaviour. Skills and helper agents are listed the same way, by name and description.

From Claude Code's Agent SDK docs, as of November 2026. Module 5 of this course covers what goes in the file.

Step 6 of 6

Then the results come back

Now the loop from lesson 1.1 runs, and each tool's answer is added to the conversation. Shape those answers too: only the fields the next step needs, names and IDs that mean something, and errors that say what to try next.

Anthropic's tool docs advise returning only high-signal information with stable identifiers, and its tools post advises errors that give specific, actionable fixes rather than bare codes.

A tool fails and returns "Error 500". What would help the agent more?

Where does this line belong?

Here are four lines of text for an agent in your business. Put each one where it should live.

  1. 1"You are a support agent for an online shop. Be brief, and never promise a refund yourself."

  2. 2"Fix the bug where the basket total shows £0 for gift cards."

  3. 3"Look up an order by its number. Returns the status, items and delivery date. Use it before answering any question about an order."

  4. 4"In this repo, prices are stored in pence, and the tests run with one command."

0 of 4 right so far, 4 to go.

An annotated tool definition

This is what you keep: a tool definition taken apart, one line per part, to check every tool you write against.

An annotated tool definition

  1. Name: a verb and a noun. When you have several services, start with the service, as in crm_find_customer.
  2. Description: what it does, when to use it, when not to, and what it does not return. Three or four sentences at least.
  3. Inputs: plain names (customer_id, not customer), each with a one-line meaning, and which ones are required.
  4. Results: only the fields the next step needs, with names and IDs that mean something.
  5. Errors: what went wrong and what to try next, never a bare code.
  6. Fewer, broader tools beat one tool for every button. Build the job, not a copy of your system.

Write every tool as if briefing a new hire who has never seen your system.

Next: Lesson 2.1: Prompting techniques, and when each applies. Which way of asking fits which job.