dspy-ruby

Implement type-safe DSPy.rb workflows with signatures, modules, and provider configuration in Ruby.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/mengblom/dex-ghx --skill dspy-ruby-mengblom
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: dspy-ruby
Source: https://github.com/mengblom/dex-ghx/tree/main/.claude/plugins/compound-engineering/skills/dspy-ruby
Command: npx skills add https://github.com/mengblom/dex-ghx --skill dspy-ruby-mengblom

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) and assets (resource) components.

What problem does it solve?

DSPy Ruby helps you replace fragile, hand-written prompts with type-safe, composable LLM modules that are easier to build, test, and optimize in real Ruby applications.

Core Features & Use Cases

  • Type-safe signatures: Define explicit input/output contracts (including enums) so outputs are validated and predictable for tasks like classification, extraction, and structured analysis.
  • Composable modules & pipelines: Build reusable DSPy::Module components that chain together for multi-step workflows such as extract → analyze → respond.
  • Predictors and agent patterns: Use DSPy::Predict, ChainOfThought, ReAct tool-using agents, and CodeAct-style code generation patterns when tasks require reasoning, tools, or dynamic execution.
  • Provider configuration + multimodal support: Configure OpenAI, Anthropic, Gemini, Ollama, and OpenRouter providers and handle vision inputs via DSPy::Image.
  • Testing and optimization: Write RSpec tests for LLM logic, then improve quality using optimization techniques like MIPROv2 and few-shot bootstrapping.

Quick Start

Tell the AI: "Show me how to implement a Ruby DSPy signature and module that classifies customer support emails into category and priority, including an RSpec test and an example DSPy provider configuration."

Frequently Asked Questions about dspy-ruby

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build type-safe LLM workflows in Ruby instead of using fragile prompts?▼

You can build type-safe LLM workflows in Ruby by defining explicit DSPy::Signature contracts and composing DSPy::Module pipelines. This replaces hand-written prompts with validated, predictable outputs for tasks like extraction and classification.

Can I configure multiple LLM providers like OpenAI and Anthropic in a Ruby application?▼

Yes, you can configure multiple LLM providers in a Ruby application. The framework supports OpenAI, Anthropic, Gemini, Ollama, and OpenRouter, allowing you to wire language model configurations directly into your composable pipelines.

How do I test and optimize LLM features in Ruby using RSpec?▼

You test and optimize LLM features in Ruby by writing RSpec tests for your module logic, then applying optimization techniques like MIPROv2 and few-shot bootstrapping to improve output quality and predictability.

What is the best way to build tool-using agents in Ruby that require reasoning?▼

The best way to build tool-using agents in Ruby is to use DSPy::Predict, ChainOfThought, and ReAct patterns. These predictors handle complex reasoning, dynamic tool execution, and CodeAct-style code generation.

Does DSPy support multimodal processing like image inputs for Ruby applications?▼

Yes, DSPy supports multimodal processing for Ruby applications. You can handle vision inputs using the DSPy::Image component within your defined signature contracts to process images alongside text.

How do I structure multi-step LLM pipelines for extract and analyze workflows?▼

You structure multi-step LLM pipelines by building reusable DSPy::Module components that chain together. This composable architecture allows you to sequence workflows like extract, analyze, and respond predictably.