From 4150ec4f570633dee45fa21a0a233f874fc56a63 Mon Sep 17 00:00:00 2001 From: ayobamiseun Date: Fri, 25 Sep 2026 08:38:08 +0100 Subject: [PATCH 1/2] docs: link the per-agent configuration guide from anatomy, README and CONTRIBUTING docs/advanced-per-agent-configuration.md calls itself the canonical reference for keeping SKILL.md frontmatter portable, yet nothing in the repository links to it. Add the frontmatter rule it states to the anatomy doc's Frontmatter section, and point at it from the README contributing paragraph and CONTRIBUTING's frontmatter step, so contributors meet the rule where they read the format. --- CONTRIBUTING.md | 2 +- README.md | 2 +- docs/skill-anatomy.md | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 533457cc7c..e66d77aa19 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -23,7 +23,7 @@ If your idea is a refinement of an existing skill, prefer a focused edit to that 1. Create a directory under `skills/` with a kebab-case name 2. Add a `SKILL.md` following the format in [docs/skill-anatomy.md](docs/skill-anatomy.md) -3. Include YAML frontmatter with `name` and `description` fields +3. Include YAML frontmatter with `name` and `description` fields, and no vendor or runtime keys at the top level (those go under `metadata` or in a per-agent adapter file; see [docs/advanced-per-agent-configuration.md](docs/advanced-per-agent-configuration.md)) 4. Ensure the `description` starts with what the skill does (third person), then includes one or more `Use when` trigger conditions ### Skill Quality Bar diff --git a/README.md b/README.md index 6361def414..563d1f5428 100644 --- a/README.md +++ b/README.md @@ -387,7 +387,7 @@ Wondering how this stacks up against [Superpowers](https://github.com/obra/super Skills should be **specific** (actionable steps, not vague advice), **verifiable** (clear exit criteria with evidence requirements), **battle-tested** (based on real workflows), and **minimal** (only what's needed to guide the agent). -See [docs/skill-anatomy.md](docs/skill-anatomy.md) for the format specification and [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines. +See [docs/skill-anatomy.md](docs/skill-anatomy.md) for the format specification, [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines, and [docs/advanced-per-agent-configuration.md](docs/advanced-per-agent-configuration.md) for applying model routing, tool restrictions, and other per-agent runtime controls without breaking the portable `SKILL.md` frontmatter. --- diff --git a/docs/skill-anatomy.md b/docs/skill-anatomy.md index fb1f1f2b53..04e493326a 100644 --- a/docs/skill-anatomy.md +++ b/docs/skill-anatomy.md @@ -31,6 +31,7 @@ description: Guides agents through [task/workflow]. Use when [specific trigger c **Rules:** - `name`: Lowercase, hyphen-separated. Must match the directory name. - `description`: Start with what the skill does in third person, then include one or more clear "Use when" trigger conditions. Include both *what* and *when*. Maximum 1024 characters. +- Top-level keys are limited to the [Agent Skills specification](https://agentskills.io) fields: `name`, `description`, `license`, `compatibility`, `metadata`, and `allowed-tools`. Vendor or runtime controls such as `model`, `tools`, `max_turns`, or `context` go under `metadata` or in a per-agent adapter file; see [docs/advanced-per-agent-configuration.md](advanced-per-agent-configuration.md). The validator rejects any other top-level key. Published names are compatibility identifiers. In particular, `browser-testing-with-devtools` is the stable upstream name because other From 0898b52faa18e2f45aa42cd191c52f42c2215b65 Mon Sep 17 00:00:00 2001 From: ayobamiseun Date: Fri, 25 Sep 2026 08:38:08 +0100 Subject: [PATCH 2/2] feat(validator): reject frontmatter keys outside the Agent Skills spec set docs/advanced-per-agent-configuration.md says vendor and runtime fields such as model, tools, max_turns and context must not appear at the top level of a SKILL.md: hosts do not promise to ignore unknown keys and a strict client can reject the file. Nothing enforced it; a skill with model: at the top level passed CI. Add SPEC_FRONTMATTER_KEYS (name, description, license, compatibility, metadata, allowed-tools) and an error for any other column-zero key, naming the key and pointing at the guide. Nested lines under metadata and list items are children of a spec key and are left alone. Export topLevelFrontmatterKeys for direct tests. validate-commands.js shares only frontmatterYamlErrors, so command frontmatter is unaffected. All 25 skills use only name and description, so the rule fires on nothing today and follows the #571 pattern of errors for rules nothing violates. The self-exemption test now expects two errors, since exempt: is also not a spec key. --- scripts/lib/skill-lint-test.js | 102 ++++++++++++++++++++++++++++++++- scripts/lib/skill-lint.js | 45 +++++++++++++++ 2 files changed, 144 insertions(+), 3 deletions(-) diff --git a/scripts/lib/skill-lint-test.js b/scripts/lib/skill-lint-test.js index 7ac1082b22..0fb5359ef3 100644 --- a/scripts/lib/skill-lint-test.js +++ b/scripts/lib/skill-lint-test.js @@ -9,7 +9,7 @@ const fs = require('node:fs'); const os = require('node:os'); const path = require('node:path'); -const { lintSkillContent, lintSkillLayout } = require('./skill-lint.js'); +const { lintSkillContent, lintSkillLayout, topLevelFrontmatterKeys } = require('./skill-lint.js'); const KNOWN = new Set(['alpha', 'beta']); @@ -97,8 +97,10 @@ test('a skill claiming its own exemption without being allowlisted fails loud', ['---', 'name: alpha', 'description: Designs alphas. Use when building one.', 'exempt: sections', '---'].join('\n') ); const { errors } = lintSkillContent('alpha', content, KNOWN); - assert.equal(errors.length, 1); - assert.match(errors[0], /not in the validator's SECTION_EXEMPT_SKILLS allowlist/); + // Two errors: 'exempt' is not a spec key, and the exemption itself is refused. + assert.equal(errors.length, 2); + assert.equal(errors.filter(e => /not in the validator's SECTION_EXEMPT_SKILLS allowlist/.test(e)).length, 1); + assert.equal(errors.filter(e => /Frontmatter key 'exempt' is not an Agent Skills spec field/.test(e)).length, 1); }); // ─── Guardrails on the rules this change sits beside ───────────────────────── @@ -449,3 +451,97 @@ test('non-markdown files are left to the Script Requirements conventions', () => assert.deepEqual(lintSkillLayout(dir), []); }); + +// ─── Spec-only top-level frontmatter keys ──────────────────────────────────── +// +// docs/advanced-per-agent-configuration.md: the specification reserves the top +// level for name, description, license, compatibility, metadata and +// allowed-tools. Vendor and runtime fields go under `metadata` or in a +// per-agent adapter file, never at the top level of a published SKILL.md. + +function skillWithFrontmatter(lines) { + return withAllSections(['---', ...lines, '---'].join('\n')); +} + +const SPEC_KEY_RE = /is not an Agent Skills spec field/; + +test('a vendor field at the top level is rejected and the message names the key', () => { + const { errors } = lintSkillContent('alpha', skillWithFrontmatter([ + 'name: alpha', + 'description: Designs alphas. Use when building one.', + 'model: claude-opus-5', + ]), KNOWN); + assert.equal(errors.length, 1); + assert.match(errors[0], /Frontmatter key 'model'/); + assert.match(errors[0], SPEC_KEY_RE); + assert.match(errors[0], /advanced-per-agent-configuration\.md/); +}); + +test('every unknown top-level key is reported, not just the first', () => { + const { errors } = lintSkillContent('alpha', skillWithFrontmatter([ + 'name: alpha', + 'description: Designs alphas. Use when building one.', + 'max_turns: 10', + 'tools: [read_file]', + 'context: fork', + ]), KNOWN); + const keyErrors = errors.filter(e => SPEC_KEY_RE.test(e)); + assert.deepEqual(keyErrors.map(e => e.match(/key '([^']+)'/)[1]), ['max_turns', 'tools', 'context']); +}); + +test('all six specification keys are accepted at the top level', () => { + const { errors } = lintSkillContent('alpha', skillWithFrontmatter([ + 'name: alpha', + 'description: Designs alphas. Use when building one.', + 'license: MIT', + 'compatibility: Requires git and a test runner', + 'allowed-tools: Read Grep', + 'metadata:', + ' author: someone', + ]), KNOWN); + assert.deepEqual(errors.filter(e => SPEC_KEY_RE.test(e)), []); +}); + +test('vendor fields nested under metadata are not top-level keys', () => { + const { errors } = lintSkillContent('alpha', skillWithFrontmatter([ + 'name: alpha', + 'description: Designs alphas. Use when building one.', + 'metadata:', + ' model: gemini-3-pro', + ' max_turns: 10', + ' tools:', + ' - read_file', + ]), KNOWN); + assert.deepEqual(errors.filter(e => SPEC_KEY_RE.test(e)), []); +}); + +test('topLevelFrontmatterKeys sees only column-zero keys, in order', () => { + const content = [ + '---', + 'name: alpha', + '# a comment: with a colon', + 'metadata:', + ' model: x', + ' tools:', + ' - a', + 'allowed-tools: Read', + '---', + '', + 'body: not frontmatter', + ].join('\n'); + assert.deepEqual(topLevelFrontmatterKeys(content), ['name', 'metadata', 'allowed-tools']); +}); + +test('topLevelFrontmatterKeys returns [] without a frontmatter block', () => { + assert.deepEqual(topLevelFrontmatterKeys('## Overview\nx\n'), []); +}); + +test('the spec-key check tolerates CRLF frontmatter', () => { + const content = skillWithFrontmatter([ + 'name: alpha', + 'description: Designs alphas. Use when building one.', + 'temperature: 0.2', + ]).replace(/\n/g, '\r\n'); + const { errors } = lintSkillContent('alpha', content, KNOWN); + assert.equal(errors.filter(e => /key 'temperature'/.test(e)).length, 1); +}); diff --git a/scripts/lib/skill-lint.js b/scripts/lib/skill-lint.js index 73f65aa4f1..ddcd49da47 100644 --- a/scripts/lib/skill-lint.js +++ b/scripts/lib/skill-lint.js @@ -36,6 +36,21 @@ const MAX_DESCRIPTION_LENGTH = 1024; // CI on line count would block unrelated work on an over-budget skill. const MAX_SKILL_LINES = 500; +// The only keys the Agent Skills specification allows at the top level of +// SKILL.md frontmatter. Anything else — model hints, tool lists, turn limits, +// host-specific switches — belongs under `metadata` or in a per-agent adapter +// file (docs/advanced-per-agent-configuration.md). Hosts do not promise to +// ignore unknown top-level keys, and a published skill carrying one can fail +// packaging on a strict client, so this is an error rather than a warning. +const SPEC_FRONTMATTER_KEYS = new Set([ + 'name', + 'description', + 'license', + 'compatibility', + 'metadata', + 'allowed-tools', +]); + // A skill directory name must be lowercase-hyphen-separated // (docs/skill-anatomy.md → Naming Conventions). const KEBAB_CASE = /^[a-z0-9]+(-[a-z0-9]+)*$/; @@ -141,6 +156,23 @@ function stripFencedCodeBlocks(content) { return out.join('\n'); } +/** + * List the top-level keys in the frontmatter block, in file order. Only + * column-zero `key:` lines count: indented lines are children of the key + * above them (e.g. fields under `metadata`), and `- item` lines are list + * entries. Returns [] when there is no frontmatter block. + */ +function topLevelFrontmatterKeys(content) { + const match = content.match(/^---[ \t]*\r?\n([\s\S]*?)\r?\n---[ \t]*\r?\n/); + if (!match) return []; + const keys = []; + for (const line of match[1].split(/\r?\n/)) { + const m = line.match(/^([A-Za-z0-9_-]+)\s*:/); + if (m) keys.push(m[1]); + } + return keys; +} + /** * Parse YAML-style frontmatter from the top of a markdown file. * Returns a key→value object, or null if no frontmatter block found. @@ -281,6 +313,18 @@ function lintSkillContent(dirName, content, knownSkills) { // frontmatter are not (#494). errors.push(...frontmatterYamlErrors(content)); + // Only the specification's keys may sit at the top level. Vendor and + // runtime fields go under `metadata` or in a per-agent adapter file. + for (const key of topLevelFrontmatterKeys(content)) { + if (!SPEC_FRONTMATTER_KEYS.has(key)) { + errors.push( + `Frontmatter key '${key}' is not an Agent Skills spec field — top level allows only ` + + `${[...SPEC_FRONTMATTER_KEYS].join(', ')}; put vendor or runtime fields under 'metadata' ` + + `or in a per-agent adapter file (docs/advanced-per-agent-configuration.md)` + ); + } + } + if (!fm.name) { errors.push("Frontmatter missing required field: 'name'"); } else if (fm.name !== dirName) { @@ -482,6 +526,7 @@ function lintSkill(dirName, skillsDir, knownSkills) { module.exports = { stripFencedCodeBlocks, parseFrontmatter, + topLevelFrontmatterKeys, frontmatterYamlErrors, extractSkillReferences, lintSkillContent,