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
48 changes: 47 additions & 1 deletion .github/workflows/test-plugin-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,53 @@
- name: Test artifact-path validator
run: node --test scripts/validate-artifact-paths-test.js

# Ubuntu coverage stays in the existing jobs above, preserving their check names.
validate-platforms:
name: Validate tooling (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest]
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: '24'

- name: Test validators and eval runner
run: >-
node --test
scripts/lib/skill-lint-test.js
scripts/validate-versions-test.js
scripts/run-evals-test.js
scripts/validate-reference-links-test.js
scripts/validate-commands-test.js
scripts/validate-artifact-paths-test.js

- name: Validate all skills
run: node scripts/validate-skills.js

- name: Validate manifest versions
run: node scripts/validate-versions.js

- name: Validate references/ links in skills
run: node scripts/validate-reference-links.js

- name: Validate commands across all tool directories
run: node scripts/validate-commands.js

- name: Validate spec/plan/todo artifact paths
run: node scripts/validate-artifact-paths.js

- name: Run skill evals (trigger + routing)
run: node scripts/run-evals.js --min-rank1 95

test-hooks:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium test

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
name: Hook regression tests
runs-on: ubuntu-latest
steps:
Expand All @@ -83,7 +129,7 @@

validate:
name: Validate plugin structure
needs: [validate-skills, validate-commands]
needs: [validate-skills, validate-commands, validate-platforms]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
Expand Down
15 changes: 15 additions & 0 deletions evals/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ Tier 3 supports two behavioral artifact kinds. `execution` is the default: each

The executor runs with an explicit permission mode (`--permission-mode acceptEdits` plus a pre-approved tool list) so execution evals can genuinely edit files, run commands, inspect diffs, and make commits rather than being denied and narrating instead. Traces are fenced as untrusted data in the grader prompt and piped to the grader over stdin (they can be megabytes; argv would hit the OS argument-size limit), executor and grader calls carry timeouts, and grader output is validated as JSON before being written to `evals/results/` (gitignored) in skill-creator's `grading.json` shape. Discipline skills also include pressure cases for time pressure, sunk cost, and authority pressure; these verify that the workflow still holds when the prompt argues for skipping it.

## Plugin evals (Claude Code)

`claude plugin eval` (Claude Code 2.1.269 or later) loads the whole plugin, every skill at once, runs the cases under `evals/plugin/`, and scores each case with and without the plugin. It complements Tier 2 rather than replacing it: Tier 2 checks that a description carries the vocabulary users say; this checks that Claude Code's own router picks the skill on a natural prompt, and what the skill adds to the reply (the `Δ` column).

```bash
claude plugin eval . --no-publish # every case, both arms, 3 runs each
claude plugin eval . --case code-review-fires --runs 1 --ablation none # one cheap iteration on one case
```

A case is a directory holding `prompt.md` (frontmatter: turn and tool limits; body: the prompt, sent verbatim) and one grader per file under `graders/`. Reports land in `evals/results/<timestamp>/`, already gitignored. Every run and every `llm` grader is a real model call on your account, so this runs on demand and never in CI, like Tier 3.

Two rules keep it honest. The command scans all of `evals/` for `prompt.md` or `case.yaml`, so never give a fixture file either name. And a `tool_used: Skill` grader only says whether the skill fired; in a two-arm run it is excluded from the score, so pair it with a grader on the reply itself. `code-review-fires` shows the pattern: the fired indicator, a free `regex` grader that looks for the skill's severity taxonomy (Critical, Required, Nit, Optional, Consider, FYI) used as a heading or as a label, and one `llm` judge on the planted off-by-one. `code-review-stays-quiet` is the precision check: the review skill must not fire on a test-first request, and its `Δ` is expected to be 0; a second, unscored indicator records whether test-driven-development fires instead.

What the first runs taught (Claude Code 2.1.278, claude-opus-5). Skill invocation is stochastic: the review skill fired in 5 of 7 runs on the phrasing the case uses, and test-driven-development fired in 2 of 7 runs on the test-first prompt, so read `Δ` and the report rather than the exit code, or pass `--threshold 0.8` as the CI example in the docs does. In one run the review skill did not fire and the reply still used its severity taxonomy as headings, which no baseline run did in nine; the loaded skill descriptions may shape the reply even without an invocation. Phrasing matters: "Review this diff before I merge it", "Can you do a proper code review of this change before I merge it?" and "Review this pull request for me before it goes into main" never fired the skill in six runs; the model reviewed the diff on its own, competently but without the verdict, the severity tiers or the five-axis pass. Naming the axes ("across correctness, readability, security and performance") is what fires it, so the case uses that; the plainer phrasings are the open finding, and the fix, if any, belongs in the skill's description, not in the prompt. The model may also reach a skill through its slash command (`agent-skills:review`, then `code-review-and-quality`), which costs two turns, so give a case a turn budget of 10 or more.

## Eval case format

One file per skill: `evals/cases/<skill-name>.json`.
Expand Down
7 changes: 7 additions & 0 deletions evals/plugin/code-review-fires/graders/off-by-one.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
type: llm
---

PASS if the review points out that `rows.slice(start, start + size - 1)` returns one row fewer than `size` on every page (the end index of slice is exclusive) and treats it as something that must be fixed before merge, for example by labelling it Critical or leaving it unprefixed as a required change.

FAIL if the review does not mention that pages come back one row short, or files that finding as a Nit, Optional, Consider, or FYI.
4 changes: 4 additions & 0 deletions evals/plugin/code-review-fires/graders/severity-labels.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
type: regex
pattern: '(^|\n)#{1,6} *(Critical|Required|Nit|Optional|Consider|FYI)\b|\b(Critical|Required|Nit|Optional|Consider|FYI):'
---
5 changes: 5 additions & 0 deletions evals/plugin/code-review-fires/graders/skill-fired.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
type: tool_used
tool: Skill
input_match: '"skill"\s*:\s*"(?:[\w-]+:)?code-review-and-quality"'
---
31 changes: 31 additions & 0 deletions evals/plugin/code-review-fires/prompt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
description: A review request that names the axes, with a small diff inline. The skill should fire (through the review command or directly) and the reply should carry its severity labels.
expected_outcome: A structured review with a verdict, findings labelled with the skill's severity taxonomy, and the off-by-one in pageOrders treated as a required change.
max_turns: 12
allowed_tools: [Read, Glob, Grep, Skill]
---

I want a code review of this diff across correctness, readability, security and performance before merging. It adds paging to the orders endpoint.

```diff
diff --git a/src/orders.js b/src/orders.js
--- a/src/orders.js
+++ b/src/orders.js
@@ -12,3 +12,15 @@ function listOrders(db) {
return db.query('SELECT * FROM orders ORDER BY created_at DESC');
}
-module.exports = { listOrders };
+function pageOrders(db, page, size) {
+ const rows = db.query('SELECT * FROM orders ORDER BY created_at DESC');
+ const start = (page - 1) * size;
+ return rows.slice(start, start + size - 1);
+}
+
+app.get('/orders', (req, res) => {
+ const page = Number(req.query.page) || 1;
+ const size = Number(req.query.size) || 20;
+ res.json(pageOrders(db, page, size));
+});
+
+module.exports = { listOrders, pageOrders };
```
8 changes: 8 additions & 0 deletions evals/plugin/code-review-stays-quiet/graders/not-fired.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
type: tool_used
tool: Skill
input_match: '"skill"\s*:\s*"(?:[\w-]+:)?code-review-and-quality"'
min: 0
max: 0
arm: both
---
6 changes: 6 additions & 0 deletions evals/plugin/code-review-stays-quiet/graders/tdd-fired.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
type: tool_used
tool: Skill
input_match: '"skill"\s*:\s*"(?:[\w-]+:)?test-driven-development"'
arm: with-only
---
8 changes: 8 additions & 0 deletions evals/plugin/code-review-stays-quiet/prompt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
description: A test-first request that belongs to test-driven-development. The review skill must not fire.
expected_outcome: The reply proposes a failing test first; code-review-and-quality is never invoked.
max_turns: 12
allowed_tools: [Read, Glob, Grep, Skill]
---

Write a failing test for this bug before we fix it: splitCents(100, 3) returns [33, 33, 33] and a cent goes missing.
88 changes: 88 additions & 0 deletions scripts/lib/skill-lint-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,91 @@ test('CRLF line endings are handled', () => {
const result = lintSkillContent('fenced', content, FENCE_KNOWN);
assert.equal(overviewMissing(result), true);
});

// ── Frontmatter must be valid YAML, not merely splittable ────────────────────
// `parseFrontmatter` splits each line on its first colon, which is forgiving by
// design. The hosts that read these skills are not: Cursor parses the
// frontmatter as YAML when a skill is attached to a message, and a parse
// failure fails the whole request and takes the chat's context with it (#494).
// Each shape below was confirmed rejected by a strict parser (ruby psych) while
// passing every other check in this linter.

/** Frontmatter that is otherwise complete, so only YAML validity varies. */
function fmLines(...lines) {
return withAllSections(['---', 'name: alpha', ...lines, '---'].join('\n'));
}

const yamlErrors = result => result.errors.filter(e => e.startsWith('Frontmatter line '));

test('a valid frontmatter reports no YAML error', () => {
const result = lintSkillContent('alpha', fmLines('description: Use when you need alpha'), KNOWN);
assert.deepEqual(yamlErrors(result), []);
});

test('an unquoted value containing a colon is rejected', () => {
// YAML reads `Use when: X` as a nested mapping and errors; the split-on-first
// -colon parser reads it as a plain string and never notices.
const result = lintSkillContent(
'alpha',
fmLines('description: Use when you need alpha: auth, secrets and review'),
KNOWN,
);
assert.equal(yamlErrors(result).length, 1);
assert.match(yamlErrors(result)[0], /unquoted value containing/);
});

test('quoting the same value makes it valid again', () => {
const result = lintSkillContent(
'alpha',
fmLines('description: "Use when you need alpha: auth, secrets and review"'),
KNOWN,
);
assert.deepEqual(yamlErrors(result), []);
});

test('a colon with no trailing space is left alone', () => {
// `https://example.com` is a perfectly good YAML scalar. The rule keys on
// colon-space, not on colons, so ordinary URLs do not trip it.
const result = lintSkillContent(
'alpha',
fmLines('description: Use when you need alpha', 'docs: https://example.com/a:b'),
KNOWN,
);
assert.deepEqual(yamlErrors(result), []);
});

test('a tab used for indentation is rejected', () => {
const result = lintSkillContent(
'alpha',
fmLines('description: Use when you need alpha', 'meta:', '\tlevel: core'),
KNOWN,
);
assert.equal(yamlErrors(result).length, 1);
assert.match(yamlErrors(result)[0], /indents with a tab/);
});

test('an unterminated quote is rejected', () => {
const result = lintSkillContent('alpha', fmLines('description: "Use when you need alpha'), KNOWN);
assert.equal(yamlErrors(result).length, 1);
assert.match(yamlErrors(result)[0], /never closes/);
});

test('a duplicate key is not reported, because YAML accepts it', () => {
// Deliberate boundary: `safe_load` accepts duplicate keys, so flagging them
// here would fail files no host rejects. The rule tracks the parser, not taste.
const result = lintSkillContent(
'alpha',
fmLines('description: Use when you need alpha', 'description: Use when you need alpha'),
KNOWN,
);
assert.deepEqual(yamlErrors(result), []);
});

test('the error names the line so the fix is obvious', () => {
const result = lintSkillContent(
'alpha',
fmLines('description: Use when you need alpha', 'owner: team: platform'),
KNOWN,
);
assert.match(yamlErrors(result)[0], /^Frontmatter line 4 /);
});
84 changes: 84 additions & 0 deletions scripts/lib/skill-lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,85 @@ function parseFrontmatter(content) {
return result;
}

/**
* Report frontmatter that this file's own parser accepts but a real YAML
* parser rejects.
*
* `parseFrontmatter` above splits each line on its first colon. That is enough
* to read `name` and `description`, and it is deliberately forgiving — but it
* means a SKILL.md whose frontmatter is not valid YAML passes every check here.
* The hosts that consume these skills do not share that forgiveness: Cursor
* parses the frontmatter as YAML when a skill is attached to a message, and a
* parse failure there fails the whole request with a generic server error and
* takes the rest of the chat's context with it (#494).
*
* So the repo could ship frontmatter that breaks a host while CI stayed green.
* That was verified once by hand, against all 25 skills, in the #494 thread;
* this makes it a check instead of a memory.
*
* Scope is deliberately narrow — the three shapes a strict parser rejects and
* the split-on-first-colon parser does not, confirmed against ruby's psych:
*
* description: Use this: when X unquoted value with a colon-space: YAML
* reads a nested mapping and errors
* \tkey: value tab indentation: invalid YAML whitespace
* description: "unterminated an unclosed quote
*
* It is not a YAML implementation. This repo has no package.json and therefore
* no parser to depend on, so the check stays a small set of rules aimed at the
* classes actually observed to break a host. No current frontmatter uses block
* scalars or multi-line values, and the check assumes that stays true; add a
* rule here rather than loosening one if it changes.
*/
function frontmatterYamlErrors(content) {
const match = content.match(/^---[ \t]*\r?\n([\s\S]*?)\r?\n---[ \t]*\r?\n/);
if (!match) return [];

const errors = [];
const lines = match[1].split(/\r?\n/);
lines.forEach((line, i) => {
const lineNo = i + 2; // the opening `---` is line 1
if (!line.trim()) return;

if (/^[ ]*\t/.test(line)) {
errors.push(
`Frontmatter line ${lineNo} indents with a tab — YAML forbids tabs in indentation, ` +
`so a host that parses this frontmatter rejects the whole file`
);
return;
}

const colonIdx = line.indexOf(':');
if (colonIdx === -1) return;
const value = line.slice(colonIdx + 1).trim();
if (!value) return;

const quote = value[0] === '"' || value[0] === "'" ? value[0] : null;
if (quote) {
// An opening quote must close. `endsWith` is enough here because a
// trailing comment after a quoted scalar does not appear in this repo.
if (value.length < 2 || !value.endsWith(quote)) {
errors.push(
`Frontmatter line ${lineNo} opens a ${quote === '"' ? 'double' : 'single'} quote that never closes — ` +
`a host parsing this frontmatter as YAML rejects the whole file`
);
}
return;
}

// Unquoted scalar. A colon followed by a space (or ending the line) makes
// YAML read a nested mapping where a plain string was meant.
if (/:(\s|$)/.test(value)) {
errors.push(
`Frontmatter line ${lineNo} has an unquoted value containing ': ' — YAML reads that as a ` +
`nested mapping and rejects the file; wrap the value in quotes`
);
}
});

return errors;
}

/**
* Collect all explicit skill cross-references from content.
* Only matches against the SKILL_REF_PATTERNS list to avoid
Expand Down Expand Up @@ -183,6 +262,10 @@ function lintSkillContent(dirName, content, knownSkills) {
return { errors, warnings, exempt };
}

// The parser above is forgiving by design; the hosts that read this
// frontmatter are not (#494).
errors.push(...frontmatterYamlErrors(content));

if (!fm.name) {
errors.push("Frontmatter missing required field: 'name'");
} else if (fm.name !== dirName) {
Expand Down Expand Up @@ -311,6 +394,7 @@ function lintSkill(dirName, skillsDir, knownSkills) {
module.exports = {
stripFencedCodeBlocks,
parseFrontmatter,
frontmatterYamlErrors,
extractSkillReferences,
lintSkillContent,
lintSkill,
Expand Down
Loading
Loading