home/roleplay/cache-alignment

Cache Alignment

GPTClaudeGemini··1,008 copies·updated 2026-07-14
cache-alignment.prompt
# Cache alignment — prefix stabilization rules

LLM providers (Anthropic, OpenAI, Gemini) cache request prefixes —
typically the system prompt plus the first few turns. Cache hits cut
latency by ~80% and cost by ~90% on the cached portion. But cache hits
require byte-identical prefixes; a single character change ahead of a
`cache_control` breakpoint invalidates everything after it.

This file gives the rules for keeping prefixes stable.

## The rule, in one sentence

> Static content goes at the head. Dynamic content goes at the tail, after
> the last `cache_control` breakpoint.

## What counts as "dynamic"

Anything that changes between requests:

- **Timestamps** — "Today is 2026-06-18", "Current time: …"
- **Session IDs** — "Session: abc123"
- **Current working directory** — "CWD: /home/z/project/src"
- **Recent file lists** — "Recently edited: foo.py, bar.py"
- **Git state** — "On branch main, commit abc123"
- **Per-user preferences** — "User likes terse answers"
- **Random examples** — "Here's a random tip: …"
- **Conversation counters** — "Turn 5 of N"

If it would change between two consecutive requests, it's dynamic.

## What counts as "static"

Anything that stays the same across all requests in a session:

- The agent's identity ("You are a coding agent…")
- The agent's capabilities ("You can read files, run commands, …")
- The agent's style guidelines (the verbosity steering block, if level
  doesn't change)
- The list of available tools (their schemas, not their call counts)
- Project conventions ("This codebase uses 4-space indentation, …")
- Long reference documents loaded once at session start

## How to structure the system prompt

when to use it

Community prompt sourced from the open-source GitHub repo roman-ryzenadvanced/headroom-skill (Apache-2.0). A "Cache Alignment" style prompt — adapt the placeholders and specifics to your task. Imported as-is and not independently retested here, so check the output before relying on it.

tags

roleplaycommunitygeneral

source

roman-ryzenadvanced/headroom-skill · Apache-2.0