SKILL.md loads into context on every /reflect turn. The per-type apply steps, the A/B tracking append and the Karpathy constraints are needed only when a proposal is applied. Move them to apply-by-type.md and read that file before any apply in 3a or 4. The move keeps the July changes: the nudge helper, the reinforcement A/B skip and the metadata memory schema. Tighten the adam agent routing description. Claude-Session: https://claude.ai/code/session_014prTNuJnKuwcAd28vUZAnN
11 KiB
Apply procedures by proposal type
Read this file before any apply in SKILL.md §3a (auto-apply) or §4 (walk the queue). Every check here is mandatory. Section numbers (§N) refer to SKILL.md.
Contents
- Karpathy constraints (every apply)
- §3a auto-apply, per type
- §3a after each auto-apply: move, A/B tracking, archive
- §4 approve, per type
- §4 reject and edit
Karpathy constraints (you must enforce on each apply)
Before writing any proposal:
- Confirm
# Assumptionssection is non-empty. - Confirm
# Diagnosissection exists and contains all four labelled lines (Trigger:,Action:,Mismatch:,Outcome:) AND at least one backtick-wrapped quote ≤80 chars in the Outcome line. Refuse if missing or malformed — agent must redraft per the "Diagnosis drafting protocol" inagents/adam.md. - Confirm
# Success criterionsection is non-empty and runnable. - Confirm change is ≤50 LOC for non-
skill_new, or ≤80 LOC forskill_newbody. If larger, ask the user once: "this proposal is N LOC — proceed?" - For
claude_md_edit: confirm 3+ distinct cwds in the# Whysection. - For
deletion: confirm both criteria (a) and (b) from the agent's special handling are documented in the proposal. - For
skill_new: confirm the slug doesn't collide with any existing skill in~/.claude/skills/. If it does, refuse and ask user to rename. - For
skill_edit: confirm the diff is append-only (no-lines that remove existing content) and that target SKILL.md exists. When auto-applying, ALSO re-verify the eligibility gate steps in §3 (cooldown, blacklist, byte cap) before anyEditcall — never trust frontmatter alone. - For
skill_editwithauto_apply_eligible: true: confirmcontradiction_flagis absent or null in frontmatter. Refuse auto-apply ifcontradiction_flagis set with any non-empty value (treat the agent's flag as a hard veto on auto-apply; user can still manually approve in walk-the-queue if they disagree with the heuristic). - For
memory: confirm# Proposed changebody starts with---frontmatter matching the live auto-memory schema — top-levelname(the slug) +description, plus ametadata:block withnode_type: memory,type, andoriginSessionId. Cross-check the shape against an existing file in the target memory dir. Refuse if frontmatter is flat (type:/originSessionId:at top level) or missing themetadata:block — agent must redraft per the Memory drafting protocol. - For
harness_edit: confirmauto_apply_eligible: false(never auto-apply). Confirmconfidence ≥ 5. Confirm# Test verificationsection names the test command. Confirm diff is ≤30 LOC and targets a single allowed harness file (seeagents/adam.md§"Harness self-modification"). Run test suite before AND after applying — revert on any regression. - Confirm
source_entriesis present in proposal frontmatter as a non-empty list (used for archive). Warn (do not refuse) if missing — legacy proposals from before v0.2.0 won't have it.
If any check fails, refuse to apply and ask the user how to proceed.
§3a auto-apply, per type
For each id that passed §3 verification, print id, target, confidence, blast_radius, cross_session_evidence, auto_apply_eligible. Then apply:
-
skill_new:mkdir -p ~/.claude/skills/<slug>/, thenWritethe proposal's# Proposed changebody to~/.claude/skills/<slug>/SKILL.md. After write, print: "skill<slug>written to~/.claude/skills/<slug>/SKILL.md— activates immediately — Claude Code v2.1.0+ auto-hot-reloads user-level skills, no restart needed." -
memory:Writethe proposal's# Proposed changebody (which MUST include the auto-memory frontmatter — see "Memory drafting protocol" inagents/adam.md) to the path intarget. Then updateMEMORY.mdindex with a one-line pointer. -
nudge: low-blast auto-apply path. Single-session evidence is sufficient — skip the cross-session gate. Apply by invoking the helper (do NOT hand-write the JSON — the helper builds the message and thecuedeterministically from frontmatter):node ~/.claude/adam/scripts/adam-apply-nudge.mjs ~/.claude/adam/proposals/<id>-*.md --home ~/.claudeThe proposal frontmatter MUST carry
type: nudge,source_session, andcwd(the cluster's dominantcwd, fromadam-batch.mjs's per-batchcwds), plusdead_end_count. The helper appends one entry to~/.claude/adam/active-nudges.json(creating it if absent) withcue: {cwd}populated — so the reminder is query-conditioned: it surfaces at SessionStart and mid-session (viaadam-observe.mjs) only when the user is working in that codebase. Output:{"status":"applied"|"gated", ...}— ongatedleave the proposal inproposals/, onappliedcontinue to archive. Do NOT modify any skill, memory, agent, or CLAUDE.md. Tell user: "nudge queued — surfaces when you return to<cwd basename>(expires in 7 days)." -
reinforcement: gated byconfidence >= 4 AND blast_radius == low(same as memory). Apply by invoking the helper:node ~/.claude/adam/scripts/adam-apply-reinforcement.mjs ~/.claude/adam/proposals/<id>-*.md --home ~/.claudeThe helper reads the proposal frontmatter (
skill_slug,count,source_session) and appends one JSON line to~/.claude/adam/reinforcements.jsonl. No code/memory/skill modifications. Output:{"status":"applied"|"gated", ...}. Ongated, leave the proposal inproposals/(the helper failed its own re-check). Onapplied, continue to the archive step. Tell user: "reinforcement logged for<skill_slug>(count=) — appended to reinforcements.jsonl." -
skill_edit: enforce the apply-time gate before writing.- Verify proposal frontmatter has
auto_apply_eligible: true. If not, abort and queue for review. - Read
targetSKILL.md, capturecurrent_bytesfrom a fresh stat — do NOT trust frontmatterbytes_before. - Verify diff in
# Proposed change: unified-diff format, zero-lines on existing SKILL.md content (additions only), total+lines ≤ 30. If any check fails, print one-line refusal reason, leave proposal inproposals/, continue. - Cooldown re-check: run
node ~/.claude/adam/scripts/adam-cooldown.mjs --skill <target_skill> --fingerprint <proposal_fingerprint>(both fields come from proposal frontmatter; missing fingerprint → "legacy"). Refuse if the script returnsstatus: cooldownORstatus: blacklisted. This per-(skill, fingerprint) gate replaces the previous coarse per-skill scan — proposals for the same skill with a different fingerprint are NOT blocked by an older entry.adam-cooldown.mjsreturnsblacklistedwhenauto_apply_blacklist: trueis found inrejected/within 30 days for the same (skill, fingerprint). - Apply via
Edittool (append the new section per the diff). Never useWriteon existing SKILL.md. - Re-stat target. If new size exceeds
2 * current_bytes(captured in step 2), revert viaEdit(remove the just-appended section) and refuse — print refusal reason. - Add
last_auto_edit: <iso8601 utc now>to the proposal frontmatter before moving it. - Tell user: "skill
<slug>extended (added lines) — auto-applied via win-evidence gate."
- Verify proposal frontmatter has
§3a after each auto-apply: move, A/B tracking, archive
-
Move proposal to
~/.claude/adam/applied/<UTC-ts>-<id>.md. -
A/B tracking append (skip for
reinforcement— positive-only ledger, intentionally not A/B-tracked peragents/adam.md§"reinforcementproposals"): as a separate atomic step right after the move, append one JSON line to~/.claude/adam/ab-tracking.jsonl(create with empty contents if absent). Read fields from the proposal's frontmatter (proposal_fingerprint,originating_signals— both populated peragents/adam.md;originating_signalsis a list of{type, count, session_ids}objects). Schema:{ "applied_at": <unix_ms now>, "proposal_id": "<id>", "proposal_type": "skill_edit|skill_new|memory|nudge", "target_skill": "<slug or target basename>", "proposal_fingerprint": "<hash>", "originating_signals": [{"type":"<signal>","count":<N>,"session_ids":[...]}], "pre_window_days": 7 }adam-ab-measure.mjsconsumes this entry on later/reflectruns to compute pre/post signal-count deltas. Seeagents/adam.md§"A/B effectiveness". If the append fails (disk-full etc.), log a warning but do NOT abort the apply path — A/B is observability, not a gate. -
Archive consumed journal entries:
node ~/.claude/adam/scripts/adam-archive.mjs ~/.claude/adam/applied/<UTC-ts>-<id>.md. This moves the entries listed in the proposal'ssource_entriesfromjournal.jsonltojournal/actioned-<id>.jsonl, so later/reflectruns do not re-cluster them.
After all ids, print: auto-applied N proposals: [ids].
§4 approve, per type
claude_md_edit: back up first withcp ~/.claude/CLAUDE.md ~/.claude/adam/applied/<ts>-claude-md-backup.md.deletion:mkdir -p ~/.claude/adam/trash/<ts>, thenmvthe artifact into it. Print the restoration command.skill_new:mkdir -p ~/.claude/skills/<slug>/, then write the# Proposed changebody to<slug>/SKILL.md. Tell user: "skill<slug>written — activates immediately (CC v2.1.0+ auto-hot-reload)."skill_edit: apply the unified diff in# Proposed changeto the existing SKILL.md attarget(append-only — never replace existing content).memory: write the# Proposed changebody (must include auto-memory frontmatter) totargetand update theMEMORY.mdindex with a one-line pointer.harness_edit(MOSS §1): apply the unified diff to the target harness file. Before applying:- Run
bash ~/.claude/adam/tests/run-tests.sh— capture pass count. - Apply the diff via
Edit. - Run
bash ~/.claude/adam/tests/run-tests.shagain — verify pass count is equal or higher and 0 failures. - If test regression: revert the edit, print "harness_edit reverted — test regression detected", leave proposal in
proposals/. - If tests pass: tell user "harness edit applied to
<target>— tests pass ( passed)."
- Run
- All other types: apply via Write/Edit per the proposal's
# Proposed change.
Then:
- Move proposal to
~/.claude/adam/applied/<ts>-<id>.md. - Archive:
node ~/.claude/adam/scripts/adam-archive.mjs ~/.claude/adam/applied/<ts>-<id>.md.
§4 reject and edit
- Reject: ask for the reason in one line. Append
# Reason\n<reason>to the proposal body. If the proposaltypeisskill_edit, ALSO addauto_apply_blacklist: trueto its frontmatter (so future reflects skip auto-apply on this target for 30 days). Move to~/.claude/adam/rejected/<id>.md. Archive:node ~/.claude/adam/scripts/adam-archive.mjs ~/.claude/adam/rejected/<id>.md. - Edit: ask the user for the change, edit the proposal in place, then loop back to §4 step a for that same id.