dspy-ruby

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

A Ruby framework for building applications that use language models through typed, reusable program components. It includes signatures, modules, agents, model-provider configuration, and prompt optimization.

In plain words
What is it for?
Use it to build typed LLM features, configure language models, create agent systems with tools, and optimize prompts in Ruby.
Why use it?
It replaces ad hoc prompt editing with defined inputs, outputs, and composable Ruby code that can be tested and adjusted systematically.

Skill for Claude CodeCodex

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

Made for: Claude Code, Codex.

Or install compound-engineering, the plugin that ships this one along with the rest of its 41 skills, 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/gvkhosla/compound-engineering-pi/dspy-ruby.svg)](https://agentmods.dev/skills/gvkhosla/compound-engineering-pi/dspy-ruby)
Your own site
<a href="https://agentmods.dev/skills/gvkhosla/compound-engineering-pi/dspy-ruby"><img src="https://agentmods.dev/badge/skills/gvkhosla/compound-engineering-pi/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 original No closer match found 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 4d 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 4d 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

Copies of this mod

2 near-identical copies found in the catalogue:

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. 4d 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 gvkhosla/compound-engineering-pi (51 stars, last pushed 4mo 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. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

fabric-exec

Troubleshooting and advanced API reference for fabricexec TypeScript programs, dynamic providers, agents, and schema recovery. Routine pi. coding calls are documented by ambient guidance; load this skill only after an argument-shape error or when an advanced surface needs exact contracts.

monotykamary/pi-fabric · 61 tokens

fabric-fusion

Multi-model deliberation. Two to 8 distinct models answer in parallel with web-capable tools, then a judge compares consensus, contradictions, coverage gaps, unique insights, and blind spots. Act mode runs 1–4 read-only references, then one actor reconciles and executes. Use when the cost of being wrong justifies…

monotykamary/pi-fabric · 74 tokens

fabric-rlm

Recursively decomposes oversized tasks into bounded child Pi agents with fresh context windows. Use for whole-repo audits, massive-context analysis, and multi-file refactors that do not fit one context.

monotykamary/pi-fabric · 44 tokens

fabric-schema

Uses Fabric's typed Schema evidence loop and, when enabled, its bounded local-file transaction channel. Use when surprise must void a plan and mutation claims need explicit postconditions.

monotykamary/pi-fabric · 37 tokens

fabric-workflow

Runs a dynamic Pi Fabric workflow with code-held phases, fan-out, pipelines, structured agents, and best-effort verification. Use for large audits, migrations, parallel research, or explicit workflow requests.

monotykamary/pi-fabric · 44 tokens

fabric-council

Runs a bounded multi-perspective Pi Fabric council with independent reviewers and best-effort synthesis. Use for architecture choices, plans, reviews, and adversarial cross-checking.

monotykamary/pi-fabric · 39 tokens