# Skillopt Sleep

Use when the user wants the dsh agent to self-improve from past usage, asks about a...

- Repository: https://github.com/microsoft/SkillOpt (18804 stars)
- Category: AI and agents
- License: MIT
- Last updated: 2026-11-01
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add microsoft/SkillOpt --skill skillopt-sleep -g -a claude-code -y`
Codex: `npx skills add microsoft/SkillOpt --skill skillopt-sleep -g -a codex -y`
Cursor: `npx skills add microsoft/SkillOpt --skill skillopt-sleep -g -a cursor -y`
Gemini CLI: `npx skills add microsoft/SkillOpt --skill skillopt-sleep -g -a gemini-cli -y`

## Description

Use when the user wants the dsh agent to self-improve from past usage, asks about a nightly/offline 'sleep' or 'dream' cycle, skill/memory consolidation, or says things like 'make my agent better the more I use it', 'review my past sessions', 'learn my preferences', 'consolidate what you learned', 'run the sleep cycle', or wants to schedule background self-optimization. Drives the skillopt_sleep engine through the skillopt_* tools: harvest past sessions -> mine recurring tasks -> replay via a selected backend -> consolidate validated skills behind a held-out gate.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# SkillOpt-Sleep: usage-driven self-evolution for the dsh agent

SkillOpt-Sleep is Microsoft's [SkillOpt](https://github.com/microsoft/SkillOpt)
deployment-time companion engine: it reviews your past sessions (harvest), mines
recurring tasks (mine), replays them through a selected backend (replay), and
consolidates what it learns into skill documents behind a **held-out validation
gate** (consolidate).

This skill drives the engine through the 7 `skillopt_*` tools exposed by the
dsh-skillopt plugin. The default `mock` backend makes no model calls, which is
useful for verifying the plumbing; a real backend consumes your API budget.

## When to use

- "make my agent better the more I use it" / "learn my preferences across sessions"
- a one-off **offline self-evolution / sleep / dream** run (immediate or scheduled)
- review past sessions/trajectories and distill recurring tasks
- consolidate feedback into `AGENTS.md` / `SKILL.md` / managed skills
- schedule (cron) the cycle, or adopt a staged proposal

## The cycle (six stages)

1. **Harvest**, read-only scan of supported local session records → digests
2. **Mine**, digests → recurring task records (intent + outcome labels + checkable refs)
3. **Replay**, re-run tasks under the current skill+memory with the selected backend → (hard, soft) scores
4. **Consolidate**, reflect on failures → propose bounded edits → **validation gate** on a held-out slice (default: accept only on strict improvement)
5. **Stage**, write accepted proposals to `<project>/.skillopt-sleep/staging/<timestamp>/`. **Live files are unchanged.** A rejected run still has a report but no proposal files.
6. **Adopt**, explicit (or operator-configured `--auto-adopt`) copies staged files over live ones, backing up first.

## Driving it

Prefer the tools over hand-editing files:

The rest: https://github.com/microsoft/SkillOpt/blob/HEAD/plugins/dsh/skills/skillopt-sleep/SKILL.md
