dspy-ruby

dspy-ruby is a skill for Claude Code, Codex from tajmahal226/compound-engineering-plugin. It costs 70 tokens per session (5,937 once invoked), scanned A, a copy of dspy-ruby, MIT.

A Ruby framework for building applications that use language models through typed, reusable program components instead of manually written prompts alone.

In plain words
What is it for?
Use it to build LLM features, define typed signatures and modules, configure model providers, create tool-using agents, and optimize prompts in Ruby.
Why use it?
It helps make AI features easier to structure, test, reuse, observe, and improve with data while defining expected inputs and outputs using Ruby types.

Skill for Claude CodeCodex

Part of the compound-engineering plugin — 20 skills, 17 commands, 1 MCP server shipped together

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/tajmahal226/compound-engineering-plugin/dspy-ruby
Any agent
npx skills add tajmahal226/compound-engineering-plugin --skill dspy-ruby
Clone the repo
git clone --depth 1 https://github.com/tajmahal226/compound-engineering-plugin

Made for: Claude Code, Codex.

Or install compound-engineering, the plugin that ships this one along with the rest of its 20 skills, 17 commands, 1 MCP server.

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 dspy-ruby

README.md
[![agentmods](https://agentmods.dev/badge/skills/tajmahal226/compound-engineering-plugin/dspy-ruby.svg)](https://agentmods.dev/skills/tajmahal226/compound-engineering-plugin/dspy-ruby)
Your own site
<a href="https://agentmods.dev/skills/tajmahal226/compound-engineering-plugin/dspy-ruby"><img src="https://agentmods.dev/badge/skills/tajmahal226/compound-engineering-plugin/dspy-ruby.svg" alt="Measured on agentmods" height="20"></a>
Per session 70 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 5,937 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin 100% 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 $0.00070 $0.05937
Opus 5 $0.00035 $0.02968
Sonnet 5 $0.00014 $0.01187
Haiku 4.5 $0.00007 $0.00594

Measured 5d ago against content hash 60cb35a0db08, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

dspy-ruby 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 5d ago.

The scan reads SKILL.md. This mod also ships 3 executable files (assets/config-template.rb, assets/module-template.rb, assets/signature-template.rb), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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

100% identical to dspy-ruby — 0 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/dspy-ruby/SKILL.md · 738 lines

How it starts

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

DSPy.rb

Build LLM apps like you build software. Type-safe, modular, testable.

DSPy.rb brings software engineering best practices to LLM development. Instead of tweaking prompts, define what you want with Ruby types and let DSPy handle the rest.

Overview

DSPy.rb is a Ruby framework for building language model applications with programmatic prompts. It provides:

  • Type-safe signatures — Define inputs/outputs with Sorbet types
  • Modular components — Compose and reuse LLM logic
  • Automatic optimization — Use data to improve prompts, not guesswork
  • Production-ready — Built-in observability, testing, and error handling

Core Concepts

1. Signatures

Define interfaces between your app and LLMs using Ruby types:

class EmailClassifier < DSPy::Signature
  description "Classify customer support emails by category and priority"

  class Priority < T::Enum
    enums do
      Low = new('low')
      Medium = new('medium')
      High = new('high')
      Urgent = new('urgent')
    end
  end

  input do
    const :email_content, String
    const :sender, String
  end

  output do
    const :category, String
    const :priority, Priority  # Type-safe enum with defined values
    const :confidence, Float
  end
end

2. Modules

Build complex workflows from simple building blocks:

  • Predict — Basic LLM calls with signatures
  • ChainOfThought — Step-by-step reasoning
  • ReAct — Tool-using agents
  • CodeAct — Dynamic code generation agents (install the dspy-code_act gem)

3. Tools & Toolsets

Create type-safe tools for agents with comprehensive Sorbet support:

# Enum-based tool with automatic type conversion
class CalculatorTool < DSPy::Tools::Base
  tool_name 'calculator'
  tool_description 'Performs arithmetic operations with type-safe enum inputs'

  class Operation < T::Enum
    enums do
      Add = new('add')
      Subtract = new('subtract')
      Multiply = new('multiply')
      Divide = new('divide')
    end
  end

  sig { params(operation: Operation, num1: Float, num2: Float).returns(T.any(Float, String)) }
  def call(operation:, num1:, num2:)
    case operation
    when Operation::Add then num1 + num2
    when Operation::Subtract then num1 - num2
    when Operation::Multiply then num1 * num2
    when Operation::Divide
      return "Error: Division by zero" if num2 == 0
      num1 / num2
    end
  end
end

# Multi-tool toolset with rich types
class DataToolset < DSPy::Tools::Toolset
  toolset_name "data_processing"

  class Format < T::Enum
    enums do
      JSON = new('json')
      CSV = new('csv')
      XML = new('xml')
    end
  end

  tool :convert, description: "Convert data between formats"
  tool :validate, description: "Validate data structure"

  sig { params(data: String, from: Format, to: Format).returns(String) }
  def convert(data:, from:, to:)
    "Converted from #{from.serialize} to #{to.serialize}"
  end

  sig { params(data: String, format: Format).returns(T::Hash[String, T.any(String, Integer, T::Boolean)]) }
  def validate(data:, format:)
    { valid: true, format: format.serialize, row_count: 42, message: "Data validation passed" }
  end
end

Read the full file on GitHub · 738 lines

Files

What ships with it

8 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. 5d ago First seen · 738 lines · 70 tokens per session scan A 60cb35a0db08

Subscribe to this mod's changes

dspy-ruby is a skill published in the GitHub repository tajmahal226/compound-engineering-plugin (4 stars, last pushed 6mo ago), licensed MIT. It adds 70 tokens to every session and 5,937 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. It is 100% identical to dspy-ruby, differing in 0 lines, and is treated as a copy.

Related

Other skills, from other repositories

dspy-ruby

Build type-safe LLM applications with DSPy.rb — Ruby's programmatic prompt framework with signatures, modules, agents, and optimization. Use when implementing predictable AI features, creating LLM signatures and modules, configuring language model providers, building agent systems with tools, optimizing prompts, or…

Jerrylalala/compound-engineering · 70 tokens

ax-signature

This skill helps an LLM generate correct DSPy signature code using @ax-llm/ax. Use when the user asks about signatures, s(), f(), field types, string syntax, fluent builder API, validation constraints, or type-safe inputs/outputs.

ax-llm/ax · 57 tokens

ax-cpp-gepa

Use when writing C++ code with axllm for GEPA, Pareto tradeoffs, reflection clients, metric budgets, optimizer state, and artifacts.

ax-llm/ax · 39 tokens

ax-gen

This skill helps an LLM generate correct AxGen code using @ax-llm/ax. Use when the user asks about ax(), AxGen, generators, forward(), streamingForward(), validation, assertions, streaming assertions, field processors, step hooks, self-tuning, or structured outputs. For MCP clients, transports, prompts, resources…

dosco/aithy · 86 tokens

ax-signature

This skill helps an LLM generate correct DSPy signature code using @ax-llm/ax. Use when the user asks about signatures, s(), f(), field types, string syntax, fluent builder API, validation constraints, or type-safe inputs/outputs.

dosco/aithy · 57 tokens

qianwen-text

Generate text, have conversations, write code, reason, and call functions with Qwen models. TRIGGER when: user asks to chat with Qwen, generate text, write code with Qwen, use Qwen function calling, or explicitly invokes this skill by name (e.g. use qianwen-text). DO NOT TRIGGER when: general coding questions without…

QianWen-AI/qianwen-ai · 111 tokens