Skip to content

The agent that grows with you

feat(skills): oversized-body lint rule, surfaced on the SKILL.md patch that crosses it

kshitijk4poor9a7b54accf84
diff --git a/agent/curator.py b/agent/curator.py
index 27c181d2ce1..0eff1464aa2 100644
--- a/agent/curator.py
+++ b/agent/curator.py
@@ -287,7 +287,10 @@ CURATOR_REVIEW_PROMPT = (
"(imperative + one clause of why), the same lesson stated twice becomes "
"one rule, and incident narration, PR/issue numbers, dates and quoted "
"chatter are dropped — the rule must stand without the story. Moving a "
- "file unchanged under references/ is filing, not consolidating.\n\n"
+ "file unchanged under references/ is filing, not consolidating. A SKILL.md "
+ "body over ~24k chars is a consolidation target on its own: skill_view loads "
+ "all of it into context for the rest of the session, so distill it to the "
+ "always-on rules and push topic depth into references/.\n\n"
"Hard rules — do not violate:\n"
"1. DO NOT touch bundled, hub-installed, or external-dir skills "
"(`skills.external_dirs`). The candidate list below is already filtered "
diff --git a/tests/tools/test_skill_linter.py b/tests/tools/test_skill_linter.py
index 721441766fc..8532f70d42b 100644
--- a/tests/tools/test_skill_linter.py
+++ b/tests/tools/test_skill_linter.py
@@ -212,3 +212,16 @@ def test_references_sprawl_flagged_above_cap(tmp_path):
assert "references-sprawl" in _rules(lint_skill(skill_dir / "SKILL.md"))
(refs / f"note-{_MAX_REFERENCE_FILES}.md").unlink()
assert "references-sprawl" not in _rules(lint_skill(skill_dir / "SKILL.md"))
+
+
+def test_oversized_body_flagged_above_budget_and_not_below():
+ # skill_view loads SKILL.md whole and it rides in context for the rest of the session, so the
+ # body has a soft budget. Threshold-relative on purpose: the number is a calibration, not a
+ # contract. The finding names the size so the author sees how far over they are.
+ from tools.skill_linter import _BODY_SOFT_BUDGET_CHARS
+ filler = "- Prefer the native tool; the shell path loses the structured result.\n"
+ over = CLEAN + filler * (_BODY_SOFT_BUDGET_CHARS // len(filler) + 1)
+ under = CLEAN + filler * (_BODY_SOFT_BUDGET_CHARS // len(filler) // 2)
+ found = [f for f in lint_content(over) if f.rule == "oversized-body"]
+ assert found and found[0].severity == WARNING and "references/" in found[0].message
+ assert "oversized-body" not in _rules(lint_content(under))
diff --git a/tests/tools/test_skill_manager_tool.py b/tests/tools/test_skill_manager_tool.py
index c75667d4fc8..7651858efa9 100644
--- a/tests/tools/test_skill_manager_tool.py
+++ b/tests/tools/test_skill_manager_tool.py
@@ -254,6 +254,20 @@ class TestPatchSkill:
content = (tmp_path / "my-skill" / "SKILL.md").read_text()
assert "Do the new thing." in content
+ def test_patch_surfaces_oversized_body_finding_and_stays_quiet_when_clean(self, tmp_path):
+ # SKILL.md grows by patches; the write that crosses the body budget carries the advisory
+ # finding, a small clean patch attaches no lint keys at all.
+ from tools.skill_linter import _BODY_SOFT_BUDGET_CHARS
+ filler = "- Prefer the native tool; the shell path loses the structured result.\n"
+ with _skill_dir(tmp_path):
+ _create_skill("my-skill", VALID_SKILL_CONTENT)
+ quiet = _patch_skill("my-skill", "Do the thing.", "Do the new thing.")
+ grown = _patch_skill("my-skill", "Do the new thing.",
+ filler * (_BODY_SOFT_BUDGET_CHARS // len(filler) + 1))
+ assert quiet["success"] is True and "lint_warnings" not in quiet
+ assert grown["success"] is True
+ assert "oversized-body" in {w["rule"] for w in grown["lint_warnings"]}
+
def test_patch_ambiguous_match_rejected(self, tmp_path):
content = """\
diff --git a/tools/skill_linter.py b/tools/skill_linter.py
index 061404d2b4e..b1fcf76e2bb 100644
--- a/tools/skill_linter.py
+++ b/tools/skill_linter.py
@@ -49,6 +49,11 @@ _INCIDENT_REF_PER_KCHAR = 0.5 # the 100k incident-log SKILL.md this targets sat
# Calibration: a deliberately curated large workflow skill sits near 50 topical files; the hoarding
# shape this catches was 443 one-per-session files.
_MAX_REFERENCE_FILES = 60
+# oversized-body: SKILL.md is loaded whole by skill_view and then rides in context for every later
+# call of the session, so body size is paid per turn, not once. The authoring standard is ~200 lines;
+# this budget is ~3x that (bundled skills average ~20k chars). The hard cap in skill_manager_tool
+# (100k) is a safety stop, not a target — agent-authored skills grew to sit right under it.
+_BODY_SOFT_BUDGET_CHARS = 24_000
ERROR = "error"
WARNING = "warning"
@@ -121,6 +126,12 @@ def _check_frontmatter(frontmatter: Dict[str, Any], skill_dir: Optional[Path]) -
def _check_body(body: str, skill_dir: Optional[Path]) -> Iterator[LintFinding]:
+ if len(body) > _BODY_SOFT_BUDGET_CHARS:
+ yield _warn("oversized-body",
+ f"SKILL.md body is {len(body):,} chars (~{len(body) // 4:,} tokens); skill_view loads "
+ f"all of it and it stays in context for every later call of the session. Keep the "
+ f"always-on rules here (~200 lines) and move topic depth into references/<topic>.md, "
+ f"linked from the body.")
# Only backtick-wrapped mentions in PROSE (not fenced code): bare words are too noisy.
prose = _strip_code_blocks(body)
for util, tool in _SHELL_UTIL_TO_TOOL.items():
diff --git a/tools/skill_manager_tool.py b/tools/skill_manager_tool.py
index abe23bbc07a..ffbe713a520 100644
--- a/tools/skill_manager_tool.py
+++ b/tools/skill_manager_tool.py
@@ -394,11 +394,16 @@ def _add_description_prompt_preview(result: Dict[str, Any], content: str) -> Dic
return result
-def _attach_lint_findings(result: Dict[str, Any], skill_md: Path) -> None:
- """Attach ADVISORY authoring findings (hard rejects already ran in _validate_frontmatter)."""
+def _attach_lint_findings(result: Dict[str, Any], skill_md: Path, before: Optional[str] = None) -> None:
+ """Attach ADVISORY authoring findings (hard rejects already ran in _validate_frontmatter).
+ With ``before`` (the pre-write content) only rules the write INTRODUCED are attached, so a
+ patch reports the line it crossed rather than re-listing the skill's standing findings."""
try:
- from tools.skill_linter import lint_skill # local import: optional path
+ from tools.skill_linter import lint_content, lint_skill # local import: optional path
findings = lint_skill(skill_md)
+ if before is not None:
+ standing = {f.rule for f in lint_content(before, skill_dir=skill_md.parent)}
+ findings = [f for f in findings if f.rule not in standing]
except Exception:
findings = None
if not findings:
@@ -406,7 +411,7 @@ def _attach_lint_findings(result: Dict[str, Any], skill_md: Path) -> None:
result["lint_warnings"] = [
{"severity": f.severity, "rule": f.rule, "message": f.message} for f in findings]
result["lint_hint"] = (
- "The skill was created. These are advisory authoring-convention findings (not blockers) "
+ "The write succeeded. These are advisory authoring-convention findings (not blockers) "
"— fix them with skill_manage(action='patch') to match Hermes skill standards.")
@@ -501,7 +506,12 @@ def _patch_skill(name: str, old_string: str, new_string: str, file_path: str = N
"success": True,
"message": f"Patched {target_label} in skill '{name}' ({match_count} replacement{'s' if match_count > 1 else ''}).",
"_change": {"old": _clip(old_string, 200, "…"), "new": _clip(new_string, 200, "…")}}
- return _attach_org_note(result, name, skill_dir)
+ result = _attach_org_note(result, name, skill_dir)
+ # SKILL.md grows by patches, not by creates: surface findings on the patch that crosses a line
+ # (oversized-body, incident-log-shape) — a clean patch attaches nothing and stays quiet.
+ if not file_path:
+ _attach_lint_findings(result, target, before=content)
+ return result
def _delete_skill(name: str, absorbed_into: Optional[str] = None) -> Dict[str, Any]:
diff --git a/website/docs/user-guide/features/skills.md b/website/docs/user-guide/features/skills.md
index 0d164d39ecf..7dfd8f5a295 100644
--- a/website/docs/user-guide/features/skills.md
+++ b/website/docs/user-guide/features/skills.md
@@ -594,10 +594,12 @@ holds a small set of files named by topic (a decision table, a recipe, provider
extended in place rather than accumulated one file per session. Skills also do not
restate what is already loaded every turn (the repo's `AGENTS.md`, tool schemas).
-`skill_manage` runs an advisory linter on `create` and on `references/` writes and
-returns its findings in the tool result. Two rules exist specifically for this shape:
-`incident-log-shape` (a body dense in PR/issue numbers) and `references-sprawl` (more
-than 60 reference files). They warn; they never block a write.
+`skill_manage` runs an advisory linter on `create`, on `SKILL.md` patches, and on `references/`
+writes and returns its findings in the tool result. Three rules exist specifically for this shape:
+`incident-log-shape` (a body dense in PR/issue numbers), `references-sprawl` (more
+than 60 reference files), and `oversized-body` (a `SKILL.md` body past ~24k chars — `skill_view`
+loads the whole file and it stays in context for the rest of the session). They warn; they never
+block a write.
### Actions