writing-system-prompts
Writing LLM System Prompts
A well-built system prompt steers behavior across the whole conversation and — if structured for KV-cache reuse — costs a fraction of an uncached prefix on providers that offer prompt caching (Anthropic, OpenAI, Bedrock, Vertex, etc.).
Rules
-
Put the role first, in one sentence. A single descriptive sentence in the system field (not the user turn) anchors tone and vocabulary, e.g.
You are a helpful coding assistant specializing in Python.Plain prose at the top — do not wrap in markup. -
Order static-first, dynamic-last. Cache hits require a byte-identical prefix. Sequence: role → tools/policies → long reference docs / few-shot examples → cache breakpoint → dynamic context → user turn. Why: one changed token before the breakpoint drops you from cached-read pricing (~10% of input) to full input cost.
-
Mark cache breakpoints explicitly when the provider supports it. Most caching is opt-in (e.g. Anthropic
cache_control, Bedrock cachePoint). Place a breakpoint at the end of each stable block to reuse. Cache writes typically cost more than base input; reads a fraction of it. TTLs vary (commonly ~5 min, sometimes longer tiers). Only cache prefixes you'll reuse within the TTL — sparse traffic pays the write penalty repeatedly.# Anthropic example — adapt to your provider's syntax system=[ {"type": "text", "text": ROLE_AND_POLICIES}, {"type": "text", "text": LONG_REFERENCE_DOC, "cache_control": {"type": "ephemeral"}}, ]
More from lwlee2608/agent-skills
gh-create-pr
Use when creating/raising/opening/submitting a GitHub PR. Produces short, feature-focused descriptions without a test plan.
32ascii-diagram
Use after generating or editing ASCII art, box diagrams, tables, or any monospace text art to ensure all lines, corners, and boxes are properly aligned.
30prefer-make
Use before running any Go toolchain command (`go build`, `go test`, `go run`, `go vet`, `go fmt`, `golangci-lint`). Substitutes make targets when a Makefile is present.
30gh-update-pr
Use when updating GitHub PR title or body. Works around the gh pr edit GraphQL bug caused by GitHub's Projects Classic deprecation.
29create-skill
Use when creating a new agent skill. Ensures the skill follows quality guidelines for SKILL.md files.
25linear
Use when the user wants to interact with Linear.app — reading or searching issues/tickets.
21