Skip to content

fix(validator): allowlisted skills only, not Object.prototype keys - #505

Merged
addyosmani merged 1 commit into
addyosmani:mainfrom
abhisheksharma2411:fix/skill-lint-frontmatter-and-exempt-lookup
Aug 21, 2026
Merged

addyosmani merged 1 commit into
addyosmani:mainfrom
abhisheksharma2411:fix/skill-lint-frontmatter-and-exempt-lookup

Conversation

@abhisheksharma2411

Copy link
Copy Markdown
Contributor

Three defects in scripts/lib/skill-lint.js, each with a regression test. Also adds scripts/lib/skill-lint-test.js — this is the only validator without a test file, while validate-versions, validate-commands, validate-reference-links, validate-artifact-paths and run-evals all have one.

Found while reading the linter after #437; these are in parseFrontmatter and the exemption lookup, so they don't overlap with the stripFencedCodeBlocks work in #428 / #444.

1. A legal YAML block scalar description is rejected

parseFrontmatter split on the first colon of every line, so:

description: >
  Designs alpha things across several lines.
  Use when building an alpha.

parsed as description = ">". The trigger check then failed on a skill whose description is legal YAML and does contain a trigger:

Description has no 'when to use' trigger — add a "Use when …" clause

Continuation lines were worse. Because every line was scanned for a colon, an indented Use when: … became its own field — so a fold could inject a phantom Use when key.

Keys are now recognised only when unindented at column zero, and > / | blocks are gathered (folded joins with spaces, literal keeps newlines).

2. A skill directory named constructor bypasses every section check

exempt = dirName in SECTION_EXEMPT_SKILLS;

in walks the prototype chain, and constructor satisfies KEBAB_CASE (the * quantifier permits a single word). So a skill with no sections at all validated clean:

exempt: true   errors: []

The "fail loud" guard missed it too, for the same reason — SECTION_EXEMPT_SKILLS['constructor'] is truthy. Both now use Object.hasOwn, which is what the comment above the allowlist already promises: "Exemptions live HERE, not in skill frontmatter, so contributors cannot bypass the validator by editing their own skill file."

I'll be straight that a skill named constructor is unlikely. I'd still rather the allowlist be the only thing granting exemptions, since that guarantee is stated in the file.

3. A sentence-initial dead cross-reference is not reported

SKILL_REF_PATTERNS matched lowercase verbs only, so See \x`at the start of a sentence was invisible to the dead-reference check. This isn't hypothetical —skills/api-and-interface-design/SKILL.md:30` writes:

  • Plan for deprecation at design time. See deprecation-and-migration for how to safely remove things users depend on.

That target exists, so nothing is wrong today; a dead reference written that way would simply go unwarned. The leading verb now accepts either case.

The captured name deliberately stays lowercase-only rather than adding an i flag to the whole pattern: a case-insensitive capture would read prose like `Foo-Bar` as a skill name and invent dead references. Confirmed no new warnings on current content — still 24 skills, 0 errors, 0 warnings.

Verification

Each of the five new failing cases was confirmed red against the unpatched rules first, by reverting only skill-lint.js and keeping the tests:

✖ accepts a folded block scalar description
✖ accepts a literal block scalar description
✖ a colon inside a block scalar continuation does not become its own field
✖ a directory named after an Object.prototype key is not exempt from section checks
✖ warns on a dead cross-reference and stays quiet on a live one

The other seven tests pass either way, which is the check that existing behaviour is unchanged.

After the fix:

  • node --test scripts/lib/skill-lint-test.js — 12/12
  • all five validators — 24 skills checked — 0 error(s), 0 warning(s) — PASSED
  • all five pre-existing test suites — pass
  • node scripts/run-evals.js --min-rank1 80 — 86% (67/78)

If you'd like skill-lint-test.js wired into .github/workflows/test-plugin-install.yml alongside the other node --test steps, say so and I'll add it here rather than leaving it to a follow-up.

`dirName in SECTION_EXEMPT_SKILLS` walks the prototype chain, and
`constructor` satisfies KEBAB_CASE (the `*` quantifier permits a single
word). A skill directory named `constructor` therefore resolved to
Object.prototype.constructor and was silently exempt from every
required-section check — `exempt: true`, zero errors, no sections. The
bypass guard missed it for the same reason, since the resolved value is
truthy.

Both lookups now use Object.hasOwn, which is what the comment above the
allowlist already promises: "Exemptions live HERE, not in skill
frontmatter, so contributors cannot bypass the validator by editing their
own skill file."

Adds scripts/lib/skill-lint-test.js — skill-lint.js was the only
validator without a test file. Confirmed the prototype-chain test goes red
against main; the other six pass either way, so existing behaviour is
unchanged.

Scope kept to the exemption lookup: addyosmani#428 already rewrites frontmatter
parsing and the cross-reference patterns, so this stays clear of both.
@abhisheksharma2411
abhisheksharma2411 force-pushed the fix/skill-lint-frontmatter-and-exempt-lookup branch from b0cbe0c to c59c4b4 Compare August 21, 2026 16:05
@abhisheksharma2411 abhisheksharma2411 changed the title fix(validator): frontmatter block scalars, prototype-chain exemptions, case-sensitive refs fix(validator): allowlisted skills only, not Object.prototype keys Aug 21, 2026
@abhisheksharma2411

Copy link
Copy Markdown
Contributor Author

I've narrowed this substantially, and I owe an explanation.

#428 already fixes two of the three things I originally reported here, and does it better. It was opened a month before this one and I should have read it before filing. Specifically it already handles block scalars with chomping indicators, comments, quoted scalars, malformed lines as errors, and nested collections; and it already makes the reference patterns case-tolerant ([Ss]ee, [Ff]ollow, …) while splitting prose from diagram patterns and running prose against fence-stripped content. All of that is strictly more thorough than what I had.

So I've reverted both of those and rebased this down to the one thing #428 does not touch.

What remains

dirName in SECTION_EXEMPT_SKILLS walks the prototype chain, and constructor satisfies KEBAB_CASE — the * quantifier permits a single unhyphenated word. A skill directory named constructor therefore resolves to Object.prototype.constructor and is silently exempt from every required-section check:

exempt: true   errors: []      // a SKILL.md with no sections at all

The bypass guard misses it for the same reason: SECTION_EXEMPT_SKILLS['constructor'] is truthy, so the "fail loud" branch never fires.

Both lookups now use Object.hasOwn. I checked #428's tree specifically and it still carries dirName in SECTION_EXEMPT_SKILLS, so this remains open after that lands, and the two don't collide — #428 rewrites parseFrontmatter and the pattern lists, this touches only the exemption lookup.

I'll be straight that a skill named constructor is unlikely. The reason I'd still take the two-line change is that the file states the guarantee outright — "contributors cannot bypass the validator by editing their own skill file" — and right now a directory name is enough to break it.

Verification

scripts/lib/skill-lint-test.js is new; skill-lint.js was the only validator without a test file. I confirmed the prototype-chain test goes red against main:

✖ a directory named after an Object.prototype key is not exempt from section checks

The other six pass either way, which is the check that existing behaviour is unchanged. The tests are deliberately narrow — no frontmatter or cross-reference assertions — so they don't collide with #428.

All five validators still report 24 skills checked — 0 error(s), 0 warning(s).

If you'd rather fold this two-line change into #428 and close this, that's completely reasonable and I'd support it — @ayobamiseun got there first on the substantial part.

@addyosmani addyosmani left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, and the right fix. in walks the prototype chain, so a skill dir named constructor (which passes the kebab check) would resolve to Object.prototype.constructor and get silently exempted from the section checks. Object.hasOwn closes that. Test-merged clean, lint tests pass. Approving.

@addyosmani
addyosmani merged commit 5a5ea45 into addyosmani:main Aug 21, 2026
4 checks passed
ujjwalks pushed a commit to ujjwalks/agent-skills that referenced this pull request Aug 27, 2026
Resolves the add/add conflict on scripts/lib/skill-lint-test.js created when
addyosmani#505 merged the same path first. The resolution is a union: addyosmani#505's exemption
and guardrail cases, then addyosmani#444's fence cases. KNOWN gains 'portable-skill'
so the fence fixtures resolve; skill-lint.js auto-merged with no conflict.

19 tests pass on the merged tree. Against main's pre-addyosmani#444 lint script, the
five tilde/indented/longer-closer/unterminated cases go red, so the fence
change stays load-bearing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants