andrew-kane-gem-writer

andrew-kane-gem-writer is a skill for Claude Code from Jerrylalala/compound-engineering. It costs 88 tokens per session (1,148 once invoked), scanned A, a copy of andrew-kane-gem-writer, MIT.

A guide for writing Ruby gems, which are reusable packages of Ruby code, using Andrew Kane's established design patterns.

In plain words
What is it for?
Use it when creating or refactoring Ruby gems, designing their APIs, or adding Rails integration without making the library depend on Rails.
Why use it?
It helps keep a gem's API and structure simple, explicit, and suitable for production use.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the compound-engineering plugin — 78 skills, 4 commands, 2 hooks shipped together

Good fit Use it when creating or refactoring Ruby gems, designing their APIs, or adding Rails integration without making the library depend on Rails.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/jerrylalala/compound-engineering/andrew-kane-gem-writer
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.

Any agent
npx skills add Jerrylalala/compound-engineering --skill andrew-kane-gem-writer
Clone the repo
git clone --depth 1 https://github.com/Jerrylalala/compound-engineering

Made for: Claude Code.

Or install compound-engineering, the plugin that ships this one along with the rest of its 78 skills, 4 commands, 2 hooks.

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 andrew-kane-gem-writer

README.md
[![agentmods](https://agentmods.dev/badge/skills/jerrylalala/compound-engineering/andrew-kane-gem-writer/github.svg)](https://agentmods.dev/skills/jerrylalala/compound-engineering/andrew-kane-gem-writer)
Your own site
<a href="https://agentmods.dev/skills/jerrylalala/compound-engineering/andrew-kane-gem-writer"><img src="https://agentmods.dev/badge/skills/jerrylalala/compound-engineering/andrew-kane-gem-writer/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for andrew-kane-gem-writer

Your own site · 80×15
<a href="https://agentmods.dev/skills/jerrylalala/compound-engineering/andrew-kane-gem-writer"><img src="https://agentmods.dev/badge/skills/jerrylalala/compound-engineering/andrew-kane-gem-writer.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 88 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,148 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin 97% copy Near-identical to another mod 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.00088 $0.01148
Opus 5 $0.00044 $0.00574
Sonnet 5 $0.00018 $0.00230
Haiku 4.5 $0.00009 $0.00115

Measured 11d ago against content hash 093983c4f9f3, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

andrew-kane-gem-writer 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 11d 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.

Origin

This is a copy

97% identical to andrew-kane-gem-writer — 10 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

plugins/compound-engineering/skills/andrew-kane-gem-writer/SKILL.md · 185 lines

How it starts

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

Andrew Kane Gem Writer

Write Ruby gems following Andrew Kane's battle-tested patterns from 100+ gems with 374M+ downloads (Searchkick, PgHero, Chartkick, Strong Migrations, Lockbox, Ahoy, Blazer, Groupdate, Neighbor, Blind Index).

Core Philosophy

Simplicity over cleverness. Zero or minimal dependencies. Explicit code over metaprogramming. Rails integration without Rails coupling. Every pattern serves production use cases.

Entry Point Structure

Every gem follows this exact pattern in lib/gemname.rb:

# 1. Dependencies (stdlib preferred)
require "forwardable"

# 2. Internal modules
require_relative "gemname/model"
require_relative "gemname/version"

# 3. Conditional Rails (CRITICAL - never require Rails directly)
require_relative "gemname/railtie" if defined?(Rails)

# 4. Module with config and errors
module GemName
  class Error < StandardError; end
  class InvalidConfigError < Error; end

  class << self
    attr_accessor :timeout, :logger
    attr_writer :client
  end

  self.timeout = 10  # Defaults set immediately
end

Class Macro DSL Pattern

The signature Kane pattern—single method call configures everything:

# Usage
class Product < ApplicationRecord
  searchkick word_start: [:name]
end

# Implementation
module GemName
  module Model
    def gemname(**options)
      unknown = options.keys - KNOWN_KEYWORDS
      raise ArgumentError, "unknown keywords: #{unknown.join(", ")}" if unknown.any?

      mod = Module.new
      mod.module_eval do
        define_method :some_method do
          # implementation
        end unless method_defined?(:some_method)
      end
      include mod

      class_eval do
        cattr_reader :gemname_options, instance_reader: false
        class_variable_set :@@gemname_options, options.dup
      end
    end
  end
end

Rails Integration

Always use ActiveSupport.on_load—never require Rails gems directly:

# WRONG
require "active_record"
ActiveRecord::Base.include(MyGem::Model)

# CORRECT
ActiveSupport.on_load(:active_record) do
  extend GemName::Model
end

# Use prepend for behavior modification
ActiveSupport.on_load(:active_record) do
  ActiveRecord::Migration.prepend(GemName::Migration)
end

Read the full file on GitHub · 185 lines

Files

What ships with it

5 files 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. 11d ago First seen · 185 lines · 88 tokens per session scan A 093983c4f9f3

Subscribe to this mod's changes

andrew-kane-gem-writer is a skill published in the GitHub repository Jerrylalala/compound-engineering (5 stars, last pushed 3mo ago), licensed MIT. It adds 88 tokens to every session and 1,148 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. It is 97% identical to andrew-kane-gem-writer, differing in 10 lines, and is treated as a copy.

Related

Other skills, from other repositories

rubyllm

Build and maintain Ruby or Rails applications with the RubyLLM AI framework. Use for chats, agents, tools, structured output, media generation, transcription, OCR, moderation, embeddings, reranking, Rails integration, and RubyLLM upgrades; not for contributing to the framework itself.

crmne/ruby_llm · 61 tokens

new

Create a new project to start development quickly.

clacky-ai/openclacky · 10 tokens

rspec-conventions

Rootstrap RSpec conventions. Use when writing, reviewing, or editing RSpec test files (spec//spec.rb, spec/railshelper.rb, spec/spechelper.rb, spec/support//.rb) or factories. Covers describe/context structure, let/subject, matchers, factories, mocking/stubbing, shared examples, and spec types (model, request…

rootstrap/rails_api_base · 82 tokens

ruby-patterns

Ruby/Rails: blocks, metaprogramming, ActiveRecord, Sidekiq, RSpec, Sorbet, Hanami. Triggers: Ruby, Rails, ActiveRecord, Sidekiq, RSpec, Gemfile, bundler, Hanami, Sorbet.

softspark/ai-toolkit · 60 tokens

ruby-rules

Ruby coding rules: style, patterns, security, testing. Triggers: .rb, Gemfile, .gemspec, Rails, ActiveRecord, Sidekiq, RSpec, Sorbet, rubocop.

softspark/ai-toolkit · 48 tokens

ruby-expert

Expert-level Ruby development with Rails, modern features, testing, and best practices. Use when the user mentions Ruby on Rails, RSpec, gem, Sinatra, or metaprogramming, or when the task involves Ruby 3+ Features, Object-Oriented, Functional Features, or Pattern Matching.

personamanagmentlayer/pcl · 64 tokens