npx skills add ...
npx skills add neolabhq/context-engineering-kit --skill thought-based-reasoning
Use when tackling complex reasoning tasks requiring step-by-step logic, multi-step arithmetic, commonsense reasoning, symbolic manipulation, or problems where simple prompting fails - provides comprehensive guide to Chain-of-Thought and related prompting techniques (Zero-shot CoT, Self-Consistency, Tree of Thoughts, Least-to-Most, ReAct, PAL, Reflexion) with templates, decision matrices, and research-backed patterns
npx skills add neolabhq/context-engineering-kit --skill thought-based-reasoning
Chain-of-Thought (CoT) prompting and its variants encourage LLMs to generate intermediate reasoning steps before arriving at a final answer, significantly improving performance on complex reasoning tasks. These techniques transform how models approach problems by making implicit reasoning explicit.
| Technique | When to Use | Complexity | Accuracy Gain |
|---|---|---|---|
| Zero-shot CoT | Quick reasoning, no examples available | Low | +20-60% |
| Few-shot CoT | Have good examples, consistent format needed | Medium | +30-70% |
| Self-Consistency | High-stakes decisions, need confidence | Medium | +10-20% over CoT |
| Tree of Thoughts | Complex problems requiring exploration | High | +50-70% on hard tasks |
| Least-to-Most | Multi-step problems with subproblems | Medium | +30-80% |
| ReAct | Tasks requiring external information | Medium | +15-35% |
| PAL | Mathematical/computational problems | Medium | +10-15% |
| Reflexion | Iterative improvement, learning from errors | High | +10-20% |
Paper: "Chain of Thought Prompting Elicits Reasoning in Large Language Models" (Wei et al., 2022) Citations: 14,255+
Provide few-shot examples that include intermediate reasoning steps, not just question-answer pairs. The model learns to generate similar step-by-step reasoning.
Paper: "Large Language Models are Zero-Shot Reasoners" (Kojima et al., 2022) Citations: 5,985+
Simply append "Let's think step by step" (or similar phrase) to the prompt. This triggers the model to generate reasoning steps without any examples.
Alternative trigger phrases:
Stage 1 - Reasoning Extraction:
Stage 2 - Answer Extraction:
Paper: "Self-Consistency Improves Chain of Thought Reasoning in Language Models" (Wang et al., 2022) Citations: 5,379+
Sample multiple diverse reasoning paths, then select the most consistent answer via majority voting. The intuition: correct answers can be reached through multiple reasoning paths.
Paper: "Tree of Thoughts: Deliberate Problem Solving with Large Language Models" (Yao et al., 2023) Citations: 3,026+
Generalize CoT to a tree structure where each node is a "thought" (coherent language unit). Uses search algorithms (BFS/DFS) with self-evaluation to explore and select promising reasoning paths.
Thought Generation:
State Evaluation:
BFS/DFS Search:
Paper: "Least-to-Most Prompting Enables Complex Reasoning in Large Language Models" (Zhou et al., 2022) Citations: 1,466+
Two-stage process:
Stage 1: Decomposition
Stage 2: Sequential Solving
Paper: "ReAct: Synergizing Reasoning and Acting in Language Models" (Yao et al., 2022) Citations: 5,012+
Interleave reasoning traces ("Thought") with actions ("Action") and observations ("Observation"). Reasoning helps plan actions; actions provide new information for reasoning.
Search[query] - Search for informationLookup[keyword] - Look up keyword in current contextFinish[answer] - Return final answerPaper: "PAL: Program-aided Language Models" (Gao et al., 2022) Citations: 608+
Generate code (typically Python) instead of natural language reasoning. Execute the code to get the answer. The LLM handles decomposition; the interpreter handles computation.
Paper: "Automatic Chain of Thought Prompting in Large Language Models" (Zhang et al., 2022) Citations: 838+
Step 1: Generate diverse demonstrations
Step 2: Use as few-shot exemplars
Paper: "Reflexion: Language Agents with Verbal Reinforcement Learning" (Shinn et al., 2023) Citations: 2,179+
After task failure, the agent generates a verbal "reflection" analyzing what went wrong. This reflection is stored in memory and used in subsequent attempts to avoid repeating mistakes.
Initial Attempt:
Reflection:
Subsequent Attempt (with memory):
Begin with Zero-shot CoT ("Let's think step by step"), then progress to more complex techniques if needed.
Techniques are often complementary:
| Mistake | Why It's Wrong | Fix |
|---|---|---|
| Using CoT for simple lookups | Adds unnecessary tokens and latency | Reserve for multi-step reasoning |
| Too few samples in Self-Consistency | Majority voting needs adequate samples | Use 5-10 samples minimum |
| Generic "think step by step" without checking output | Model may produce irrelevant reasoning | Validate reasoning quality, not just presence |
| Mixing techniques without understanding trade-offs | Computational cost without benefit | Understand when each technique adds value |
| Using PAL without code interpreter | Code generation is useless without execution | Ensure execution environment available |
| Not testing exemplar quality in few-shot CoT | Poor exemplars lead to poor reasoning | Validate exemplars solve problems correctly |
| Applying Tree of Thoughts to linear problems | Massive overhead for no benefit | Use ToT only when exploration needed |
Wei, J. et al. (2022). "Chain of Thought Prompting Elicits Reasoning in Large Language Models." arXiv:2201.11903
Kojima, T. et al. (2022). "Large Language Models are Zero-Shot Reasoners." arXiv:2205.11916
Wang, X. et al. (2022). "Self-Consistency Improves Chain of Thought Reasoning in Language Models." arXiv:2203.11171
Yao, S. et al. (2023). "Tree of Thoughts: Deliberate Problem Solving with Large Language Models." arXiv:2305.10601
Zhou, D. et al. (2022). "Least-to-Most Prompting Enables Complex Reasoning in Large Language Models." arXiv:2205.10625
Yao, S. et al. (2022). "ReAct: Synergizing Reasoning and Acting in Language Models." arXiv:2210.03629
Gao, L. et al. (2022). "PAL: Program-aided Language Models." arXiv:2211.10435
Zhang, Z. et al. (2022). "Automatic Chain of Thought Prompting in Large Language Models." arXiv:2210.03493
Shinn, N. et al. (2023). "Reflexion: Language Agents with Verbal Reinforcement Learning." arXiv:2303.11366