SkillOpt-Sleep: Usage-Driven Agent Self-Evolution
Gives your Claude coding agent a nightly offline sleep cycle that reviews past sessions and consolidates recurring work into gate-validated memory and skills — better with every use, no weight training required.
Officially published by Microsoft (verifiable official source). The core mechanism has an agent offline-review past sessions and self-modify its own CLAUDE.md/SKILL.md — a self-modifying behavior. It has a validation gate (keeps only changes that improve a held-out score) and requires explicit adoption (changes don't silently take effect) — restrained design, but 'an agent rewriting its own instruction files' still warrants understanding the scope of impact.
What does this skill do, and when should you use it?
SkillOpt-Sleep is a Claude Code skill from Microsoft's SkillOpt repository that gives a local agent a 'sleep cycle'. On demand or on a nightly schedule, it reads real Claude Code sessions, mines recurring tasks, replays them through a selected backend, and consolidates held-out-gated improvements into CLAUDE.md and SKILL.md. Nothing live changes until you explicitly adopt (or opt into --auto-adopt), and adoption backs up existing files first. The whole loop trains no model weights — it is framed as deployment-time training. The skill shipped with SkillOpt v0.2.0 (2026-07-02).
Runs a six-stage cycle: 1) Harvest — read-only reading of ~/.claude/projects/*/<session>.l and ~/.claude/history.l into session digests; 2) Mine — convert digests into TaskRecords with outcome labels; 3) Replay — re-run tasks under the current skill+memory via a selected backend for (hard, soft) scores (default mock backend, no API spend); 4) Consolidate — reflect on failures and propose bounded add/delete/replace edits, accepted only if a held-out slice strictly improves; 5) Stage — write proposed_CLAUDE.md / proposed_SKILL.md plus report, manifest, and diagnostics into .skillopt-sleep/staging/ without touching live files; 6) Adopt — apply with backup, explicitly or auto. Supports cron scheduling and real backends including --backend claude/codex/copilot/azure_openai.
- Engineers using Claude Code daily who want the agent to remember coding preferences and accumulate experience across sessions
- Developers on long-running projects who want nightly offline review of sessions to distill solutions for recurring workflows
- Team leads who want to inspect each proposal's held-out baseline-to-candidate score before adopting any skill change
- Privacy-sensitive users who validate the plumbing on the mock backend, or redact a harvested JSON and replay it via --tasks-file
- Heavy agent users who want the cycle scheduled (e.g., 3:17 AM) so self-optimization happens while they sleep
What are this skill's strengths and limitations?
- Default validation gate: only edits that strictly improve a held-out score are accepted, with rejected edits recorded for review
- Mock backend verifies the plumbing at zero API cost, plus a deterministic synthetic demo that demonstrates held-out lift and gate rejection
- Non-destructive by design: read-only harvest, staging-only writes, automatic backup on adoption
- Multi-backend support (mock/claude/codex/copilot/handoff/azure_openai), cron scheduling, and independently togglable memory vs. skill evolution
- Real backends send truncated transcript excerpts and derived tasks to third-party providers; the docs state the Claude transcript path is not guaranteed to remove every secret before those calls
- A held-out gain is run-specific evidence, not a guarantee of broader improvement; results depend on tasks, model, and checks
- Documented limitations exist, and effectiveness on your own workload requires consulting recorded results in docs/sleep
- Tightly bound to Claude Code session paths and plugin mechanics; other platforms need adaptation
How do you install this skill?
The skill lives at plugins/claude-code/skills/skillopt-sleep/ in the microsoft/SkillOpt repository and is used as a Claude Code plugin after cloning/installing the repo, invoked via ${CLAUDE_PLUGIN_ROOT}/scripts/sleep.sh. Follow the repository's Documentation & Reproduction Guide (microsoft.github.io/SkillOpt); SKILL.md does not document standalone install steps — see docs/sleep/README.md for details.
How do you use this skill?
Prefer the /skillopt-sleep command in Claude Code, or call the runner directly: '${CLAUDE_PLUGIN_ROOT}/scripts/sleep.sh' dry-run --project "$(pwd)" for a no-staging preview; run for a full cycle that stages a proposal; adopt to apply (with backup); schedule --hour 3 --minute 17 to install a nightly cron, unschedule to remove. The default mock backend costs nothing; add --backend claude or codex to spend real budget. Trigger phrases include 'review my past sessions' or 'run the sleep cycle'. Use python -m skillopt_sleep <action> --help for the authoritative flag surface.
How does this skill compare with similar options?
The SkillOpt paper positions one-shot LLM-generated skills and loosely controlled self-revision as the alternatives it improves on: SkillOpt-Sleep treats the skill document as trainable state with held-out gated acceptance of edits. The source material names no third-party competitors.