Community写作与编辑github.com

newdee/lamarck-skill

生产环境的 skill 自进化系统 | A production self-evolving system for Claude Code: every installed skill keeps accumulating evidence from real usage and evolves when the gate opens - governed, user-authorized, reversible.

lamarck-skill 是什么?

lamarck-skill is a Claude Code agent skill that 生产环境的 skill 自进化系统 | A production self-evolving system for Claude Code: every installed skill keeps accumulating evidence from real usage and evolves when the gate opens - governed, user-authorized, reversible.

兼容平台✓Claude Code~Codex CLI~Cursor
npx skills add newdee/lamarck-skill

Installed? Explore more 写作与编辑 skills: steipete/notion, langchain-ai/langchain, bytedance/podcast-generation · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

lamarck: Skill Evolution Through Use and Disuse

Lamarckian evolution: the experience a skill gains through real usage is written back into its "genes" (SKILL.md); the rubric that measures it evolves as well; parts that are chronically unused atrophy (are pruned). Arena: SkillOpt is the training ground (benchmark-score-driven), darwin-skill is the exam hall (synthetic tests + judge), lamarck is life—production telemetry-driven, both use and disuse. A three-tier mechanism, triggered by load level:

  • Bookkeeping (automatic, on every Skill call, in all modes): PostToolUse hook writes to data/pending.jsonl.
  • Light loop (end of turn, does not load this file): protocol text originates solely from protocol/light-loop.md (harness-agnostic, verbatim injected by any adapter, see protocol/adapter-contract.md), Claude Code adapter is read in at runtime by the Stop hook and spliced into the reasoning— matches scenario-tagged rubric entries against this skill's rubric, performs a four-dimensional assessment, writes to data/ledger.jsonl, crystallizes user corrections (n=1) into data/rubrics/<skill>.md, sinks experience into data/learnings/<skill>.md, distills regression test cases into data/replays/<skill>.jsonl, and clears pending entries for this session; when backlog in other sessions reaches a threshold, prompts the user to manually clear it (pointers decay, silent backlog = lost evidence). Trigger timing determined by config.json: {"mode":"every|manual|threshold","threshold":N}— every triggers at the end of every turn where a skill was used; manual never triggers automatically; threshold (default, N=5) triggers a batch evaluation only after N entries have accumulated.
  • Upgrade (conditionally triggered, this file is loaded): a skill has ≥2 independent calls, with a similar gap → go through the optimization gate; or manually via /lamarck.

Rubric: Per-Skill Dynamic Rubric

data/rubrics/<skill>.md, format and rules in data/rubrics/README.md. Key points:

  • Behavioral Standards Crystallize from Evidence: a single user correction can be recorded (n=1; the rubric is only an evaluation perspective); each entry must carry a ledger source and scenario tag—no source, no write. Deletions go into the attic, not removed.
  • Three Uses: ① When performing a four-dimensional evaluation, check gaps against this skill's rubric; ② comparison standard for pairwise blind evaluation; ③ criterion for "did it get worse" in rollout validation. During evaluation, only scenario-matching entries are enabled.
  • Git versioned: this directory is a git repository, rubric and skill protocol are committed together, diffable and revertable; telemetry (pending/ledger/learnings) is .gitignore'd, local only.

Evolution Tiers (Whitelist) and Anti-Negative Optimization

config.json (local file, not checked in; copy from config.example.json on first use) has an evolution block that determines each skill's evolution level (explicit list > default; newly installed skills automatically fall into default, which is observe). If config.json is missing: all skills are observe, user is prompted to create one:

  • auto (autonomous level, only effective if explicitly listed in evolution.auto): proposals go through the gate, skip the user's three-choice pre-approval and go straight to implementation, but replay verification is elevated from post-hoc validation to a release condition—if it fails immediately, automatic rollback and rejection are performed; each edit is explicitly reported in the next output, and is still recorded in CHANGELOG, ledger, and git, with a one-step git revert for undoing. Forbidden zones: lamarck itself, Iron Rules, and plugin files are never subject to auto—user approval is always required. Autonomy is earned: it is recommended to only promote skills that have undergone multiple successful evolve-level edits to this tier.
  • evolve (whitelist, currently: seo-cron-ops, lamarck): when a proposal passes the gate, the user can choose from three options to directly implement.
  • suggest: proposals only write to suggestions/<skill>.md, never directly edit.
  • observe (default): only bookkeeping, sink learnings, grow rubrics, no proposals generated; evidence still accumulates; when upgraded to evolve, historical evidence becomes immediately available.
  • Plugin / marketplace / synced skill: regardless of configuration, never directly edited (maximum: suggest).

Dynamic scoring anti-negative optimization: each ledger entry carries a ver (8-character content hash of the target SKILL.md at the time of the call). During upgrades or audit, the skill's health is computed per ver window (proportion of corrected+failed calls, gap frequency): if the post-edit window (sample ≥3) is worse than the pre-edit window → negative optimization is declared, and a rollback proposal is automatically generated (still going through the user's three-choice). This is a second statistical defense (multiple-times, delayed) beyond the pairwise blind evaluation (single-instance, immediate).

Maturity: Converging Skills Downgraded to Spot-Check

Not every evaluation is valuable—skills converge when scenarios stay the same. Each skill has two states, stored in data/maturity.json ({"<skill>":{"state":"active|stable","clean_streak":N,"ver":"..."}}, maintained during evaluation):

  • active (default): each pending entry gets a full four-dimensional evaluation.
  • stable (entry condition: stability.streak consecutive clean evaluations—no gaps, no corrected/failed, no rubric additions; default 10): each entry gets only a quick scan (any user corrections or anomalies this turn), if none, log one line {"outcome":"stable-skip","ver":"..."} (with ver, version-window statistics are not starved) and streak++; every stability.sample-th entry still gets a full evaluation (default 5, sampling prevents drift); rubric is frozen, no new entries.
  • Awakened back to active (any trigger, immediate): user correction or failed; full evaluation finds a gap; ver changes (edited or externally changed—the post-edit verification period must be full); args present a new scenario not covered by rubric scenario tags (the scenario has changed, the convergence precondition is invalid).
  • Convergence is a certificate: report presents the stable state and clean streak count as Tier 2 evidence ("this skill has had zero corrections in its last N real calls"). stable + long-zero-referenced entries = natural candidates for atrophy pruning.

stability configuration is in config.json (defaults if missing: streak=10, sample=5).

After Upgrade: Optimization Gate (Textual Version of SkillOpt Validation Gate)

To propose an edit to a skill, all of the following must be satisfied (and the skill's evolution level must be evolve or suggest):

  • Evidence ≥2: the ledger/learnings for this skill have ≥2 independent calls with a similar gap (a single observation never triggers an edit, n=1 is noise).
  • Full Evidence Synthesis: the proposal must synthesize all on-file evidence for this skill (ledger, learnings, rubric), not just the two that triggered the threshold (the SkillOpt mini-batch approach).
  • Proposal Specific: must be a point operation written as add / delete / replace, with expected improvement and verification method stated.
  • Net Growth Budget (Atrophy): the proposal gives the net line count change; if it would make SKILL.md exceed 500 lines, or if the last two proposals had a net increase >10%, a deletion proposal must be included. Deletion proposals are first-class citizens: rubric entries with zero references for ≥90 days, paragraphs marked as "misleading/never used" by gap evidence, actively produce pruning proposals (also through the user's three-choice; pruned content goes into attic/git history, not physically deleted).
  • Scenario Fence (Anti-Oscillation): proposals where all evidence comes from a single scenario tag can only do scenario-branch incremental—add a conditional section "When ...", must not rewrite shared core; rewriting shared core requires ≥2 different scenarios of evidence. Optimization for scenario B can therefore never harm parts that scenario A depends on; switching back will not degrade.
  • Full-Scenario Replay: Any edit's replay verification must include existing test cases from other scenarios, not just the triggering scenario—the replay corpus is the memory of all historical scenarios; "switching back to old scenario" is rehearsed before implementation.
  • Anti-Oscillation Detection: If a proposal substantively overthrows edits in CHANGELOG/git that were accepted within the last 10 commits, it is considered an oscillation: direct overwriting is prohibited and it is forced into a scenario-branch proposal, with evidence from both scenarios presented side-by-side for user decision.
  • Not in Rejection Buffer: Proposals similar to those already rejected in data/rejected.md cannot be re-proposed unless new types of evidence exist.
  • Not Frozen: No new proposal is allowed while the last edit's verification rollout for this skill is still in progress.

Gate passed → first check the level: auto-level skills skip the three-choice and go straight to implementation, but must pass a full-scenario replay immediately to be considered landed (if it fails, automatic rollback, proposal goes to rejected); implementation and verification results are explicitly reported in the next output. If the replay corpus for this skill is empty, auto degrades to three-choice—no release condition means no release, zero-validation landing is forbidden. All other levels → user in the loop: Use AskUserQuestion to present the user with choices (include evidence summary and diff highlights):

  1. Edit now (explain the rationale when recommending)
  2. Keep as suggestion only → write to suggestions/<skill>.md, do not change files
  3. Reject → write the reason to data/rejected.md

Non-interactive sessions (user not present) always choose 2, and hint in the final output that there are pending proposals.

After the user chooses 1, implement according to ownership:

  • User-owned skill (~/.claude/skills/<name>/, not synced/): target directory is inside a git repository → commit before and after the edit (lamarck: optimize <skill>: <summary>); otherwise copy SKILL.md to SKILL.md.bak first. Bounded edit (≤3 changes at once, each ≤10 lines, no full file rewrite); CHANGELOG.md records one line: date, target, change, evidence source.
  • Plugin / marketplace / synced skill: never modify the original file, only go with option 2.

Post-edit immediate replay verification (before natural verification): from data/replays/<skill>.jsonl take the regression test cases for this skill (see below), dispatch new subagents to execute with the old and new versions respectively, compare pairwise according to the rubric. Newer version worse → immediate rollback, no need to wait for the next real call. The source of replay test cases is traces of real calls: during light loop evaluation, calls that were corrected/failed, and clean calls whose scenario is not yet covered by the corpus (one representative per scenario), are distilled into test cases: {"essence":"task summary","expect":"passing criteria according to rubric","src":"ledger ts"}. Skills that never break also need a corpus: the "full-scenario replay" requirement above means the edit's verification must cover other scenarios; auto's release condition also assumes the corpus is non-empty—only harvesting failures would cause the healthiest skills to have zero corpus forever. Real distribution, zero manual authoring (darwin's test prompts are hand-crafted; this is strictly superior).

Verification Rollout (Pairwise Blind Evaluation): The next evaluated call of the edited skill is the natural verification. Dispatch a new independent subagent, providing it with: the full old version (previous git commit or .bak), the full new version, the real execution trace of that call, and the skill's rubric—within the same context, produce a pairwise comparison: better / worse / tie (absolute scoring has calibration noise across sessions, pairwise comparison cancels it out). Tie or disagreement with the replay conclusion → dispatch 2 additional independent judges for a majority vote (N=3; normally one judge to save costs, escalate only when the decision is difficult). Worse → rollback (git revert or restore .bak), write the proposal and failure reason to data/rejected.md; better / tie → keep, unfreeze.

Rollback semantics (graded by evidence strength): rollback = restore the last user-approved baseline, not a new edit, not subject to the "three-choice" or bounded-edit constraint (Iron Rule 2/6 exemption)—but must be recorded in the ledger and explicitly reported to the user in the next output. Grading: replay / blind evaluation are direct comparisons with the same input (strong evidence) → automatic rollback; version window is observational statistics (weak evidence, may be confounded by task drift) → only a rollback proposal, going through the three-choice.

Conclusions Must Be Recorded (Provability): each of the three verification methods—replay, blind evaluation, version window—records one verify line in the ledger: {"ts","skill","type":"verify","stage":"replay|judge|window","old_ver","new_ver","result":"better|worse|tie","decision":"keep|revert","judges":N,"detail":""}. judges records the number of judge agents used this time (cost tracking: report can compute "judge calls per valid edit", compared to darwin's fixed 3 judges × 3 rounds). report's evolution track record is entirely aggregated from these records—no recorded effect = no effect.

Self-Optimization (Only During Upgrade or Manual Run)

Evaluate this protocol itself using the same rules (false positive proposals? Gate too tight/loose? Light loop smooth?), meta observations are recorded in the ledger with "skill":"lamarck". Any edits to this SKILL.md or the hook scripts, besides going through the optimization gate, must be explicitly approved by the user; protocol and script changes must be committed to this repository.

Iron Rules (Modifications to This Section Require Explicit User Approval)

  1. A single observation never triggers an edit, only bookkeeping and sinking (rubric enrollment excepted, n=1 allowed).
  2. Before any skill edit is implemented, the user must be given a choice (AskUserQuestion); non-interactive sessions only drop suggestions. Exception 1: automatic rollback restoring a user-approved baseline (triggered by strong evidence), must be recorded in the ledger and reported. Exception 2 (2026-08-29 user approved): skills explicitly listed in evolution.auto skip the pre-approval three-choice, but the replay release condition and post-hoc explicit reporting are not exempt; when the replay corpus is empty, Exception 2 does not apply (falls back to three-choice); lamarck itself, Iron Rules, and plugins never qualify for auto.
  3. Every edit must be revertible (git commit or .bak) and recorded in CHANGELOG. Rollbacks themselves are also recorded in CHANGELOG.
  4. Never edit files of plugins / marketplace / synced skills.
  5. Never delete ledger history, learnings existing observations, or rubric attic.
  6. Each edit ≤3 changes at once, each change ≤10 lines, no full file rewrite.
  7. Proposals in rejected.md cannot be re-proposed unless new types of evidence appear.
  8. Evaluations only cite real observed execution traces; if unavailable, archive (outcome=archived), do not fabricate.
  9. Rubric entries must carry a ledger source; until the verification rollout for a skill is complete, that skill is frozen from new proposals.
  10. Single-scenario evidence cannot rewrite shared core (only scenario-branch incremental); proposals that overthrow recently accepted edits must be converted to scenario branches and go through user decision; direct overwriting oscillation is forbidden.

Manual /lamarck

  • No arguments: process all pending + sink learnings/rubric + go through optimization gate. Entries in the current session get a full four-dimensional evaluation; for entries from historical sessions, first try the transcript pointer: if the recorded transcript path still exists (within the 30-day cleanup period), Read the relevant segment of that call from it (locate by ts and skill name, only read the needed slice, not the whole file), perform a four-dimensional evaluation based on the real execution trace, and extract objective friction (number of tool calls, errors/retries, elapsed time); if the pointer is invalid or the segment cannot be located, fall back to aggregating by skill and archiving: {"outcome":"archived","note":"N calls, args sample"}.
  • audit <skill> — summarize all evidence for this skill, produce an edit proposal (still through optimization gate + user in the loop).
  • stats — report only: per-skill call frequency, corrected rate, gap ranking.
  • mode <every|manual|threshold> [N] — modify config.json to switch trigger mode; threshold can include a threshold N (default 5). After modification, restate the current configuration. If config.json is missing or corrupted, the script falls back to threshold/5.
  • evolve list — list all skills with their evolution level and ledger health; evolve add <skill> [evolve|suggest|auto] / evolve remove <skill> — modify the evolution block in config.json, then restate (auto forbidden zones: lamarck itself and plugins will not be effective even if written).
  • report [skill] — evolution narrative card: health trend per version (ver), retained/rolled-back edits, rubric additions/deletions, replay pass rate; without argument, output a global summary.

Data Files

data/pending.jsonl (pending, includes ver gene version stamp and transcript execution log pointer— execution log is not self-constructed, points to Claude Code's own session transcript, read by slice on demand)· data/ledger.jsonl (ledger, format {"ts","session","skill","ver","trigger_fit","gaps","outcome","friction","note"}, during evaluation, the ver from the pending entry is carried over as-is)· data/learnings/<skill>.md (per-skill experience)· data/rubrics/<skill>.md (per-skill rubric, git versioned)· data/replays/<skill>.jsonl (regression test cases distilled from real calls, local only)· data/maturity.json (per-skill maturity state, maintained during evaluation)· data/rejected.md (rejection buffer)· suggestions/<skill>.md (pending proposals)· data/hook-errors.log (hook error diagnostics, one line per error; silence = health)· CHANGELOG.md (edit trail). off file: disable automatic hooks (manual calls unaffected).

File naming rule: for per-skill paths above, <skill> replaces : with __ (caveman:caveman-help → caveman__caveman-help)—colons are reserved characters on Windows (NTFS treats them as alternate data streams), using the plugin name directly will silently corrupt files. The skill key in JSON and keys in maturity.json retain the colon-separated real name; only file names undergo this mapping.

Storage design decision: ledger uses append-only JSONL instead of sqlite—at the current scale (tens of entries per day), the model reads directly with zero dependencies; if it ever reaches tens of thousands of lines or requires complex joins, data/*.jsonl can be imported into sqlite in one step (sqlite3 is already available on the system), no need to prebuild now.

相关技能