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.

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:

  • Multi-step logic -- math, puzzles, conditional reasoning
  • Analysis and judgment -- "Is this code buggy?", "Should we approve this loan?"
  • Classification with nuance -- when the label depends on weighing multiple factors
  • Explanation-heavy tasks -- anything where you want to see why the LM chose its answer
  • Complex extraction -- parsing ambiguous data where the LM needs to resolve conflicts

Rule of thumb: If a human would need to think through the problem before answering, use ChainOfThought.

Related skills

More from lebsral/dspy-programming-not-prompting-lms-skills

Installs
5
GitHub Stars
5
First Seen
Mar 17, 2026