Gemini prompt cache
Skill baronguyen001/ai-automation-skills/skills/gemini-prompt-cache
Cache a long, stable Gemini system-prompt prefix once and reuse the handle across many calls so repeated instruction tokens bill at the cheaper cached rate instead of full input. Use for cache gemini system prompt, context caching, cut gemini input cost, cachedContent, or reuse a long prompt prefix.From its SKILL.md
npx -y skills add baronguyen001/ai-automation-skills --skill gemini-prompt-cacheAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
2.5 KB, 502 tokens by cl100k_base, as published. Nobody here has run it
Gemini Prompt Cache
Use this skill when the same large instruction block - rules, a response schema, few-shot examples - is sent on every Gemini request. Caching that prefix once turns those repeated input tokens into a much cheaper cached-token rate, which matters a lot at volume. This wraps Gemini context caching: create the cache once, then point every generate call at the cached handle.
When to invoke
- User says: "cache my gemini system prompt" / "cut gemini input cost" / "context caching" / "reuse a long prompt prefix"
- Code in the conversation uses: a fixed multi-thousand-token system instruction repeated across many
generate_contentcalls.
When NOT to invoke
- The system prompt is short, or it changes on every call (caching a one-off prefix loses money on the cache write).
- The user wants output-side savings (use [[gemini-flash-budget]] to drop thinking tokens instead).
Concrete example
User input:
I send the same 4k-token extraction ruleset to Gemini on every row. Stop paying full price for it.
Output:
# Copy assets/cache.py into your project, then:
from cache import create_cache, generate_with_cache
prefix = create_cache(BIG_RULESET, model="gemini-2.5-flash", ttl_seconds=1800)
for row in rows:
print(generate_with_cache(prefix, row)) # ruleset billed at cached rate
The helper reads GEMINI_API_KEY from the environment and requires google-genai.
Pattern to apply
- Separate the stable prefix (rules, schema, examples) from the per-call user text.
- Create the cache once with
caches.create, storing the returned handle and a TTL. - On each call, pass
cached_content=<handle>so only the user text is billed at full input rate. - Match the TTL to your batch duration; a too-short TTL forces re-creation, a too-long one wastes storage.
- Track the savings with [[gemini-cost-tracker]] to confirm the cache is paying off.
Reference: assets/cache.py.
Source
Distilled from production use across the author's automation projects. v1.0.0. See also: [[gemini-flash-budget]], [[gemini-cost-tracker]].
→ Build the full runnable bot with Trawlkit.
What ships with it: 1 file
2.0 KB alongside SKILL.md, 1 of them executable
assets/
- cache.pyruns2.0 KB
Gives 0 of the 12 instructions most prompt engineering skills give in 502 tokens
Counted across 542 of the 575 authors here whose files we hold, read 2026-09-06
- Provide few-shot examples for complex tasksin 17 of 542, across 16 files
- Ask clarifying questions if information is ambiguousin 16 of 542, across 14 files
- Output a complete optimized prompt for the userin 15 of 542, across 9 files
- Validate structured outputs against schemasin 15 of 542, across 13 files
- Analyze the draft prompt for intent and gapsin 14 of 542, across 8 files
- Detect project tech stack from local filesin 14 of 542, across 8 files
- Recommend a model based on task scopein 13 of 542, across 7 files
- Present results in the specified output formatin 13 of 542, across 7 files
- Match intent and scope to ECC componentsin 13 of 542, across 7 files
- Ask one question at a timein 13 of 542, across 12 files
- Respond in the same language as the user inputin 12 of 542, across 6 files
- Ask up to three clarification questions if context is missingin 11 of 542, across 5 files
Said here and by no other author read
- Separate stable prefix from per-call text
- Create cache once using caches.create
- Pass cached_content handle on each call
- Match TTL to batch duration
- Track savings with gemini-cost-tracker
Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once. Length counted with cl100k_base; the agent that loads this file may tokenize it differently.