name: auto-skill-extractor
emoji: 🔄
description: Automatically learn from your AI's work and turn repeated subagent tasks into reusable skills
details: |
Auto-Skill Extractor v1.0.2 watches your subagents work, detects patterns worth reusing, and creates draft skills automatically.
Security Notice
✅ No sensitive data persisted - Only tool counts, scores, and timestamps are stored
✅ Configurable workspace - Set AUTO_SKILL_WORKSPACE environment variable
✅ Sanitized metadata - Session IDs are hashed, transcripts are not written to disk
✅ Path validation - All paths checked before file operations
✅ No raw trigger files - Recommended usage uses stdin, not file-based input
What It Does
Your OpenClaw agent runs subagents to do complex tasks. This skill:
- Observes subagent completions (what tools they used, what they accomplished)
- Scores complexity (3+ tool calls? multi-domain work? error recovery?)
- Extracts if the work looks reusable → creates
skills/auto-draft/{name}/
- Promotes after 3 successful uses → moves to
skills/auto/ (ACTIVE)
- Archives unused drafts after 7 days
Why Use This
- Stop manually writing skills for every pattern
- Build a library of your actual workflows
- Learn from your agent's own work
- Automate skill lifecycle (draft → test → promote)
How Complexity Scoring Works
| Factor | Points | Example |
|---|
| 3 tool calls | 2 pts | read + exec + write |
| 5 tool calls | 4 pts | complex analysis |
| Multi-domain | +2 pts | files + system + web |
| Error recovery | +2 pts | retry on failure |
Threshold: 4 points = creates DRAFT skill
Safety Features
- ✅ Won't overwrite existing skills (collision check)
- ✅ Sanitizes names (no path traversal)
- ✅ Atomic promotions (copy → verify → move)
- ✅ Queue limits (max 50 pending)
Install
clawhub install auto-skill-extractor
Setup
-
Create skill directories:
mkdir -p skills/auto-draft skills/auto skills/manual
-
Add to AGENTS.md after subagent completion (RECOMMENDED: stdin piping):
import subprocess, json
trigger_data = {
"completion_status": "success",
"tool_calls": tool_call_count,
"session_id": session_key,
"multi_domain": True,
"transcript_summary": summary
}
result = subprocess.run(
["python3", "scripts/auto-skill-trigger.py"],
input=json.dumps(trigger_data),
capture_output=True,
text=True
)
Alternative (file-based, less secure - delete file immediately after):
import subprocess, json
import os
trigger_path = "/tmp/trigger.json"
with open(trigger_path, "w") as f:
json.dump(trigger_data, f)
result = subprocess.run(
["python3", "scripts/auto-skill-trigger.py", trigger_path],
capture_output=True
)
os.remove(trigger_path)
Commands
python3 scripts/skill-lifecycle.py list
python3 scripts/skill-lifecycle.py drafts
python3 scripts/skill-lifecycle.py process
python3 scripts/skill-lifecycle.py promote my-skill-name
Directives
#skill: extract — Manually trigger from last subagent
#skill: force — Force extraction (ignore thresholds)
Based On
Hermes Agent by Nous Research — adapted for OpenClaw.
See Also
Auto-Skill Extractor
Turn your agent's work into reusable skills. Automatically.
When to Use
✅ You run complex subagent tasks repeatedly
✅ You want to build a skill library without manual authoring
✅ You run multi-domain tasks (files + system + web)
✅ You want your agent to learn from its own patterns
When NOT to Use
❌ Simple 1-2 tool tasks (not worth skilling)
❌ One-off exploratory work
❌ You prefer manually authoring every skill
Quick Start
1. Install
clawhub install auto-skill-extractor
2. Create Directories
mkdir -p skills/auto-draft skills/auto skills/manual
3. Wire Into Your Agent
Add to AGENTS.md after subagent completion:
import subprocess
import json
trigger_data = {
"completion_status": "success",
"tool_calls": tool_call_count,
"transcript_summary": brief_summary,
"session_id": session_key,
"multi_domain": True
}
result = subprocess.run(
["python3", "scripts/auto-skill-trigger.py"],
input=json.dumps(trigger_data),
capture_output=True,
text=True
)
output = json.loads(result.stdout)
if output.get("action") == "extract":
print(f"🔄 Created DRAFT skill: {output['skill_name']}")
4. Use It
Run a subagent with complex work:
Spawn subagent to analyze codebase...
- Read 5 config files ✓
- Check processes ✓
- Write summary report ✓
Result: skills/auto-draft/codebase-analyzer-abc123/ created automatically
How It Works
Step 1: Trigger Evaluation
After every subagent completion:
| Check | Must Pass |
|---|
| Status | success |
| Tool calls | ≥ 3 |
| Complexity | ≥ 4 |
Step 2: Complexity Scoring
Base: tool_calls × 0.7 (max 5 pts)
3 tools = 2 pts, 5 tools = 4 pts
Bonus: +2 multi-domain (files + system + web)
+2 error recovery (retry logic)
+1 fail-then-succeed
Threshold: 4 points = extract
Step 3: DRAFT Creation
skills/auto-draft/my-skill-abc123/
├── SKILL.md ← Template with metadata
└── meta.json ← Invocation tracking
Step 4: Evaluation Period
- Use the DRAFT skill 3 times successfully
- Each use logged in
meta.json
- After 3rd use → auto-promoted to
skills/auto/
Step 5: ACTIVE Status
Promoted skills are:
- Visible in
/skills auto list
- Ready for manual completion
- Versioned and tracked
Configuration
Edit scripts/auto-skill-trigger.py:
COMPLEXITY_THRESHOLD = 4
MAX_QUEUE_SIZE = 50
PROMOTE_THRESHOLD = 3
Manual Control
Force Extraction
Ignore thresholds:
#skill: force
List Drafts
python3 scripts/skill-lifecycle.py drafts
Promote Early
python3 scripts/skill-lifecycle.py promote my-skill-name
Archive Stale Drafts
python3 scripts/skill-lifecycle.py process
Safety
- ✅ Collision detection — Won't overwrite existing skills
- ✅ Path sanitization —
../../../etc → blocked
- ✅ Atomic promotion — Copy → verify → move → delete
- ✅ Queue limits — Max 50 pending extractions
- ✅ Return value checks — Errors logged, not silent
Verification
Check extraction worked:
ls -la skills/auto-draft/
cat scripts/skill-extraction-queue.json
cat skills/auto-draft/my-skill-abc123/SKILL.md
Pitfalls
| Problem | Cause | Fix |
|---|
| No DRAFTs created | Threshold too high | Lower COMPLEXITY_THRESHOLD |
| Too many DRAFTs | Threshold too low | Raise threshold, manually curate |
| Promotion never happens | Not using DRAFTs | Run /skills promote manually |
| Skills not useful | Noise in extraction | Tune thresholds, review DRAFTs weekly |
Architecture
Subagent completes
↓
auto-skill-trigger.py
↓
Score complexity (0-10)
↓
If ≥ 4: Create DRAFT
↓
skill-lifecycle.py
↓
After 3 uses: PROMOTE → skills/auto/
↓
After 7 days: ARCHIVE
Related
References