Structure and delimiters
The model sees one token stream. Humans use headings, whitespace, and color. Models need role messages, markup, and delimiters so instructions stay separate from source material. Anthropic: when instructions, context, examples, and variable inputs mix, use XML-style tags. OpenAI: keep a stable prefix for prompt caching; put dynamic content later.
System vs user
If a product has no system channel, put policy in a fixed leading block and materials in later tags. Same idea: policy first, materials next, “now please…” last.
Cursor rules, Claude Code CLAUDE.md, and LangChain system_prompt are system contracts. The user’s sentence is the user task.
XML tags (Anthropic style)
Tags need not be valid XML. Names should be stable and descriptive: <instructions>, <document>, <example>. Nest when you have several sources:
Gain: the model is less likely to treat “ignore the above” inside a document as your new policy (defensive notes in Pitfalls). Cost: ten layers of tags on a three-line task is noise.
Markdown sections
Markdown headings work well for GPT-family models and for humans who maintain the prompt:
Use fenced code blocks for code; named header rows for CSV. The value is the boundary, not a magic glyph.
Order and length
A useful order (stable → changing):
- Policy / role (cacheable prefix)
- Tool-use policy (if tools exist)
- Examples
- This turn’s materials
- This turn’s question and output format
Include only materials you will use. The longer the context, the easier it is to drown the instruction—see Evaluation and “overlong context” in Pitfalls. For a whole book, retrieve (RAG, LangChain RAG); do not treat prompt engineering as “paste everything.”