Local, evidence-backed self-improvement for agent skills.
self-improvement-skill installs a self-improvement skill and optional
Claude Code / Codex hooks. When a user correction follows a slash-skill call,
the hooks can record that feedback as local learning evidence instead of
turning one-off feedback into an untraceable rule change.
中文文档见 README.zh.md.
Use this project when you want agent skills to improve from real usage while keeping the improvement loop auditable:
- record user corrections, failures, workarounds, and reusable success patterns
- keep raw evidence in local
.learnings/files - distill repeated lessons into promotion candidates
- decide later whether a candidate should become a durable skill rule
This project does not directly rewrite other SKILL.md files. It records
evidence and generates candidates so humans can review changes before promoting
them.
- Node.js 18 or newer
- Claude Code and/or Codex CLI, if you want hook-based recording
- A local environment where the CLI may write to
~/.claudeand/or~/.codex
Install for both supported platforms:
npx self-improvement-skill installInstall for one platform only:
npx self-improvement-skill install --target claude
npx self-improvement-skill install --target codexCheck the installation:
npx self-improvement-skill doctorAfter installation, use Claude Code or Codex normally. When a slash skill such
as /super-get-wiki is followed by a correction like "wrong", "not that", or
"you should have...", the hook can record a learning event for the previously
used skill.
The installer copies this skill into the selected global skill directories:
~/.claude/skills/self-improvement~/.codex/skills/self-improvement
It also writes managed hook entries into the selected platform config files:
~/.claude/settings.json~/.codex/hooks.json
Those hook entries point at scripts in the installed skill directory. Existing unmanaged configuration should remain outside the installer-owned block.
The learning loop has two layers:
UserPromptSubmittracks the most recent slash skill and detects later prompts that look like reusable corrections.Stopcaptures the latest assistant output when the host runtime exposes it, so the next correction has concrete observed context.
Recorded events are then processed through this workflow:
- Raw events are appended to
.learnings/events.jsonl. - Human-readable Markdown logs are mirrored under
.learnings/. - Repeated lessons are distilled into
.learnings/patterns.json. - Promotion candidates are generated in
.learnings/promotion_candidates.md. - Humans decide whether enough evidence exists to promote a candidate.
Default promotion threshold:
evidence_count >= 3distinct_tasks >= 2- seen within the last 30 days
- expressible as a reusable instruction
This package is designed for local evidence collection. Learning files are
written under the installed self-improvement skill's .learnings/ directory.
The project does not include a cloud sync service or telemetry pipeline. Treat
learning logs as potentially sensitive because they can contain user prompts,
assistant output snippets, and corrections. Review .learnings/ before sharing
or publishing any generated files.
npx self-improvement-skill install [--target both|claude|codex]
npx self-improvement-skill doctor [--json]
npx self-improvement-skill uninstall [--target both|claude|codex] [--remove-files]
npx self-improvement-skill distill [--min-evidence 3] [--min-distinct-tasks 2]See CLI.md for command details.
Remove managed hook entries only:
npx self-improvement-skill uninstallRemove managed hook entries and installed skill files:
npx self-improvement-skill uninstall --remove-filesLimit uninstall to one platform:
npx self-improvement-skill uninstall --target claude
npx self-improvement-skill uninstall --target codexHook behavior is described in HOOKS_INSTALL.md. The minimum event context used by the recorder is:
used_skill: skill that produced the experiencesignal:correction,failure,success,workaround, orcapability_gaptask: short task summaryobserved: concrete behavior or previous assistant outputfeedback: raw user correction or acceptance signallesson: reusable lessontarget_scope: usuallyskilltarget_name: usually the used skill name
Do not record every skill call. Record only events with a plausible reusable lesson.
The CLI and hooks are the normal team path. These scripts remain available for tests, debugging, and custom runtime integration:
node scripts/log-learning.js --help
node scripts/record-from-context.js --help
node scripts/distill-patterns.js --helpUse record-from-context.js when a host runtime already knows a reusable signal
should be recorded. Use log-learning.js when all event fields are already
known.
Run the test suite:
npm testThe tests cover CLI parsing, hook behavior, installation wiring, event logging, pattern distillation, and the end-to-end local learning workflow.
self-improvement-skill/
|-- SKILL.md
|-- README.md
|-- README.zh.md
|-- CLI.md
|-- HOOKS_INSTALL.md
|-- bin/
| `-- cli.js
|-- scripts/
| |-- log-learning.js
| |-- record-from-context.js
| |-- distill-patterns.js
| |-- install-team-skill.js
| |-- uninstall-team-skill.js
| |-- install-claude-hooks.js
| |-- install-codex-hooks.js
| |-- claude-hook-user-prompt-submit.js
| |-- claude-hook-stop.js
| |-- codex-hook-user-prompt-submit.js
| `-- codex-hook-stop.js
|-- integrations/
|-- references/
| `-- event-schema.md
`-- tests/
Issues and pull requests are welcome. For code changes, run npm test before
opening a pull request and keep changes focused on one behavior or document at a
time.
Please avoid committing local .learnings/ data, generated package tarballs, or
machine-specific hook configuration.