# Nightly Skill Optimizer

Runs an offline cycle that consolidates past sessions into better agent memory and skills.

- 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 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.

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

# 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)

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