tree-of-thoughts

Multi-path reasoning with evaluation and backtracking - 74% success on complex tasks

170 stars

Best use case

tree-of-thoughts is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Multi-path reasoning with evaluation and backtracking - 74% success on complex tasks

Teams using tree-of-thoughts should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/tree-of-thoughts/SKILL.md --create-dirs "https://raw.githubusercontent.com/Miosa-osa/canopy/main/library/skills/ai-patterns/tree-of-thoughts/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/tree-of-thoughts/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How tree-of-thoughts Compares

Feature / Agenttree-of-thoughtsStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Multi-path reasoning with evaluation and backtracking - 74% success on complex tasks

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Tree of Thoughts (ToT) Pattern

Multi-path reasoning that explores, evaluates, and backtracks. Achieved **74% success rate** on Game of 24 vs 4% with standard CoT.

## Activation

Triggers on:
- Problems requiring non-trivial planning
- Decision trees with multiple valid paths
- Complex debugging with multiple hypotheses
- Creative tasks with evaluation criteria

## Process

### Phase 1: Decompose
Break problem into intermediate steps that can be evaluated independently.

### Phase 2: Generate (Branch)
At each step, generate 3 candidate "thoughts" (reasoning paths):

```
STEP N:
├─ Thought A: [approach 1]
├─ Thought B: [approach 2]
└─ Thought C: [approach 3]
```

### Phase 3: Evaluate
Score each thought (0-10) on:
- Progress toward goal
- Feasibility
- Reversibility if wrong

### Phase 4: Search Strategy
- **BFS**: Explore all branches at depth N before N+1 (shallow trees)
- **DFS**: Follow promising paths deeper (deep trees)
- **Beam Search**: Keep top-K paths at each level

### Phase 5: Backtrack
If path scores drop below threshold (5/10), backtrack to last good node.

## Zero-Shot ToT Prompt

Use this simple prompt for ToT without explicit tree construction:

```
"Imagine three different experts are answering this question.
All experts will write down 1 step of their thinking, then share it with the group.
Then all experts will go on to the next step.
If any expert realizes they're wrong at any point, they leave.
Continue until consensus."
```

## Integration

- Works with @architect for system design decisions
- Pairs with @debugger for multi-hypothesis testing
- Feed final path to learning engine for pattern storage

---

*Based on Princeton/DeepMind research - arXiv:2305.10601*