caching-strategy

caching-strategy is a skill for Claude Code from marcusgoll/Spec-Flow. It costs 74 tokens per session (7,576 once invoked), scanned A, original, MIT.

A caching system that remembers results from repeated file reads, searches, package lookups, web searches, and calculations for a limited time. It refreshes cached results when files change or the cache expires.

In plain words
What is it for?
Use it when workflows repeatedly read project documents, search the codebase, look up npm packages, count tokens, or run the same web search.
Why use it?
It avoids repeating the same expensive work during different stages of a coding task. This reduces unnecessary file access, searches, network requests, and token counting.

Skill for Claude Code

Written for Claude Code: installed under .claude/.

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/marcusgoll/spec-flow/caching-strategy
Any agent
npx skills add marcusgoll/Spec-Flow --skill caching-strategy
Clone the repo
git clone --depth 1 https://github.com/marcusgoll/Spec-Flow

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for caching-strategy

README.md
[![agentmods](https://agentmods.dev/badge/skills/marcusgoll/spec-flow/caching-strategy.svg)](https://agentmods.dev/skills/marcusgoll/spec-flow/caching-strategy)
Your own site
<a href="https://agentmods.dev/skills/marcusgoll/spec-flow/caching-strategy"><img src="https://agentmods.dev/badge/skills/marcusgoll/spec-flow/caching-strategy.svg" alt="Measured on agentmods" height="20"></a>
Per session 74 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 7,576 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00074 $0.07576
Opus 5 $0.00037 $0.03788
Sonnet 5 $0.00015 $0.01515
Haiku 4.5 $0.00007 $0.00758

Measured 6d ago against content hash ac90da460b1d, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

caching-strategy scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/skills/caching-strategy/SKILL.md · 1,060 lines

How it starts

The opening of the file, as written. The whole thing — 1,060 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Repeated work wastes time and resources:

  • Reading docs/project/api-strategy.md 5 times in /plan phase (5× file I/O)
  • Searching codebase for "user" pattern 3 times (3× grep execution)
  • Fetching npm package info for same package repeatedly (3× network calls)
  • Counting tokens in spec.md every phase (5× token calculation)
  • Web searching "React hooks best practices" multiple times (3× API calls)

This skill implements smart caching with:

  1. File read cache: Cache file contents until file modified (mtime check)
  2. Search result cache: Cache grep/glob results for 30 minutes
  3. Network request cache: Cache npm/web API calls for 15-60 minutes
  4. Computed value cache: Cache expensive calculations until inputs change
  5. Automatic invalidation: TTL expiration + file modification detection

The result: 20-40% faster workflow execution with zero behavior changes (transparent caching).

<quick_start> <cacheable_operations> High-value caching targets (biggest time savings):

  1. Project documentation reads (15min TTL):

    • docs/project/api-strategy.md
    • docs/project/system-architecture.md
    • docs/project/tech-stack.md
    • Read once per phase, not 5× per phase
  2. Codebase searches (30min TTL):

    • Grep: "user" in **/*.ts → Cache results
    • Glob: **/components/**/*.tsx → Cache file list
    • Repeated in anti-duplication, implementation, review
  3. Package registry queries (60min TTL):

    • npm info for package versions
    • Dependency metadata
    • Rarely changes during single workflow
  4. Web searches (15min TTL):

    • Documentation lookups
    • Error message searches
    • Best practice research
  5. Token counts (until file modified):

    • spec.md token count
    • plan.md token count
    • Recompute only when file changes </cacheable_operations>

<basic_workflow> Before caching:

Phase 1 (/plan):
  - Read api-strategy.md (250ms)
  - Read tech-stack.md (200ms)
  - Read api-strategy.md again (250ms) ← Redundant
  - Grep "user" in codebase (3s)
Total: 3.7s

After caching:

Phase 1 (/plan):
  - Read api-strategy.md (250ms) → Cache
  - Read tech-stack.md (200ms) → Cache
  - Read api-strategy.md (from cache: 5ms) ← Cached!
  - Grep "user" (3s) → Cache
Total: 3.45s saved 250ms (6.7%)

Across multiple phases:

/plan:   Read api-strategy.md (250ms) → Cache
/tasks:  Read api-strategy.md (from cache: 5ms) ← Saved 245ms
/impl:   Read api-strategy.md (from cache: 5ms) ← Saved 245ms
/opt:    Read api-strategy.md (from cache: 5ms) ← Saved 245ms

Total saved: 735ms on single file across 4 phases

</basic_workflow>

<immediate_value> Typical /feature workflow (7 phases):

Without caching:

Phase reads:
- api-strategy.md: 7 reads × 250ms = 1.75s
- tech-stack.md: 5 reads × 200ms = 1s
- spec.md: 10 reads × 150ms = 1.5s
- Grep "user": 3 searches × 3s = 9s
- npm info react: 2 calls × 500ms = 1s
Total redundant work: 14.25s

With caching:

Phase reads:
- api-strategy.md: 1 read (250ms) + 6 cache hits (30ms) = 280ms
- tech-stack.md: 1 read (200ms) + 4 cache hits (20ms) = 220ms
- spec.md: 1 read (150ms) + 9 cache hits (45ms) = 195ms
- Grep "user": 1 search (3s) + 2 cache hits (10ms) = 3.01s
- npm info react: 1 call (500ms) + 1 cache hit (5ms) = 505ms
Total with caching: 4.21s

Time saved: 14.25s - 4.21s = 10.04s (70% reduction)

Savings scale with workflow length:

  • Single phase: 5-10% faster
  • Full /feature (7 phases): 20-30% faster
  • /epic (20+ phases): 30-40% faster </immediate_value> </quick_start>

Identify operations that are:

  • Idempotent: Same input → Same output
  • Expensive: Takes >100ms
  • Repeated: Called 2+ times
  • Predictable: Output doesn't change rapidly

Cacheable:

  • File reads (same file, unchanged content)
  • Codebase searches (same pattern, unchanged code)
  • API calls (package info, docs, rarely changes)
  • Expensive computations (token counts, parsing)

Read the full file on GitHub · 1,060 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 1,060 lines · 74 tokens per session scan A ac90da460b1d

Subscribe to this mod's changes

caching-strategy is a skill published in the GitHub repository marcusgoll/Spec-Flow (92 stars, last pushed 4mo ago), licensed MIT. It adds 74 tokens to every session and 7,576 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.