FDE Times dataFDE jobs open 932▼14 Change in open roles over 7 days, like-for-like: roles from companies we started tracking this week are left outNew in 7 days 62Companies hiring 202Remote-friendly 24%Median US pay $201kTop hirer Databricks 92
中文VI

The newspaper of the Forward Deployed Engineer

Guides

Build a system prompt that survives the second department

Split it into four layers (role, policies, customer context and department configuration), so each new team costs one config block rather than another copy.

ShareLinkedInFacebookX

In brief

  • Each layer lives in its own XML tag. Tag names must stay the same across prompt versions, and tags should be nested when the content is hierarchical.
  • Every policy needs a reason attached, because the model generalizes from explanations rather than just memorizing commands.
  • The department layer holds the specific role and its own output format. Every other layer is shared across the whole company.
Diagram comparing two approaches. On the left, copying the prompt: three equal-height blocks for CS, Finance and Team 3, each a full copy of the prompt, so every team keeps its own version. On the right, layering: one large dark blue block holding three shared layers, with three small config blocks beneath it for CS, Finance and Team 3. The Team 3 block is coloured orange to show that adding a team needs only one more config block.
Adding a third team: if you copy, you gain one more prompt to maintain. If you split into layers, the role, policy and customer-context layers stay as they are, and you only write one more department_config block.

The internal assistant you built for a client’s customer service team has run smoothly for a few weeks. Then the head of accounting stops by and asks: “Can my team use it too?”

You have two options. The first is to copy the prompt into a second version, edit it, and maintain two separate copies forever after. The second is to reorganize the prompt into layers, so that each new department costs only one extra configuration block.

FDEs run into this very early on client engagements, and only the second approach holds up once a third and fourth department join the queue. This guide walks through building such a prompt step by step.

All you need is a text editor and any chat interface or playground to test in. The sample code is plain, simplified Python and does not call any provider’s API.

What you will build

The client in this guide is a hypothetical logistics company with two departments sharing an internal assistant: customer service and accounting. The prompt will have four layers.

The role layer says who the assistant is. The policy layer sets out what it may and may not do. The customer context layer describes the company, and the department configuration layer changes depending on who is using it.

DAIR.AI’s Prompt Engineering Guide notes that not every prompt needs every component, and that the structure depends on the problem. Treat the four layers as a starting framework; if your problem does not need a layer, drop it.

Step 1: write the role layer as if you only get one sentence

Anthropic’s prompting guidance says that a single role-assigning sentence in the system prompt is enough to steer Claude’s behavior and tone. Learn Prompting defines the role component as giving the AI a specific persona or perspective. Write the most important sentence first:

<role>
You are the internal assistant of a logistics company, helping staff look up procedures and draft replies.
</role>

Check: ask the same question (“What do I do when an order is late?”) twice, once with the <role> tag and once without. The answer with the role should sound like someone inside the company, not like a generic consultant.

Keep the company-level role broad. Each department’s detailed role belongs in step 4.

Step 2: write policies with a “because”

The usual temptation here is a long string of “Do NOT…” lines with no explanation. Anthropic recommends stating the context or motivation behind each instruction, explaining why the behavior matters, so that Claude understands your actual goal.

<policies>
  <policy>Do not include customers' bank account numbers in answers, because chat content may be forwarded outside the company.</policy>
  <policy>When unsure about a procedure, say so clearly and point to the person to ask, because staff will follow the answer word for word.</policy>
</policies>

Check: ask something the list does not cover, such as a customer’s personal phone number. If the model has understood the reason (“may be forwarded outside the company”), it will be careful with the phone number even though you never wrote a rule for it. The reason is what lets a policy generalize.

Step 3: separate customer context from instructions

Anthropic recommends putting each type of content in its own tag, such as <instructions>, <context> and <input>, so the model is less likely to misread it. Customer context is the part most easily confused with instructions. A line such as “the company prioritizes business customers” may be a fact describing the company, but the model can also read it as an order.

<customer_context>
  The company has two customer groups: individuals and businesses.
  The internal order management system is called "the waybill system".
</customer_context>

Check: reread every line in this tag. Any line that reads like a command should move to <policies>. The context tag should contain only facts.

Step 4: the department layer is the only part that changes

This layer holds everything that differs between departments. Anthropic recommends consistent, descriptive tag names across all prompts, and nesting tags when the content is hierarchical.

According to Learn Prompting, different roles produce different results that match each role’s perspective, while the output format is a separate part of the prompt whose job is to force the answer into a set structure.

<department_config>
  <department_role>You help accounting staff reconcile shipping invoices.</department_role>
  <main_instruction>Answer reconciliation questions based on the procedures in the context.</main_instruction>
  <output_format>A table with: order ID, amount, reconciliation status, notes.</output_format>
</department_config>

The <main_instruction> tag is not decoration. Learn Prompting warns that without a clear instruction, the AI tends to give generic or off-topic answers. For customer service, keep the same three child tag names and change only the content: the output format, for instance, becomes a short, polite reply to the customer.

The table below shows exactly where the two departments differ:

Child tag Accounting Customer service
department_role Helps reconcile invoices Helps draft customer replies
main_instruction Answer reconciliation questions Draft replies to complaints
output_format Four-column table Short paragraph sent to the customer

The three layers above stay the same for both departments. When a third department comes along, you write one more <department_config> block.

Step 5: add examples and department policies, then assemble in code

Anthropic recommends examples that are relevant to the task and sufficiently varied, wrapped in <example> tags (grouped in <examples> when there are several) so Claude can tell examples apart from instructions. Examples belong inside <department_config>, because a sample accounting answer is of no use to customer service.

Policies that apply to only one department belong there too, in a child tag such as <department_policies>, still carrying their “because” as in step 2. The simplified code below shows only how one department’s pieces are joined to the shared part:

# Illustrative, simplified: combine the shared layers with one department's config
SHARED = "<role>...</role>\n<policies>...</policies>\n<customer_context>...</customer_context>"

DEPTS = {
    "accounting": {
        "department_role": "You help accounting staff reconcile shipping invoices.",
        "main_instruction": "Answer reconciliation questions based on the procedures in the context.",
        "output_format": "A table with: order ID, amount, reconciliation status, notes.",
        "department_policies": [
            "Never write 'Reconciled' when the waybill system has no status yet, because accounting posts entries based on the answer."
        ],
        "examples": [
            "Q: Has order VD-0001 been reconciled? A: | VD-0001 | ... | Reconciled | |"
        ],
    },
}

def build_prompt(dept: str) -> str:
    c = DEPTS[dept]
    policies = "\n".join(f"    <policy>{p}</policy>" for p in c["department_policies"])
    examples = "\n".join(f"    <example>{e}</example>" for e in c["examples"])
    return f"""{SHARED}
<department_config>
  <department_role>{c['department_role']}</department_role>
  <main_instruction>{c['main_instruction']}</main_instruction>
  <output_format>{c['output_format']}</output_format>
  <department_policies>
{policies}
  </department_policies>
  <examples>
{examples}
  </examples>
</department_config>"""

Check: run print(build_prompt("accounting")) and read the output. Every opening tag needs a closing tag, and accounting’s own policies must not leak into the shared <policies> block.

Now look at what comes out. Say an accounting clerk asks, “Has order VD-1023 been reconciled?” With a prompt that has only the three shared layers, an illustrative answer might be nothing more than a generic paragraph:

To check whether an order has been reconciled, you can look in the system
or contact the relevant department.

With the accounting block added, the same question (still illustrative) produces exactly the four-column table this department needs:

| Order ID | Amount | Reconciliation status | Notes                                                                 |
| VD-1023  | —      | Undetermined          | The waybill system has no status yet; ask the person in charge of reconciliation |

The cell to watch is “Reconciliation status”: the model writes “Undetermined” instead of filling in “Reconciled” to complete the table, because accounting’s own policy forbids it. The amount cell is left empty instead of holding an invented figure, and the reminder in the “Notes” column to ask the person in charge comes from the shared policy on saying clearly when unsure.

Further check: if answers start copying the examples almost word for word, your examples are too similar. Replace one with a completely different situation.

Step 6: the colleague test

Anthropic offers a “golden rule”: give the prompt to a colleague who knows almost nothing about the task and ask them to follow it. If they are confused, Claude will be too.

Ask someone outside the project to read the whole prompt and then play the accounting assistant. Every time they ask “what does this mean?”, you have found a line to rewrite.

Common mistakes

The first mistake is renaming tags between versions, for example writing <context> today and switching to <background> next week. That defeats the consistency Anthropic recommends.

The second is putting one department’s policies in the shared <policies> instead of <department_policies>, which saddles the other department with rules that make no sense for it. The third is writing a department role so long that it overwhelms the company-wide role.

How the request arrives at a client

At a client, nobody calls it a “layered prompt”. They say: “My team wants the assistant to answer a bit differently.”

Your first move should be to sit down with that department and ask three questions: what role they need the assistant to play, what format answers must follow, and what it must never say, with the reason why.

Those three answers fill the <department_config> block, including <department_policies>.

On your CV, do not just write “wrote prompts”. Write that you designed a prompt shared by several departments, where adding a new department takes only one extra configuration block.

Once the assistant spreads beyond its first department, the hard part is no longer writing good sentences. It is deciding which parts belong to the whole company and which belong to a single department.

Was this article useful?

Use with your AI assistantAsk Claude ↗Ask ChatGPT ↗
4 sources
Read next on the roadmap · Stage 3: Applied AIProviders are locking the temperature dial. Tuning still mattersMax tokens, stop sequences and penalties still decide whether output is usable, and each client task, from extraction to support bots, needs its own settings.