Subchapter 20.1
references/core-patterns.mdMarkdown5 KBView on GitHub
Use markers when the prompt mixes different content types:
Good section names are concrete and stable:
<role><goal><context><tool_policy><workflow><constraints><output_format>Do not add markup around every sentence. Markers are useful when they carve the prompt into distinct blocks, not when they add noise.
If the target stack or model family responds better to plain markdown, use headings and bullets instead of XML-style tags. The structure matters more than the syntax.
| Block type | Examples | Content |
|---|---|---|
| descriptive | <context>, <state>, <environment> | facts, inputs, current state |
| rules | <behavior>, <constraints>, <tool_policy>, <workflow> | directives |
Rules:
Keep these layers separate:
If a rule should apply across tasks, keep it out of the user payload and put it in the stable layer. Keep one authoritative owner for each major behavior rule instead of repeating it across all layers.
Collapse common duplicates such as:
When prompts are long, separate policy from evidence explicitly:
For long-context prompts, place long evidence before the final query and keep the actual ask in a terminal section. Do not cargo-cult this ordering into short prompts that do not need it.
When a runtime concatenates prompt layers from different owners:
| Layer | Owns | Must not own |
|---|---|---|
| platform | tool policy, output contract, safety, escalation, workflow | voice-only identity |
| deployer/persona | voice, tone, domain framing, sparse identity files | load-bearing behavior |
| user payload | task facts, variables, current request | durable policy |
Rules:
AGENTS.md, CLAUDE.md, or persona files are empty or customized.Use path inventories when prompts depend on repo docs, specs, or policies.
<external_files>
- `AGENTS.md` - repo agent rules; loaded
- `docs/api.md` - API contract; reference before endpoint changes
- `SECURITY.md` - security policy; reference for disclosure or auth changes
</external_files>Rules:
loaded, referenced, or out of scope.docs/api.md over “read the docs”.<behavior>, <constraints>, <tool_policy>, <workflow>), not buried inside descriptive markers like <context>, <state>, or <turn-state>.| Symptom | Likely fix |
|---|---|
| Output format drifts | Add a stronger output contract or a format example |
| The agent guesses instead of checking | Add tool-use criteria and “gather facts before acting” language |
| The agent stays too passive | Add explicit default behavior and action bias |
| The agent is too aggressive | Add ask-first and escalation boundaries |
| Responses are verbose | Tighten output sections and verbosity constraints |
| The prompt is long but still unstable | Remove duplicate rules and choose one owner per behavior |
| Long context causes confusion | Separate context from instructions and move the query to a clear terminal section |
| The prompt works on one provider but not another | Split base prompt from provider-specific adapter notes |