Skip to content

Latest commit

Β 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” Self-Discover Skill

Self-composing reasoning structures for AI agents.

Let AI discover the optimal reasoning strategy β€” before solving the problem.

License: MIT OpenClaw Claude Code Cursor GitHub Copilot Codex CLI Gemini CLI Windsurf JetBrains Benchmarked


What It Does

Most AI reasoning uses a single strategy (usually "think step by step"). This skill lets the AI discover the optimal reasoning structure for each specific task:

SELECT β†’ ADAPT β†’ IMPLEMENT β†’ SOLVE

Based on peer-reviewed research showing up to 32% improvement over Chain-of-Thought and >20% over Self-Consistency with 10-40x less compute (Zhou et al., 2024, ICML).

One file. Zero dependencies. Zero API cost. The host AI composes its own reasoning structures.


Proven Results

Benchmarked on 20 questions across 5 categories with controlled before/after evaluation. β†’ Full report

Metric Result
Overall improvement +25.3%
Questions improved 20/20 (100%)
Best single improvement +48.2%

Per-dimension improvement:

Dimension Ξ”
Reasoning Depth +31.5%
Structure Quality +28.8%
Answer Accuracy +24.2%
Problem Coverage +23.7%
Actionability +22.0%
Efficiency +19.5%

πŸ“– Read the full benchmark report β†’


Before & After

Example 1 β€” Complex Debugging

User: "My microservice throws intermittent 503s under load. Sometimes works, sometimes doesn't. No pattern I can see."

❌ Without Self-Discover:

This sounds like a capacity issue. Your service might be running out of resources under load. Check your CPU and memory usage during peak times. You might need to scale horizontally or optimize your code. Also check your database connections β€” connection pool exhaustion is a common cause. Consider adding circuit breakers and retry logic.

βœ… With Self-Discover:

Selected modules: Decomposition, Causal Analysis, Hypothesis Testing, Constraint Satisfaction

Root cause candidates (ranked by likelihood):

# Hypothesis Evidence to Check Fix
1 Connection pool exhaustion SHOW STATUS LIKE 'Threads_connected' during 503 Increase pool size + add timeout
2 Thread pool saturation wrk -t12 -c400 + watch ActiveThreads in metrics Switch to async I/O or increase worker count
3 Downstream timeout cascade Check upstream service latency at P99 during 503 window Add circuit breaker, fail fast

Debugging sequence:

# 1. Confirm it's load-dependent
watch -n1 'curl -s -o /dev/null -w "%{http_code}" http://service/health'
# 2. Check connections during 503 window
netstat -an | grep ESTABLISHED | wc -l
# 3. Compare against pool config
grep -i pool application.yml
Example 2 β€” Architecture Decision

User: "Should we use WebSockets or Server-Sent Events for real-time notifications?"

❌ Without Self-Discover:

Both work for real-time. WebSockets are bidirectional and SSE is server-to-client only. If you only need server push, SSE is simpler. If you need the client to send messages too, use WebSockets. Consider compatibility β€” SSE works everywhere, WebSockets might have proxy issues.

βœ… With Self-Discover:

Selected modules: Comparative Analysis, Constraint Satisfaction, Systems Thinking

Factor SSE WebSocket Winner
Direction Server→Client Bidirectional Depends
Reconnection Auto (built-in) Manual (heartbeat + reconnect) SSE
Protocol HTTP/1.1+ (simple) Upgrade handshake (complex) SSE
Binary data No (text only) Yes WS
Load balancer compat Native HTTP Requires sticky sessions/config SSE
Scaling Easy (stateless connections) Harder (stateful) SSE

For notifications (server→client, text-based, needs reliability): SSE.

// Server (Express)
app.get('/notifications', (req, res) => {
  res.setHeader('Content-Type', 'text/event-stream');
  res.setHeader('Cache-Control', 'no-cache');
  const push = (data) => res.write(`data: ${JSON.stringify(data)}\n\n`);
  subscribe(req.user.id, push);
  req.on('close', () => unsubscribe(req.user.id, push));
});

Use WebSocket only if you need client→server real-time (e.g., collaborative editing, gaming).

Example 3 β€” Math Problem

User: "A bat and ball cost $1.10 total. The bat costs $1.00 more than the ball. How much is the ball?"

❌ Without Self-Discover:

The ball costs $0.10. The bat costs $1.00 more, so $1.10. Total is $1.10. βœ“

βœ… With Self-Discover:

Selected modules: Critical Thinking, Constraint Satisfaction, Hypothesis Testing

Constraint setup:

  • Bat + Ball = $1.10
  • Bat = Ball + $1.00

Substitute: (Ball + $1.00) + Ball = $1.10 β†’ 2 Γ— Ball = $0.10 β†’ Ball = $0.05

Verify: Bat = $0.05 + $1.00 = $1.05. Total = $1.05 + $0.05 = $1.10 βœ“

The intuitive answer ($0.10) fails: $0.10 + $1.10 = $1.20 β‰  $1.10.


How It Works

20 Seed Reasoning Modules

# Module Best For
1 Step-by-Step Thinking Sequential procedures
2 Decomposition Multi-part problems
3 Critical Thinking Evaluating claims
4 Reflective Thinking Deep analysis
5 Creative Thinking Open-ended design
6 Pattern Recognition Data, sequences
7 Analogical Reasoning Transfer learning
8 Causal Analysis Debugging, diagnostics
9 Constraint Satisfaction Optimization
10 Abstraction Architecture, generalization
... + 10 more in SKILL.md

4 Depth Levels (Auto-Selected)

Level When Modules Token Cost
0 Simple Q&A 0 +0%
1 Most conversations 1-2 ~10%
2 Complex technical 3-5 ~25%
3 High-stakes / full discovery 4-7 ~40%

No configuration. The agent picks the right depth automatically based on task complexity.

Cross-Task Structure Transfer

Discovered reasoning structures transfer between similar tasks β€” use memory/discovered-structures.md to cache and reuse. Based on Zhou et al.'s finding that structures transfer across model families.


Installation

OpenClaw (recommended)
# Copy to your skills directory
cp -r self-discover-skill/ ~/.openclaw/skills/

That's it. OpenClaw auto-detects skills.

Claude Code
# Copy to your project
cp -r self-discover-skill/ skills/

# Add to CLAUDE.md
echo "Read and follow skills/self-discover-skill/SKILL.md" >> CLAUDE.md
Cursor
# Copy to project root
cp -r self-discover-skill/ skills/

# Add to .cursorrules
echo "Read and follow skills/self-discover-skill/SKILL.md" >> .cursorrules
Gemini CLI
# Copy to project, add to GEMINI.md
cp -r self-discover-skill/ skills/
echo "Read and follow skills/self-discover-skill/SKILL.md" >> GEMINI.md
GitHub Copilot
# Add to your repository's Copilot instructions
mkdir -p skills && cp -r self-discover-skill/ skills/
echo "Read and follow skills/self-discover-skill/SKILL.md" >> .github/copilot-instructions.md
Codex CLI (OpenAI)
cp -r self-discover-skill/ skills/
echo "Read and follow skills/self-discover-skill/SKILL.md" >> AGENTS.md
Windsurf
cp -r self-discover-skill/ skills/
echo "Read and follow skills/self-discover-skill/SKILL.md" >> .windsurfrules
Cline / AI Coding Assistants

Copy self-discover-skill/ to your project. Reference SKILL.md in your assistant's custom instructions.

JetBrains AI / Junie
  1. Open Settings β†’ Tools β†’ AI Assistant β†’ System Instructions
  2. Add: Read and follow skills/self-discover-skill/SKILL.md
  3. Place the skill folder in your project root
Zed
  1. Open Zed settings
  2. Add to your context or assistant instructions:
Read and follow skills/self-discover-skill/SKILL.md
Kiro
  1. Add skill folder to project
  2. Reference in Kiro's instruction configuration
OpenCode
  1. Add skill folder to project
  2. Add to AGENTS.md: Read and follow skills/self-discover-skill/SKILL.md
ChatGPT Custom GPT
  1. Open your GPT β†’ Settings β†’ Instructions
  2. Paste the contents of SKILL.md
  3. Save

Note: SKILL.md includes inline templates for environments without file access β€” all depth levels work. Structure memory is in-conversation only (no persistence).

Any AI Tool

Copy SKILL.md into your system prompt or instructions file. That's the only file you need.


Platform Compatibility

Top platforms (most popular by usage):

Platform Rating Structure Memory Notes
Claude Code ⭐⭐⭐⭐⭐ βœ… File write #1 coding agent 2026, full support
Cursor ⭐⭐⭐⭐⭐ βœ… File write $2B ARR AI IDE, full support
GitHub Copilot ⭐⭐⭐⭐⭐ βœ… File write Largest user base, full support
Codex CLI ⭐⭐⭐⭐⭐ βœ… File write OpenAI's coding agent, full support
ChatGPT ⭐⭐⭐⭐ ⚠️ In-conversation Inline templates auto-load, all levels
Show all 14 supported platforms
Platform Rating Structure Memory Install
OpenClaw ⭐⭐⭐⭐⭐ βœ… memory/ dir Copy to skills/, auto-detect
Claude Code ⭐⭐⭐⭐⭐ βœ… File write Copy to project, add to CLAUDE.md
Cursor ⭐⭐⭐⭐⭐ βœ… File write Copy to project, add to .cursorrules
GitHub Copilot ⭐⭐⭐⭐⭐ βœ… File write Add to .github/copilot-instructions.md
Codex CLI ⭐⭐⭐⭐⭐ βœ… File write Add to AGENTS.md
Gemini CLI ⭐⭐⭐⭐⭐ βœ… File write Add to GEMINI.md
Windsurf ⭐⭐⭐⭐⭐ βœ… File write Add to .windsurfrules
Cline ⭐⭐⭐⭐⭐ βœ… File write Add to custom instructions
JetBrains AI / Junie ⭐⭐⭐⭐½ βœ… File write Add to AI Assistant instructions
Aider ⭐⭐⭐⭐ βœ… File write Place in project, reference with --file
Zed ⭐⭐⭐⭐ βœ… File write Add to Zed settings
ChatGPT GPT ⭐⭐⭐⭐ ⚠️ In-conversation Paste SKILL.md into GPT Instructions
Kiro ⭐⭐⭐⭐ βœ… File write Add to Kiro instructions
OpenCode ⭐⭐⭐⭐ βœ… File write Add to AGENTS.md

Academic Foundations

Paper Year What We Use
SELF-DISCOVER — Zhou et al. 2024 Core SELECT→ADAPT→IMPLEMENT→SOLVE framework
Chain of Thought β€” Wei et al. 2022 Baseline single-module reasoning
Self-Consistency β€” Wang et al. 2022 Comparison target (Self-Discover outperforms with less compute)
Least-to-Most Prompting β€” Zhou et al. 2022 Decomposition module inspiration
Tree of Thoughts β€” Yao et al. 2023 Multi-path reasoning comparison
Step-Back Prompting β€” Zheng et al. 2023 Principle-first reasoning module
OPRO β€” Yang et al. 2023 Optimized prompt comparison

Full bibliography: references/sources.md


File Structure

self-discover-skill/
β”œβ”€β”€ SKILL.md                          # Core instructions (the only required file)
β”œβ”€β”€ README.md                         # This file
β”œβ”€β”€ LICENSE                           # MIT
└── references/
    β”œβ”€β”€ sources.md                    # Academic sources with URLs
    └── discovery-templates.md        # Ready-to-use discovery templates per depth level

The art of reasoning is not in the answer, but in discovering the structure that leads to it.

⭐ Star this repo if it improved your AI's reasoning quality.

About

SELF-DISCOVER: AI agents self-compose reasoning structures. Based on Zhou et al. (2024), NeurIPS.

Topics

Resources

Contributing

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors