Skip to content

The agent that grows with you

feat(skills): per-skill content lock against autonomous writes (#25083)

Davis Fordb694c7d90770
diff --git a/agent/background_review.py b/agent/background_review.py
index 7b62515afc9..108e4518ed5 100644
--- a/agent/background_review.py
+++ b/agent/background_review.py
@@ -480,7 +480,9 @@ _SKILL_REVIEW_PROMPT = (
"new learning, PATCH that one first (re-load it with skill_view during this review — see "
"Read-before-write below). It is the skill that was in play, so it's the right one to extend — "
"whoever wrote it: hand-written, installed, bundled, and pinned skills are all yours to "
- "improve.\n"
+ "improve. The one exception is a skill the user LOCKED (`hermes curator lock`): skill_manage "
+ "refuses it — do not retry and do not recreate it under another name; put the suggested "
+ "change in your summary instead.\n"
" 2. UPDATE AN EXISTING UMBRELLA (via skills_list + skill_view). If no loaded skill fits but "
"an existing class-level skill does, patch it. Add a subsection, a pitfall, or broaden a "
"trigger.\n"
diff --git a/hermes_cli/curator.py b/hermes_cli/curator.py
index fc949df8c51..2e8ccbdaf5d 100644
--- a/hermes_cli/curator.py
+++ b/hermes_cli/curator.py
@@ -105,6 +105,9 @@ def _cmd_status(args) -> int:
from agent import curator
from tools import skill_usage
_print_curator_config(curator)
+ if locked := skill_usage.locked_skill_names():
+ print(f"\nlocked ({len(locked)}): {', '.join(locked)} "
+ f"(autonomous content writes refused; `hermes curator unlock <skill>` lifts it)")
rows = skill_usage.curated_report()
if not rows:
print("\nno curator-managed skills")
@@ -237,6 +240,37 @@ def _cmd_pin(args) -> int: return _set_pin(args, True)
def _cmd_unpin(args) -> int: return _set_pin(args, False)
+def _set_lock(args, locked: bool) -> int:
+ """``hermes curator lock|unlock``: a user declaration stored beside ``pinned`` in the active
+ profile's skills/.usage.json. Not restricted to agent-created skills — hand-written skills are
+ the main thing people lock — but the name must resolve in this profile, so a typo never forges a
+ record for a skill that does not exist."""
+ from tools import skill_usage
+ from tools.skill_manager_tool import _find_skill
+ verb = "lock" if locked else "unlock"
+ existing = _find_skill(args.skill)
+ if existing is None:
+ print(f"curator: no skill named '{args.skill}' in the active profile — nothing to {verb}. "
+ f"`hermes skills list` shows the names.")
+ return 1
+ key = existing["path"].name # directory name: the key the skill_manage guard resolves to
+ if not skill_usage.set_locked(key, locked):
+ print(f"curator: could not record the {verb} for '{key}' (skills/.usage.json not writable).")
+ return 1
+ if locked:
+ print(f"curator: locked '{key}' — the background review and curator passes can no longer patch, "
+ f"edit, write or remove files in it, or delete it (skill_manage refuses; the skill stays "
+ f"readable, listed and auto-loadable). Edits you ask for in a normal turn and your own "
+ f"editor are unaffected. Unlock with `hermes curator unlock {key}`.")
+ else:
+ print(f"curator: unlocked '{key}' — the autonomous passes may improve it again.")
+ return 0
+
+
+def _cmd_lock(args) -> int: return _set_lock(args, True)
+def _cmd_unlock(args) -> int: return _set_lock(args, False)
+
+
def _cmd_list_unmanaged(args) -> int:
"""Itemize the unmanaged population that `status` summarizes (input for `adopt`)."""
from tools import skill_usage
@@ -646,6 +680,10 @@ _SUBCOMMANDS = (
("resume", "Resume a paused curator", _cmd_resume),
("pin", "Pin a skill so the curator never auto-transitions it", _cmd_pin, _SKILL),
("unpin", "Unpin a skill", _cmd_unpin, _SKILL),
+ ("lock", "Lock a skill's content against the background review and curator passes "
+ "(skill_manage refuses their patch/edit/write_file/remove_file/delete; the skill stays "
+ "readable and auto-loadable; edits you ask for are unaffected)", _cmd_lock, _SKILL),
+ ("unlock", "Lift a content lock", _cmd_unlock, _SKILL),
("list-unmanaged", "List curation-eligible skills with no provenance marker",
_cmd_list_unmanaged),
(
diff --git a/tests/hermes_cli/test_curator_lock.py b/tests/hermes_cli/test_curator_lock.py
new file mode 100644
index 00000000000..569dc647b2f
--- /dev/null
+++ b/tests/hermes_cli/test_curator_lock.py
@@ -0,0 +1,102 @@
+"""`hermes curator lock|unlock` (#25083, #140332): a per-profile user declaration that the
+autonomous passes may not change a skill's content. The flag lives beside ``pinned`` in the
+active profile's ``skills/.usage.json``; ``curator status`` lists it."""
+
+from __future__ import annotations
+
+import importlib
+import io
+import json
+from contextlib import redirect_stdout
+from pathlib import Path
+
+import pytest
+
+
+def _make_skill(skills_dir: Path, name: str) -> Path:
+ d = skills_dir / name
+ d.mkdir(parents=True, exist_ok=True)
+ (d / "SKILL.md").write_text(f"---\nname: {name}\ndescription: x\n---\n# {name}\n", encoding="utf-8")
+ return d
+
+
+def lock_env(tmp_path, monkeypatch):
+ """Isolated HERMES_HOME with freshly reloaded modules (same shape as test_curator_pin_visibility)."""
+ home = tmp_path / ".hermes"
+ skills = home / "skills"
+ skills.mkdir(parents=True)
+ monkeypatch.setattr(Path, "home", lambda: tmp_path)
+ monkeypatch.setenv("HERMES_HOME", str(home))
+
+ import hermes_constants
+ importlib.reload(hermes_constants)
+ from tools import skill_usage
+ importlib.reload(skill_usage)
+ from agent import curator
+ importlib.reload(curator)
+ monkeypatch.setattr(curator, "_load_config", dict)
+ monkeypatch.setattr(skill_usage, "_prune_builtins_enabled", lambda: False)
+ from hermes_cli import curator as curator_cli
+ importlib.reload(curator_cli)
+ # `lock` resolves the name through skill_manage's finder; pin its search roots to this profile.
+ monkeypatch.setattr("agent.skill_utils.get_all_skills_dirs", lambda: [skills])
+ monkeypatch.setattr("tools.skill_manager_tool.SKILLS_DIR", skills)
+ return {"home": home, "skills": skills, "usage": skill_usage, "cli": curator_cli}
+
+
+def _run(cli, *argv):
+ buf = io.StringIO()
+ with redirect_stdout(buf):
+ code = cli.cli_main(list(argv))
+ return code, buf.getvalue()
+
+
+def _sidecar(skills: Path) -> dict:
+ path = skills / ".usage.json"
+ return json.loads(path.read_text(encoding="utf-8")) if path.exists() else {}
+
+
+def test_lock_then_unlock_round_trip_on_a_hand_written_skill(lock_env):
+ env = lock_env
+ _make_skill(env["skills"], "coding-standards")
+
+ code, out = _run(env["cli"], "lock", "coding-standards")
+ assert code == 0, out
+ assert "locked 'coding-standards'" in out
+ assert "hermes curator unlock coding-standards" in out
+ assert env["usage"].is_locked("coding-standards") is True
+ rec = _sidecar(env["skills"])["coding-standards"]
+ assert rec["locked"] is True
+ assert rec["pinned"] is False # the pin axis is untouched
+
+ code, out = _run(env["cli"], "unlock", "coding-standards")
+ assert code == 0, out
+ assert "unlocked 'coding-standards'" in out
+ assert env["usage"].is_locked("coding-standards") is False
+
+
+def test_lock_refuses_a_name_that_does_not_resolve(lock_env):
+ env = lock_env
+ code, out = _run(env["cli"], "lock", "no-such-skill")
+ assert code == 1
+ assert "no skill named 'no-such-skill'" in out
+ assert "no-such-skill" not in _sidecar(env["skills"]) # a typo never forges a record
+
+
+def test_lock_resolves_a_categorized_path_and_records_the_directory_name(lock_env):
+ env = lock_env
+ _make_skill(env["skills"] / "ops", "deploy-runbook")
+ code, out = _run(env["cli"], "lock", "ops/deploy-runbook")
+ assert code == 0, out
+ assert "locked 'deploy-runbook'" in out
+ assert env["usage"].is_locked("deploy-runbook") is True
+
+
+def test_status_lists_locked_skills(lock_env):
+ env = lock_env
+ _make_skill(env["skills"], "coding-standards")
+ assert _run(env["cli"], "lock", "coding-standards")[0] == 0
+ code, out = _run(env["cli"], "status")
+ assert code == 0, out
+ assert "locked (1): coding-standards" in out
diff --git a/tests/tools/test_skill_manager_tool.py b/tests/tools/test_skill_manager_tool.py
index aead1638780..5c46c80a540 100644
--- a/tests/tools/test_skill_manager_tool.py
+++ b/tests/tools/test_skill_manager_tool.py
@@ -1367,3 +1367,174 @@ class TestCuratorConsolidationDeleteGuard:
assert allowed["success"] is True, allowed
_reset_background_review_read_marks()
+
+
+# ---------------------------------------------------------------------------
+# Content lock (#25083, #140332) — `hermes curator lock <name>` makes skill_manage refuse
+# AUTONOMOUS mutations (review fork / curator pass) of that one skill: whole directory,
+# single-op and batch paths. Foreground user-directed writes are not gated; unlocked
+# siblings keep learning; an unreadable sidecar fails closed for autonomous writes only.
+# ---------------------------------------------------------------------------
+
+@contextmanager
+def _background_origin():
+ from tools.skill_provenance import (
+ BACKGROUND_REVIEW,
+ reset_current_write_origin,
+ set_current_write_origin,
+ )
+ token = set_current_write_origin(BACKGROUND_REVIEW)
+ try:
+ yield
+ finally:
+ reset_current_write_origin(token)
+
+
+class TestLockedGuard:
+ _PATCH = dict(action="patch", old_string="Do the thing.", new_string="Do the new thing.")
+ _MUTATIONS = (
+ _PATCH,
+ dict(action="patch", file_path="references/notes.md", old_string="Keep this.", new_string="Changed."),
+ dict(action="edit", content=VALID_SKILL_CONTENT_2),
+ dict(action="write_file", file_path="references/new.md", file_content="# New\n"),
+ dict(action="remove_file", file_path="references/notes.md"),
+ dict(action="delete", absorbed_into="umbrella"),
+ )
+
+ @staticmethod
+ def _profile(tmp_path, monkeypatch, name="default"):
+ """Isolated HERMES_HOME whose skills/ dir doubles as the patched SKILLS_DIR, so the lock
+ sidecar (<home>/skills/.usage.json) and the skill files share one profile root."""
+ skills = tmp_path / name / ".hermes" / "skills"
+ skills.mkdir(parents=True)
+ monkeypatch.setenv("HERMES_HOME", str(skills.parent))
+ return skills
+
+ @staticmethod
+ def _make(skills, name, category=None):
+ from tools.skill_manager_tool import _write_file
+ assert _create_skill(name, VALID_SKILL_CONTENT, category)["success"]
+ assert _write_file(name, "references/notes.md", "# Notes\n\nKeep this.\n")["success"]
+ return skills / (f"{category}/{name}" if category else name)
+
+ @staticmethod
+ def _bg(skill_dir, **op):
+ """skill_manage from the review fork with read-before-write satisfied for every file of
+ *skill_dir*, so the lock is the only guard that can refuse."""
+ from tools.skill_manager_guards import mark_background_review_skill_read
+ with _background_origin():
+ for f in skill_dir.rglob("*"):
+ if f.is_file():
+ mark_background_review_skill_read(f)
+ return json.loads(skill_manage(**op))
+
+ @staticmethod
+ def _tree(skill_dir):
+ return {p.relative_to(skill_dir).as_posix(): p.read_text() for p in skill_dir.rglob("*") if p.is_file()}
+
+ def test_locked_skill_refuses_every_autonomous_mutation(self, tmp_path, monkeypatch):
+ from tools import skill_usage
+ skills = self._profile(tmp_path, monkeypatch)
+ with _skill_dir(skills):
+ d = self._make(skills, "locked-skill")
+ _create_skill("umbrella", VALID_SKILL_CONTENT)
+ assert skill_usage.set_locked("locked-skill", True)
+ before = self._tree(d)
+ results = [self._bg(d, name="locked-skill", **op) for op in self._MUTATIONS]
+ after = self._tree(d)
+ for op, res in zip(self._MUTATIONS, results):
+ assert res["success"] is False, (op, res)
+ assert "locked" in res["error"], (op, res)
+ assert "hermes curator unlock locked-skill" in res["error"], (op, res)
+ assert after == before
+
+ def test_unlocked_sibling_keeps_learning_and_unlock_lifts_refusal(self, tmp_path, monkeypatch):
+ from tools import skill_usage
+ skills = self._profile(tmp_path, monkeypatch)
+ with _skill_dir(skills):
+ locked = self._make(skills, "locked-skill")
+ sibling = self._make(skills, "sibling-skill")
+ assert skill_usage.set_locked("locked-skill", True)
+ sib = self._bg(sibling, name="sibling-skill", **self._PATCH)
+ refused = self._bg(locked, name="locked-skill", **self._PATCH)
+ assert skill_usage.set_locked("locked-skill", False)
+ lifted = self._bg(locked, name="locked-skill", **self._PATCH)
+ assert sib["success"] is True, sib
+ assert refused["success"] is False and "locked" in refused["error"], refused
+ assert lifted["success"] is True, lifted
+ assert "Do the new thing." in (locked / "SKILL.md").read_text()
+
+ def test_foreground_write_to_locked_skill_goes_through(self, tmp_path, monkeypatch):
+ """Documented: the lock gates autonomous origins only. A user-directed edit still lands."""
+ from tools import skill_usage
+ skills = self._profile(tmp_path, monkeypatch)
+ with _skill_dir(skills):
+ d = self._make(skills, "locked-skill")
+ assert skill_usage.set_locked("locked-skill", True)
+ res = json.loads(skill_manage(name="locked-skill", **self._PATCH))
+ assert res["success"] is True, res
+ assert "Do the new thing." in (d / "SKILL.md").read_text()
+
+ def test_batch_refuses_before_any_sibling_op_is_applied(self, tmp_path, monkeypatch):
+ from tools import skill_usage
+ skills = self._profile(tmp_path, monkeypatch)
+ with _skill_dir(skills):
+ d = self._make(skills, "locked-skill")
+ assert skill_usage.set_locked("locked-skill", True)
+ res = self._bg(d, action="", name="", operations=[
+ {"name": "sibling", "action": "create", "content": VALID_SKILL_CONTENT},
+ {"name": "locked-skill", **self._PATCH}])
+ sibling_created = _find_skill("sibling") is not None
+ assert res["success"] is False and "locked" in res["error"], res
+ assert not sibling_created
+ assert "Do the thing." in (d / "SKILL.md").read_text()
+
+ def test_create_is_not_gated_and_cannot_shadow_a_locked_name(self, tmp_path, monkeypatch):
+ from tools import skill_usage
+ skills = self._profile(tmp_path, monkeypatch)
+ with _skill_dir(skills):
+ d = self._make(skills, "locked-skill")
+ assert skill_usage.set_locked("locked-skill", True)
+ fresh = self._bg(d, action="create", name="brand-new", content=VALID_SKILL_CONTENT)
+ shadow = self._bg(d, action="create", name="locked-skill", content=VALID_SKILL_CONTENT_2)
+ assert fresh["success"] is True, fresh
+ assert shadow["success"] is False and "already exists" in shadow["error"], shadow
+ assert "Do the thing." in (d / "SKILL.md").read_text()
+
+ def test_categorized_and_frontmatter_names_resolve_to_the_lock(self, tmp_path, monkeypatch):
+ from tools import skill_usage
+ skills = self._profile(tmp_path, monkeypatch)
+ with _skill_dir(skills):
+ d = self._make(skills, "locked-cat", category="ops")
+ assert skill_usage.set_locked("locked-cat", True) # keyed by directory name, as the CLI does
+ by_path = self._bg(d, name="ops/locked-cat", **self._PATCH)
+ by_frontmatter = self._bg(d, name="test-skill", **self._PATCH) # the frontmatter name
+ assert by_path["success"] is False and "locked" in by_path["error"], by_path
+ assert by_frontmatter["success"] is False and "locked" in by_frontmatter["error"], by_frontmatter
+ assert "Do the thing." in (d / "SKILL.md").read_text()
+
+ def test_lock_is_per_profile(self, tmp_path, monkeypatch):
+ from tools import skill_usage
+ work = self._profile(tmp_path, monkeypatch, "work")
+ with _skill_dir(work):
+ self._make(work, "shared-name")
+ assert skill_usage.set_locked("shared-name", True)
+ assert skill_usage.is_locked("shared-name") is True
+ home = self._profile(tmp_path, monkeypatch, "home")
+ with _skill_dir(home):
+ d = self._make(home, "shared-name")
+ assert skill_usage.is_locked("shared-name") is False
+ res = self._bg(d, name="shared-name", **self._PATCH)
+ assert res["success"] is True, res
+ assert "Do the new thing." in (d / "SKILL.md").read_text()
+
+ def test_corrupt_sidecar_fails_closed_for_autonomous_writes_only(self, tmp_path, monkeypatch):
+ skills = self._profile(tmp_path, monkeypatch)
+ with _skill_dir(skills):
+ d = self._make(skills, "any-skill")
+ (skills / ".usage.json").write_text("{not json", encoding="utf-8")
+ autonomous = self._bg(d, name="any-skill", **self._PATCH)
+ foreground = json.loads(skill_manage(name="any-skill", **self._PATCH))
+ assert autonomous["success"] is False, autonomous
+ assert "could not be verified" in autonomous["error"], autonomous
+ assert foreground["success"] is True, foreground
diff --git a/tests/tools/test_skill_usage.py b/tests/tools/test_skill_usage.py
index fb9c95f8b33..f399f6f6ecf 100644
--- a/tests/tools/test_skill_usage.py
+++ b/tests/tools/test_skill_usage.py
@@ -613,3 +613,43 @@ def test_skill_file_lock_is_reentrant_in_thread_and_exclusive_across_threads(tmp
assert not other_done.wait(timeout=0.2), "second thread acquired a held lock"
t.join(timeout=2)
assert entered.is_set() and other_done.is_set()
+
+
+# ---------------------------------------------------------------------------
+# Content lock (#25083): `locked` beside `pinned`; set_locked is not curation-gated and
+# is_locked is strict so the write guard can fail closed on a corrupt sidecar.
+# ---------------------------------------------------------------------------
+
+
+def test_set_locked_round_trip_and_listing(skills_home):
+ from tools import skill_usage as mod
+
+ (skills_home / "skills" / "hand-written").mkdir()
+ assert mod.is_locked("hand-written") is False # no sidecar yet
+ assert mod.set_locked("hand-written", True) is True # hand-written: not curation-gated
+ assert mod.is_locked("hand-written") is True
+ assert mod.locked_skill_names() == ["hand-written"]
+ assert mod.get_record("hand-written")["pinned"] is False # pin axis untouched
+ assert mod.set_locked("hand-written", False) is True
+ assert mod.is_locked("hand-written") is False
+ assert mod.locked_skill_names() == []
+
+
+def test_is_locked_is_strict_on_a_corrupt_sidecar(skills_home):
+ from tools import skill_usage as mod
+
+ (skills_home / "skills" / ".usage.json").write_text("{not json", encoding="utf-8")
+ with pytest.raises(ValueError): # json.JSONDecodeError; load_usage() would return {} here
+ mod.is_locked("anything")
+ assert mod.locked_skill_names() == [] # the listing stays best-effort
+
+
+def test_is_locked_ignores_malformed_records_but_never_relaxes_a_truthy_flag(skills_home):
+ from tools import skill_usage as mod
+
+ (skills_home / "skills" / ".usage.json").write_text(
+ json.dumps({"a": "junk", "b": {"locked": "yes"}, "c": {}}), encoding="utf-8")
+ assert mod.is_locked("a") is False
+ assert mod.is_locked("b") is True
+ assert mod.is_locked("c") is False
+ assert mod.is_locked("missing") is False
diff --git a/tools/skill_manager_guards.py b/tools/skill_manager_guards.py
index 7b3c8283381..b35e34eba52 100644
--- a/tools/skill_manager_guards.py
+++ b/tools/skill_manager_guards.py
@@ -221,7 +221,44 @@ def _background_review_read_before_write_guard(
_read_before_write_required=True)
+def _locked_guard(name: str, action: str) -> Optional[dict[str, Any]]:
+ """Refuse autonomous mutations (review fork, curator consolidation pass) of a skill the user
+ locked with ``hermes curator lock``. Foreground user-directed writes are not gated: the lock is
+ against unattended drift, not against the user. ``create`` is exempt (the existing collision
+ check already refuses a name that resolves anywhere). Unlike the pin guard this fails CLOSED on
+ an unreadable sidecar — silently relaxing a lock the user set is the failure it exists to
+ prevent. The lock is keyed by directory name, so the bare, categorized (``cat/name``) and
+ frontmatter-name forms the tool accepts all resolve to the same record."""
+ if action == "create" or not name or not _is_background_review():
+ return None
+ refuse = f"Refusing background curator {action} for"
+ try:
+ from tools import skill_manager_tool as _smt
+ from tools import skill_usage
+ candidates = {name, Path(name).name}
+ if existing := _smt._find_skill(name):
+ candidates.add(existing["path"].name)
+ locked = any(skill_usage.is_locked(candidate) for candidate in candidates)
+ except Exception:
+ logger.warning("locked skill guard lookup failed for %s", name, exc_info=True)
+ return _refusal(
+ f"{refuse} skill '{name}': the lock state could not be verified because the "
+ f"skills/.usage.json sidecar is unreadable. Leave the skill alone and report it; the user "
+ f"can repair the sidecar or run `hermes curator unlock {name}`.", _locked=True)
+ if locked:
+ return _refusal(
+ f"{refuse} locked skill '{name}': the user locked it against autonomous changes. Do not "
+ f"retry and do not recreate it under another name; describe the proposed change in your "
+ f"summary instead. The user lifts the lock with `hermes curator unlock {name}`.",
+ _locked=True)
+ return None
+
+
def _background_review_preflight(action: str, name: str) -> Optional[dict[str, Any]]:
+ """Guards that run on the bare action/name before any handler, for the single-op AND the
+ batch path: the content lock (every mutating action) and the ownership delete guard."""
+ if (locked := _locked_guard(name, action)) is not None:
+ return locked
if action != "delete":
return None
from tools import skill_manager_tool as _smt
diff --git a/tools/skill_usage.py b/tools/skill_usage.py
index 6e90cfb2fd8..a0ef91d1e7e 100644
--- a/tools/skill_usage.py
+++ b/tools/skill_usage.py
@@ -577,6 +577,31 @@ def set_pinned(skill_name: str, pinned: bool) -> bool:
return _set_field(skill_name, "pinned", bool(pinned))
+def set_locked(skill_name: str, locked: bool) -> bool:
+ """User declaration (``hermes curator lock``) that the autonomous passes — background review and
+ curator — must not change this skill's content. NOT curation-gated: hand-written, bundled and
+ hub skills can all be locked; archival eligibility is the separate ``pinned`` axis. True when
+ the write landed."""
+ return bool(_mutate(skill_name, lambda rec: rec.update({"locked": bool(locked)}) or True))
+
+
+def is_locked(skill_name: str) -> bool:
+ """``locked`` flag of *skill_name*. Strict on purpose: a corrupt or unreadable sidecar RAISES
+ instead of reading as "unlocked" (``load_usage`` returns {} there), so the write guard can fail
+ closed rather than silently relax a lock the user set."""
+ path = _usage_file()
+ if not path.exists():
+ return False
+ data = json.loads(path.read_text(encoding="utf-8-sig"))
+ rec = data.get(skill_name) if isinstance(data, dict) else None
+ return bool(rec.get("locked")) if isinstance(rec, dict) else False
+
+
+def locked_skill_names() -> list[str]:
+ """Names carrying ``locked: true`` (best-effort listing; empty on a corrupt sidecar)."""
+ return sorted(name for name, rec in load_usage().items() if rec.get("locked"))
+
+
def forget(skill_name: str) -> None:
if skill_name:
_locked_update(skill_name, lambda d: (None, d.pop(skill_name, None) is not None), "skill_usage.forget(%s) failed: %s")
diff --git a/website/docs/user-guide/features/curator.md b/website/docs/user-guide/features/curator.md
index c89fab7267b..f4fcfd1235c 100644
--- a/website/docs/user-guide/features/curator.md
+++ b/website/docs/user-guide/features/curator.md
@@ -44,7 +44,7 @@ A run has two phases:
By default the curator only **prunes** — the deterministic inactivity pass marks skills stale and archives long-unused ones. The opinionated LLM **consolidation** pass (umbrella-building, merging overlapping skills) is off by default because it costs aux-model tokens on every run and makes broad structural changes to your library. Turn it on with `curator.consolidate: true`, or run it once on demand with `hermes curator run --consolidate`.
:::
-Pinned skills are off-limits to both the curator's auto-transitions and the agent's own `skill_manage` tool. See [Pinning a skill](#pinning-a-skill) below.
+Pinned skills are skipped by the curator's auto-transitions, and the agent's `skill_manage` tool refuses to **delete** them; edits and patches still go through. To stop the autonomous passes from changing a skill's *content*, lock it instead. See [Pinning a skill](#pinning-a-skill) and [Locking a skill's content](#locking-a-skills-content) below.
## Configuration
@@ -109,6 +109,8 @@ hermes curator pause # stop runs until resumed
hermes curator resume
hermes curator pin <skill> # never auto-transition this skill
hermes curator unpin <skill>
+hermes curator lock <skill> # autonomous passes may not change its content
+hermes curator unlock <skill>
hermes curator adopt <skill> # hand an unmanaged skill to the curator
hermes curator adopt --all-unmanaged # hand over every unmanaged skill
hermes curator list-unmanaged # itemize skills with no provenance marker
@@ -310,9 +312,10 @@ Skills that ARE agent-created follow the full lifecycle:
- Pinned skills bypass all auto-transitions
- Archives are recoverable via `hermes curator restore <name>`
-If you want to protect a specific skill from ever being touched — for example a
-hand-authored skill you rely on — use `hermes curator pin <name>`. See the next
-section.
+If you want to protect an agent-created skill from archival, use
+`hermes curator pin <name>`. If you want the autonomous passes to stop changing a
+skill's content — for example a hand-authored skill you rely on — use
+`hermes curator lock <name>`. Both are described below.
## Pinning a skill
@@ -336,7 +339,32 @@ Only **agent-created** skills can be pinned — `hermes curator pin` refuses on
A small set of **protected built-ins** can be hardcoded as never-archivable and never-consolidatable, regardless of `curator.prune_builtins`, pin state, or LLM judgment. These back load-bearing UX, so silently archiving one would turn its slash command into an "Unknown command" error with no signal to you. (The set is currently empty — `plan`, its original member, graduated to a built-in `/plan` command with no skill on disk.) Protected built-ins are filtered out of the curator's candidate list entirely, so the consolidation pass never sees them.
-If you want a stronger guarantee than "no deletion" — for instance, freezing a skill's content entirely while the agent still reads it — edit `~/.hermes/skills/<name>/SKILL.md` directly with your editor. The pin guards tool-driven deletion, not your own filesystem access.
+If you want a stronger guarantee than "no deletion" — freezing a skill's content against the autonomous passes while the agent still reads it — lock it (next section). Neither pin nor lock guards your own filesystem access: editing `~/.hermes/skills/<name>/SKILL.md` in your editor always works.
+
+## Locking a skill's content
+
+Pinning stops archival. Locking stops the **autonomous passes from changing what a skill says**, while the skill stays readable, listed in the skill index, auto-loadable and usable exactly as before.
+
+```bash
+hermes curator lock <skill>
+hermes curator unlock <skill>
+hermes curator status # lists locked skills
+```
+
+Once a skill is locked:
+
+- `skill_manage` **refuses** `patch`, `edit`, `write_file`, `remove_file` and `delete` on it when the write comes from the background self-improvement review or the curator's LLM consolidation pass — the two origins with no user in the loop. The refusal covers the whole skill directory (`SKILL.md`, `references/`, `scripts/`, `templates/`, `assets/`), both the single-op and the atomic batch form of the tool, and it tells the fork not to retry or recreate the skill under another name. Unlocked skills next to it keep learning as usual.
+- **Foreground writes are not blocked.** When you ask the agent in a normal turn to change a locked skill, the edit goes through: the lock is against unattended drift, not against you. To review user-directed writes too, turn on [`skills.write_approval`](./skills.md#gating-agent-skill-writes-skillswrite_approval); the two compose.
+- A corrupt or unreadable `.usage.json` makes the autonomous write **fail closed** (refused with an explanation) rather than quietly treating the skill as unlocked. Repair the sidecar, or run `hermes curator unlock <skill>` to rewrite it.
+- Any skill that resolves in the active profile can be locked — hand-written, agent-created, bundled or hub-installed. The skill must exist: `lock` refuses a name it cannot resolve, so a typo never records a lock for a skill that is not there.
+
+The flag is stored as `"locked": true` on the skill's entry in `~/.hermes/skills/.usage.json` — the same sidecar as `pinned`, so it is **per profile**: `hermes -p work curator lock deploy-runbook` locks that profile's copy and leaves every other profile's `deploy-runbook` unchanged.
+
+What a lock is not:
+
+- It is **not a sandbox.** It is a policy inside the skill tool and the curator. The agent's generic file tools and `terminal` can still change files under the skills directory if the process can write there. For a path-level gate on the file tools, add a basename pattern such as `SKILL.md` to `security.protected_instruction_extra_patterns` (writes then ask a human first); shell commands need filesystem permissions or a read-only mount.
+- It does **not** change archival or the inactivity clock. Hand-written skills are never archived autonomously anyway; for an agent-created skill you also want kept out of `stale → archived`, pin it as well.
+- It does **not** stop `hermes update` / `hermes skills update` from refreshing a bundled skill you have not modified — those syncs are not `skill_manage` writes.
## Usage telemetry
diff --git a/website/docs/user-guide/features/skills.md b/website/docs/user-guide/features/skills.md
index ba9dd6e2e76..b62317c8080 100644
--- a/website/docs/user-guide/features/skills.md
+++ b/website/docs/user-guide/features/skills.md
@@ -698,6 +698,13 @@ The review surface works in the interactive CLI and on messaging platforms
in the pending JSON file). Memory writes have the same gate under
`memory.write_approval` — see [Controlling memory writes](./memory.md#controlling-memory-writes-write_approval).
+To protect one *specific* skill from the autonomous passes without gating every
+write, lock it: `hermes curator lock <skill>`. A locked skill stays readable and
+auto-loadable, but the background review and curator passes can no longer patch,
+edit, add or remove files in it, or delete it; edits you ask for in a normal turn
+still go through. Lock and `write_approval` compose. See
+[Locking a skill's content](./curator.md#locking-a-skills-content).
+
> The separate `skills.guard_agent_created` setting is a content scanner
> (dangerous-pattern heuristics), not an approval gate — the two are
> independent. See [Guard on agent-created skill writes](../configuration.md#guard-on-agent-created-skill-writes).