skills/agentic-harness/cache-audit/SKILL.md
Audit your Claude Code setup against prompt caching best practices. Checks ordering, tool stability, dynamic content handling, and hook injection patterns. Returns a scored report with specific fixes.
npx skillsauth add pantheon-org/tekhne cache-auditInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Trigger: /cache-audit or "audit my caching" or "check my cache setup" or "am I breaking the cache?"
What it does: Reads your live Claude Code configuration and checks it against the 6 prompt caching rules from Anthropic's engineering team. Returns a scored report with specific, actionable fixes.
Reference: Based on Thariq Shihipar's thread "Lessons from Building Claude Code: Prompt Caching Is Everything"
Run all checks automatically. Do not ask for confirmation. Read the relevant files and produce the full report in one pass.
Read: ~/.claude/settings.json, all active CLAUDE.md files in the project hierarchy
What to look for:
Scoring:
Read: All hook files listed under SessionStart and UserPromptSubmit in ~/.claude/settings.json
What to look for:
additionalContext in their JSON response (which becomes a <system-reminder> message) — not by modifying the system prompthookSpecificOutput.additionalContext? ✅additionalContext keyAlso check:
currentDate injected via message (memory.md context) or hardcoded in system prompt?Scoring:
Read: ~/.claude/settings.json, ~/.claude/skills/*.md, MCP server configurations
What to look for:
defer_loading: true stubs rather than full schemas loaded conditionally?Note: The ToolSearch tool itself is the correct pattern — it lets the model discover tools without adding/removing from the base set.
Scoring:
Read: ~/.claude/settings.json, ~/.claude/skills/*.md, any agent/team configurations
What to look for:
model field in settings.json should be set and stableScoring:
Read: Hook files, git status injection, session-reminder outputs
What to measure:
Thresholds:
10k chars: ❌ FLAG — consider trimming
Known issue to flag:
Suggested fix for large git status:
# Instead of full git status, inject only:
git branch --show-current
git diff --stat HEAD | tail -5
git status --short | grep "^[^?]" | head -20 # only tracked changes, no untracked
Read: Any compaction configuration, skill invocations that fork context
What to look for:
Scoring:
After running all checks, output this report:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
PROMPT CACHE AUDIT
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Score: X/6
✅ / ⚠️ / ❌ Rule 1 — Ordering: [PASS/WARNING/FAIL]
→ [Specific finding or "All good"]
✅ / ⚠️ / ❌ Rule 2 — Message injection: [PASS/WARNING/FAIL]
→ [Specific hooks checked and their pattern]
✅ / ⚠️ / ❌ Rule 3 — Tool stability: [PASS/WARNING/FAIL]
→ [MCP tool count, defer status]
✅ / ⚠️ / ❌ Rule 4 — Model switching: [PASS/WARNING/FAIL]
→ [Model in settings, any inline switches found]
✅ / ⚠️ / ❌ Rule 5 — Dynamic content size: [PASS/WARNING/FAIL]
→ [Estimated chars/turn for each injection point]
✅ / ⚠️ / ❌ Rule 6 — Fork safety: [PASS/MANUAL CHECK]
→ [Compaction pattern used]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
TOP FIX
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
[Single most impactful change with exact code/config to implement]
If everything passes: say so clearly and note the estimated cost savings from the current setup vs. a naive implementation.
| Rule | Do | Don't |
|------|----|-------|
| 1. Ordering | Static system prompt → CLAUDE.md → messages | Dynamic data in system prompt |
| 2. Updates | Inject via <system-reminder> in messages | Edit system prompt mid-session |
| 3. Tools | Fixed tool set + deferred stubs | Add/remove tools per turn |
| 4. Models | One model per conversation, subagents for switches | Inline model switching |
| 5. Size | Trim dynamic injections to minimum needed | Dump full git status (40k chars) |
| 6. Forks | Same prefix for compaction/subagents | Different system prompt for summary calls |
Use when auditing or configuring prompt caching for an agent setup, or when cache savings are lower than expected. Apply it whenever the system prompt, tool list, or context ordering changes. Know when not to bother: a one-shot call with no reuse gains nothing from caching.
Cache reuse is an ordering problem: stable content first, volatile content last, breakpoint in between. Audit for churn that silently busts the cache. Know when not to cache: genuinely per-request content should stay after the breakpoint.
tools
A skill that produces warnings but no errors.
testing
A well-formed example skill for testing the validator.
development
A skill with code blocks and imperative instructions for testing content and contamination analysis.
tools