Skip to content

The meta-skill that builds and improves all your skills, including itself. Watches your work sessions (autonomous or human-led), captures patterns, corrections and judgement calls, and turns them into skill improvements and new skill candidates for your review. Practical application of the Augmented Expertise methodology. Open source: CC BY 4.0.

Validator: reject edit residue and duplicated frontmatter blocks

Eoghan Henn24b6ef0dbcc4
diff --git a/references/weekly-review.md b/references/weekly-review.md
index 0e11b25..723fa1e 100644
--- a/references/weekly-review.md
+++ b/references/weekly-review.md
@@ -539,7 +539,7 @@ writable — staging-only is a deliberate safety property of the review loop
constraint. For any skill with
supporting files, zip the staged directory into a `.skill` bundle and
present the bundle; a bare SKILL.md install silently truncates a
-multi-file skill. Pre-delivery gate (two items, run as the last step
+multi-file skill. Pre-delivery gate (run as the last step
before presenting): (1) grep the staged SKILL.md body for `references/`,
`scripts/`, `assets/` paths and fail the delivery if any referenced file
is missing from the staged set; (2) for multi-file skills, fail the
@@ -550,8 +550,16 @@ delivery above 1024 characters, with a soft warning above ~900 —
measure every skill in the set, not just the one that failed; (4) `name`
is kebab-case, matches the directory, and the frontmatter parses; (5) the
bundle's member paths use `/`, checked on raw bytes (Windows packers write
-`\`, and normalising readers hide it). `scripts/validate-skill-bundle.py`
-asserts all five and packs a well-formed bundle — run it where Python is
+`\`, and normalising readers hide it); (6) exactly one frontmatter block
+— a second `---` block or stray `name:`/`description:` lines directly
+after the first is a duplicated header that every field check passes by
+construction; (7) no edit residue in any text file of the bundle,
+outside code: a literal regex backreference (`\1`) on its own line or in
+prose, merge-conflict markers, unresolved `{{slot}}` placeholders — the
+gate checks the form of a delivery, and this is the one content assertion,
+because a failed replacement once passed apply, gate and install as a
+literal `\1`. `scripts/validate-skill-bundle.py`
+asserts all seven and packs a well-formed bundle — run it where Python is
available. Sweep build artefacts (`__pycache__/`, `*.pyc`, `.DS_Store`,
`.~lock.*`) before zipping and read the archive listing back after, for
leaked artefacts and for path separators. When seeding staged
diff --git a/scripts/validate-skill-bundle.py b/scripts/validate-skill-bundle.py
index cc05248..7c310b2 100644
--- a/scripts/validate-skill-bundle.py
+++ b/scripts/validate-skill-bundle.py
@@ -32,6 +32,18 @@ MAX_DESCRIPTION_CHARS = 1024 # installer's documented cap on the folded descri
NAME_RE = re.compile(r"^[a-z0-9]+(-[a-z0-9]+)*$") # kebab-case
PATH_RE = re.compile(r"`((?:references|scripts|assets)/[^`\s*?]+\.[A-Za-z0-9]+)`")
BUILD_JUNK = {"__pycache__", ".DS_Store"}
+# Edit residue: strings that only ever enter a file through a failed
+# replacement, an unresolved template slot or an unfinished merge. The gate
+# checks bundle FORM; this is the one CONTENT assertion, because a literal
+# backreference passed apply, gate and install once.
+RESIDUE_RES = [
+ (re.compile(r"(?m)^\\[0-9]\s*$"), "literal regex backreference on its own line"),
+ (re.compile(r"(?<![\w`])\\[1-9](?![\w])"), "literal regex backreference in prose"),
+ (re.compile(r"(?m)^(<<<<<<<|=======|>>>>>>>)( |$)"), "merge conflict marker"),
+ (re.compile(r"\{\{[A-Za-z_][A-Za-z0-9_ .-]*\}\}"), "unresolved template slot"),
+ (re.compile(r"\b(TODO|FIXME|XXX)\b: ?(fill|replace|write)", re.I), "placeholder note left in"),
+]
+SECOND_FRONTMATTER_RE = re.compile(r"^---\n.*?\n---\n\s*(---\n|name:|description:)", re.S)
def frontmatter(text):
@@ -88,9 +100,26 @@ def check_dir(skill_dir, fails):
for rel in sorted(set(PATH_RE.findall(text))):
if not (skill_dir / rel).is_file():
fails.append(f"cited path missing from staged set: {rel}")
+ # exactly one frontmatter block: a second `---` block (or stray
+ # name:/description: lines) directly after the first is a duplicated
+ # header that every field check passes by construction
+ if SECOND_FRONTMATTER_RE.match(text):
+ fails.append("frontmatter: a second frontmatter block follows the first")
for p in skill_dir.rglob("*"):
if p.name in BUILD_JUNK or p.suffix == ".pyc" or p.name.startswith(".~lock"):
fails.append(f"build artefact in staged tree: {p.relative_to(skill_dir)}")
+ # content residue in every text file of the bundle, not only SKILL.md
+ if p.is_file() and p.suffix.lower() in (".md", ".txt", ".yml", ".yaml", ".json"):
+ body = p.read_text(encoding="utf-8", errors="replace")
+ # code is where backreferences legitimately live: blank out
+ # fenced blocks and inline spans, keeping line numbers intact
+ prose = re.sub(r"(?ms)^```.*?^```[ \t]*$", lambda m: re.sub(r"[^\n]", " ", m.group(0)), body)
+ prose = re.sub(r"`[^`\n]*`", lambda m: " " * len(m.group(0)), prose)
+ for rx, why in RESIDUE_RES:
+ m = rx.search(prose)
+ if m:
+ line = body.count("\n", 0, m.start()) + 1
+ fails.append(f"edit residue in {p.relative_to(skill_dir)}:{line}: {why} ({m.group(0).strip()!r})")
def pack(src, out):