An AI agent skill for self-composing task-specific reasoning structures. Based on Zhou et al. (2024) — SELF-DISCOVER: Large Language Models Self-Compose Reasoning Structures.
At skill load time, detect your runtime environment and adjust capabilities:
CapabilityHow to CheckFallbackFile systemCan you read references/discovery-templates.md?Use the inline templates below insteadPersistent memoryCan you write to memory/?Store discovery notes in conversation context onlyLong contextIs your context window > 32K tokens?Cap at Level 2 (skip full discovery)Tool accessCan you call external tools?Use mental reasoning only
Detection rules:
references/ directory → full mode (all levels + memory)This means every platform gets the best possible experience automatically — no manual configuration needed.
If you cannot read references/discovery-templates.md, use these directly:
text
Before answering: (1) What type of reasoning does this task need? (2) Pick 1-2 modules from the seed list. (3) Apply them. Deliver.
text
1. SELECT: From the seed modules, choose 3-5 relevant to this task.
2. ADAPT: Rephrase each selected module to be task-specific.
3. IMPLEMENT: Compose into a step-by-step reasoning structure.
4. Follow the structure to produce the answer.
text
1. SELECT: Choose 4-7 modules relevant to the task type.
2. ADAPT: Tailor each to the specific task, adding domain expertise.
3. IMPLEMENT: Build a JSON-like reasoning structure with keys and expected outputs.
4. Execute the structure step-by-step.
5. VERIFY: Check the answer against the structure — did every key get a valid value?
6. If gaps found, refine the structure and re-execute.
Activate when you are about to solve a reasoning-intensive task — after gathering all information but before producing your answer. Discovery happens before reasoning, not instead of work.
Strong triggers: Multi-step reasoning, math, logic puzzles, planning, debugging, architecture decisions, analytical tasks.
Skip: Simple factual lookups, greetings, formatting requests, single-sentence answers.
text
1. SELECT — Choose relevant reasoning modules from the seed set
2. ADAPT — Rephrase selected modules to be task-specific
3. IMPLEMENT — Compose modules into a structured reasoning plan (key-value format)
4. SOLVE — Follow the reasoning structure to produce the final answer
Source: Zhou et al., "Self-Discover: Large Language Models Self-Compose Reasoning Structures" (2024, ICML) — LLMs self-compose atomic reasoning modules into task-intrinsic structures, achieving up to 32% improvement over Chain-of-Thought.
These are atomic reasoning skills drawn from cognitive science and prompting research (Fernando et al., 2023; Zhou et al., 2024). The agent selects a subset relevant to each task.
#ModuleDescriptionBest For1Step-by-Step ThinkingBreak reasoning into sequential stepsSequential tasks, procedures2DecompositionBreak problem into sub-problems, solve eachComplex multi-part problems3Critical ThinkingAnalyze from multiple perspectives, question assumptionsEvaluating claims, decisions4Reflective ThinkingSearch for first principles, examine underlying theoryScience, deep analysis5Creative ThinkingGenerate novel approaches, brainstorm alternativesDesign, open-ended tasks6Pattern RecognitionIdentify recurring patterns and regularitiesData analysis, sequences7Analogical ReasoningMap solutions from similar known problemsTransfer learning, explanations8Causal AnalysisIdentify cause-effect relationshipsDebugging, diagnostics9Constraint SatisfactionCheck solutions against all constraintsOptimization, planning10AbstractionExtract general principles from specificsGeneralization, architecture11Hypothesis TestingForm and test hypotheses systematicallyTroubleshooting, debugging12Comparative AnalysisCompare options against defined criteriaDecision-making, trade-offs13Temporal ReasoningReason about sequences and time dependenciesScheduling, process flows14Spatial ReasoningReason about spatial relationshipsLayout, geometry, UI15Counterfactual ThinkingConsider "what if" alternativesRisk analysis, planning16Lateral ThinkingApproach from unconventional anglesInnovation, problem-solving17Deductive ReasoningApply general rules to specific casesLogic, validation18Inductive ReasoningInfer general rules from specific examplesPattern generalization19Probabilistic ThinkingReason under uncertainty with probabilitiesRisk assessment, forecasting20Systems ThinkingConsider interactions between componentsArchitecture, complex systems
The depth is determined by task complexity, not user preference. The agent auto-selects.
Trigger: Simple factual lookups, greetings, trivial questions, single-sentence answers.
Action: Do nothing extra. Just respond. Cost: 0 additional tokens.
Examples: "What time is it?", "Thanks", simple formatting requests.
Trigger: Medium-complexity tasks — explanations, how-to guides, code snippets, questions requiring one type of reasoning.
Action: Select 1-2 relevant modules. Apply mentally. Deliver.
Budget: 1 discovery pass. ~10% overhead on response tokens.
Internal process:
text
After receiving the task:
- What type of reasoning does this need?
- Pick the most relevant module (e.g., "decomposition" for multi-part questions)
- Apply it while composing the answer
- Deliver
Trigger: Complex tasks — technical architectures, multi-step plans, debugging, anything requiring 3+ reasoning steps or multiple perspectives.
Action: Select 3-5 modules. Adapt to task. Compose into structured plan. Execute.
Budget: 1 full discovery cycle (SELECT + ADAPT + IMPLEMENT). ~25% overhead.
Internal process:
text
1. SELECT 3-5 relevant modules from the seed set
2. ADAPT each to be specific to this task
3. IMPLEMENT into a step-by-step structure
4. Follow the structure to produce the answer
Trigger: High-stakes tasks — complex math, logic puzzles, production architecture, multi-constraint optimization, or user explicitly requests thorough reasoning.
Action: Full SELECT → ADAPT → IMPLEMENT cycle with 4-7 modules, JSON-like reasoning structure, and verification pass.
Budget: Full discovery cycle + verification. ~40% overhead.
Internal process:
text
1. SELECT 4-7 relevant modules
2. ADAPT with domain-specific tailoring
3. IMPLEMENT into key-value reasoning structure:
{
"step_1": { "action": "...", "expected_output": "..." },
"step_2": { "action": "...", "expected_output": "..." },
...
}
4. Execute each step, filling in values
5. VERIFY: Did every step produce a valid output?
6. If gaps → refine structure, re-execute gap steps only
For common task types, use these pre-composed structures instead of running full discovery:
json
{
"step_1": { "action": "Reproduce: Identify the exact error and trigger condition", "output": "error description" },
"step_2": { "action": "Decompose: Break the code path into segments", "output": "list of code segments" },
"step_3": { "action": "Hypothesis: Form 2-3 hypotheses for root cause", "output": "ranked hypotheses" },
"step_4": { "action": "Test: Verify top hypothesis against evidence", "output": "confirmed root cause" },
"step_5": { "action": "Fix: Implement the fix with edge case handling", "output": "corrected code" }
}
json
{
"step_1": { "action": "Decompose: List all requirements and constraints", "output": "requirement matrix" },
"step_2": { "action": "Compare: Generate 2-3 options", "output": "option summaries" },
"step_3": { "action": "Evaluate: Score each option against constraints", "output": "comparison table" },
"step_4": { "action": "Decide: Select best option with justification", "output": "decision + rationale" },
"step_5": { "action": "Validate: Check for overlooked constraints", "output": "final recommendation" }
}
json
{
"step_1": { "action": "Understand: Restate the problem, identify given and unknown", "output": "problem statement" },
"step_2": { "action": "Plan: Select relevant formulas/approaches", "output": "solution strategy" },
"step_3": { "action": "Execute: Apply step-by-step with intermediate results", "output": "workings" },
"step_4": { "action": "Verify: Substitute answer back or check invariants", "output": "verification" }
}
json
{
"step_1": { "action": "Scope: Define what needs to be analyzed and why", "output": "analysis scope" },
"step_2": { "action": "Gather: Identify key facts, data points, or evidence", "output": "evidence list" },
"step_3": { "action": "Pattern: Find patterns, trends, or anomalies", "output": "findings" },
"step_4": { "action": "Synthesize: Combine findings into conclusions", "output": "conclusions" },
"step_5": { "action": "Validate: Check conclusions against original scope", "output": "final analysis" }
}
Based on the empirical finding from Zhou et al. that self-discovered structures are effective in a single pass:
Anti-pattern — DO NOT:
DepthModulesMax StepsApprox. Token OverheadWhen to UseLevel 000+0%Simple Q&ALevel 11-2Mental10%Most conversationsLevel 23-5Structured plan25%Complex technicalLevel 34-7Full JSON + verify~40%High-stakes only
Principle: Discovery should cost less than the cost of a wrong approach. For low-stakes responses, skip discovery entirely.
Discovery is internal — the user should not see the raw reasoning structure. However:
Level 1: No note (keep it invisible).
Level 2: Optionally: _(response composed via multi-module reasoning)_ Level 3: Optionally: _(reasoning structure self-discovered from [N] modules)_
Inspired by Zhou et al.'s finding that self-discovered structures transfer across model families — the same reasoning structure that works for GPT-4 also helps Llama-2.
When to reuse: When you encounter a task of the same type as one you've previously solved with discovery (e.g., another debugging task, another architecture decision).
How to reuse: Write the discovered structure to memory/discovered-structures.md:
text
## [Task Type]
Structure: [paste the key-value structure]
Effective for: [describe task characteristics]
Date: [today]
Next time you encounter a similar task, check memory first before running discovery again.
TechniqueSourceHow Self-Discover DiffersChain of ThoughtWei et al. 2022CoT is a single module; Self-Discover composes multipleLeast-to-MostZhou et al. 2022Decomposition only; Self-Discover selects best modules per taskSelf-ConsistencyWang et al. 2022Requires 10-40x more compute; Self-Discover is more efficientTree of ThoughtsYao et al. 2023Explores multiple paths; Self-Discover composes optimal structureStep-Back PromptingZheng et al. 2023Single principle; Self-Discover combines multiple heuristicsOPROYang et al. 2023Optimizes prompts with training data; Self-Discover needs no labels
text
DISCOVER? ──→ Simple/trivial? ──→ NO → Just respond
│
YES
│
├─ Single reasoning type → LEVEL 1 (1-2 modules, mental)
├─ Multi-step / multi-perspective → LEVEL 2 (3-5 modules, structured)
└─ High-stakes / complex → LEVEL 3 (4-7 modules, full JSON + verify)
SELECT → ADAPT → IMPLEMENT → SOLVE
│ │ │ │
Pick Tailor Structure Execute
modules to task the plan the plan