Works with the AI Agents you already use
Agent Context Engineering: Prompts, Caching and Cost
Engineer what goes into your agent's context window: system prompt structure, cache-friendly ordering, retrieval, memory and compaction, token budgets, and the cost levers in the right order, plus a cache-buster scanner.
$7
Agent Context Engineering: Prompts, Caching and Cost
Example session with this skill installed
Our support agent's prompt cache hit rate is basically 0% and the bill keeps growing. Look at agent.py and fix it. Write the corrected file as agent_fixed.py and explain the changes in notes.md.
- Read your context and instructions
- Compiled the agent context engineering
notes.md: the system prompt interpolated the current time and a new UUID on every call, so no prefix ever matched; tools were filtered through a set, so their order varied; the profile was serialised without sort_keys; and the model switched by question length, which splits the cache. agent_fixed.py: frozen system prompt with a cache breakpoint, tools in a fixed sorted order, the date and user profile moved into the latest user turn with sorted JSON, one model per conversation. cache_audit.py now reports 0 findings.
Connects securely to your tools. The creator never sees your data.
About this skill
The context window is your agent's working memory and your biggest cost line. Good context engineering means the smallest set of high-signal tokens that lets the model do the next step well, laid out so the expensive part is cached.
What your agent does with it
- System prompt structure: role and goal, context, how to work, boundaries, output contract, a few examples; reasons instead of shouted rules.
- Cache-friendly ordering: tools, frozen system prompt and long docs first, volatile data last; the silent cache killers (timestamps and ids in the prompt, unsorted JSON, non-deterministic tool order, per-request model switching, edited history).
- A cache-buster scanner (
cache_audit.py) for Python agent code: volatile values in prompt-building lines, unsortedjson.dumps, set-ordered tools, f-string system prompts with per-request data, several model ids in one file. - Retrieval into context: agentic vs pre-retrieval, snippets with ids, chunking by meaning, retrieval evaluated separately.
- Long-running agents: context editing, compaction, external memory, sub-agent isolation, structured state.
- Token budgets per section and cost levers in order: caching, smaller tool outputs, fewer turns, batch, lower effort, smaller model, judged by cost per successful task.
Included: SKILL.md, cache_audit.py (standard library), and an eval case with a cache-busting agent to fix.
Part of the Production AI Agents series. Pair with Agent Evals to prove each change; start free with Agent Architecture.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for LLM Ops.
The scanner is static and heuristic for Python code; confirm findings with the API's cache usage fields. Provider-specific features (cache breakpoints, context editing) vary; check your provider's docs.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 1 day ago
- Software
Python 3.10+
Permissions
File Scopes
cache_audit.py reads Python files locally and makes no network calls.