npx skills add ...
npx skills add neolabhq/context-engineering-kit --skill tree-of-thoughts
Execute tasks through systematic exploration, pruning, and expansion using Tree of Thoughts methodology with meta-judge evaluation specifications and multi-agent evaluation
npx skills add neolabhq/context-engineering-kit --skill tree-of-thoughts
Key benefits:
This command implements an eight-phase systematic reasoning pattern with meta-judge evaluation and adaptive strategy selection:
Before starting, ensure the directory structure exists:
Naming conventions:
.specs/research/{solution-name}-{YYYY-MM-DD}.proposals.[a|b|c].md.specs/research/{solution-name}-{YYYY-MM-DD}.pruning.[1|2|3].md.specs/research/{solution-name}-{YYYY-MM-DD}.selection.md.specs/reports/{solution-name}-{YYYY-MM-DD}.[1|2|3].mdWhere:
{solution-name} - Derived from output path (e.g., users-api from output specs/api/users.md){YYYY-MM-DD} - Current dateNote: Solutions remain in their specified output locations; only research and evaluation files go to .specs/
Launch 3 independent agents in parallel (recommended: Sonnet for speed):
.specs/research/{solution-name}-{date}.proposals.[a|b|c].mdKey principle: Systematic exploration through probabilistic sampling from the full distribution of possible approaches.
Prompt template for explorers:
CRITICAL: Launch the pruning meta-judge in parallel with Phase 1 exploration agents. The meta-judge does not need exploration output to generate pruning criteria — it only needs the original task description.
The pruning meta-judge generates an evaluation specification (rubrics, checklist, scoring criteria) tailored to evaluating high-level proposals for pruning.
Prompt template for pruning meta-judge:
Dispatch:
Wait for BOTH Phase 1 exploration agents AND Phase 1.5 pruning meta-judge to complete before proceeding.
Launch 3 independent judges in parallel (recommended: Opus for rigor):
.specs/research/) and the pruning meta-judge evaluation specification YAML.specs/research/{solution-name}-{date}.pruning.[1|2|3].mdKey principle: Independent evaluation with meta-judge-generated criteria ensures consistent, tailored assessment without hardcoded weights.
CRITICAL: Provide to each judge the EXACT pruning meta-judge's evaluation specification YAML. Do not skip, add, modify, shorten, or summarize any text in it!
Prompt template for pruning judges:
{.specs/research/{solution-name}-{date}.pruning.[1|2|3].md}
Follow your full judge process as defined in your agent instructions!
CRITICAL: You must reply with this exact structured evaluation report format in YAML at the START of your response!
Use Task tool:
CRITICAL: Launch the evaluation meta-judge in parallel with Phase 3 expansion agents. The meta-judge does not need expansion output to generate evaluation criteria — it only needs the original task description.
The evaluation meta-judge generates an evaluation specification (rubrics, checklist, scoring criteria) tailored to evaluating full solution implementations.
Prompt template for evaluation meta-judge:
Dispatch:
Wait for BOTH Phase 3 expansion agents AND Phase 3.5 evaluation meta-judge to complete before proceeding.
Launch 3 independent judges in parallel (recommended: Opus for rigor):
.specs/reports/{solution-name}-{date}.[1|2|3].mdKey principle: Multiple independent evaluations with meta-judge-generated specifications and explicit evidence reduce bias and catch different quality aspects.
CRITICAL: Provide to each judge the EXACT evaluation meta-judge's evaluation specification YAML. Do not skip, add, modify, shorten, or summarize any text in it!
CRITICAL: NEVER provide score threshold to judges. Judge MUST not know what threshold for score is, in order to not be biased!!!
Prompt template for evaluation judges:
Write full report to: .specs/reports/{solution-name}-{date}.[1|2|3].md
CRITICAL: You must reply with this exact structured header format:
VOTE: [Solution A/B/C] SCORES: Solution A: [X.X]/5.0 Solution B: [X.X]/5.0 Solution C: [X.X]/5.0 CRITERIA:
[Summary of your evaluation]
Follow your full judge process as defined in your agent instructions!
CRITICAL: You must reply with this exact structured evaluation report format in YAML at the START of your response!
Use Task tool:
When: All solutions scored <3.0/5.0 (fundamental issues across the board)
Process:
Note: If redesign fails twice, escalate to user for guidance.
Prompt template for new implementation:
When: No clear winner AND solutions have merit (scores >=3.0)
Process: Proceed to Phase 5 (Evidence-Based Synthesis)
Only executed when Strategy 3 (FULL_SYNTHESIS) selected in Phase 4.5
Launch 1 synthesis agent (recommended: Opus for quality):
.specs/reports/).specs/research/)Key principle: Evidence-based synthesis leverages collective intelligence from exploration and evaluation.
Prompt template for synthesizer:
Research directory: .specs/research/ (created if not exists)
.specs/research/{solution-name}-{date}.proposals.[a|b|c].md - High-level approaches with probabilities.specs/research/{solution-name}-{date}.pruning.[1|2|3].md - Judge evaluations and votes.specs/research/{solution-name}-{date}.selection.md - Vote tallies and selected proposalsExpansion outputs:
solution.a.md, solution.b.md, solution.c.md - Full implementations (in specified output location)Reports directory: .specs/reports/ (created if not exists)
.specs/reports/{solution-name}-{date}.[1|2|3].md - Final judge reportsResulting solution: {output_path}
Phase 1 outputs (assuming date 2025-01-15):
.specs/research/users-api-2025-01-15.proposals.a.md - 6 approaches from Agent A.specs/research/users-api-2025-01-15.proposals.b.md - 6 approaches from Agent B.specs/research/users-api-2025-01-15.proposals.c.md - 6 approaches from Agent CPhase 1.5 output (runs in parallel with Phase 1):
sadd:meta-judge) generates pruning evaluation specification YAMLPhase 2 outputs (3 judges with pruning meta-judge spec):
.specs/research/users-api-2025-01-15.pruning.1.md - Top 3: Resource-based REST, Pure REST, Monolithic.specs/research/users-api-2025-01-15.pruning.2.md - Top 3: Pure REST, Hybrid (services), Resource-based REST.specs/research/users-api-2025-01-15.pruning.3.md - Top 3: Resource-based REST, REST+GraphQL hybrid, Pure REST.specs/research/users-api-2025-01-15.selection.md - Selected: Resource-based REST (8 pts), Pure REST (7 pts), Monolithic (4 pts)Phase 3 outputs:
specs/api/users.a.md - Full resource-based design with nested routesspecs/api/users.b.md - Flat REST design with simple endpointsspecs/api/users.c.md - Monolithic API with service-oriented internalsPhase 3.5 output (runs in parallel with Phase 3):
sadd:meta-judge) generates evaluation specification YAMLPhase 4 outputs (3 judges with evaluation meta-judge spec):
.specs/reports/users-api-2025-01-15.1.md:
"Prefers A for RESTfulness, criticizes C complexity"
.specs/reports/users-api-2025-01-15.2.md:
"Prefers B for simplicity, criticizes A deep nesting"
.specs/reports/users-api-2025-01-15.3.md:
"Prefers A for discoverability, criticizes B lack of structure"
Phase 4.5 decision (orchestrator parses headers):
Phase 5 output (synthesis):
specs/api/users.md - Resource-based structure (from A), max 2-level nesting (from B), internal services (from C)Phase 1: Exploration (Propose Approaches)
┌─ Agent A → Proposals A1, A2 (with probabilities) ─┐
Task ───┼─ Agent B → Proposals B1, B2 (with probabilities) ─┼─┐
└─ Agent C → Proposals C1, C2 (with probabilities) ─┘ │
│
Phase 1.5: Pruning Meta-Judge (runs in parallel with Phase 1) │
Meta-Judge → Pruning Evaluation Specification YAML ───┤
│
Phase 2: Pruning (Vote for Best 3) │
┌─ Judge 1 → Votes + Rationale ─┐ │
├─ Judge 2 → Votes + Rationale ─┼─────────────────────┤
└─ Judge 3 → Votes + Rationale ─┘ │
│ │
├─→ Select Top 3 Proposals │
│ │
Phase 3: Expansion (Develop Full Solutions) │
┌─ Agent A → Solution A (from proposal X) ─┐ │
├─ Agent B → Solution B (from proposal Y) ─┼──────────┤
└─ Agent C → Solution C (from proposal Z) ─┘ │
│
Phase 3.5: Evaluation Meta-Judge (runs in parallel w/ Phase 3)│
Meta-Judge → Evaluation Specification YAML ───────────┤
│
Phase 4: Evaluation (Judge Full Solutions) │
┌─ Judge 1 → Report 1 ─┐ │
├─ Judge 2 → Report 2 ─┼──────────────────────────────┤
└─ Judge 3 → Report 3 ─┘ │
│
Phase 4.5: Adaptive Strategy Selection │
Analyze Consensus ────────────────────────────────────┤
├─ Clear Winner? → SELECT_AND_POLISH │
├─ All Flawed (<3.0)? → REDESIGN (Phase 3) │
└─ Split Decision? → FULL_SYNTHESIS │
│ │
Phase 5: Synthesis (Only if FULL_SYNTHESIS) │
Synthesizer ────────────────────┴──────────────────────┴─→ Final Solutionmkdir -p .specs/research .specs/reports<task>
{task_description}
</task>
<constraints>
{constraints_if_any}
</constraints>
<context>
{relevant_context}
</context>
<output>
{.specs/research/{solution-name}-{date}.proposals.[a|b|c].md - each agent gets unique letter identifier}
</output>
Instructions:
Let's approach this systematically by first understanding what we're solving, then exploring the solution space.
**Step 1: Decompose the problem**
Before generating approaches, break down the task:
- What is the core problem being solved?
- What are the key constraints and requirements?
- What subproblems must any solution address?
- What are the evaluation criteria for success?
**Step 2: Map the solution space**
Identify the major dimensions along which solutions can vary:
- Architecture patterns (e.g., monolithic vs distributed)
- Implementation strategies (e.g., eager vs lazy)
- Trade-off axes (e.g., performance vs simplicity)
**Step 3: Generate 6 distinct high-level approaches**
**Sampling guidance:**
Please sample approaches at random from the [full distribution / tails of the distribution]
- For first 3 approaches aim for high probability, over 0.80
- For last 3 approaches aim for diversity - explore different regions of the solution space, such that the probability of each response is less than 0.10
For each approach, provide:
- Name and one-sentence summary
- Detailed description (2-3 paragraphs)
- Key design decisions and rationale
- Trade-offs (what you gain vs what you sacrifice)
- Probability (0.0-1.0)
- Complexity estimate (low/medium/high)
- Potential risks and failure modes
**Step 4: Verify diversity**
Before finalizing, check:
- Are approaches genuinely different, not minor variations?
- Do they span different regions of the solution space?
- Have you covered both conventional and unconventional options?
CRITICAL:
- Do NOT implement full solutions yet - only high-level approaches
- Ensure approaches are genuinely different, not minor variations## Task
Generate an evaluation specification yaml for pruning high-level solution proposals. You will produce rubrics, checklists, and scoring criteria that judge agents will use to select the top 3 proposals for full development.
CLAUDE_PLUGIN_ROOT=`${CLAUDE_PLUGIN_ROOT}`
## User Prompt
{Original task description from user}
## Context
{Any relevant codebase context, file paths, constraints}
## Artifact Type
proposals (high-level approaches with probability estimates, not full implementations)
## Evaluation Focus
Feasibility, alignment with requirements, potential for high-quality result, risk manageability
## Instructions
Return only the final evaluation specification YAML in your response.
The specification should support comparative evaluation and ranking of proposals.Use Task tool:
- description: "Pruning Meta-judge: {brief task summary}"
- prompt: {pruning meta-judge prompt}
- model: opus
- subagent_type: "sadd:meta-judge"## Task
Generate an evaluation specification yaml for evaluating full solution implementations. You will produce rubrics, checklists, and scoring criteria that judge agents will use to evaluate and compare competitive implementations.
CLAUDE_PLUGIN_ROOT=`${CLAUDE_PLUGIN_ROOT}`
## User Prompt
{Original task description from user}
## Context
{Any relevant codebase context, file paths, constraints}
## Artifact Type
{code | documentation | configuration | etc.}
## Number of Solutions
3 (full implementations developed from selected proposals)
## Instructions
Return only the final evaluation specification YAML in your response.
The specification should support comparative evaluation across multiple solutions.Use Task tool:
- description: "Evaluation Meta-judge: {brief task summary}"
- prompt: {evaluation meta-judge prompt}
- model: opus
- subagent_type: "sadd:meta-judge"You are analyzing why all solutions failed to meet quality standards, to inform a redesign. And implement new solution based on it.
<task>
{task_description}
</task>
<constraints>
{constraints_if_any}
</constraints>
<context>
{relevant_context}
</context>
<failed_solutions>
{list of paths to all solution files}
Average scores: A={avg_a}/5.0, B={avg_b}/5.0, C={avg_c}/5.0
</failed_solutions>
<evaluation_reports>
{list of paths to all evaluation reports}
All solutions scored below 3.0/5.0 threshold.
</evaluation_reports>
<output>
.specs/research/{solution-name}-{date}.redesign-analysis.md
</output>
Instructions:
Let's break this down systematically to understand what went wrong and how to design new solution based on it.
1. First, analyze the task carefully - what is being asked and what are the key requirements?
2. Read through each solution and its evaluation report
3. For each solution, think step by step about:
- What was the core approach?
- What specific issues did judges identify?
- Why did this approach fail to meet the quality threshold?
4. Identify common failure patterns across all solutions:
- Are there shared misconceptions?
- Are there missing requirements that all solutions overlooked?
- Are there fundamental constraints that weren't considered?
5. Extract lessons learned:
- What approaches should be avoided?
- What constraints must be addressed?
6. Generate improved guidance for the next iteration:
- New constraints to add
- Specific approaches to try - what are the different ways to solve this?
- Key requirements to emphasize
7. Think through the tradeoffs step by step and choose the approach you believe is best
8. Implement it completely
9. Generate 5 verification questions about critical aspects
10. Answer your own questions:
- Review solution against each question
- Identify gaps or weaknesses
11. Revise solution:
- Fix identified issues
12. Explain what was changed and whyYou are synthesizing the best solution from explored, pruned, and evaluated implementations.
<task>
{task_description}
</task>
<solutions>
{list of paths to all solution files}
</solutions>
<evaluation_reports>
{list of paths to all evaluation reports}
</evaluation_reports>
<selection_rationale>
{path to selection.md explaining why these proposals were chosen}
</selection_rationale>
<output>
{output_path} - The final synthesized solution
</output>
Instructions:
Let's approach this synthesis systematically by first analyzing, then decomposing, then building.
**Step 1: Build the evidence base**
Before synthesizing, gather evidence from judge reports:
- What did multiple judges praise? (consensus strengths)
- What did multiple judges criticize? (consensus weaknesses)
- Where did judges disagree? (areas needing careful analysis)
**Step 2: Decompose into synthesis subproblems**
Break the solution into logical sections or components. For each component:
- Which solution handles this best? (cite evidence)
- Are there complementary elements from multiple solutions?
- What issues were identified that need fixing?
**Step 3: Solve each subproblem**
For each component/section, determine the synthesis strategy:
*Strategy A - Clear winner:* If one solution is clearly superior for this component:
- Copy that section directly
- Document: "Taken from Solution X because [judge evidence]"
*Strategy B - Complementary combination:* If solutions have complementary strengths:
- Identify what each contributes
- Combine carefully, ensuring consistency
- Document: "Combined X from Solution A with Y from Solution B because [rationale]"
*Strategy C - All flawed:* If all solutions have issues in this area:
- Start with the best version
- Apply fixes based on judge criticism
- Document: "Based on Solution X, modified to address [specific issues]"
**Step 4: Integrate and verify consistency**
After synthesizing all components:
- Check that combined elements work together
- Resolve any contradictions between borrowed sections
- Ensure consistent terminology and style
**Step 5: Document synthesis decisions**
Create a synthesis log:
- What you took from each solution (with specific citations)
- Why you made those choices (reference judge feedback)
- How you addressed identified weaknesses
- Any novel combinations or improvements
<example>
**Example synthesis decision for an API design:**
Component: Authentication flow
- Solution A: JWT with refresh tokens (praised for security by 2/3 judges)
- Solution B: Session-based (praised for simplicity by 1 judge, criticized for scalability)
- Solution C: OAuth2 only (criticized as over-engineered for use case)
Decision: Take Solution A's authentication flow directly.
Evidence: Judges 1 and 3 both noted "JWT approach provides good balance of security and statelessness"
Modification: None needed - this section was rated highest across judges.
</example>
**Step 6: Revise your solution**
- Generate 5 verification questions about critical aspects
- Answer your own questions:
- Review solution against each question
- Identify gaps or weaknesses
- Revise solution:
- Fix identified issues
- Explain what was changed and why
CRITICAL:
- Do not create something entirely new - synthesize the best from what exists
- Cite your sources (which solution, which section)
- Explain every major decision
- Address all consensus weaknesses identified by judges/tree-of-thoughts "Design REST API for user management (CRUD + auth)" \
--output "specs/api/users.md" \
--criteria "RESTfulness,security,scalability,developer-experience"