dspy-fundamentals

dspy-fundamentals is a skill for Claude Code from intertwine/dspy-agent-skills. It costs 84 tokens per session (1,465 once invoked), scanned A, original, MIT.

A guide to writing DSPy 3.2 programs with typed input and output definitions, reusable modules, and built-in program patterns.

In plain words
What is it for?
Use it when starting a DSPy project or correcting DSPy code that uses raw prompt strings, untyped outputs, or classes that cannot be saved reliably.
Why use it?
It helps replace hard-coded prompts and loosely structured results with code that is easier to compose, test, save, and load.

Skill for Claude Code

Written for Claude Code: when-to-use in frontmatter.

Part of the dspy-agent-skills plugin — 5 skills shipped together

Good fit Use it when starting a DSPy project or correcting DSPy code that uses raw prompt strings, untyped outputs, or classes that cannot be saved reliably.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/intertwine/dspy-agent-skills/dspy-fundamentals
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 intertwine/dspy-agent-skills --skill dspy-fundamentals
Clone the repo
git clone --depth 1 https://github.com/intertwine/dspy-agent-skills

Made for: Claude Code.

Or install dspy-agent-skills, the plugin that ships this one along with the rest of its 5 skills.

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-fundamentals

README.md
[![agentmods](https://agentmods.dev/badge/skills/intertwine/dspy-agent-skills/dspy-fundamentals/github.svg)](https://agentmods.dev/skills/intertwine/dspy-agent-skills/dspy-fundamentals)
Your own site
<a href="https://agentmods.dev/skills/intertwine/dspy-agent-skills/dspy-fundamentals"><img src="https://agentmods.dev/badge/skills/intertwine/dspy-agent-skills/dspy-fundamentals/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 dspy-fundamentals

Your own site · 80×15
<a href="https://agentmods.dev/skills/intertwine/dspy-agent-skills/dspy-fundamentals"><img src="https://agentmods.dev/badge/skills/intertwine/dspy-agent-skills/dspy-fundamentals.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 84 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,465 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. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
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.1 $0.00084 $0.01465
Opus 5 $0.00042 $0.00732
Sonnet 5 $0.00017 $0.00293
Haiku 4.5 $0.00008 $0.00146

Measured 12d ago against content hash 6afd892cb16c, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

dspy-fundamentals 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 12d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (example_qa.py), 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.

skills/dspy-fundamentals/SKILL.md · 121 lines

How it starts

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

DSPy Fundamentals (3.2.x)

DSPy is the "PyTorch for prompts" — you declare Signatures (typed I/O contracts), compose them into Modules, and let optimizers (not you) tune the instructions and few-shot examples. Never write raw prompts.

The one-paragraph model

Configure a single LM globally with dspy.configure(lm=...). Define a dspy.Signature subclass with dspy.InputField() / dspy.OutputField() (docstring becomes the instruction). Wrap it in a predictor — dspy.Predict (direct), dspy.ChainOfThought (adds reasoning), dspy.ReAct (tool-using agent), dspy.ProgramOfThought (code-executing), or dspy.RLM (long-context). Subclass dspy.Module to compose multi-step programs. For built-in providers, use dspy.LM("provider/model"); for a truly custom backend, subclass dspy.BaseLM. Optimize later with GEPA.

Canonical template

import dspy

dspy.configure(lm=dspy.LM("openai/gpt-4o"), track_usage=True)

class QuestionAnswer(dspy.Signature):
    """Answer questions with rigorous step-by-step reasoning."""
    question: str = dspy.InputField()
    answer: str = dspy.OutputField(desc="concise final answer")

class QAProgram(dspy.Module):
    def __init__(self):
        super().__init__()
        self.solve = dspy.ChainOfThought(QuestionAnswer)

    def forward(self, question: str) -> dspy.Prediction:
        return self.solve(question=question)

program = QAProgram()
pred = program(question="What is 2 + 2?")
print(pred.reasoning, pred.answer)

Predictor cheatsheet (DSPy 3.2.x)

Predictor When to use Adds
dspy.Predict(sig) Simple structured I/O nothing — just the signature
dspy.ChainOfThought(sig) Reasoning tasks a reasoning output field
dspy.ReAct(sig, tools=[...], max_iters=20) Tool-using agent Thought/Action/Observation loop
dspy.ProgramOfThought(sig, max_iters=3) Math/data tasks generates & runs Python (needs Deno)
dspy.RLM(sig, ...) Long context / codebases recursive REPL exploration (see dspy-rlm-module)

Read the full file on GitHub · 121 lines

Files

What ships with it

2 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. 12d ago First seen · 121 lines · 84 tokens per session scan A 6afd892cb16c

Subscribe to this mod's changes

dspy-fundamentals is a skill published in the GitHub repository intertwine/dspy-agent-skills (277 stars, last pushed 6d ago), licensed MIT. It adds 84 tokens to every session and 1,465 once invoked, about $0.0004 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

pytorch-patterns

PyTorch deep learning patterns and best practices for building robust, efficient, and reproducible training pipelines, model architectures, and data loading.

affaan-m/ECC · 32 tokens

optimize-for-gpu

GPU-accelerates scientific Python on NVIDIA hardware and verifies that the result is correct and faster. Use for CUDA/GPU optimization; CPU-bound NumPy, SciPy, pandas, scikit-learn, NetworkX, scikit-image, vector-search, image-processing, graph, simulation, or file-I/O workloads; CuPy, cuDF, cuML, cuGraph, cuVS…

K-Dense-AI/scientific-agent-skills · 151 tokens

developing-genkit-python

Develop AI-powered applications using Genkit in Python. Use when the user asks about Genkit, AI agents, flows, or tools in Python, or when encountering Genkit errors, import issues, or API problems.

google/skills · 49 tokens

azure-ai-openai-dotnet

Azure OpenAI SDK for .NET. Client library for Azure OpenAI and OpenAI services. Use for chat completions, embeddings, image generation, audio transcription, and assistants. Triggers: "Azure OpenAI", "AzureOpenAIClient", "ChatClient", "chat completions .NET", "GPT-4", "embeddings", "DALL-E", "Whisper", "OpenAI .NET".

microsoft/skills · 92 tokens

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

ax-cpp-gen

Use when writing C++ code with axllm for AxGen programs, forward calls, indexed multi-sampling, result pickers, streaming, tools, assertions, traces, usage, and output parsing.

ax-llm/ax · 48 tokens