Agent skill

Dspy Fundamentals

by intertwine in intertwine/dspy-agent-skills

Write idiomatic DSPy 3.2.x programs — typed Signatures, dspy.Module subclasses, Predict/ChainOfThought/ReAct/ProgramOfThought, and save/load.

MITAuto-check passed

Install Dspy Fundamentals

skills CLI
$ npx skills add intertwine/dspy-agent-skills --skill dspy-fundamentals -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install intertwine/dspy-agent-skills dspy-fundamentals --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/intertwine/dspy-agent-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/dspy-fundamentals .claude/skills/dspy-fundamentals && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
dspy-fundamentals
GitHub stars
278
Token cost
~1.4k tokens
SKILL.md length
383 words
Files
3
Skills in repo
5
Repo updated
First seen
Licence
MIT

At a glance

Write idiomatic DSPy 3.2.x programs — typed Signatures, dspy.Module subclasses, Predict/ChainOfThought/ReAct/ProgramOfThought, and save/load.

  • Works in 10 steps: Hard-coded prompt strings ("You are a… → dspy.TypedPredictor(...) in new code —… → dspy.OpenAI(...) /… → …
  • SKILL.md covers The one-paragraph model, Canonical template, Predictor cheatsheet (DSPy… and Typed outputs — use Pydantic…, plus 4 more sections
  • Runs Python scripts from its folder

What it does

Dspy Fundamentals is an agent skill from intertwine/dspy-agent-skills. Write idiomatic DSPy 3.2.x programs — typed Signatures, dspy.Module subclasses, Predict/ChainOfThought/ReAct/ProgramOfThought, and save/load. Use this when starting any new DSPy project or when fixing non-idiomatic DSPy code (hard-coded prompts, ad-hoc string templates, untyped outputs, non-serializable classes).

Its SKILL.md is about 1.4k tokens, which your agent loads only when the skill is triggered. The skill folder holds 2 other files (for example `example_qa.py` and `reference.md`).

It works with React and Pydantic. The repository describes itself as: Production-grade DSPy 3.2.x agent skills + validated end-to-end examples for Claude Code and Codex CLI — fundamentals, evaluation, GEPA, BetterTogether, and RLM. The licence is MIT.

Example prompts

  • “/dspy-fundamentals”

Requirements

  • Python 3

Workflow steps

10 steps, taken from the first numbered list in SKILL.md.

  1. Hard-coded prompt strings ("You are a helpful assistant...") — write a Signature.
  2. dspy.TypedPredictor(...) in new code — use dspy.Predict with Pydantic fields.
  3. dspy.OpenAI(...) / dspy.settings.configure(...) — use dspy.configure(lm=dspy.LM(...)).
  4. Provider-specific LM classes for built-in providers — use dspy.LM("provider/model"). If DSPy doesn't ship your backend, subclass…
  5. Giant monolithic predictors that do five jobs — decompose into a Module with named sub-predictors.
  6. Mutating signature.instructions by hand — let the optimizer do it.
  7. In-lining few-shot demos in the Signature docstring — bootstrap/optimize them.
  8. Using pickle.dump(program) — use program.save(...).
  9. Setting an LM per module at construction time without reason — configure globally, override only when you need model mixing.
  10. Vague metrics (yes/no, exact-match only) when training an optimizer — see dspy-evaluation-harness.

What it can do on your machine

Read from SKILL.md and the folder at commit 623dca0. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships script files (Python), which the agent can run.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Dspy Fundamentals loads about 1.4k tokens when it runs. Until then it costs about 83 tokens; SKILL.md has 383 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~83
When it runs · the whole SKILL.md, loaded when a task matches
~1.4k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from intertwine/dspy-agent-skills at commit 623dca0, republished under its MIT licence (© intertwine). 383 words, ~1,424 tokens.

Download SKILL.mdSave it as .claude/skills/dspy-fundamentals/SKILL.md (or your agent's skills folder). This skill also uses 2 other files; get the full folder from GitHub.
name
dspy-fundamentals
description
Write idiomatic DSPy 3.2.x programs — typed Signatures, dspy.Module subclasses, Predict/ChainOfThought/ReAct/ProgramOfThought, and save/load. Use this when starting any new DSPy project or when fixing non-idiomatic DSPy code (hard-coded prompts, ad-hoc string templates, untyped outputs, non-serializable classes).
when_to_use
User mentions DSPy, writes a file that imports `dspy`, asks to build an LLM pipeline/program/agent with structured inputs/outputs, or requests refactoring of…

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

python
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)

PredictorWhen to useAdds
dspy.Predict(sig)Simple structured I/Onothing — just the signature
dspy.ChainOfThought(sig)Reasoning tasksa reasoning output field
dspy.ReAct(sig, tools=[...], max_iters=20)Tool-using agentThought/Action/Observation loop
dspy.ProgramOfThought(sig, max_iters=3)Math/data tasksgenerates & runs Python (needs Deno)
dspy.RLM(sig, ...)Long context / codebasesrecursive REPL exploration (see dspy-rlm-module)

Typed outputs — use Pydantic on fields, not TypedPredictor

dspy.TypedPredictor is superseded; dspy.Predict now handles Pydantic types natively via field annotations.

python
from pydantic import BaseModel
from typing import Literal

class Entity(BaseModel):
    name: str
    kind: Literal["person", "org", "place"]

class ExtractEntities(dspy.Signature):
    """Extract named entities from text."""
    text: str = dspy.InputField()
    entities: list[Entity] = dspy.OutputField()

extractor = dspy.Predict(ExtractEntities)

Save & load

Two modes — know the difference:

python
# State-only (portable JSON; you must rebuild the architecture to load)
program.save("program.json", save_program=False)
new = QAProgram(); new.load("program.json")

# Full program (cloudpickle into a directory; restores everything)
program.save("./program_dir/", save_program=True)
restored = dspy.load("./program_dir/")

Prefer state-only for version control; full-program for deployment artifacts.

Show full SKILL.md (201 more words)Show less

Ten anti-patterns to refuse

  1. Hard-coded prompt strings ("You are a helpful assistant...") — write a Signature.
  2. dspy.TypedPredictor(...) in new code — use dspy.Predict with Pydantic fields.
  3. dspy.OpenAI(...) / dspy.settings.configure(...) — use dspy.configure(lm=dspy.LM(...)).
  4. Provider-specific LM classes for built-in providers — use dspy.LM("provider/model"). If DSPy doesn't ship your backend, subclass dspy.BaseLM.
  5. Giant monolithic predictors that do five jobs — decompose into a Module with named sub-predictors.
  6. Mutating signature.instructions by hand — let the optimizer do it.
  7. In-lining few-shot demos in the Signature docstring — bootstrap/optimize them.
  8. Using pickle.dump(program) — use program.save(...).
  9. Setting an LM per module at construction time without reason — configure globally, override only when you need model mixing.
  10. Vague metrics (yes/no, exact-match only) when training an optimizer — see dspy-evaluation-harness.

Configuring the LM

python
dspy.configure(
    lm=dspy.LM("openai/gpt-4o", temperature=0.0, max_tokens=2000),
    track_usage=True,        # accumulate token counts on predictions
    async_max_workers=4,     # for .acall / batch
)

DSPy 3.2.x warns by default when a module call passes extra input fields or values that don't match the signature's declared types. Treat those warnings as a callsite bug first; if you're intentionally passing pre-serialized values, disable them with dspy.configure(warn_on_type_mismatch=False).

Common provider prefixes: openai/, anthropic/, azure/, vertex_ai/, bedrock/, ollama/. For local Ollama: dspy.LM("ollama_chat/llama3.1:8b", api_base="http://localhost:11434").

Where to go next

  • Measuring quality → dspy-evaluation-harness
  • Automatic optimization → dspy-gepa-optimizer
  • Context >100k tokens → dspy-rlm-module
  • Full pipeline → dspy-advanced-workflow
  • Full API reference → reference.md
  • Runnable example → example_qa.py

© intertwine, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 2 other files in skills/dspy-fundamentals of intertwine/dspy-agent-skills.

  • SKILL.md
  • example_qa.py
  • reference.md

Open the folder on GitHubat commit 623dca0

Compare with similar skills

Dspy Fundamentals next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Dspy Fundamentals compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Dspy Fundamentals this skillintertwine/dspy-agent-skills278—~1.4kAutomated safety check: PassMIT
Web Artifacts Builderanthropics/skills180k40 repos~769Automated safety check: PassApache-2.0
Vercel Composition Patternssupabase/supabase111k58 repos~726Automated safety check: PassMIT
React Doctormakeplane/plane61k12 repos~657Automated safety check: PassAGPL-3.0
React Router Developmentremix-run/react-router57k1 repos~1.5kAutomated safety check: PassMIT
React UI State PatternsChrisWiles/claude-code-showcase6.1k8 repos~1.6kAutomated safety check: PassNone

Similar skills

  • Web Artifacts Builder

    anthropics/skills

    Official

    Builds multi-component claude.ai HTML artifacts as a small React, TypeScript and Tailwind project, then bundles it into one shareable HTML file.

    180k GitHub starsUsed in 40 repos~769 tokens
    Frontend & DesignAuto-check passed
  • Official

    React composition patterns that scale. An agent skill from supabase/supabase.

    111k GitHub starsUsed in 58 repos~726 tokens
    DevelopmentAuto-check passed
  • React Doctor

    makeplane/plane

    Scans React code for lint, accessibility, bundle size and architecture issues, reports a health score and checks that changes do not lower it.

    61k GitHub starsUsed in 12 repos~657 tokens
    Frontend & DesignAuto-check passed
  • React Router Development

    remix-run/react-router

    Guides work on React Router apps by first identifying whether the app uses Framework, Data or Declarative mode, then loading the matching reference and the installed package docs.

    57k GitHub starsUsed in 1 repo~1.5k tokens
    Frontend & DesignAuto-check passed
  • React UI State Patterns

    ChrisWiles/claude-code-showcase

    Sets patterns for React interfaces: when to show loading spinners or skeletons, how to surface errors, how to disable buttons during async work and how to handle empty lists.

    6.1k GitHub starsUsed in 8 repos~1.6k tokens
    Frontend & DesignAuto-check passed
  • Tells the agent where new code belongs in an Electron multi-process project and which APIs each process may use, with rules for new bridges, services, agents and workers.

    33k GitHub starsUsed in 1 repo~1.8k tokens
    DevelopmentAuto-check passed

More from intertwine/dspy-agent-skills

  • Dspy Advanced Workflow

    intertwine/dspy-agent-skills

    Build DSPy 3.2.x programs through spec, program, metric and baseline; extend to optimization and export when requested and justified by task budget.

    278 GitHub stars~1.7k tokensUpdated 1 mo ago
    Auto-check passed
  • Dspy Evaluation Harness

    intertwine/dspy-agent-skills

    Build DSPy evaluation harnesses with rich-feedback metrics that are essential for GEPA optimization.

    278 GitHub stars~1.5k tokensUpdated 1 mo ago
    Auto-check passed
  • Dspy Gepa Optimizer

    intertwine/dspy-agent-skills

    Optimize DSPy programs with dspy.GEPA — a reflective/evolutionary optimizer to consider against task-specific baselines within an authorized evaluation budget.

    278 GitHub stars~2.6k tokensUpdated 1 mo ago
    Auto-check passed
  • Dspy Rlm Module

    intertwine/dspy-agent-skills

    Use dspy.RLM (Recursive Language Model) for reasoning over contexts too large to fit in an LLM's working window — entire codebases, long logs, massive documents, or multi-step data exploration that…

    278 GitHub stars~1.3k tokensUpdated 1 mo ago
    Auto-check passed

Works with

Questions about Dspy Fundamentals

What does Dspy Fundamentals do?

Write idiomatic DSPy 3.2.x programs — typed Signatures, dspy.Module subclasses, Predict/ChainOfThought/ReAct/ProgramOfThought, and save/load. Dspy Fundamentals is an agent skill from intertwine/dspy-agent-skills.Module subclasses, Predict/ChainOfThought/ReAct/ProgramOfThought, and save/load.

How do I install Dspy Fundamentals in Claude Code?

Run `npx skills add intertwine/dspy-agent-skills --skill dspy-fundamentals -a claude-code`. Or copy the skill folder (skills/dspy-fundamentals in intertwine/dspy-agent-skills) into .claude/skills/dspy-fundamentals in your project. Claude Code loads it when a task matches its description.

How do I install Dspy Fundamentals in Codex?

Run `npx skills add intertwine/dspy-agent-skills --skill dspy-fundamentals -a codex`. Or copy the skill folder (skills/dspy-fundamentals in intertwine/dspy-agent-skills) into .agents/skills/dspy-fundamentals in your project. Codex loads it when a task matches its description.

Can I use Dspy Fundamentals in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add intertwine/dspy-agent-skills --skill dspy-fundamentals -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/dspy-fundamentals, .gemini/skills/dspy-fundamentals, .github/skills/dspy-fundamentals and .opencode/skills/dspy-fundamentals in your project.

What does Dspy Fundamentals need to run?

Going by SKILL.md and its folder, Dspy Fundamentals needs Python for the scripts in its folder. Our summary lists: Python 3.

Does Dspy Fundamentals access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Dspy Fundamentals safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Dspy Fundamentals use?

Dspy Fundamentals is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Dspy Fundamentals use?

About 1.4k tokens (SKILL.md is roughly 5.7k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Dspy Fundamentals?

Skills that share tags, products or a category with Dspy Fundamentals: Web Artifacts Builder (anthropics/skills, 180k stars), Vercel Composition Patterns (supabase/supabase, 111k stars), React Doctor (makeplane/plane, 61k stars) and React Router Development (remix-run/react-router, 57k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Dspy Fundamentals?

intertwine (a GitHub user) maintains it in intertwine/dspy-agent-skills, which has 278 GitHub stars. The repository holds 5 skills in this directory. The repository was last updated on September 6, 2026.

Source: intertwine/dspy-agent-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.