dspy-chain-of-thought

Installation
SKILL.md

Step-by-Step Reasoning with dspy.ChainOfThought

Guide the user through using DSPy's ChainOfThought module -- the go-to module for tasks that benefit from intermediate reasoning before producing an answer.

Step 1: Gather context

Before writing any code, ask:

  1. What are the input and output fields? Paste or describe your signature — inline string or class-based. This determines how to structure the module.
  2. What kind of task is this? Classification, extraction, analysis, decision-making, or multi-step reasoning? Tasks where a human would need to think before answering benefit most from CoT.
  3. Have you tried dspy.Predict already? If so, what went wrong — wrong answers, missing nuance, or poor edge-case handling? This shapes whether to demonstrate optimization too.

What is ChainOfThought

dspy.ChainOfThought is a drop-in replacement for dspy.Predict that automatically injects a reasoning field before your output fields. Same signature, one-word swap -- the LM reasons step-by-step before answering. The reasoning field is always available on the result even though your signature doesn't declare it.

When CoT helps

ChainOfThought improves accuracy when the task requires the LM to work through intermediate steps before arriving at an answer:

Installs
8
GitHub Stars
11
First Seen
Mar 17, 2026
dspy-chain-of-thought — lebsral/dspy-programming-not-prompting-lms-skills