Official agent skill

SkillOpt Sleep Cycle

by microsoft in microsoft/SkillOpt

Runs an on-demand or nightly sleep cycle that reviews past Claude Code sessions and proposes validated updates to CLAUDE.md and skills.

OfficialMITAuto-check passedAgent Workflows

Install SkillOpt Sleep Cycle

skills CLI
$ npx skills add microsoft/SkillOpt --skill skillopt-sleep -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install microsoft/SkillOpt skillopt-sleep --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/microsoft/SkillOpt.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/claude-code/skills/skillopt-sleep .claude/skills/skillopt-sleep && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
skillopt-sleep
GitHub stars
18k
Token cost
~2.3k tokens
SKILL.md length
938 words
Files
1
Skills in repo
5
Repo updated
First seen
Licence
MIT

At a glance

Runs an on-demand or nightly sleep cycle that reviews past Claude Code sessions and proposes validated updates to CLAUDE.md and skills.

  • Works in 6 steps: Harvest — read… → Mine — digests → TaskRecords (recurring… → Replay — re-run tasks through the… → …
  • Having the agent learn your preferences from past sessions
  • SKILL.md covers When to use this skill, The cycle (six stages), How to drive it and Common CLI flags, plus 4 more sections
  • Calls python

What it does

The skill gives a local Claude agent a sleep cycle: it reviews real past Claude Code sessions, replays recurring tasks through a chosen backend and consolidates what it learns into memory (CLAUDE.md) and skills (SKILL.md). With the default validation gate on, it keeps only changes that improve a held-out score, and live files change only through explicit adoption or a requested --auto-adopt. No model weights are trained.

The cycle has six stages, starting with harvest, mine, replay, consolidate and stage. Harvest reads session logs under ~/.claude read-only into digests, mine turns them into recurring task records, replay re-runs those under the current skill and memory, consolidate proposes bounded edits and gates them on a held-out slice, and stage writes proposed_CLAUDE.md and proposed_SKILL.md plus report and manifest files into a staging folder in the project's .skillopt-sleep directory. The cycle can also be scheduled with cron.

When your agent uses it

  • Having the agent learn your preferences from past sessions
  • Scheduling a nightly self-improvement run
  • Reviewing and adopting a staged proposal for CLAUDE.md or a skill

Example prompts

  • “Run the sleep cycle on my recent sessions and show me what it would change.”
  • “Schedule the skillopt sleep cycle to run every night.”
  • “Adopt the staged CLAUDE.md proposal from last night's run.”

Requirements

  • Past Claude Code session history under ~/.claude
  • The skillopt_sleep engine

Workflow steps

6 steps, taken from the first numbered list in SKILL.md.

  1. Harvest — read ~/.claude/projects/*/.jsonl + ~/.claude/history.jsonl (READ-ONLY) → session digests.
  2. Mine — digests → TaskRecords (recurring intents + outcome labels + checkable refs where possible).
  3. Replay — re-run tasks through the selected backend under the current
  4. Consolidate — reflect on failures → propose bounded edits → gate on a held-out slice; with the default gate enabled, accept only if it…
  5. Stage — write the accepted proposed_CLAUDE.md and/or
  6. Adopt — explicit (or opt-in auto): copy staged files over live ones, backing up first.

What it can do on your machine

Read from SKILL.md and the folder at commit 343db22. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • python

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

SkillOpt Sleep Cycle loads about 2.3k tokens when it runs. Until then it costs about 144 tokens; SKILL.md has 938 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~144
When it runs · the whole SKILL.md, loaded when a task matches
~2.3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from microsoft/SkillOpt at commit 343db22, republished under its MIT licence (© microsoft). 938 words, ~2,250 tokens.

Download SKILL.mdSave it as .claude/skills/skillopt-sleep/SKILL.md (or your agent's skills folder).
name
skillopt-sleep
description
Use when the user wants their Claude agent to self-improve from past usage, asks about a nightly/offline 'sleep' or 'dream' cycle, memory/skill 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: harvest past sessions -> mine recurring tasks -> replay through a selected backend -> consolidate validated CLAUDE.md/SKILL.md behind a held-out gate.

SkillOpt-Sleep: usage-driven self-evolution for a local Claude agent

SkillOpt-Sleep gives the user's agent a sleep cycle. On demand or on a nightly schedule, it reviews real past Claude Code sessions, re-runs recurring tasks through the selected backend, and consolidates what it learns into memory (CLAUDE.md) and skills (SKILL.md). With the default validation gate enabled, it keeps only changes that improve a held-out score. Live files change only through explicit adoption or a user-requested --auto-adopt. It aims to improve this user's recurring work, while making each accepted proposal measurable on the run's held-out tasks, with no model-weight training. It is the deployment-time analogue of training: short-term experience → long-term competence.

It synthesizes three ideas:

  • SkillOpt — the skill/memory doc is trainable text; bounded add/delete/replace edits; accepted only through a held-out gate; rejected edits are recorded in the run report for review.
  • Claude Dreams — consolidation that reads past sessions and proposes changes inside protected learned blocks; the input is never mutated, and output is reviewed before adoption.
  • Agent sleep — periodic background replay turns episodes into durable skill.

When to use this skill

Trigger when the user wants any of:

  • "make my agent learn from how I use it" / "get better the more I use it" / "remember my preferences across sessions"
  • a nightly/scheduled or on-demand offline self-improvement / dream / sleep run
  • to review past sessions/trajectories and distill recurring tasks
  • to consolidate feedback into CLAUDE.md or a managed skill
  • to schedule the cycle (cron) or adopt a staged proposal

The cycle (six stages)

  1. Harvest — read ~/.claude/projects/*/<session>.jsonl + ~/.claude/history.jsonl (READ-ONLY) → session digests.
  2. Mine — digests → TaskRecords (recurring intents + outcome labels + checkable refs where possible).
  3. Replay — re-run tasks through the selected backend under the current skill+memory → (hard, soft) scores.
  4. Consolidate — reflect on failures → propose bounded edits → gate on a held-out slice; with the default gate enabled, accept only if it strictly improves.
  5. Stage — write the accepted proposed_CLAUDE.md and/or proposed_SKILL.md, plus report.md, report.json, manifest.json, and diagnostics.json into <project>/.skillopt-sleep/staging/<timestamp>/. Nothing live changes. A rejected run still has a report but no proposed live-file replacement.
  6. Adopt — explicit (or opt-in auto): copy staged files over live ones, backing up first.

How to drive it

Prefer the /skillopt-sleep command. Under the hood it calls the bundled runner:

bash
"${CLAUDE_PLUGIN_ROOT}/scripts/sleep.sh" status                       # what's happened
"${CLAUDE_PLUGIN_ROOT}/scripts/sleep.sh" dry-run --project "$(pwd)"    # no-staging preview
"${CLAUDE_PLUGIN_ROOT}/scripts/sleep.sh" run --project "$(pwd)"        # full cycle, stages a proposal
"${CLAUDE_PLUGIN_ROOT}/scripts/sleep.sh" adopt --project "$(pwd)"      # apply staged proposal (with backup)
  • Default backend is mock (deterministic, no API spend) — good for trying the plumbing.
  • Add --backend claude or --backend codex to spend the user's real budget for model-driven optimization. A held-out gain is run-specific evidence, not a guarantee of broader improvement; results depend on the tasks, model, and checks.
  • Scope defaults to the invoked project; --scope all harvests every Claude project into the current run's configured targets.
  • A real backend sends truncated transcript/task content to its provider. See the data-boundary rules below before using one with sensitive sessions.
Scheduling
bash
"${CLAUDE_PLUGIN_ROOT}/scripts/sleep.sh" schedule --project "$(pwd)" --hour 3 --minute 17
"${CLAUDE_PLUGIN_ROOT}/scripts/sleep.sh" unschedule --project "$(pwd)"

Installs a nightly cron entry. unschedule --all removes every managed entry.

Common CLI flags

FlagDefaultDescription
--project PATHcwdProject directory to evolve
--scope all|invokedinvokedHarvest scope
--backend mock|claude|codex|copilot|handoff|azure_openaimockBackend (mock = no provider calls)
--model NAMEbackend defaultOverride the model used for replay
--source claude|codex|autoclaudeTranscript source
--lookback-hours N72Harvest window
--max-sessions NderivedCap harvested sessions; defaults to 3 × max tasks (120 with current defaults)
--max-tasks N40Cap mined tasks
--target-skill-path PATH~/.claude/skills/skillopt-sleep-learned/SKILL.mdExplicit SKILL.md to evolve
--tasks-file PATH—Reviewed TaskRecord JSON (skip harvest)
--progressoffPrint phase progress to stderr
--auto-adoptoffAuto-adopt if gate passes
--edit-budget N4Max bounded edits per night
--preferences TEXTemptyAdd house rules to the optimizer's reflection prior
--jsonoffMachine-readable JSON output

The CLI also has source/runtime path overrides (--claude-home, --codex-home, and --codex-path) and action-specific flags. Use python -m skillopt_sleep <action> --help as the authoritative surface.

Show full SKILL.md (330 more words)Show less

Config keys (~/.skillopt-sleep/config.json)

Beyond the CLI flags, advanced behavior is controlled via config:

  • preferences — free-text house rules injected into the optimizer's reflect step (e.g. "Always use async/await", "Answers in \boxed{}").
  • gate_mode — on (default, validation-gated) or off (greedy, accept all edits).
  • gate_metric — hard, soft, or mixed (default). Controls how the held-out gate scores.
  • gate_no_regression — false by default. Set to true to reject a candidate when any validation task's configured gate score decreases.
  • dream_rollouts — >1 enables multi-rollout contrastive reflection per task.
  • recall_k — >0 recalls K similar past tasks into the dream (long-term memory).
  • evolve_memory / evolve_skill — independently toggle CLAUDE.md vs SKILL.md consolidation.

Memory consolidation

The sleep cycle can consolidate both:

  • SKILL.md — the managed skill file (bounded edits: add/delete/replace)
  • CLAUDE.md — the project memory (same bounded edits)

With the default gate enabled, both are evaluated by the same held-out score. Set evolve_memory: false to consolidate only skills, or evolve_skill: false for only memory.

Hard rules

  • Never hand-edit the user's CLAUDE.md / SKILL.md as part of this skill. Let the engine's explicit adopt or user-requested --auto-adopt path apply the staging manifest and back up existing live files first.
  • Harvest is read-only. mock replay has no side effects.
  • Real backends send truncated transcript excerpts and derived tasks to the selected provider for mining, replay, judging, and reflection. The Claude transcript path is not guaranteed to remove every secret before those calls. Review provider policy and session contents first. For sensitive data, use mock or run harvest --output <file>, inspect/redact the JSON, set "reviewed": true, and replay it with --tasks-file; real backends refuse an unreviewed task file.
  • Always show the user the held-out baseline → candidate score and the exact proposed edits before suggesting adoption. Evidence before adoption.
  • If asked to demonstrate the mechanism without provider calls, run python -m skillopt_sleep.experiments.run_experiment --persona researcher --json — a deterministic synthetic demo of held-out lift and gate rejection. It validates the mechanism, not effectiveness on the user's own tasks.

Validate / demo

bash
# deterministic synthetic demo (no API): score rises and the gate blocks a regression
python -m skillopt_sleep.experiments.run_experiment --persona researcher --assert-improves
python -m skillopt_sleep.experiments.run_experiment --persona programmer  --assert-improves

See the SkillOpt-Sleep documentation for recorded results, limitations, and the supported integration surface.

© microsoft, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in plugins/claude-code/skills/skillopt-sleep of microsoft/SkillOpt.

Open the folder on GitHubat commit 343db22

Compare with similar skills

SkillOpt Sleep Cycle next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

SkillOpt Sleep Cycle compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
SkillOpt Sleep Cycle this skillmicrosoft/SkillOpt18k—~2.3kAutomated safety check: PassMIT
Neat-Freak Knowledge CloseoutKKKKhazix/khazix-skills21k—~1.9kAutomated safety check: PassMIT
CLAUDE.md Improveranthropics/claude-plugins-official37k5 repos~1.5kAutomated safety check: PassApache-2.0
Self ImprovementCraftOS-dev/CraftBot3925 repos~4.9kAutomated safety check: PassMIT
Harness Engineering10xChengTu/harness-engineering1021 repos~1kAutomated safety check: PassNone
Codebase Analyzerseverity1/claude-code-auto-memory159—~1.5kAutomated safety check: PassMIT

Similar skills

  • Neat-Freak Knowledge Closeout

    KKKKhazix/khazix-skills

    Brings project docs, agent rule files, authorized memory and leftover workspace files back in line with what the code and runtime actually do at the end of a work session.

    21k GitHub stars~1.9k tokensUpdated 6 days ago
    Agent WorkflowsAuto-check passed
  • CLAUDE.md Improver

    anthropics/claude-plugins-official

    Official

    Finds every CLAUDE.md file in a repository, scores each against quality criteria, shows a report, then makes targeted updates after you approve.

    37k GitHub starsUsed in 5 repos~1.5k tokens
    Agent WorkflowsAuto-check passed
  • Self Improvement

    CraftOS-dev/CraftBot

    Captures learnings, errors, and corrections to enable continuous improvement.

    392 GitHub starsUsed in 5 repos~4.9k tokens
    Agent WorkflowsAuto-check passed
  • Harness Engineering

    10xChengTu/harness-engineering

    Set up and improve harness engineering (AGENTS.md, docs/, lint rules, eval systems, project-level prompt engineering) for AI-agent-friendly codebases.

    102 GitHub starsUsed in 1 repo~1k tokens
    Agent WorkflowsAuto-check passed
  • Codebase Analyzer

    severity1/claude-code-auto-memory

    This skill should be used when the user asks to "initialize auto-memory", "create CLAUDE.md", "set up project memory", or runs the /auto-memory:init command.

    159 GitHub stars~1.5k tokensUpdated 5 mo ago
    Agent WorkflowsAuto-check passed
  • Self Improving For Codex

    GODGOD126/self-improving-for-codex

    Build or maintain a Codex-native self-improving memory loop using global AGENTS.md, a persistent memories directory, and optional nightly refinement automation.

    130 GitHub stars~1.2k tokensUpdated 1 mo ago
    Agent WorkflowsAuto-check passed

More from microsoft/SkillOpt

  • Official

    Runs a nightly or on-demand sleep cycle for a local Codex agent: review past sessions, replay recurring tasks and stage validated skill and memory edits for adoption.

    18k GitHub stars~2.3k tokensUpdated today
    Auto-check passed
  • SkillOpt-Sleep for Cursor

    microsoft/SkillOpt

    Official

    Mines recurring tasks from recent local Cursor sessions, replays them to test bounded skill edits, and stages validated improvements to a project Cursor skill for review.

    18k GitHub stars~2.4k tokensUpdated today
    Auto-check passed
  • SkillOpt Sleep Cycle

    microsoft/SkillOpt

    Official

    Runs a usage-driven self-improvement cycle for the dsh agent: harvest past sessions, mine recurring tasks, replay them and stage validated skill edits.

    18k GitHub stars~1.4k tokensUpdated today
    Auto-check passed
  • Official

    Reference-only OpenClaw adaptation of SkillOpt-Sleep. Use it to study or port the contributed DeepSeek wrapper, not as a ready-to-run installation.

    18k GitHub stars~1.3k tokensUpdated today
    Auto-check passed

Categories

Questions about SkillOpt Sleep Cycle

What does SkillOpt Sleep Cycle do?

Runs an on-demand or nightly sleep cycle that reviews past Claude Code sessions and proposes validated updates to CLAUDE.md and skills. md). With the default validation gate on, it keeps only changes that improve a held-out score, and live files change only through explicit adoption or a requested --auto-adopt.

When should I use SkillOpt Sleep Cycle?

SkillOpt Sleep Cycle fits situations like: having the agent learn your preferences from past sessions; scheduling a nightly self-improvement run; reviewing and adopting a staged proposal for CLAUDE.md or a skill.

How do I install SkillOpt Sleep Cycle in Claude Code?

Run `npx skills add microsoft/SkillOpt --skill skillopt-sleep -a claude-code`. Or copy the skill folder (plugins/claude-code/skills/skillopt-sleep in microsoft/SkillOpt) into .claude/skills/skillopt-sleep in your project. Claude Code loads it when a task matches its description.

How do I install SkillOpt Sleep Cycle in Codex?

Run `npx skills add microsoft/SkillOpt --skill skillopt-sleep -a codex`. Or copy the skill folder (plugins/claude-code/skills/skillopt-sleep in microsoft/SkillOpt) into .agents/skills/skillopt-sleep in your project. Codex loads it when a task matches its description.

Can I use SkillOpt Sleep Cycle in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add microsoft/SkillOpt --skill skillopt-sleep -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/skillopt-sleep, .gemini/skills/skillopt-sleep, .github/skills/skillopt-sleep and .opencode/skills/skillopt-sleep in your project.

What does SkillOpt Sleep Cycle need to run?

Going by SKILL.md and its folder, SkillOpt Sleep Cycle needs the command-line tools its instructions call (python). Our summary lists: Past Claude Code session history under ~/.claude; The skillopt_sleep engine.

Does SkillOpt Sleep Cycle access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is SkillOpt Sleep Cycle safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does SkillOpt Sleep Cycle use?

SkillOpt Sleep Cycle is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does SkillOpt Sleep Cycle use?

About 2.3k tokens (SKILL.md is roughly 9k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to SkillOpt Sleep Cycle?

Skills that share tags, products or a category with SkillOpt Sleep Cycle: Neat-Freak Knowledge Closeout (KKKKhazix/khazix-skills, 21k stars), CLAUDE.md Improver (anthropics/claude-plugins-official, 37k stars), Self Improvement (CraftOS-dev/CraftBot, 392 stars) and Harness Engineering (10xChengTu/harness-engineering, 102 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains SkillOpt Sleep Cycle?

microsoft (a GitHub organization, an official publisher) maintains it in microsoft/SkillOpt, which has 18,087 GitHub stars. The repository holds 5 skills in this directory. The repository was last updated on October 6, 2026.

Source: microsoft/SkillOpt on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.