Agent skill

Caching Strategies

by ThibautBaissac in ThibautBaissac/rails_ai_agents

Implements Rails caching patterns for performance optimization.

MITAuto-check passedBackend & APIs

Install Caching Strategies

skills CLI
$ npx skills add ThibautBaissac/rails_ai_agents --skill caching-strategies -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install ThibautBaissac/rails_ai_agents caching-strategies --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/ThibautBaissac/rails_ai_agents.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/caching-strategies .claude/skills/caching-strategies && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
caching-strategies
GitHub stars
665
Token cost
~1.4k tokens
SKILL.md length
347 words
Files
4 (incl. references)
Skills in repo
19
Repo updated
First seen
Licence
MIT

At a glance

Implements Rails caching patterns for performance optimization.

  • Adding fragment caching
  • SKILL.md covers Overview, Quick Start, Cache Store Options and Fragment Caching, plus 8 more sections
  • Calls rails
  • Russian doll caching

What it does

Caching Strategies is an agent skill from ThibautBaissac/rails_ai_agents. Implements Rails caching patterns for performance optimization. Use when adding fragment caching, Russian doll caching, low-level caching, cache invalidation, or when user mentions caching, performance, cache keys, or memoization. WHEN NOT: General query optimization (use performance-optimization), background job processing, or problems caused by N+1 queries rather than missing caches.

Its SKILL.md is about 1.4k tokens, which your agent loads only when the skill is triggered. The skill folder holds 4 other files, including reference files (for example `references/cache-invalidation.md`, `references/http-caching-and-testing.md` and `references/low-level-caching.md`).

It sits in Backend & APIs, covering Caching. It works with Redis. The repository describes itself as: Specialized AI skills, agents, rules and hooks for modern Rails AI driven-development + Spec-Driven-Development kit + MCP. The licence is MIT.

When your agent uses it

  • Adding fragment caching
  • Russian doll caching
  • Low-level caching
  • Cache invalidation

Example prompts

  • “Use the caching-strategies skill to implement Rails caching patterns for performance optimization”
  • “/caching-strategies”

What it can do on your machine

Read from SKILL.md and the folder at commit 03622f2. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • rails

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Caching Strategies loads about 1.4k tokens when it runs, and up to ~3.2k if it reads all its reference files. Until then it costs about 102 tokens; SKILL.md has 347 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~102
When it runs · the whole SKILL.md, loaded when a task matches
~1.4k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~3.2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from ThibautBaissac/rails_ai_agents at commit 03622f2, republished under its MIT licence (© ThibautBaissac). 347 words, ~1,436 tokens.

Download SKILL.mdSave it as .claude/skills/caching-strategies/SKILL.md (or your agent's skills folder). This skill also uses 3 other files; get the full folder from GitHub.
name
caching-strategies
description
Implements Rails caching patterns for performance optimization. Use when adding fragment caching, Russian doll caching, low-level caching, cache invalidation, or when user mentions caching, performance, cache keys, or memoization. WHEN NOT: General query optimization (use performance-optimization), background job processing, or problems caused by N+1 queries rather than missing caches.
paths
app/views/**/*.erb, app/controllers/**/*.rb

Caching Strategies for Rails 8

Overview

Rails provides multiple caching layers:

  • Fragment caching: Cache view partials
  • Russian doll caching: Nested cache fragments
  • Low-level caching: Cache arbitrary data
  • HTTP caching: Browser and CDN caching
  • Query caching: Automatic within requests

Quick Start

ruby
# config/environments/development.rb
config.action_controller.perform_caching = true
config.cache_store = :memory_store

# config/environments/production.rb
config.cache_store = :solid_cache_store  # Rails 8 default
# OR
config.cache_store = :redis_cache_store, { url: ENV["REDIS_URL"] }

Enable caching in development:

bash
bin/rails dev:cache

Cache Store Options

StoreUse CaseProsCons
:memory_storeDevelopmentFast, no setupNot shared, limited size
:solid_cache_storeProduction (Rails 8)Database-backed, no RedisSlightly slower
:redis_cache_storeProductionFast, sharedRequires Redis
:file_storeSimple productionPersistent, no RedisSlow, not shared
:null_storeTestingNo cachingN/A

Fragment Caching

Basic Fragment Cache
erb
<%# app/views/events/_event.html.erb %>
<% cache event do %>
  <article class="event-card">
    <h3><%= event.name %></h3>
    <p><%= event.description %></p>
    <time><%= l(event.event_date, format: :long) %></time>
    <%= render event.venue %>
  </article>
<% end %>
Cache Key Components

Rails generates cache keys from:

  • Model name
  • Model ID
  • updated_at timestamp
  • Template digest (automatic)
ruby
# Generated key example:
# views/events/123-20240115120000000000/abc123digest
Custom Cache Keys
erb
<%# With version %>
<% cache [event, "v2"] do %>
  ...
<% end %>

<%# With user-specific content %>
<% cache [event, current_user] do %>
  ...
<% end %>

<%# With explicit key %>
<% cache "featured-events-#{Date.current}" do %>
  <%= render @featured_events %>
<% end %>

Russian Doll Caching

Nested caches where inner caches are reused when outer cache is invalidated:

erb
<%# app/views/events/show.html.erb %>
<% cache @event do %>
  <h1><%= @event.name %></h1>

  <section class="vendors">
    <% @event.vendors.each do |vendor| %>
      <% cache vendor do %>
        <%= render partial: "vendors/card", locals: { vendor: vendor } %>
      <% end %>
    <% end %>
  </section>

  <section class="comments">
    <% @event.comments.each do |comment| %>
      <% cache comment do %>
        <%= render comment %>
      <% end %>
    <% end %>
  </section>
<% end %>

Use touch: true on belongs_to associations to cascade invalidation up the chain. See cache-invalidation.md for examples.

Collection Caching

Efficient Collection Rendering
erb
<%# Caches each item individually %>
<%= render partial: "events/event", collection: @events, cached: true %>

<%# With custom cache key %>
<%= render partial: "events/event",
           collection: @events,
           cached: ->(event) { [event, current_user.admin?] } %>

Low-Level Caching

Use Rails.cache.fetch with a block for the most common pattern. See low-level-caching.md for:

  • Basic read/write/fetch examples
  • Caching in service objects
  • Caching in query objects
  • Instance variable memoization
  • Request-scoped memoization with CurrentAttributes

Cache Invalidation

Three strategies: time-based expiration, key-based expiration (using updated_at), and manual deletion. See cache-invalidation.md for:

  • Time-based and key-based expiration
  • Manual invalidation in model callbacks and services
  • Pattern-based deletion (delete_matched)
  • touch: true for Russian doll cascade
  • Built-in and custom counter caches

HTTP Caching

Use stale? for conditional GET (ETags/Last-Modified) and expires_in for Cache-Control headers. See http-caching-and-testing.md for full examples.

Testing Caching

Use a :caching metadata tag to enable caching in specs. See http-caching-and-testing.md for:

  • rails_helper.rb configuration
  • Testing cached view invalidation
  • Testing cache invalidation in services
  • Performance monitoring and instrumentation

Checklist

  • Cache store configured for environment
  • Fragment caching on expensive partials
  • touch: true on belongs_to for Russian doll
  • Collection caching with cached: true
  • Low-level caching for expensive queries
  • Cache invalidation strategy defined
  • Counter caches for counts
  • HTTP caching headers for API
  • Cache warming for cold starts (if needed)
  • Monitoring for hit/miss rates

References

© ThibautBaissac, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 3 other files (references) in .agents/skills/caching-strategies of ThibautBaissac/rails_ai_agents.

  • SKILL.md
  • references/cache-invalidation.md
  • references/http-caching-and-testing.md
  • references/low-level-caching.md

Open the folder on GitHubat commit 03622f2

Compare with similar skills

Caching Strategies next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Caching Strategies compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Caching Strategies this skillThibautBaissac/rails_ai_agents665—~1.4kAutomated safety check: PassMIT
Stripe Projectsfossasia/eventyay1.7k5 repos~2kAutomated safety check: NotesApache-2.0
FoundatioFoundatioFx/Foundatio2.1k—~3.9kAutomated safety check: PassApache-2.0
FastAPI-Redis SDK Developmentredis/fastapi-redis-sdk405—~2.5kAutomated safety check: NotesMIT
Caching Patternsdilolabs/nosia2131 repos~1.9kAutomated safety check: PassMIT
Cachingcodewithmukesh/dotnet-claude-kit7561 repos~1.4kAutomated safety check: PassMIT

Similar skills

  • Stripe Projects

    fossasia/eventyay

    A skill your agent uses when the user wants to provision infrastructure or third-party services using Stripe Projects.

    1.7k GitHub starsUsed in 5 repos~2k tokens
    Backend & APIsAuto-check: notes
  • Foundatio

    FoundatioFx/Foundatio

    A skill your agent uses when working with Foundatio infrastructure abstractions for .NET -- caching, queuing, messaging, file storage, distributed locking, or background jobs.

    2.1k GitHub stars~3.9k tokensUpdated 2 days ago
    Backend & APIsAuto-check passed
  • FastAPI-Redis SDK Development

    redis/fastapi-redis-sdk

    Official

    Guides development on the fastapi-redis-sdk library itself - its connection lifecycle, dependency-injected caching, and async/sync bridging.

    405 GitHub stars~2.5k tokensUpdated 9 days ago
    Backend & APIsAuto-check: notes
  • Caching Patterns

    dilolabs/nosia

    Implements HTTP caching with ETags, fragment caching, Russian doll caching, and Solid Cache configuration.

    213 GitHub starsUsed in 1 repo~1.9k tokens
    Backend & APIsAuto-check passed
  • Caching

    codewithmukesh/dotnet-claude-kit

    Caching strategies for .NET 10 applications. An agent skill from codewithmukesh/dotnet-claude-kit.

    756 GitHub starsUsed in 1 repo~1.4k tokens
    Backend & APIsAuto-check passed
  • Frontmcp Config

    agentfront/frontmcp

    A skill your agent uses when configuring a FrontMCP server through frontmcp.config or the @FrontMcp options.

    146 GitHub stars~7k tokensUpdated today
    Backend & APIsAuto-check passed

More from ThibautBaissac/rails_ai_agents

All 19 skills in this repo
  • Accessibility Review

    ThibautBaissac/rails_ai_agents

    Audits Rails application accessibility against WCAG 2.2 Level AA, detects violations with axe-core / Lighthouse / Pa11y, and reports remediation guidance for ERB views, ViewComponents, Stimulus…

    665 GitHub stars~2.9k tokensUpdated 4 mo ago
    Auto-check: notes
  • Action Cable Patterns

    ThibautBaissac/rails_ai_agents

    Implements real-time features with Action Cable and WebSockets.

    665 GitHub stars~1.2k tokensUpdated 4 mo ago
    Auto-check passed
  • Active Storage Setup

    ThibautBaissac/rails_ai_agents

    Configures Active Storage for file uploads with variants and direct uploads.

    665 GitHub stars~1.2k tokensUpdated 4 mo ago
    Auto-check passed
  • Authentication Flow

    ThibautBaissac/rails_ai_agents

    Implements authentication using Rails 8 built-in generator. An agent skill from ThibautBaissac/rails_ai_agents.

    665 GitHub stars~1.9k tokensUpdated 4 mo ago
    Auto-check passed
  • I18n Patterns

    ThibautBaissac/rails_ai_agents

    Implements internationalization with Rails I18n for multi-language support.

    665 GitHub stars~1.4k tokensUpdated 4 mo ago
    Auto-check passed
  • Performance Optimization

    ThibautBaissac/rails_ai_agents

    Identifies and fixes Rails performance issues including N+1 queries, slow queries, and memory problems.

    665 GitHub stars~1.2k tokensUpdated 4 mo ago
    Auto-check: notes

Works with

Categories

Questions about Caching Strategies

What does Caching Strategies do?

Implements Rails caching patterns for performance optimization. Caching Strategies is an agent skill from ThibautBaissac/rails_ai_agents. Implements Rails caching patterns for performance optimization.

When should I use Caching Strategies?

Caching Strategies fits situations like: adding fragment caching; russian doll caching; low-level caching; cache invalidation.

How do I install Caching Strategies in Claude Code?

Run `npx skills add ThibautBaissac/rails_ai_agents --skill caching-strategies -a claude-code`. Or copy the skill folder (.agents/skills/caching-strategies in ThibautBaissac/rails_ai_agents) into .claude/skills/caching-strategies in your project. Claude Code loads it when a task matches its description.

How do I install Caching Strategies in Codex?

Run `npx skills add ThibautBaissac/rails_ai_agents --skill caching-strategies -a codex`. Or copy the skill folder (.agents/skills/caching-strategies in ThibautBaissac/rails_ai_agents) into .agents/skills/caching-strategies in your project. Codex loads it when a task matches its description.

Can I use Caching Strategies in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add ThibautBaissac/rails_ai_agents --skill caching-strategies -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/caching-strategies, .gemini/skills/caching-strategies, .github/skills/caching-strategies and .opencode/skills/caching-strategies in your project.

What does Caching Strategies need to run?

Going by SKILL.md and its folder, Caching Strategies needs the command-line tools its instructions call (rails).

Does Caching Strategies access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Caching Strategies safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Caching Strategies use?

Caching Strategies is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Caching Strategies use?

About 1.4k tokens (SKILL.md is roughly 5.7k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 1.8k tokens, read only when the agent opens those files.

What are the alternatives to Caching Strategies?

Skills that share tags, products or a category with Caching Strategies: Stripe Projects (fossasia/eventyay, 1.7k stars), Foundatio (FoundatioFx/Foundatio, 2.1k stars), FastAPI-Redis SDK Development (redis/fastapi-redis-sdk, 405 stars) and Caching Patterns (dilolabs/nosia, 213 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Caching Strategies?

ThibautBaissac (a GitHub user) maintains it in ThibautBaissac/rails_ai_agents, which has 665 GitHub stars. The repository holds 19 skills in this directory. The repository was last updated on June 1, 2026.

Source: ThibautBaissac/rails_ai_agents on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.