Official agent skill

SkillOpt-Sleep Self-Improvement Cycle

by microsoft in microsoft/SkillOpt

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.

OfficialMITAuto-check passedAgent Workflows

Install SkillOpt-Sleep Self-Improvement 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/codex/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
926 words
Files
1
Skills in repo
5
Repo updated
First seen
Licence
MIT

At a glance

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.

  • Works in 7 steps: Harvest - read local session transcripts… → Mine - turn digests into recurring… → Replay - re-run mined tasks through the… → …
  • Letting a Codex agent learn from past sessions and improve a skill
  • SKILL.md covers When to use, The cycle, How to drive it and Steps, plus 2 more sections
  • Calls bash and python

What it does

SkillOpt-Sleep gives a local Codex agent a sleep cycle: on demand or on a nightly schedule it reviews past local sessions, replays recurring tasks through a chosen backend and proposes changes to a configured skill and to the project's `CLAUDE.md`. With the default validation gate on, only edits that raise a held-out score are kept. Nothing live changes until you adopt a proposal (or ask for `--auto-adopt`), and no model weights are trained.

The cycle has seven stages: harvest session transcripts into digests, mine recurring tasks, replay them under the current skill and memory, consolidate failures into bounded edits, gate them on the validation score, stage the proposal under `.skillopt-sleep/staging/` and adopt it with backups. The agent drives a bundled runner through the shell for `status`, `harvest`, `dry-run`, `run` and `adopt`. The engine does not write `AGENTS.md`, so a Codex skill must be named with `--target-skill-path`, and `evolve_memory` can be turned off in the config to leave `CLAUDE.md` alone.

When your agent uses it

  • Letting a Codex agent learn from past sessions and improve a skill
  • Running a dry run before adopting proposed skill edits
  • Scheduling a nightly self-optimization run
  • Checking the status of a SkillOpt-Sleep run

Example prompts

  • “Run a SkillOpt-Sleep dry run against .agents/skills/example/SKILL.md and show me what it would change.”
  • “Review my past sessions and propose improvements to my deploy skill, but don't adopt anything.”
  • “Set up a nightly sleep run for this project.”
  • “Adopt the staged proposal from last night.”

Requirements

  • Python 3.10 or later
  • A SkillOpt checkout providing the sleep engine (set SKILLOPT_SLEEP_REPO if it is not auto-detected)

Workflow steps

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

  1. Harvest - read local session transcripts according to the engine
  2. Mine - turn digests into recurring TaskRecords with outcomes and
  3. Replay - re-run mined tasks through the selected backend under the
  4. Consolidate - reflect on failures and propose bounded edits.
  5. Gate - with the default gate enabled, accept edits only when the held-out
  6. Stage - write the proposal under
  7. Adopt - explicitly, or through user-requested auto-adopt, copy staged

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:

    • bash
    • 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 Self-Improvement Cycle loads about 2.3k tokens when it runs. Until then it costs about 122 tokens; SKILL.md has 926 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~122
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). 926 words, ~2,344 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 Codex to self-improve from past usage, asks about a nightly/offline 'sleep' or 'dream' cycle, wants Codex to review past sessions, learn preferences, consolidate memory/skills, run dry-run/run/adopt/status for SkillOpt-Sleep, or schedule background self-optimization. Drives the skillopt_sleep engine: harvest past sessions -> mine recurring tasks -> replay through a selected backend -> consolidate validated memory + skills behind a held-out gate.

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

SkillOpt-Sleep gives the user's Codex agent a sleep cycle. On demand or on a nightly schedule, it reviews past local sessions, re-runs recurring tasks through the selected backend, and proposes changes to a configured skill and to the project's CLAUDE.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. There is no model-weight training.

The current shared engine does not write AGENTS.md. For a Codex-visible result, always select a Codex skill explicitly with --target-skill-path (for example .agents/skills/<name>/SKILL.md). If project CLAUDE.md is not a desired secondary target, set "evolve_memory": false in ~/.skillopt-sleep/config.json before running.

When to use

Trigger when the user wants any of:

  • Codex to learn from past sessions or get better the more they use it;
  • a nightly/scheduled or on-demand sleep/dream/offline self-improvement run;
  • to review past sessions and distill recurring tasks;
  • to consolidate feedback into memory or managed skills;
  • to run status, harvest, dry-run, run, or adopt for SkillOpt-Sleep.

The cycle

  1. Harvest - read local session transcripts according to the engine configuration and normalize them into session digests.
  2. Mine - turn digests into recurring TaskRecords with outcomes and checkable references where possible.
  3. Replay - re-run mined tasks through the selected backend under the current skill and memory.
  4. Consolidate - reflect on failures and propose bounded edits.
  5. Gate - with the default gate enabled, accept edits only when the held-out validation score improves.
  6. Stage - write the proposal under <project>/.skillopt-sleep/staging/<date>/; nothing live changes.
  7. Adopt - explicitly, or through user-requested auto-adopt, copy staged files over live files with backups for existing targets.

How to drive it

Invoke the bundled runner via shell (Codex exec has shell access). The runner finds the engine and a Python >= 3.10 automatically.

bash
# point at the repo if it isn't auto-detected from CWD:
export SKILLOPT_SLEEP_REPO=/path/to/SkillOpt
TARGET_SKILL=.agents/skills/example/SKILL.md
bash "$SKILLOPT_SLEEP_REPO/plugins/run-sleep.sh" status --project "$(pwd)"
bash "$SKILLOPT_SLEEP_REPO/plugins/run-sleep.sh" harvest --project "$(pwd)" \
  --source codex --target-skill-path "$TARGET_SKILL"
bash "$SKILLOPT_SLEEP_REPO/plugins/run-sleep.sh" dry-run --project "$(pwd)" \
  --source codex --target-skill-path "$TARGET_SKILL" --backend mock
bash "$SKILLOPT_SLEEP_REPO/plugins/run-sleep.sh" run --project "$(pwd)" \
  --source codex --target-skill-path "$TARGET_SKILL" --backend codex \
  --max-sessions 5 --max-tasks 3 --progress
bash "$SKILLOPT_SLEEP_REPO/plugins/run-sleep.sh" status --project "$(pwd)"
bash "$SKILLOPT_SLEEP_REPO/plugins/run-sleep.sh" adopt --project "$(pwd)" --legacy

For a fan-out night, select reviewed proposals with repeatable --skill NAME or --all-skills; do not treat bare adopt as “adopt everything.”

On Windows (CMD / PowerShell):

cmd
:: CMD
set SKILLOPT_SLEEP_REPO=C:\path\to\SkillOpt-Sleep
"%SKILLOPT_SLEEP_REPO%\plugins\run-sleep.cmd" status --project "%CD%"
powershell
# PowerShell
$env:SKILLOPT_SLEEP_REPO = "C:\path\to\SkillOpt-Sleep"
powershell -File "$env:SKILLOPT_SLEEP_REPO\plugins\run-sleep.ps1" status --project "$(pwd)"

Actions are status, harvest, dry-run, run, adopt, schedule, and unschedule.

  • Default backend is mock, which is deterministic and spends no API budget.
  • --backend codex uses the user's Codex budget for model-driven optimization. An accepted held-out gain is run-specific evidence, not a guarantee of broader improvement; results depend on the tasks, model, and checks.
  • --source codex reads Codex Desktop archived sessions from ~/.codex/archived_sessions; use --codex-home /path/to/.codex if the archive lives elsewhere.
  • --target-skill-path is required for a Codex skill target. Without it, the shared default is a Claude-managed skill under ~/.claude/skills/, not an .agents skill.
  • Keep dry-run --backend mock as the first smoke check unless the user explicitly asked for a real optimization run.
Scheduling
bash
bash "$SKILLOPT_SLEEP_REPO/plugins/run-sleep.sh" schedule --project "$(pwd)" \
  --backend codex --hour 3 --minute 17
bash "$SKILLOPT_SLEEP_REPO/plugins/run-sleep.sh" unschedule --project "$(pwd)"

The scheduler persists the project, backend, time, and optional auto-adopt flag; it does not persist --source or --target-skill-path from this command. Before scheduling a Codex-targeted run, set "transcript_source": "codex" and an absolute "target_skill_path" in ~/.skillopt-sleep/config.json. On systems without crontab, schedule prints a line for manual installation. unschedule --all removes every managed entry.

All backends
  • --backend mock — deterministic, no API spend (default)
  • --backend claude — uses the Claude CLI
  • --backend codex — uses the Codex CLI
  • --backend copilot — uses the GitHub Copilot CLI
  • --backend handoff — emits prompt/answer files for an interactive session
  • --backend azure_openai — uses the configured Azure OpenAI endpoint
Additional flags
FlagDescription
--auto-adoptAuto-adopt if the gate passes (default: stage only)
--edit-budget NMax bounded edits per night (default: 4)
--lookback-hours NHarvest window in hours (default: 72)
--jsonMachine-readable JSON output
Show full SKILL.md (356 more words)Show less
Config keys (~/.skillopt-sleep/config.json)
  • preferences — free-text house rules for the optimizer
  • gate_mode — on (validation-gated, default) or off (greedy)
  • gate_metric — hard | soft | mixed (default)
  • gate_no_regression — false by default; set it to true to reject a candidate when any validation task's gate score decreases
  • dream_rollouts — >1 for multi-rollout contrastive reflection
  • recall_k — >0 recalls similar past tasks from the archive
Memory consolidation

The shared sleep cycle consolidates project memory (CLAUDE.md) and the selected skill (SKILL.md) by default. It does not update AGENTS.md. Each target is independently toggleable through evolve_memory / evolve_skill, and both are gated by the same held-out validation score.

Steps

  1. Run the requested action; capture stdout.
  2. For dry-run and run, report the held-out baseline -> candidate score, gate action, task count, session count, and exact proposed edits.
  3. If a staging directory is printed, read report.md before summarizing.
  4. run stages by default; if --auto-adopt was explicitly supplied, report the paths it updated instead of claiming nothing changed.
  5. Offer adoption only after the user has reviewed a still-staged proposal.
  6. Never hand-edit the configured CLAUDE.md or target skill as a substitute for the engine's adopt path; adoption is the safety boundary and backs up existing targets first.

Hard rules

  • Harvest is read-only. Do not edit archived sessions or raw transcripts.
  • Codex transcript harvesting removes known secret-shaped strings, developer instructions, and raw tool payloads, but pattern-based redaction is not a guarantee. A real backend still sends truncated transcript/task content to its provider. Review sensitive sessions and provider policy first; prefer a reviewed --tasks-file workflow when the data boundary matters.
  • Keep raw secrets, credentials, private user data, and transcript contents out of messages, logs, generated artifacts, and commits.
  • Show validation evidence before recommending adoption.
  • Treat generated edits as proposals, not as source of truth.
  • Do not rely on deprecated custom prompts or /sleep slash commands for this Codex integration. This skill is the entrypoint.

Validate

bash
python -m skillopt_sleep dry-run --project "$(pwd)" --source codex \
  --target-skill-path .agents/skills/example/SKILL.md --backend mock --json
python -m skillopt_sleep.experiments.run_gbrain --backend codex \
  --seeds brief-writer --data-root /path/to/gbrain-evals/eval/data/skillopt-v1 \
  --nights 2 --limit-replay 3 --limit-holdout 3

In the recorded brief-writer gbrain run, the deliberately deficient fixture went 0.00 -> 1.00 on that run's held-out set. Treat this as reproducible benchmark evidence for that configuration, not a guarantee for other skills, tasks, or models; see the recorded results for context and limitations.

© 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/codex/skills/skillopt-sleep of microsoft/SkillOpt.

Open the folder on GitHubat commit 343db22

Compare with similar skills

SkillOpt-Sleep Self-Improvement 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 Self-Improvement Cycle compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
SkillOpt-Sleep Self-Improvement Cycle this skillmicrosoft/SkillOpt18k—~2.3kAutomated safety check: PassMIT
Cherry Studio Tool GuideCherryHQ/cherry-studio52k—~1.9kAutomated safety check: PassAGPL-3.0
Mem0 CLI Memory Commandsmem0ai/mem067k—~1.4kAutomated safety check: NotesApache-2.0
MemPalace Setup and OperationMemPalace/mempalace59k—~2.2kAutomated safety check: PassMIT
PicoClaw Agentsipeed/picoclaw30k—~7.2kAutomated safety check: NotesMIT
Agent Memorytigerless-labs/agent-memory2.4k—~1.2kAutomated safety check: PassMIT

Similar skills

  • Cherry Studio Tool Guide

    CherryHQ/cherry-studio

    Routes an agent inside Cherry Studio to the right first-party tool or bundled runtime for local scripts, documents, memory, schedules, knowledge bases, MCP servers and more.

    52k GitHub stars~1.9k tokensUpdated today
    Agent WorkflowsAuto-check passed
  • Adds, searches, lists, updates and deletes memories on the Mem0 platform from the terminal with the mem0 command, including a JSON mode built for agents.

    67k GitHub stars~1.4k tokensUpdated yesterday
    Agent WorkflowsAuto-check: notes
  • Installs and configures MemPalace as a private local palace, a shared-brain hub or a client of an existing hub, including MCP registration and version-correct initialization.

    59k GitHub stars~2.2k tokensUpdated today
    Agent WorkflowsAuto-check passed
  • PicoClaw Agent

    sipeed/picoclaw

    Answers questions about running and changing PicoClaw, from onboarding and model selection to MCP server setup, skill loading and scheduled jobs.

    30k GitHub stars~7.2k tokensUpdated 12 days ago
    Agent WorkflowsAuto-check: notes
  • Agent Memory

    tigerless-labs/agent-memory

    Read and write the shared long-term memory store. An agent skill from tigerless-labs/agent-memory.

    2.4k GitHub stars~1.2k tokensUpdated today
    Agent WorkflowsAuto-check passed
  • Mindmemos CLI

    mindscale-noah/MindMemOS

    Give an AI agent persistent, cross-session long-term memory through MindMemOS.

    1k GitHub stars~3.4k tokensUpdated 8 days ago
    Agent WorkflowsAuto-check passed

More from microsoft/SkillOpt

  • SkillOpt Sleep Cycle

    microsoft/SkillOpt

    Official

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

    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

Works with

Categories

Questions about SkillOpt-Sleep Self-Improvement Cycle

What does SkillOpt-Sleep Self-Improvement Cycle do?

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. md`. With the default validation gate on, only edits that raise a held-out score are kept.

When should I use SkillOpt-Sleep Self-Improvement Cycle?

SkillOpt-Sleep Self-Improvement Cycle fits situations like: letting a Codex agent learn from past sessions and improve a skill; running a dry run before adopting proposed skill edits; scheduling a nightly self-optimization run; checking the status of a SkillOpt-Sleep run.

How do I install SkillOpt-Sleep Self-Improvement Cycle in Claude Code?

Run `npx skills add microsoft/SkillOpt --skill skillopt-sleep -a claude-code`. Or copy the skill folder (plugins/codex/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 Self-Improvement Cycle in Codex?

Run `npx skills add microsoft/SkillOpt --skill skillopt-sleep -a codex`. Or copy the skill folder (plugins/codex/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 Self-Improvement 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 Self-Improvement Cycle need to run?

Going by SKILL.md and its folder, SkillOpt-Sleep Self-Improvement Cycle needs the command-line tools its instructions call (bash and python). Our summary lists: Python 3.10 or later; A SkillOpt checkout providing the sleep engine (set SKILLOPT_SLEEP_REPO if it is not auto-detected).

Does SkillOpt-Sleep Self-Improvement 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 Self-Improvement 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 Self-Improvement Cycle use?

SkillOpt-Sleep Self-Improvement 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 Self-Improvement Cycle use?

About 2.3k tokens (SKILL.md is roughly 9.4k 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 Self-Improvement Cycle?

Skills that share tags, products or a category with SkillOpt-Sleep Self-Improvement Cycle: Cherry Studio Tool Guide (CherryHQ/cherry-studio, 52k stars), Mem0 CLI Memory Commands (mem0ai/mem0, 67k stars), MemPalace Setup and Operation (MemPalace/mempalace, 59k stars) and PicoClaw Agent (sipeed/picoclaw, 30k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains SkillOpt-Sleep Self-Improvement 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.