Rails caching strategies including fragment caching, low-level caching with Rails.cache, Solid Cache, cache keys, and conditional GET. Use when the user asks about caching performance or invalidation in Rails.
/plugin marketplace add bastos/rails-plugin/plugin install bastos-ruby-on-rails@bastos/rails-pluginThis skill inherits all available tools. When active, it can use any tool Claude has access to.
Use Rails caching to reduce response time and database load while keeping content fresh. This skill focuses on fragment caching, low-level caching, Solid Cache, cache keys, and conditional GETs.
Wrap view fragments that can be reused:
<% @products.each do |product| %>
<% cache product do %>
<%= render product %>
<% end %>
<% end %>
Notes:
cache_key_with_version) help expire cached content when
records change.Use Rails.cache.fetch for expensive computations:
class Product < ApplicationRecord
def competing_price
Rails.cache.fetch("#{cache_key_with_version}/competing_price", expires_in: 12.hours) do
Competitor::API.find_price(id)
end
end
end
Guidance:
fetch to avoid separate read/write logic.expires_in for data that should age out.Solid Cache is a database-backed ActiveSupport cache store optimized for SSDs. It uses FIFO eviction and is enabled by default in Rails 8.0+.
Skip it when creating a new app:
rails new app_name --skip-solid
Example database config (separate cache DB):
production:
primary:
<<: *default
database: storage/production.sqlite3
cache:
<<: *default
database: storage/production_cache.sqlite3
migrations_paths: db/cache_migrate
Objects should implement cache_key (Active Record provides it).
Keys can be arrays or hashes:
Rails.cache.read(site: "mysite", owners: [owner_1, owner_2])
Notes:
Leverage ETags and Last-Modified to return 304 Not Modified:
class ProductsController < ApplicationController
def show
@product = Product.find(params[:id])
if stale?(last_modified: @product.updated_at.utc, etag: @product.cache_key_with_version)
# normal response rendering
end
end
end
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.