{"slug":"skillopt-sleep-3","title":"skillopt-sleep","summary":"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-op","platform":"Claude","tags":[],"authorName":"LLM Mart","authorSlug":"llm-mart","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-09-30T16:42:59.281608Z","repo":{"url":"https://github.com/microsoft/SkillOpt","stars":17898,"forks":1683,"license":"MIT","updatedAt":"2026-09-30T11:22:44Z"},"bodyHtml":"<hr>\n<h2>name: skillopt-sleep\ndescription: \"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 -&gt; mine recurring tasks -&gt; replay through a selected backend -&gt; consolidate validated memory + skills behind a held-out gate.\"</h2>\n<h1>SkillOpt-Sleep: usage-driven self-evolution for a local Codex agent</h1>\n<p>SkillOpt-Sleep gives the user's Codex agent a sleep cycle. On demand or on a\nnightly schedule, it reviews past local sessions, re-runs recurring tasks\nthrough the selected backend, and proposes changes to a configured skill and to\nthe project's <code>CLAUDE.md</code>. With the default validation gate enabled, it keeps\nonly changes that improve a held-out score. Live files change only through\nexplicit adoption or a user-requested <code>--auto-adopt</code>. There is no model-weight\ntraining.</p>\n<p>The current shared engine does <strong>not</strong> write <code>AGENTS.md</code>. For a Codex-visible\nresult, always select a Codex skill explicitly with <code>--target-skill-path</code> (for\nexample <code>.agents/skills/&lt;name&gt;/SKILL.md</code>). If project <code>CLAUDE.md</code> is not a\ndesired secondary target, set <code>\"evolve_memory\": false</code> in\n<code>~/.skillopt-sleep/config.json</code> before running.</p>\n<h2>When to use</h2>\n<p>Trigger when the user wants any of:</p>\n<ul>\n<li>Codex to learn from past sessions or get better the more they use it;</li>\n<li>a nightly/scheduled or on-demand sleep/dream/offline self-improvement run;</li>\n<li>to review past sessions and distill recurring tasks;</li>\n<li>to consolidate feedback into memory or managed skills;</li>\n<li>to run <code>status</code>, <code>harvest</code>, <code>dry-run</code>, <code>run</code>, or <code>adopt</code> for SkillOpt-Sleep.</li>\n</ul>\n<h2>The cycle</h2>\n<ol>\n<li><strong>Harvest</strong> - read local session transcripts according to the engine\nconfiguration and normalize them into session digests.</li>\n<li><strong>Mine</strong> - turn digests into recurring <code>TaskRecord</code>s with outcomes and\ncheckable references where possible.</li>\n<li><strong>Replay</strong> - re-run mined tasks through the selected backend under the\ncurrent skill and memory.</li>\n<li><strong>Consolidate</strong> - reflect on failures and propose bounded edits.</li>\n<li><strong>Gate</strong> - with the default gate enabled, accept edits only when the held-out\nvalidation score improves.</li>\n<li><strong>Stage</strong> - write the proposal under\n<code>&lt;project&gt;/.skillopt-sleep/staging/&lt;date&gt;/</code>; nothing live changes.</li>\n<li><strong>Adopt</strong> - explicitly, or through user-requested auto-adopt, copy staged\nfiles over live files with backups for existing targets.</li>\n</ol>\n<h2>How to drive it</h2>\n<p>Invoke the bundled runner via shell (Codex <code>exec</code> has shell access). The runner\nfinds the engine and a Python &gt;= 3.10 automatically.</p>\n<pre><code># point at the repo if it isn't auto-detected from CWD:\nexport SKILLOPT_SLEEP_REPO=/path/to/SkillOpt\nTARGET_SKILL=.agents/skills/example/SKILL.md\nbash \"$SKILLOPT_SLEEP_REPO/plugins/run-sleep.sh\" status --project \"$(pwd)\"\nbash \"$SKILLOPT_SLEEP_REPO/plugins/run-sleep.sh\" harvest --project \"$(pwd)\" \\\n  --source codex --target-skill-path \"$TARGET_SKILL\"\nbash \"$SKILLOPT_SLEEP_REPO/plugins/run-sleep.sh\" dry-run --project \"$(pwd)\" \\\n  --source codex --target-skill-path \"$TARGET_SKILL\" --backend mock\nbash \"$SKILLOPT_SLEEP_REPO/plugins/run-sleep.sh\" run --project \"$(pwd)\" \\\n  --source codex --target-skill-path \"$TARGET_SKILL\" --backend codex \\\n  --max-sessions 5 --max-tasks 3 --progress\nbash \"$SKILLOPT_SLEEP_REPO/plugins/run-sleep.sh\" status --project \"$(pwd)\"\nbash \"$SKILLOPT_SLEEP_REPO/plugins/run-sleep.sh\" adopt --project \"$(pwd)\" --legacy\n</code></pre>\n<p>For a fan-out night, select reviewed proposals with repeatable\n<code>--skill NAME</code> or <code>--all-skills</code>; do not treat bare adopt as “adopt everything.”</p>\n<p>On Windows (CMD / PowerShell):</p>\n<pre><code>:: CMD\nset SKILLOPT_SLEEP_REPO=C:\\path\\to\\SkillOpt-Sleep\n\"%SKILLOPT_SLEEP_REPO%\\plugins\\run-sleep.cmd\" status --project \"%CD%\"\n</code></pre>\n<pre><code># PowerShell\n$env:SKILLOPT_SLEEP_REPO = \"C:\\path\\to\\SkillOpt-Sleep\"\npowershell -File \"$env:SKILLOPT_SLEEP_REPO\\plugins\\run-sleep.ps1\" status --project \"$(pwd)\"\n</code></pre>\n<p>Actions are <code>status</code>, <code>harvest</code>, <code>dry-run</code>, <code>run</code>, <code>adopt</code>, <code>schedule</code>, and <code>unschedule</code>.</p>\n<ul>\n<li>Default backend is <code>mock</code>, which is deterministic and spends no API budget.</li>\n<li><code>--backend codex</code> uses the user's Codex budget for model-driven optimization.\nAn accepted held-out gain is run-specific evidence, not a guarantee of\nbroader improvement; results depend on the tasks, model, and checks.</li>\n<li><code>--source codex</code> reads Codex Desktop archived sessions from <code>~/.codex/archived_sessions</code>;\nuse <code>--codex-home /path/to/.codex</code> if the archive lives elsewhere.</li>\n<li><code>--target-skill-path</code> is required for a Codex skill target. Without it, the\nshared default is a Claude-managed skill under <code>~/.claude/skills/</code>, not an\n<code>.agents</code> skill.</li>\n<li>Keep <code>dry-run --backend mock</code> as the first smoke check unless the user\nexplicitly asked for a real optimization run.</li>\n</ul>\n<h3>Scheduling</h3>\n<pre><code>bash \"$SKILLOPT_SLEEP_REPO/plugins/run-sleep.sh\" schedule --project \"$(pwd)\" \\\n  --backend codex --hour 3 --minute 17\nbash \"$SKILLOPT_SLEEP_REPO/plugins/run-sleep.sh\" unschedule --project \"$(pwd)\"\n</code></pre>\n<p>The scheduler persists the project, backend, time, and optional auto-adopt flag;\nit does not persist <code>--source</code> or <code>--target-skill-path</code> from this command. Before\nscheduling a Codex-targeted run, set <code>\"transcript_source\": \"codex\"</code> and an\nabsolute <code>\"target_skill_path\"</code> in <code>~/.skillopt-sleep/config.json</code>. On systems\nwithout <code>crontab</code>, <code>schedule</code> prints a line for manual installation.\n<code>unschedule --all</code> removes every managed entry.</p>\n<h3>All backends</h3>\n<ul>\n<li><code>--backend mock</code> — deterministic, no API spend (default)</li>\n<li><code>--backend claude</code> — uses the Claude CLI</li>\n<li><code>--backend codex</code> — uses the Codex CLI</li>\n<li><code>--backend copilot</code> — uses the GitHub Copilot CLI</li>\n<li><code>--backend handoff</code> — emits prompt/answer files for an interactive session</li>\n<li><code>--backend azure_openai</code> — uses the configured Azure OpenAI endpoint</li>\n</ul>\n<h3>Additional flags</h3>\n<table>\n<thead>\n<tr>\n<th>Flag</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>--auto-adopt</code></td>\n<td>Auto-adopt if the gate passes (default: stage only)</td>\n</tr>\n<tr>\n<td><code>--edit-budget N</code></td>\n<td>Max bounded edits per night (default: 4)</td>\n</tr>\n<tr>\n<td><code>--lookback-hours N</code></td>\n<td>Harvest window in hours (default: 72)</td>\n</tr>\n<tr>\n<td><code>--json</code></td>\n<td>Machine-readable JSON output</td>\n</tr>\n</tbody>\n</table>\n<h3>Config keys (<code>~/.skillopt-sleep/config.json</code>)</h3>\n<ul>\n<li><strong><code>preferences</code></strong> — free-text house rules for the optimizer</li>\n<li><strong><code>gate_mode</code></strong> — <code>on</code> (validation-gated, default) or <code>off</code> (greedy)</li>\n<li><strong><code>gate_metric</code></strong> — <code>hard</code> | <code>soft</code> | <code>mixed</code> (default)</li>\n<li><strong><code>gate_no_regression</code></strong> — <code>false</code> by default; set it to <code>true</code> to reject a candidate when any validation task's gate score decreases</li>\n<li><strong><code>dream_rollouts</code></strong> — &gt;1 for multi-rollout contrastive reflection</li>\n<li><strong><code>recall_k</code></strong> — &gt;0 recalls similar past tasks from the archive</li>\n</ul>\n<h3>Memory consolidation</h3>\n<p>The shared sleep cycle consolidates project <strong>memory</strong> (<code>CLAUDE.md</code>) and the\nselected <strong>skill</strong> (<code>SKILL.md</code>) by default. It does not update <code>AGENTS.md</code>.\nEach target is independently toggleable through <code>evolve_memory</code> /\n<code>evolve_skill</code>, and both are gated by the same held-out validation score.</p>\n<h2>Steps</h2>\n<ol>\n<li>Run the requested action; capture stdout.</li>\n<li>For <code>dry-run</code> and <code>run</code>, report the held-out baseline -&gt; candidate score,\ngate action, task count, session count, and exact proposed edits.</li>\n<li>If a staging directory is printed, read <code>report.md</code> before summarizing.</li>\n<li><code>run</code> stages by default; if <code>--auto-adopt</code> was explicitly supplied, report\nthe paths it updated instead of claiming nothing changed.</li>\n<li>Offer adoption only after the user has reviewed a still-staged proposal.</li>\n<li>Never hand-edit the configured <code>CLAUDE.md</code> or target skill as a substitute\nfor the engine's adopt path; adoption is the safety boundary and backs up\nexisting targets first.</li>\n</ol>\n<h2>Hard rules</h2>\n<ul>\n<li>Harvest is read-only. Do not edit archived sessions or raw transcripts.</li>\n<li>Codex transcript harvesting removes known secret-shaped strings, developer\ninstructions, and raw tool payloads, but pattern-based redaction is not a\nguarantee. A real backend still sends truncated transcript/task content to\nits provider. Review sensitive sessions and provider policy first; prefer a\nreviewed <code>--tasks-file</code> workflow when the data boundary matters.</li>\n<li>Keep raw secrets, credentials, private user data, and transcript contents out\nof messages, logs, generated artifacts, and commits.</li>\n<li>Show validation evidence before recommending adoption.</li>\n<li>Treat generated edits as proposals, not as source of truth.</li>\n<li>Do not rely on deprecated custom prompts or <code>/sleep</code> slash commands for this\nCodex integration. This skill is the entrypoint.</li>\n</ul>\n<h2>Validate</h2>\n<pre><code>python -m skillopt_sleep dry-run --project \"$(pwd)\" --source codex \\\n  --target-skill-path .agents/skills/example/SKILL.md --backend mock --json\npython -m skillopt_sleep.experiments.run_gbrain --backend codex \\\n  --seeds brief-writer --data-root /path/to/gbrain-evals/eval/data/skillopt-v1 \\\n  --nights 2 --limit-replay 3 --limit-holdout 3\n</code></pre>\n<p>In the recorded <code>brief-writer</code> gbrain run, the deliberately deficient fixture\nwent 0.00 -&gt; 1.00 on that run's held-out set. Treat this as reproducible\nbenchmark evidence for that configuration, not a guarantee for other skills,\ntasks, or models; see the\n<a href=\"https://github.com/microsoft/SkillOpt/blob/main/docs/sleep/RESULTS.md\">recorded results</a>\nfor context and limitations.</p>\n","files":[{"path":"SKILL.md","sizeBytes":9402,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"clean","suspicious":0,"notes":0,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-09-30T16:44:15.150418Z","sha256":"04D10C1240D1E8A7D2FC9583A7C90C06E532E5621A15B457B29A162270B17939","sizeBytes":3957},"review":null,"source":{"repositoryUrl":"https://github.com/microsoft/SkillOpt","path":"plugins/codex/skills/skillopt-sleep","license":"MIT","commit":"f02c6fce16e958c185b57ebb66e241a8ab2a7b76","subtreeSha":"4531968E0E6E3E1C2550635B98476899128E1BDF6A1E4BA9C6A411A0E923FCBC","lastSyncedAt":"2026-09-30T16:42:58.831078Z"},"reviewedAt":"2026-09-30T16:46:58.082434Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/microsoft/SkillOpt/tree/main/plugins/codex/skills/skillopt-sleep"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install microsoft-skillopt@llmmart"},{"target":"git","command":"git clone https://github.com/microsoft/SkillOpt.git"}]}