Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

---

Expand Down
1 change: 1 addition & 0 deletions docs/skill-anatomy.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
102 changes: 99 additions & 3 deletions scripts/lib/skill-lint-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']);

Expand Down Expand Up @@ -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 ─────────────────────────
Expand Down Expand Up @@ -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);
});
45 changes: 45 additions & 0 deletions scripts/lib/skill-lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]+)*$/;
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -482,6 +526,7 @@ function lintSkill(dirName, skillsDir, knownSkills) {
module.exports = {
stripFencedCodeBlocks,
parseFrontmatter,
topLevelFrontmatterKeys,
frontmatterYamlErrors,
extractSkillReferences,
lintSkillContent,
Expand Down
Loading