This skill should be used when the user asks to "configure Sqids", "add Sqids to Rails", "add the sqids gem", "add short URL-safe IDs", "generate YouTube-like IDs", "replace numeric IDs with opaque IDs", "add a Sqidable concern", or "use find_by_sqid" in a Rails application.
Ships in configure-sqids. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Sqids generates short, URL-safe IDs from numbers,
similar to YouTube IDs. This skill configures a shared SqidsWrapper singleton
and a Sqidable concern so models expose opaque IDs in URLs while their
integer primary keys stay intact in the database.
to_param so routes and path helpers automatically use sqids.bundle add sqids
config/initializers/sqids.rb:
# Sqids configuration - https://sqids.org/ruby
# Sqids generates short, URL-safe IDs from numbers. Running Sqids.new on every
# call adds overhead, so build a single shared instance here and reuse it.
SqidsWrapper = Sqids.new(min_length: 8)
Calling Sqids.new on every use adds overhead, so the shared SqidsWrapper
singleton is built once here. min_length: 8 guarantees IDs of at least 8
characters.
app/models/concerns/sqidable.rb:
module Sqidable
extend ActiveSupport::Concern
class_methods do
def find_by_sqid(sqid)
ids = SqidsWrapper.decode(sqid.to_s)
ids.empty? ? nil : find_by(id: ids.first)
end
end
def to_param
SqidsWrapper.encode([id])
end
end
to_param makes Rails automatically use the sqid in generated URLs and
path helpers.find_by_sqid decodes the sqid then looks up by id. It returns nil for
invalid input, mirroring find_by semantics.Add include Sqidable to each model that should use sqids:
class List < ApplicationRecord
include Sqidable
validates :name, presence: true
end
Replace find (including with .expect) with find_by_sqid in controllers
that reference these models:
@list = Current.user.lists.find_by_sqid(params[:id])
to_param would break behavior. In Jumpstart
Pro, User and Account are excluded because changing them would break
authentication and user-facing links.find_by_sqid returns nil instead of raising for invalid sqids, matching
find_by. The concern does not define a bang (find_by_sqid!) variant.bin/rails runner 'puts SqidsWrapper.encode([123])'
bin/rails runner 'puts SqidsWrapper.decode(SqidsWrapper.encode([123])).inspect'
Confirm URL-safe output and a working encode/decode round trip, then run the
app's test suite (e.g. bin/rails test). Cover:
\A[a-zA-Z0-9]+\zto_param returns the expected sqidfind_by_sqid finds the record and returns nil for invalid inputUse Rails.application.eager_load! in a test to load every application model
and assert that all of them include Sqidable. This guards against adding a
new model and forgetting to include the concern. No need to iterate the
app/models file structure — eager_load! already loads every model, so
filter ActiveRecord::Base.descendants directly:
require "test_helper"
class SqidableTest < ActiveSupport::TestCase
# Persisted ActiveRecord models that intentionally do not use sqids.
# User and Account are Jumpstart engine models where changing to_param would
# break authentication and user-facing links, so they are excluded here.
EXCLUDED_MODELS = %w[User Account].freeze
test "every application model uses sqids" do
Rails.application.eager_load!
app_models.each do |klass|
next if EXCLUDED_MODELS.include?(klass.name)
assert klass.include?(Sqidable), "#{klass.name} should include Sqidable"
end
end
private
def app_models
ActiveRecord::Base.descendants.select do |klass|
next false if klass.abstract_class?
klass < ApplicationRecord
end
end
end
klass < ApplicationRecord scopes to app models and drops ApplicationRecord
itself (empty/abstract) plus ActiveRecord's internal bookkeeping classes like
ActiveRecord::SchemaMigration. Adjust EXCLUDED_MODELS to match models in
the app that must keep their real IDs (e.g. anything used for authentication
or user-facing links).
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
2 plugins in one repository ship this exact skill · first indexed Sep 15, 2026
/configure-sqids:configure-sqidsfrom configure-sqids
npx claudepluginhub andyw8/agent-skills --plugin configure-sqids