system-vs-user-prompt
БесплатноБез исполняемых скриптовНе проверенWhat belongs in system prompt vs user prompt and why. Placement decisions for API calls, system messages, and prompt architecture — system as…
от crouton-labs★ 25 звёзд на GitHubОб этом скилле
System Prompt vs User Prompt
The single most consequential decision in prompt architecture is where an instruction lives. The same sentence placed in the system prompt vs. the first user message produces measurably different behavior — not because the words change, but because the model's relationship to them changes.
This skill covers the mechanics of why placement matters, what each zone is for, and what breaks when you get it wrong. For API patterns, caching math, and security details, see reference.md.
prompting-effectively covers the broader Two Zones framework. This skill goes deep on the system/user boundary specifically.
The Cognitive Model
System prompt = identity; user messages = task. Everyone knows that. The interesting question is why placement produces measurably different behavior — and what breaks when you get it wrong.
Why Placement Matters Mechanically
Position has direct effects on instruction compliance:
System prompts benefit from primacy. Liu et al. (2023) — "Lost in the Middle" — showed a U-shaped recall curve: models retrieve information best from the beginning and end of context. System prompts are always at position 0. In a long conversation, early user messages end up in the middle and suffer significant recall degradation.
System prompts get trained authority, not just positional advantage. OpenAI's Instruction Hierarchy paper (2024) demonstrated that explicit hierarchical training (Platform > Developer > User) improves robustness against prompt injection by 20–30% on benchmarks. The hierarchy isn't just positional — it's baked into model weights.
User messages accumulate and dilute. In multi-turn conversations, each new message pushes earlier ones further from the current generation point. The system prompt stays at position 0 regardless of conversation length. Instructions placed in early user turns get diluted as the conversation grows.
Practical test: If an instruction must hold reliably at turn 50, it belongs in the system prompt. If it only applies to the current task, the user turn is fine.
Note: System prompts only accept text. Images, files, and structured document blocks must go in user messages — which reinforces the conceptual model: system prompt is behavioral, user messages carry content.
Multi-Turn Degradation
System prompt instructions outlast user message instructions in long conversations because the system prompt occupies a persistent first position while user message instructions get interleaved and diluted by subsequent turns.
However, all instructions degrade as conversations grow. Recency of recent turns creates competing attention signals that partially override even system-level guidance.
Mitigation: For critical constraints in long conversations (10+ turns), periodically reinforce in user messages using a "reminder" pattern. Test instruction compliance at turn 10 and turn 20, not just turn 1. For very long sessions, consider a "system prompt refresh" by appending a summary of current constraints into the user turn.
Caching Implications
Prompt caching makes placement a cost/latency decision, not just a behavioral one.
The rule: System prompt = stable, cacheable zone. User prompt = variable, per-request zone. Never put per-user data, session state, uploaded documents, or dynamic content in the system prompt — any variation produces a cache miss.
Anthropic gives a 90% discount on cached reads (cached tokens cost 10% of base price). OpenAI gives 50% off. Any variation in the system prompt produces a cache miss. Per-user data or session state injected into the system prompt means every request is unique — zero cache benefit.
At scale this is significant: a 10K token system prompt cached across 100 requests costs roughly 11% of what an uncached equivalent would. See reference.md → Caching Math for the breakdown. See also context-management for comprehensive caching strategies.
Provider Differences
All major providers have a dedicated system channel, but the implementation differs:
| Provider | API Pattern | Caching |
|---|---|---|
| Anthropic | Dedicated system field (not a message) |
Explicit cache_control, 90% discount |
| OpenAI | system role or newer developer role in messages |
Automatic, 50% discount |
system_instruction in constructor |
Explicit, 75% discount, 32K min | |
| Open-source | Template tags, inconsistent enforcement | N/A |
OpenAI note: The newer developer role (introduced with o1 family, late 2024) gets stronger adherence than system on newer models. Same position, trained with explicit Platform > Developer > User hierarchy. Update to developer for o1+ models.
Open-source caution: Llama, Mistral, and similar models don't enforce system > user priority as reliably as commercial APIs — it depends heavily on
Установить system-vs-user-prompt в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл system-vs-user-prompt?
What belongs in system prompt vs user prompt and why. Placement decisions for API calls, system messages, and prompt architecture — system as identity/constraints/tools, user as task/context/state. Use when designing system prompts, structuring API calls, deciding where instructions belong, writing prompts for production systems, or debugging instruction compliance.
Как установить скилл system-vs-user-prompt?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл system-vs-user-prompt запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic