prompt-caching
/prompt-caching
Buforuje stałe części promptu, żeby długa pętla agenta nie płaciła pełnej ceny za każdą turę, gdy prompt systemowy i narzędzia się nie zmieniają.
- Autor
- archive228 ↗
- Repozytorium
- loopkit ↗
- Licencja
- MIT
- Ostatnia zmiana repozytorium
- 15.07.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 1
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 15.07.2026, bez odwołań do wycofanych modeli i API.
MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.
Co robi i kiedy
Buforuje stałe części promptu, żeby długa pętla agenta nie płaciła pełnej ceny za każdą turę, gdy prompt systemowy i narzędzia się nie zmieniają.
Oryginalny opis (EN)
Cache the parts of the prompt that don't change so a long-running loop stops paying full price on every turn. Use when the system prompt, tool defs, or reference docs are stable across many turns.
Jak działa
- Where to put breakpoints
- TTL choice
- Staleness rules — cache invalidation is silent
- When NOT to cache
- Red flags
- The math
Podgląd SKILL.md
--- name: prompt-caching description: Cache the parts of the prompt that don't change so a long-running loop stops paying full price on every turn. Use when the system prompt, tool defs, or reference docs are stable across many turns. when_to_use: long session, repeated large context, cost climbing, system prompt >1024 tokens, unchanged tool definitions across turns --- # Prompt Caching Every turn of a Plan→Act→Verify loop resends the same system prompt, the same tool definitions, and (usually) the same reference docs. Without cache breakpoints you pay full input price on all of it, every turn. With them, cached reads cost ~10% of the write. ## Where to put breakpoints Cache from the top of the prompt down. The cache is prefix-matched — a break in the middle invalidates everything after it. 1. **System prompt** — mark the end of it as a breakpoint if it's >1024 tokens (Sonnet/Opus) or >2048 (Haiku). 2. **Tool definitions** — cache immediately after, if the tool set is stable across the loop. 3. **Large stable docs** — repo map, style guide, spec — before any turn-specific user text. 4. **User message stem** — only if the same preamble repeats every turn. Everything past the last breakpoint is billed fresh every turn. That's fine — that's where the changing content goes. ## TTL choice - **5-minute cache** (default) — for tight loops where turns are seconds apart. Free to write. - **1-hour cache** — for slow loops (human in the loop, background jobs). Write cost is higher; break-even is ~2 hits. Pick 5m unless you know turns are minutes apart. ## Staleness rules — cache invalidation is silent - **Any byte change** above the breakpoint invalidates the cache from that point. - **Reordering** tools or messages counts as change. - **Trailing whitespace** counts as change. - **A different model version** counts as change. If cost isn't dropping, log the cache-hit metric. Do not assume. ## When NOT to cache - Prompt <1024 tokens — below the minimum block size, no savings. - One-shot calls — no reuse, cache write is wasted. - Highly dynamic system prompt (per-user templating) — cache misses will exceed hits. ## Red flags - **Cost graph flat after adding breakpoints** — you're invalidating on every turn. Diff two consecutive requests byte-for-byte above the breakpoint. - **Breakpoint after user message** — pointless; the user message changes every turn. - **Four+ breakpoints** — max is four; extras are ignored silently. - **Caching a prompt that gets edited mid-session** — one edit above the cut wipes all downstream savings. ## The math Cache write ≈ 1.25× normal input. Cache read ≈ 0.1× normal input. So a stable 20K-token prefix hit N times: N=1 costs more than no-cache; N=2 breaks even; N=10 costs ~15% of no-cache. Long loops win big; short chats lose. Cache is the single biggest cost lever on a long-running agent. Set it once at the start of the loop, verify hits, forget it.
Wersje
| Repozytorium | Wynik | Licencja |
|---|---|---|
| Ta strona · archive228/loopkit | 90 | MIT |
| cestercian/claude-playbook-skills | 100 | MIT |
| latestaiagents/agent-skills | 100 | MIT |
| Amey-Thakur/AI-SKILLS | 100 | MIT |
| cobusgreyling/agent-skills | 100 | Apache-2.0 |
| rootcastleco/rei-skills | 90 | MIT |
| davila7/claude-code-templates | 90 | MIT |
Migawka bazy z 13.11.2026 · wersja paczki 5955a5b93e84 (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 5 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 90stable-prompt-cache-methodology
Znajduje, które sekcje promptu zmieniają się między turami, gdy agent płaci za pełne przepisanie przy każdej wiadomości. - 100context-audit
Audytuje układ kontekstu agenta w czterech miejscach: prompt systemowy, narzędzia, historia i ogon, w tym prompt caching, koszt tokenów i plik CLAUDE.md, tylko raportując wnioski. - 100prompt-caching-strategy
Optymalizuje współczynnik trafień cache promptów: analizuje strukturę promptu, wskazuje treści nadające się i nienadające się do cache'owania i proponuje przebudowę dla OpenAI, Anthropic i innych dostawców. - 100cortex-prompt
Buduje gotowy do produkcji pakiet promptu: prompt systemowy, przykłady few-shot, format wyjścia, obsługę przypadków brzegowych i kryteria ewaluacji. - 100prompt-caching-patterns
Pomaga wdrożyć cache'owanie w aplikacjach LLM: cache semantyczny, cache odpowiedzi i strategie ograniczające koszty powtarzanych promptów. - 90prompt-engineering
Tworzy, poprawia i przegląda prompty do LLM, takie jak prompt systemowy, skill albo agent, oraz diagnozuje ich błędy.