Skip to content

Multi-tier framework for evaluating AI agent skills and plugins with quality gates, security scanning, harness compatibility checks, semantic overlap detection, synthetic evaluation dataset generation, and live agent evaluation that measures how skills affect agent behavior. Ships reusable CI templates that bring every check to any repository.

feat(tier1): start yaml setup for Efficiency, Discoverability and Correctness (#611)

Weston Platter0f3d980d1feb
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 492e2f4f..e6095a56 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -155,6 +155,21 @@ All notable changes to SkillEvaluator are documented in this file.
cannot be confirmed stopped after a timeout or interruption, no further arm starts
beside it and the failure is reported. After a timeout, the failed run still keeps
the scores of the arms that finished.
+- Add four configurable quality rules to the `--quality-config` file. Each
+ sets `points`, `message` and `suggestion` plus one setting, and `points: 0`
+ turns it off:
+
+ | Rule | Setting | Packaged value |
+ | --- | --- | --- |
+ | `efficiency.token_budget` | `max_tokens` | 5,000 |
+ | `discoverability.description_too_short` | `min_chars` | 20 |
+ | `discoverability.description_too_long` | `max_chars` | 200 |
+ | `correctness.reserved_name` | `terms` | `anthropic`, `claude` |
+
+ Please note - This change set moves hard coded values into the default
+ quality config file, so scores, deductions and severities are unchanged,
+ but the before/after `finding_id` will be different. A custom file from
+ an earlier version keeps its digest; the packaged digest changes once.
- Tier 1 **Incomplete referenced artifact analysis (AE1)** findings from
SkillSpector now say why SkillSpector stopped inspecting the file that a skill
diff --git a/docs/cli-reference.mdx b/docs/cli-reference.mdx
index ac737e2b..a49493d9 100644
--- a/docs/cli-reference.mdx
+++ b/docs/cli-reference.mdx
@@ -151,7 +151,7 @@ errors, such as an option the workflow does not accept, exit `2`.
| `--skip CHECKS` | none | Comma-separated checks to leave out, e.g. `secrets` for the Gitleaks scan. Skipped checks are shown and reported as skipped, nothing is installed for them, and the run cannot certify Tier 1 for publication |
| `--llm / --no-llm` | Enabled when a provider is configured | Enable or skip rubric, LLM security, and finding verification; explicit `--llm` requires valid provider configuration |
| `--min-score INTEGER` | `70` | Minimum passing quality and rubric score, from 0 to 100; quality severity overrides cannot waive the minimum |
-| `--quality-config PATH` | packaged `quality-default.yaml` | YAML file that adjusts the quality check's expected headings and error-handling rules; settings it omits keep their packaged values. See [Tier 1: Validation](/skills/skillevaluator/tier1-reference#the-checks). |
+| `--quality-config PATH` | packaged `quality-default.yaml` | YAML file that adjusts the quality check's expected headings, error-handling rules, token budget, description length limits, and reserved name words; settings it omits keep their packaged values. See [Tier 1: Validation](/skills/skillevaluator/tier1-reference#the-checks). |
| `--pii-waivers PATH` | none | Reviewed, expiring PII waivers applied by the `pii` check. See [PII waivers](/skills/skillevaluator/tier1-reference#pii-waivers). |
| `--profile TEXT` | `SKILLEVALUATOR_PROFILE`, then `default` | Validation policy: `default` or `registry`. `external` is a compatibility alias for `default`. |
| `--policy FILE` | none | Explicit policy overlay, including reviewed ownership-contact severity. See [Tier 1 policies](/skills/skillevaluator/tier1-reference#validation-profiles-and-policies). |
@@ -306,7 +306,7 @@ Static checks; LLM-free by default. Tier 1 gates the exit code and always runs.
| `--llm-verify` | off | Run a second LLM pass to suppress false-positive findings. |
| `--skillspector-baseline FILE` | unset | Audited SkillSpector suppression baseline for the `security` check; never discovered from the skill. See [Audited SkillSpector baselines](/skills/skillevaluator/tier1-reference#audited-skillspector-baselines). |
| `--min-score INTEGER` | `70` | Minimum quality score (0–100) required per skill when the `quality` check runs; policy severity overrides cannot waive this gate. |
-| `--quality-config PATH` | packaged `quality-default.yaml` | YAML file that adjusts the quality check's expected headings and error-handling rules; settings it omits keep their packaged values. See [Tier 1: Validation](/skills/skillevaluator/tier1-reference#the-checks). |
+| `--quality-config PATH` | packaged `quality-default.yaml` | YAML file that adjusts the quality check's expected headings, error-handling rules, token budget, description length limits, and reserved name words; settings it omits keep their packaged values. See [Tier 1: Validation](/skills/skillevaluator/tier1-reference#the-checks). |
| `--pii-waivers PATH` | none | Reviewed, expiring PII waivers applied by the `pii` check; forwarded to each skill of a catalog run. See [PII waivers](/skills/skillevaluator/tier1-reference#pii-waivers). |
### Tier 2 · Deduplication
@@ -378,7 +378,7 @@ skillevaluator quality-check ./my-skill
| Flag | Default | Effect |
| --- | --- | --- |
| `--min-score INTEGER` | `70` | Minimum composite score required per skill; passing also requires no HIGH or CRITICAL quality findings. |
-| `--quality-config PATH` | packaged `quality-default.yaml` | YAML file that adjusts the expected headings and error-handling rules used for grading; settings it omits keep their packaged values. |
+| `--quality-config PATH` | packaged `quality-default.yaml` | YAML file that adjusts the expected headings, error-handling rules, token budget, description length limits, and reserved name words used for grading; settings it omits keep their packaged values. |
Plus the standard report options. A collection's displayed average does not
replace the minimum required of each skill. Scoring weights, grade bands, the
diff --git a/docs/metrics-reference.mdx b/docs/metrics-reference.mdx
index 8f4a192a..7c43704a 100644
--- a/docs/metrics-reference.mdx
+++ b/docs/metrics-reference.mdx
@@ -441,7 +441,7 @@ checks in
```text
each area starts at 100
-each triggered finding subtracts its fixed deduction, floored at 0
+each triggered finding subtracts its deduction, floored at 0
Quality = 0.35 * Correctness
+ 0.25 * Discoverability
@@ -466,9 +466,12 @@ type. Only one block below can fire on a given skill:
| resource-based | No documentation of the available resources (10) |
| guide-only | Fewer than 20 non-blank body lines (15) |
-The Reliability rules and the expected-heading list are configurable with
-`--quality-config`, so those deductions are defaults rather than fixed; see
-[Tier 1 validation](/skills/skillevaluator/tier1-validation).
+Some rules are configurable with `--quality-config`, so their deductions and
+thresholds are defaults rather than fixed: the Reliability rules and the
+expected-heading list, the reserved-name words (Correctness), the
+description length limits (Discoverability) and the token budget (Efficiency). The
+token budget in force is reported as `metrics.recommended_max_tokens`; see
+[Tier 1 reference](/skills/skillevaluator/tier1-reference#the-checks).
**Range and units:** 0–100 points. Grades are A at 90 or above, B at 80, C at
70, D at 60, F below. The default `--min-score` is 70, and the minimum is an
diff --git a/docs/tier1-reference.mdx b/docs/tier1-reference.mdx
index e6101ef2..0a3e5140 100644
--- a/docs/tier1-reference.mdx
+++ b/docs/tier1-reference.mdx
@@ -483,7 +483,7 @@ For `validate`, the default set is `schema`, `version`, `security`, `pii`, `lice
| Reliability | 25% | Error handling, prerequisites, limitations, troubleshooting, and implementation safeguards |
| Efficiency | 15% | Estimated token budget, body length, repetition, instruction clarity, and reference use |
- The 5,000-token budget for `SKILL.md` is a recommendation, not a hard limit. Token counts are estimates (characters divided by 4), not tokenizer output: each model family counts differently, and dense files with tables, identifiers or code spans usually have fewer than 4 characters per token, so the estimate runs low. `metrics.estimated_tokens` holds the estimate and `metrics.estimate_method` names how it was made; `metrics.total_tokens` is kept as the same value for existing consumers. A larger `SKILL.md` gets a MEDIUM `quality_efficiency` finding and a 15-point Efficiency deduction. The finding does not fail the check by itself, but the deduction can still take the score below `--min-score`.
+ The 5,000-token budget for `SKILL.md` is a recommendation, not a hard limit. Token counts are estimates (characters divided by 4), not tokenizer output: each model family counts differently, and dense files with tables, identifiers or code spans usually have fewer than 4 characters per token, so the estimate runs low. `metrics.estimated_tokens` holds the estimate and `metrics.estimate_method` names how it was made; `metrics.total_tokens` is kept as the same value for existing consumers. A larger `SKILL.md` gets a MEDIUM `quality_efficiency` finding and a 15-point Efficiency deduction. The finding does not fail the check by itself, but the deduction can still take the score below `--min-score`. The limit and the deduction are set in the quality config file described below.
Grades are A for scores of at least 90, B for at least 80, C for at least 70, D for at least 60, and F below 60. The default `--min-score` is 70. Passing requires the score to reach that minimum and no HIGH or CRITICAL quality findings under the active policy.
@@ -508,7 +508,7 @@ For `validate`, the default set is `schema`, `version`, `security`, `pii`, `lice
If a quality score changes unexpectedly, inspect the finding message rather than adding keywords. The checker rewards usable instructions and evidence in their relevant context, not vocabulary alone.
</Tip>
- **Quality config file.** Pass `--quality-config PATH` to `quality-check`, `tier1`, or `validate` to adjust the Reliability rules below. The file has two optional sections, `expected_headers` and `error_handling`. Anything you leave out keeps its packaged value from `quality-default.yaml`, and any list you set replaces the packaged list rather than merging with it.
+ **Quality config file.** Pass `--quality-config PATH` to `quality-check`, `tier1`, or `validate` to adjust the rules below. The file has five optional sections: `expected_headers` and `error_handling` for Reliability, `efficiency` for the token budget, `discoverability` for the description length limits, and `correctness` for reserved words in the skill name. Anything you leave out keeps its packaged value from `quality-default.yaml`, and any list you set replaces the packaged list rather than merging with it.
**Expected headings.** Reliability deducts points when `SKILL.md` lacks an expected heading. The packaged `quality-default.yaml` expects `## Prerequisites` (or `## Requirements`), `## Limitations`, and `## Troubleshooting` (or `## Common Issues` or `## FAQ`), each worth 5 points. Omit `expected_headers` to keep that list. A list you set replaces it, so copy any default entries you want to keep. Set `expected_headers: []` to turn heading checks off.
@@ -563,7 +563,67 @@ For `validate`, the default set is `schema`, `version`, `security`, `pii`, `lice
Each rule also takes `message` and `suggestion`. The `scripts` and `lib` findings append up to three file names to the message, as in `Scripts may lack error handling: run.py`. The `try:`/`except` pair always counts as error handling and is not configurable. See the packaged `quality-default.yaml` for every default term and marker. The `quality_config` digest in the report covers only the rules your file sets, not the packaged values it leaves out, so the digest changes only when your file's rules change.
- The file is checked before any validation runs. A file that is missing, unreadable, not UTF-8, invalid YAML, has an unknown key (such as `point` instead of `points`), lists the same heading twice, has a negative or non-numeric `points`, an empty `terms` or `markers` list, or a repeated entry in one of those lists is a usage error: the command exits with code 2 and names the file and the problem. `validate` checks the file even when `--checks` leaves out `quality`.
+ **Token budget.** Efficiency deducts points when `SKILL.md` is larger than a token limit, set in the `efficiency` section under `token_budget`. As with `error_handling`, an omitted key keeps its packaged value and `points: 0` turns the rule off, so it adds no finding. This file raises the limit and changes nothing else:
+
+ ```yaml title="quality.yaml"
+ efficiency:
+ token_budget:
+ max_tokens: 8000
+ ```
+
+ | Field | Packaged value | Meaning |
+ | --- | --- | --- |
+ | `max_tokens` | `5000` | A positive whole number. The rule deducts when the estimated size of `SKILL.md` is above it; a file estimated at exactly `max_tokens` passes |
+ | `points` | `15` | Non-negative number deducted from Efficiency. `0` turns the rule off |
+ | `message` | `Large skill` | Start of the finding message |
+ | `suggestion` | See `quality-default.yaml` | Fix suggestion attached to the finding, including the agentskills.io guidance on size |
+
+ The size is an estimate, not a tokenizer count: the number of characters in `SKILL.md`, frontmatter included, divided by 4 and rounded down. Files in `references/` and `scripts/` are not counted. The finding appends the estimate and the limit to `message`, as in `Large skill: ~6200 estimated tokens at 4 characters per token, recommended max <5000; a real tokenizer may count more`. Keep a custom `message` short: report summaries show only the first 160 characters of a finding message, so a long one pushes the estimate and the limit out of view. Reports show the limit in force as `recommended_max_tokens` in the quality metrics, whether or not the rule is turned off.
+
+ **Description length.** Discoverability deducts points when the frontmatter `description` is too short or too long, set in the `discoverability` section under `description_too_short` and `description_too_long`. An omitted key keeps its packaged value and `points: 0` turns a rule off, so it adds no finding. This file raises the minimum and the maximum and changes nothing else:
+
+ ```yaml title="quality.yaml"
+ discoverability:
+ description_too_short:
+ min_chars: 40
+ description_too_long:
+ max_chars: 300
+ ```
+
+ | `description_too_short` field | Packaged value | Meaning |
+ | --- | --- | --- |
+ | `min_chars` | `20` | A positive whole number. The rule deducts when the description has fewer characters than this; a description of exactly `min_chars` characters passes |
+ | `points` | `20` | Non-negative number deducted from Discoverability. `0` turns the rule off |
+ | `message` | `Description too short (recommend 50-150 chars)` | Start of the finding message |
+ | `suggestion` | `Add more context: what tasks does this skill handle?` | Fix suggestion attached to the finding |
+
+ | `description_too_long` field | Packaged value | Meaning |
+ | --- | --- | --- |
+ | `max_chars` | `200` | A positive whole number. The rule deducts when the description has more characters than this; a description of exactly `max_chars` characters passes |
+ | `points` | `5` | Non-negative number deducted from Discoverability. `0` turns the rule off |
+ | `message` | `Description very long (recommend 50-150 chars)` | Start of the finding message |
+ | `suggestion` | `Keep descriptions concise for progressive disclosure` | Fix suggestion attached to the finding |
+
+ The length is counted in characters after leading and trailing whitespace is removed. A skill without a `description` key, or with an empty one (`description: ""`), is not reported by these rules. A `description:` key left without a value is not empty: YAML reads it as null, which is counted as the 4-character text `None` and reported as too short. Each finding appends the length and the limit to `message`, as in `Description too short (recommend 50-150 chars): 12 chars, minimum 20` and `Description very long (recommend 50-150 chars): 251 chars, maximum 200`. The two rules are checked independently, so a minimum set above the maximum makes both fire on a description between them. The other Discoverability rules are not configurable yet.
+
+ **Reserved words in the name.** Correctness deducts points when the frontmatter `name` contains a reserved word, set in the `correctness` section under `reserved_name`. An omitted key keeps its packaged value. A `terms` list you set replaces the packaged list, so copy `anthropic` and `claude` if you want to keep them:
+
+ ```yaml title="quality.yaml"
+ correctness:
+ reserved_name:
+ terms: [anthropic, claude, acme]
+ ```
+
+ | Field | Packaged value | Meaning |
+ | --- | --- | --- |
+ | `terms` | `[anthropic, claude]` | Whole words, any case. `claude` matches `claude-helper` but not `claudette-helper`. A term may contain only letters, digits and single hyphens between them, as in `claude-code`, because a skill name allows nothing else. Spaces around a term are ignored |
+ | `points` | `15` | Non-negative number deducted from Correctness. `0` turns the rule off |
+ | `message` | `Name contains reserved word` | Start of the finding message |
+ | `suggestion` | `Remove reserved words from skill name` | Fix suggestion attached to the finding |
+
+ The finding appends the matched terms to `message`, as in `Name contains reserved word: claude`. Several matches still deduct `points` once. This is an error-level rule: its finding is HIGH and fails the quality check whatever the score, so `points: 0` removes that failure as well as the deduction. The schema check has its own fixed list (`anthropic`, `claude`) that this file does not change, so with the default checks a name containing either word is still rejected there. The other Correctness rules are not configurable yet.
+
+ The file is checked before any validation runs. A file that is missing, unreadable, not UTF-8, invalid YAML, has an unknown key (such as `point` instead of `points`), lists the same heading twice, has a negative or non-numeric `points`, a `max_tokens`, `min_chars` or `max_chars` that is not a whole number from 1 to 1,000,000,000, an empty `terms` or `markers` list, a repeated entry in one of those lists, or a reserved-name term that could never match a skill name (such as `Claude Code` or `claude_code`) is a usage error: the command exits with code 2 and names the file and the problem. `validate` checks the file even when `--checks` leaves out `quality`.
```text title="Example error"
Error: Invalid value for '--quality-config': quality.yaml: unknown key(s) in expected_headers[0]: point (allowed: alternatives, heading, message, points, suggestion)
diff --git a/skills/skillevaluator/references/commands-tier1.md b/skills/skillevaluator/references/commands-tier1.md
index 3ab4c0ba..6edf3744 100644
--- a/skills/skillevaluator/references/commands-tier1.md
+++ b/skills/skillevaluator/references/commands-tier1.md
@@ -31,7 +31,7 @@ rubric, LLM security and finding verification when a provider is configured.
| `--skip CHECKS` | none | Leave checks out (also `secrets` for Gitleaks); the run cannot certify Tier 1 |
| `--llm / --no-llm` | on when a provider is configured | Explicit `--llm` requires a valid provider |
| `--min-score INTEGER` | `70` | Quality and rubric minimum |
-| `--quality-config PATH` | packaged | Replace expected-heading rules |
+| `--quality-config PATH` | packaged | Adjust expected-heading, error-handling, token-budget, description-length (minimum and maximum), and reserved-name rules |
| `--pii-waivers PATH` | none | Reviewed, expiring PII waivers |
| `--profile TEXT` | `default` | Validation policy |
diff --git a/skills/skillevaluator/references/troubleshooting.md b/skills/skillevaluator/references/troubleshooting.md
index 829959a3..47b0d1d9 100644
--- a/skills/skillevaluator/references/troubleshooting.md
+++ b/skills/skillevaluator/references/troubleshooting.md
@@ -8,7 +8,7 @@
| Scanner `INCOMPLETE` | SkillSpector, Gitleaks or Bandit missing or failed | `skillevaluator health-check --tier 1`; install the `security` extra; an old scanner earlier on `PATH` wins over the pinned one |
| `--skip` used and publication fails | Skipped checks cannot certify Tier 1 | Rerun without `--skip` |
| Schema: directory does not match name | Folder name differs from frontmatter `name` | Rename one so both match (kebab-case) |
-| Quality below minimum | Missing expected headings, vague description, no examples, `SKILL.md` over 500 lines or 5,000 tokens | Follow each finding's suggestion; move detail into `references/` |
+| Quality below minimum | Missing expected headings, vague description, no examples, `SKILL.md` over 500 lines or 5,000 tokens (the token limit is `efficiency.token_budget.max_tokens` in `--quality-config`) | Follow each finding's suggestion; move detail into `references/` |
| Rubric fails although the score is high | One criterion below 7/10 | Read that criterion's feedback in the JSON report |
| Tier 2 needs embeddings | Anthropic and Bedrock have no embeddings | Set `SKILL_EVAL_EMBEDDING_*` for another provider |
| `<skill-dir>/evals/config.yml` rejected | Unknown key or credential in `runtime_env` | Fix the key; move secrets to the host environment |
diff --git a/src/skillevaluator/config/quality-default.yaml b/src/skillevaluator/config/quality-default.yaml
index 9862fca2..629c35c2 100644
--- a/src/skillevaluator/config/quality-default.yaml
+++ b/src/skillevaluator/config/quality-default.yaml
@@ -43,3 +43,47 @@ error_handling:
message: "Lib modules may lack error handling"
suggestion: "Library code should handle errors explicitly with try/except or raise"
markers: ["raise", "assert", "ValueError", "TypeError", "RuntimeError"]
+
+# Efficiency rules. They overlay the same way as error_handling: a custom file may set any
+# subset, omitted keys keep the values below, and points: 0 turns a rule off.
+efficiency:
+ # SKILL.md is estimated at more than max_tokens tokens (characters divided by 4, frontmatter
+ # included). The finding appends the estimate and the limit to the message. Keep the message
+ # short: report summaries cut a finding message at 160 characters.
+ token_budget:
+ points: 15
+ message: "Large skill"
+ suggestion: "Per agentskills.io, SKILL.md should be concise (~500 lines) — large skill bodies increase token cost after invocation; long or unfocused top-level descriptions can degrade agent routing accuracy. Keep required sections concise; move detailed examples, reference material, and supporting docs to the references/ directory"
+ max_tokens: 5000
+
+# Discoverability rules. They overlay the same way as error_handling and efficiency.
+discoverability:
+ # The frontmatter description, with surrounding whitespace removed, has fewer than min_chars
+ # characters. A skill without a description key, or with an empty one, is not checked here; a
+ # key left without a value is read as null and counted as the 4-character text "None". The
+ # finding appends the length and the minimum to the message.
+ description_too_short:
+ points: 20
+ message: "Description too short (recommend 50-150 chars)"
+ suggestion: "Add more context: what tasks does this skill handle?"
+ min_chars: 20
+ # The description, with surrounding whitespace removed, has more than max_chars characters.
+ # The finding appends the length and the maximum to the message.
+ description_too_long:
+ points: 5
+ message: "Description very long (recommend 50-150 chars)"
+ suggestion: "Keep descriptions concise for progressive disclosure"
+ max_chars: 200
+
+# Correctness rules. They overlay the same way as the sections above.
+correctness:
+ # The frontmatter name contains one of the terms as a whole word (any case). This is an
+ # error-level rule: its finding is HIGH and fails the quality check whatever the score.
+ # The finding appends the matched terms to the message. A term may contain only letters,
+ # digits and single hyphens, like a skill name. The schema check keeps its own
+ # reserved-word list, which this file does not change.
+ reserved_name:
+ points: 15
+ message: "Name contains reserved word"
+ suggestion: "Remove reserved words from skill name"
+ terms: [anthropic, claude]
diff --git a/src/skillevaluator/constants.py b/src/skillevaluator/constants.py
index 82162dd3..d11d6a91 100644
--- a/src/skillevaluator/constants.py
+++ b/src/skillevaluator/constants.py
@@ -408,12 +408,10 @@ QUALITY_SCORE_WEIGHTS = {
QUALITY_GRADE_THRESHOLDS = [(90, "A"), (80, "B"), (70, "C"), (60, "D"), (0, "F")]
QUALITY_DEFAULT_MIN_SCORE = 70
-QUALITY_RECOMMENDED_MAX_TOKENS = 5000
# Tier 1 estimates tokens as characters / QUALITY_CHARS_PER_TOKEN; it does not run a tokenizer.
QUALITY_CHARS_PER_TOKEN = 4
QUALITY_MAX_BODY_LINES = 500
-QUALITY_RESERVED_NAMES = ["anthropic", "claude"]
QUALITY_EXCLUDED_DIRS = frozenset(
{
diff --git a/src/skillevaluator/models/quality.py b/src/skillevaluator/models/quality.py
index bcc083d2..37dfd11d 100644
--- a/src/skillevaluator/models/quality.py
+++ b/src/skillevaluator/models/quality.py
@@ -15,7 +15,6 @@ from dataclasses import dataclass, field
from skillevaluator.constants import (
QUALITY_CHARS_PER_TOKEN,
QUALITY_GRADE_THRESHOLDS,
- QUALITY_RECOMMENDED_MAX_TOKENS,
QUALITY_SCORE_WEIGHTS,
)
@@ -115,6 +114,7 @@ class QualityScoreResult:
# Metrics
total_tokens: int = 0
+ recommended_max_tokens: int | None = None # token budget in force; None when no config was applied
frontmatter_tokens: int = 0
instructions_tokens: int = 0
script_count: int = 0
@@ -162,7 +162,11 @@ class QualityScoreResult:
"total_tokens": self.total_tokens,
"estimated_tokens": self.total_tokens,
"estimate_method": f"characters/{QUALITY_CHARS_PER_TOKEN}",
- "recommended_max_tokens": QUALITY_RECOMMENDED_MAX_TOKENS,
+ **(
+ {"recommended_max_tokens": self.recommended_max_tokens}
+ if self.recommended_max_tokens is not None
+ else {}
+ ),
"frontmatter_tokens": self.frontmatter_tokens,
"instructions_tokens": self.instructions_tokens,
"script_count": self.script_count,
diff --git a/src/skillevaluator/quality_config.py b/src/skillevaluator/quality_config.py
index 7fcfd0d9..e6e1901f 100644
--- a/src/skillevaluator/quality_config.py
+++ b/src/skillevaluator/quality_config.py
@@ -7,6 +7,8 @@ from __future__ import annotations
import hashlib
import json
import re
+from collections.abc import Callable
+from functools import partial
from importlib.resources import files
from math import isfinite
from pathlib import Path
@@ -16,9 +18,7 @@ import yaml
DEFAULT_QUALITY_CONFIG = files("skillevaluator.config").joinpath("quality-default.yaml")
_ATX_HEADING_RE = re.compile(r"^(#{1,6})[ \t]+(.+?)(?:[ \t]+#+)?[ \t]*$")
-_TOP_LEVEL_KEYS = frozenset({"expected_headers", "error_handling"})
_EXPECTED_HEADER_KEYS = frozenset({"heading", "alternatives", "points", "message", "suggestion"})
-_ERROR_HANDLING_LIST_KEYS = {"mentioned": "terms", "scripts": "markers", "lib": "markers"}
class QualityConfigError(ValueError):
@@ -61,11 +61,69 @@ class ErrorHandlingConfig(TypedDict):
lib: CodeErrorHandlingRule
+class TokenBudgetRule(TypedDict):
+ """Deduction when the estimated SKILL.md token count is above max_tokens."""
+
+ points: int | float
+ message: str
+ suggestion: str
+ max_tokens: int
+
+
+class EfficiencyConfig(TypedDict):
+ """Efficiency rules; a rule with points 0 is skipped."""
+
+ token_budget: TokenBudgetRule
+
+
+class DescriptionTooShortRule(TypedDict):
+ """Deduction when the frontmatter description is shorter than min_chars."""
+
+ points: int | float
+ message: str
+ suggestion: str
+ min_chars: int
+
+
+class DescriptionTooLongRule(TypedDict):
+ """Deduction when the frontmatter description is longer than max_chars."""
+
+ points: int | float
+ message: str
+ suggestion: str
+ max_chars: int
+
+
+class DiscoverabilityConfig(TypedDict):
+ """Discoverability rules; a rule with points 0 is skipped."""
+
+ description_too_short: DescriptionTooShortRule
+ description_too_long: DescriptionTooLongRule
+
+
+class ReservedNameRule(TypedDict):
+ """Deduction when the frontmatter name contains one of the terms (whole word, any case)."""
+
+ points: int | float
+ message: str
+ suggestion: str
+ terms: list[str]
+
+
+class CorrectnessConfig(TypedDict):
+ """Correctness rules; a rule with points 0 is skipped."""
+
+ reserved_name: ReservedNameRule
+
+
class QualityConfig(TypedDict):
"""Validated deterministic quality configuration."""
expected_headers: list[ExpectedHeader]
error_handling: ErrorHandlingConfig
+ efficiency: EfficiencyConfig
+ discoverability: DiscoverabilityConfig
+ correctness: CorrectnessConfig
class QualityConfigProvenance(TypedDict):
@@ -124,17 +182,83 @@ def _validate_entries(value: object, source: str, location: str, *, ignore_case:
return list(value)
-def _parse_error_handling(raw: object, source: str, base: ErrorHandlingConfig | None) -> ErrorHandlingConfig:
+# A reserved word is matched against a skill name, which allows only letters, digits and hyphens.
+_RESERVED_TERM_RE = re.compile(r"[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*")
+
+
+def _validate_reserved_terms(value: object, source: str, location: str) -> list[str]:
+ """Validate reserved name words, stored without surrounding whitespace.
+
+ Unlike the generic entry lists, these are echoed in the finding and matched against a
+ constrained name format, so padded duplicates and words that can never match are rejected.
+ """
+ if not isinstance(value, list) or not value:
+ raise QualityConfigError(f"{source}: {location} must be a non-empty list")
+ terms: list[str] = []
+ seen: set[str] = set()
+ for index, entry in enumerate(value):
+ if not isinstance(entry, str) or not entry.strip():
+ raise QualityConfigError(f"{source}: {location}[{index}] must be a non-blank string")
+ term = entry.strip()
+ if not _RESERVED_TERM_RE.fullmatch(term):
+ raise QualityConfigError(
+ f"{source}: {location}[{index}] '{term}' can never match a skill name; "
+ "use only letters, digits and single hyphens between them"
+ )
+ if term.casefold() in seen:
+ raise QualityConfigError(f"{source}: duplicate entry '{term}' in {location}")
+ seen.add(term.casefold())
+ terms.append(term)
+ return terms
+
+
+# Upper bound for integer settings. YAML builds hex, octal and binary integers of any size, and
+# one past Python's int-to-str digit limit would crash the digest instead of failing as a usage error.
+_MAX_INT_SETTING = 10**9
+
+
+def _validate_positive_int(value: object, source: str, location: str) -> int:
+ if isinstance(value, bool) or not isinstance(value, int) or not 1 <= value <= _MAX_INT_SETTING:
+ raise QualityConfigError(f"{source}: {location} must be a positive integer no greater than {_MAX_INT_SETTING}")
+ return value
+
+
+# Sections made of named rules. Every rule takes points, message and suggestion, plus the one
+# rule-specific key listed here with the function that validates it.
+_RuleSetting = tuple[str, Callable[[object, str, str], object]]
+_RULE_SECTIONS: dict[str, dict[str, _RuleSetting]] = {
+ "error_handling": {
+ "mentioned": ("terms", partial(_validate_entries, ignore_case=True)),
+ "scripts": ("markers", partial(_validate_entries, ignore_case=False)),
+ "lib": ("markers", partial(_validate_entries, ignore_case=False)),
+ },
+ "efficiency": {
+ "token_budget": ("max_tokens", _validate_positive_int),
+ },
+ "discoverability": {
+ "description_too_short": ("min_chars", _validate_positive_int),
+ "description_too_long": ("max_chars", _validate_positive_int),
+ },
+ "correctness": {
+ "reserved_name": ("terms", _validate_reserved_terms),
+ },
+}
+_TOP_LEVEL_KEYS = frozenset({"expected_headers", *_RULE_SECTIONS})
+
+
+def _parse_rule_section(section: str, raw: object, source: str, base: dict | None) -> dict:
+ """Validate one rule section. With a base, keys the section omits keep the base value."""
+ rules = _RULE_SECTIONS[section]
if not isinstance(raw, dict):
- raise QualityConfigError(f"{source}: error_handling must be a mapping")
- _reject_unknown_keys(raw, frozenset(_ERROR_HANDLING_LIST_KEYS), source, "error_handling")
+ raise QualityConfigError(f"{source}: {section} must be a mapping")
+ _reject_unknown_keys(raw, frozenset(rules), source, section)
parsed = {}
- for name, list_key in _ERROR_HANDLING_LIST_KEYS.items():
- location = f"error_handling.{name}"
+ for name, (setting, validate_setting) in rules.items():
+ location = f"{section}.{name}"
block = raw.get(name) if base is None else raw.get(name, {})
if not isinstance(block, dict):
raise QualityConfigError(f"{source}: {location} must be a mapping")
- allowed = frozenset({"points", "message", "suggestion", list_key})
+ allowed = frozenset({"points", "message", "suggestion", setting})
_reject_unknown_keys(block, allowed, source, location)
if base is None:
missing = sorted(allowed - block.keys())
@@ -145,11 +269,9 @@ def _parse_error_handling(raw: object, source: str, base: ErrorHandlingConfig |
"points": _validate_points(merged["points"], source, location),
"message": _validate_text(merged["message"], source, f"{location}.message"),
"suggestion": _validate_text(merged["suggestion"], source, f"{location}.suggestion"),
- list_key: _validate_entries(
- merged[list_key], source, f"{location}.{list_key}", ignore_case=list_key == "terms"
- ),
+ setting: validate_setting(merged[setting], source, f"{location}.{setting}"),
}
- return parsed # type: ignore[return-value]
+ return parsed
class _UniqueKeySafeLoader(yaml.SafeLoader):
@@ -226,7 +348,6 @@ def _load(path: Path | None) -> tuple[QualityConfig, dict]:
raise QualityConfigError(f"{source}: expected_headers must be a list")
_reject_unknown_keys(raw, _TOP_LEVEL_KEYS, source, "top level")
if not headers_declared:
- packaged_config = load_quality_config()
raw = {**raw, "expected_headers": []}
expected_headers: list[ExpectedHeader] = []
@@ -274,23 +395,24 @@ def _load(path: Path | None) -> tuple[QualityConfig, dict]:
)
if path is None:
- error_handling = _parse_error_handling(raw.get("error_handling"), source, base=None)
- config: QualityConfig = {"expected_headers": expected_headers, "error_handling": error_handling}
+ sections = {name: _parse_rule_section(name, raw.get(name), source, base=None) for name in _RULE_SECTIONS}
+ config: QualityConfig = {"expected_headers": expected_headers, **sections} # type: ignore[typeddict-item]
return config, dict(config)
- raw_error_handling = raw.get("error_handling", {})
- packaged = load_quality_config()["error_handling"]
+ packaged = load_quality_config()
if not headers_declared:
- expected_headers = [dict(rule) for rule in packaged_config["expected_headers"]] # type: ignore[misc]
- error_handling = _parse_error_handling(raw_error_handling, source, base=packaged)
+ expected_headers = [dict(rule) for rule in packaged["expected_headers"]] # type: ignore[misc]
declared: dict = {"expected_headers": expected_headers} if headers_declared else {}
- declared_error_handling = {
- name: {key: error_handling[name][key] for key in block}
- for name, block in raw_error_handling.items()
- if block
- }
- if declared_error_handling:
- declared["error_handling"] = declared_error_handling
- return {"expected_headers": expected_headers, "error_handling": error_handling}, declared
+ sections = {}
+ for name in _RULE_SECTIONS:
+ raw_section = raw.get(name, {})
+ sections[name] = _parse_rule_section(name, raw_section, source, base=packaged[name]) # type: ignore[literal-required]
+ # Only the keys the file sets are declared, so the digest ignores inherited packaged values.
+ declared_rules = {
+ rule: {key: sections[name][rule][key] for key in block} for rule, block in raw_section.items() if block
+ }
+ if declared_rules:
+ declared[name] = declared_rules
+ return {"expected_headers": expected_headers, **sections}, declared # type: ignore[typeddict-item]
def quality_config_digest(config: QualityConfig | dict) -> str:
diff --git a/src/skillevaluator/validators/quality_score.py b/src/skillevaluator/validators/quality_score.py
index 1b26dae1..05b6dab3 100644
--- a/src/skillevaluator/validators/quality_score.py
+++ b/src/skillevaluator/validators/quality_score.py
@@ -34,8 +34,6 @@ from skillevaluator.constants import (
QUALITY_CHARS_PER_TOKEN,
QUALITY_DEFAULT_MIN_SCORE,
QUALITY_EXCLUDED_DIRS,
- QUALITY_RECOMMENDED_MAX_TOKENS,
- QUALITY_RESERVED_NAMES,
QUALITY_RESOURCE_DIRS,
)
from skillevaluator.logging_config import get_logger
@@ -407,7 +405,10 @@ class QualityScoreValidator(ValidatorBase):
validator_name="QUALITY",
validator_description=self.description,
)
- qs = QualityScoreResult(skill_name=skill_path.name)
+ qs = QualityScoreResult(
+ skill_name=skill_path.name,
+ recommended_max_tokens=self.quality_config["efficiency"]["token_budget"]["max_tokens"],
+ )
manifest = self._find_skill_manifest(skill_path)
if not manifest:
@@ -591,12 +592,14 @@ class QualityScoreValidator(ValidatorBase):
f"Invalid name format: '{name}' (lowercase/numbers/hyphens only)",
"Use only lowercase letters, numbers, and hyphens",
)
- if _contains_any_term(name, QUALITY_RESERVED_NAMES):
+ reserved = self.quality_config["correctness"]["reserved_name"]
+ matched = [term for term in reserved["terms"] if _contains_term(name, term)]
+ if matched and reserved["points"]:
dim.deduct(
- 15,
+ reserved["points"],
"error",
- "Name contains reserved word (anthropic, claude)",
- "Remove reserved words from skill name",
+ f"{reserved['message']}: {', '.join(matched)}",
+ reserved["suggestion"],
)
if XML_TAG_RE.search(name):
dim.deduct(15, "error", "Name contains XML tags", "Remove XML tags from skill name")
@@ -720,19 +723,22 @@ class QualityScoreValidator(ValidatorBase):
desc = str(frontmatter.get("description", "")).strip()
if desc:
- if len(desc) < 20:
+ too_short = self.quality_config["discoverability"]["description_too_short"]
+ if too_short["points"] and len(desc) < too_short["min_chars"]:
dim.deduct(
- 20,
+ too_short["points"],
"warning",
- f"Description too short ({len(desc)} chars, recommend 50-150)",
- "Add more context: what tasks does this skill handle?",
+ f"{too_short['message']}: {len(desc)} chars, minimum {too_short['min_chars']}",
+ too_short["suggestion"],
)
- elif len(desc) > 200:
+ # Checked independently of the minimum, so neither limit can hide the other rule.
+ too_long = self.quality_config["discoverability"]["description_too_long"]
+ if too_long["points"] and len(desc) > too_long["max_chars"]:
dim.deduct(
- 5,
+ too_long["points"],
"info",
- f"Description very long ({len(desc)} chars, recommend 50-150)",
- "Keep descriptions concise for progressive disclosure",
+ f"{too_long['message']}: {len(desc)} chars, maximum {too_long['max_chars']}",
+ too_long["suggestion"],
)
trigger_words = ["use", "when", "for", "helps", "allows"]
@@ -864,19 +870,16 @@ class QualityScoreValidator(ValidatorBase):
# The token budget is a recommendation: exceeding it is advisory (MEDIUM),
# and the deduction still counts toward the --min-score gate.
- if qs.total_tokens > QUALITY_RECOMMENDED_MAX_TOKENS:
+ budget = self.quality_config["efficiency"]["token_budget"]
+ if budget["points"] and qs.total_tokens > budget["max_tokens"]:
dim.deduct(
- 15,
+ budget["points"],
"warning",
(
- f"Large skill (~{qs.total_tokens} estimated tokens at {QUALITY_CHARS_PER_TOKEN} characters per token, "
- f"recommended max <{QUALITY_RECOMMENDED_MAX_TOKENS}; a real tokenizer may count more). "
- f"Per agentskills.io, SKILL.md should be concise (~500 lines) — "
- f"large skill bodies increase token cost after invocation; long or unfocused "
- f"top-level descriptions can degrade agent routing accuracy"
+ f"{budget['message']}: ~{qs.total_tokens} estimated tokens at {QUALITY_CHARS_PER_TOKEN} "
+ f"characters per token, recommended max <{budget['max_tokens']}; a real tokenizer may count more"
),
- "Keep required sections concise; move detailed examples, reference material, "
- "and supporting docs to the references/ directory",
+ budget["suggestion"],
)
# Repetition (compare against non-empty lines to avoid false positives from blank lines)
diff --git a/tests/test_metrics_reference_docs.py b/tests/test_metrics_reference_docs.py
index b51d511f..ff296bef 100644
--- a/tests/test_metrics_reference_docs.py
+++ b/tests/test_metrics_reference_docs.py
@@ -48,13 +48,12 @@ from skillevaluator.constants import (
QUALITY_CHARS_PER_TOKEN,
QUALITY_DEFAULT_MIN_SCORE,
QUALITY_GRADE_THRESHOLDS,
- QUALITY_RECOMMENDED_MAX_TOKENS,
QUALITY_SCORE_WEIGHTS,
TIER3_LIFT_FAIL_THRESHOLD,
TIER3_LIFT_PASS_THRESHOLD,
TOKEN_EFFICIENCY_HALF_LIFE,
)
-from skillevaluator.quality_config import load_quality_config_with_provenance
+from skillevaluator.quality_config import load_quality_config, load_quality_config_with_provenance
from skillevaluator.tier3 import dataset_sufficiency
from skillevaluator.tier3.eval_core.llm_judge import _ACCURACY_CRITERIA
from skillevaluator.tier3.harbor.collector import (
@@ -396,7 +395,12 @@ def test_quality_grades_and_minimum_match_constants() -> None:
def test_token_estimate_divisor_matches_constants() -> None:
assert int(_every(r"`len\(SKILL\.md\) // (\d+)`", DOC)) == QUALITY_CHARS_PER_TOKEN
budget = int(_one(r"Over the ([\d,]+) estimated-token budget").group(1).replace(",", ""))
- assert budget == QUALITY_RECOMMENDED_MAX_TOKENS
+ assert budget == load_quality_config()["efficiency"]["token_budget"]["max_tokens"]
+
+
+def test_description_minimum_matches_the_packaged_quality_config() -> None:
+ minimum = int(_one(r"Description under (\d+) characters").group(1))
+ assert minimum == load_quality_config()["discoverability"]["description_too_short"]["min_chars"]
def _quality_score_functions() -> dict[str, ast.FunctionDef]:
@@ -464,7 +468,7 @@ def _deduction_amounts_by_area() -> dict[str, set[int]]:
if not (isinstance(call, ast.Call) and isinstance(call.func, ast.Attribute) and call.func.attr == "deduct"):
continue
if not (call.args and isinstance(call.args[0], ast.Constant) and isinstance(call.args[0].value, int)):
- continue # config-driven amount; covered by the reliability test instead
+ continue # config-driven amount; the tests add it from the packaged quality config
target = call.func.value
if isinstance(target, ast.Attribute) and target.attr in areas:
amounts[target.attr].add(call.args[0].value)
@@ -480,6 +484,10 @@ def _documented_amounts(cell: str) -> set[int]:
def test_tier1_deduction_amounts_are_fully_documented() -> None:
"""Every deduction size the scorer can apply appears in the page, and vice versa."""
source = _deduction_amounts_by_area()
+ # Rule sections named after an area take their deduction from the packaged quality config.
+ packaged = load_quality_config()
+ for area in ("correctness", "discoverability", "efficiency"):
+ source[area] |= {int(rule["points"]) for rule in packaged.get(area, {}).values()}
rows = _table_rows("Area")
documented = {area.lower(): _documented_amounts(cells[1]) for area, cells in rows.items() if len(cells) > 1}
diff --git a/tests/test_quality_config.py b/tests/test_quality_config.py
index 3cb33f80..a501d515 100644
--- a/tests/test_quality_config.py
+++ b/tests/test_quality_config.py
@@ -466,3 +466,326 @@ def test_digest_does_not_declare_packaged_headings_when_the_key_is_omitted(tmp_p
assert _digest(omitted) != _digest(empty)
assert _digest(bare) == quality_config_digest({})
assert _digest(bare) != _digest(None)
+
+
+# Longer than Python's 4300-digit int-to-str limit once written in decimal; YAML still loads it.
+_HUGE_HEX = "0x" + "f" * 4000
+
+
+def test_integer_settings_accept_the_largest_allowed_value(tmp_path: Path) -> None:
+ config = load_quality_config(_write_config(tmp_path, "efficiency:\n token_budget:\n max_tokens: 1000000000\n"))
+
+ assert config["efficiency"]["token_budget"]["max_tokens"] == 10**9
+
+
+PACKAGED_TOKEN_BUDGET = {
+ "points": 15,
+ "message": "Large skill",
+ "suggestion": (
+ "Per agentskills.io, SKILL.md should be concise (~500 lines) — large skill bodies increase "
+ "token cost after invocation; long or unfocused top-level descriptions can degrade agent routing accuracy. "
+ "Keep required sections concise; move detailed examples, reference material, "
+ "and supporting docs to the references/ directory"
+ ),
+ "max_tokens": 5000,
+}
+
+
+def test_packaged_token_budget_matches_former_hard_coded_values() -> None:
+ token_budget = load_quality_config()["efficiency"]["token_budget"]
+
+ assert token_budget == PACKAGED_TOKEN_BUDGET
+ assert type(token_budget["points"]) is int
+
+
+def test_custom_file_with_only_a_token_limit_keeps_every_other_packaged_value(tmp_path: Path) -> None:
+ config_path = tmp_path / "quality.yaml"
+ config_path.write_text("efficiency:\n token_budget:\n max_tokens: 8000\n", encoding="utf-8")
+ packaged = load_quality_config()
+
+ config = load_quality_config(config_path)
+
+ assert config["efficiency"]["token_budget"] == {**PACKAGED_TOKEN_BUDGET, "max_tokens": 8000}
+ assert config["expected_headers"] == packaged["expected_headers"]
+ assert config["error_handling"] == packaged["error_handling"]
+
+
+def test_custom_file_without_efficiency_keeps_the_packaged_token_budget(tmp_path: Path) -> None:
+ assert load_quality_config(_write_config(tmp_path, ""))["efficiency"]["token_budget"] == PACKAGED_TOKEN_BUDGET
+
+
+ ("body", "match"),
+ [
+ ("efficiency: []\n", r"efficiency must be a mapping"),
+ ("efficiency:\n", r"efficiency must be a mapping"),
+ ("efficiency:\n repetition: {}\n", r"unknown key\(s\) in efficiency: repetition"),
+ ("efficiency:\n token_budget: 8000\n", r"efficiency\.token_budget must be a mapping"),
+ (
+ "efficiency:\n token_budget:\n max_token: 8000\n",
+ r"unknown key\(s\) in efficiency\.token_budget: max_token "
+ r"\(allowed: max_tokens, message, points, suggestion\)",
+ ),
+ ("efficiency:\n token_budget:\n max_tokens: 0\n", r"efficiency\.token_budget\.max_tokens must be a positive"),
+ ("efficiency:\n token_budget:\n max_tokens: -1\n", r"efficiency\.token_budget\.max_tokens must be a positive"),
+ ("efficiency:\n token_budget:\n max_tokens: 5000.0\n", r"efficiency\.token_budget\.max_tokens must be a positive"),
+ ("efficiency:\n token_budget:\n max_tokens: true\n", r"efficiency\.token_budget\.max_tokens must be a positive"),
+ ('efficiency:\n token_budget:\n max_tokens: "8000"\n', r"efficiency\.token_budget\.max_tokens must be a positive"),
+ ("efficiency:\n token_budget:\n max_tokens:\n", r"efficiency\.token_budget\.max_tokens must be a positive"),
+ (
+ "efficiency:\n token_budget:\n max_tokens: 1000000001\n",
+ r"\.max_tokens must be a positive integer no greater than 1000000000",
+ ),
+ (f"efficiency:\n token_budget:\n max_tokens: {_HUGE_HEX}\n", r"\.max_tokens must be a positive integer no"),
+ ("efficiency:\n token_budget:\n points: -1\n", r"efficiency\.token_budget\.points must be a non-negative"),
+ ('efficiency:\n token_budget:\n message: ""\n', r"efficiency\.token_budget\.message must be a non-empty"),
+ ],
+)
+def test_quality_config_rejects_invalid_efficiency(tmp_path: Path, body: str, match: str) -> None:
+ config_path = _write_config(tmp_path, body)
+
+ with pytest.raises(QualityConfigError, match=rf"^{tmp_path}.*{match}"):
+ load_quality_config(config_path)
+
+
+def test_packaged_file_must_declare_every_token_budget_key(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
+ from skillevaluator import quality_config
+
+ incomplete = tmp_path / "incomplete-default.yaml"
+ incomplete.write_text(
+ quality_config.DEFAULT_QUALITY_CONFIG.read_text(encoding="utf-8").replace(" max_tokens: 5000\n", ""),
+ encoding="utf-8",
+ )
+ monkeypatch.setattr(quality_config, "DEFAULT_QUALITY_CONFIG", incomplete)
+
+ with pytest.raises(QualityConfigError, match=r"efficiency\.token_budget is missing key\(s\): max_tokens"):
+ load_quality_config()
+
+
+def test_custom_digest_declares_only_the_efficiency_keys_the_file_sets(tmp_path: Path) -> None:
+ def write(name: str, body: str) -> Path:
+ path = tmp_path / name
+ path.write_text(body, encoding="utf-8")
+ return path
+
+ limit_only = write("limit-only.yaml", "efficiency: {token_budget: {max_tokens: 8000}}\n")
+ other_limit = write("other-limit.yaml", "efficiency: {token_budget: {max_tokens: 9000}}\n")
+ empty_rule = write("empty-rule.yaml", "efficiency: {token_budget: {}}\n")
+ both_sections = write(
+ "both.yaml", "efficiency: {token_budget: {max_tokens: 8000}}\nerror_handling: {lib: {points: 0}}\n"
+ )
+
+ assert _digest(limit_only) == quality_config_digest({"efficiency": {"token_budget": {"max_tokens": 8000}}})
+ assert _digest(other_limit) != _digest(limit_only)
+ assert _digest(empty_rule) == quality_config_digest({})
+ assert _digest(both_sections) == quality_config_digest(
+ {"efficiency": {"token_budget": {"max_tokens": 8000}}, "error_handling": {"lib": {"points": 0}}}
+ )
+
+
+PACKAGED_DESCRIPTION_TOO_SHORT = {
+ "points": 20,
+ "message": "Description too short (recommend 50-150 chars)",
+ "suggestion": "Add more context: what tasks does this skill handle?",
+ "min_chars": 20,
+}
+
+
+def test_packaged_description_too_short_matches_former_hard_coded_values() -> None:
+ rule = load_quality_config()["discoverability"]["description_too_short"]
+
+ assert rule == PACKAGED_DESCRIPTION_TOO_SHORT
+ assert type(rule["points"]) is int
+
+
+PACKAGED_DESCRIPTION_TOO_LONG = {
+ "points": 5,
+ "message": "Description very long (recommend 50-150 chars)",
+ "suggestion": "Keep descriptions concise for progressive disclosure",
+ "max_chars": 200,
+}
+
+
+def test_packaged_description_too_long_matches_former_hard_coded_values() -> None:
+ rule = load_quality_config()["discoverability"]["description_too_long"]
+
+ assert rule == PACKAGED_DESCRIPTION_TOO_LONG
+ assert type(rule["points"]) is int
+
+
+def test_custom_file_with_only_a_description_maximum_keeps_every_other_packaged_value(tmp_path: Path) -> None:
+ config_path = tmp_path / "quality.yaml"
+ config_path.write_text("discoverability:\n description_too_long:\n max_chars: 300\n", encoding="utf-8")
+ packaged = load_quality_config()
+
+ config = load_quality_config(config_path)
+
+ assert config["discoverability"] == {
+ "description_too_short": PACKAGED_DESCRIPTION_TOO_SHORT,
+ "description_too_long": {**PACKAGED_DESCRIPTION_TOO_LONG, "max_chars": 300},
+ }
+ assert {key: value for key, value in config.items() if key != "discoverability"} == {
+ key: value for key, value in packaged.items() if key != "discoverability"
+ }
+
+
+def test_custom_file_with_only_a_description_minimum_keeps_every_other_packaged_value(tmp_path: Path) -> None:
+ config_path = tmp_path / "quality.yaml"
+ config_path.write_text("discoverability:\n description_too_short:\n min_chars: 40\n", encoding="utf-8")
+ packaged = load_quality_config()
+
+ config = load_quality_config(config_path)
+
+ assert config["discoverability"] == {
+ "description_too_short": {**PACKAGED_DESCRIPTION_TOO_SHORT, "min_chars": 40},
+ "description_too_long": PACKAGED_DESCRIPTION_TOO_LONG,
+ }
+ assert {key: value for key, value in config.items() if key != "discoverability"} == {
+ key: value for key, value in packaged.items() if key != "discoverability"
+ }
+
+
+ ("body", "match"),
+ [
+ ("discoverability: []\n", r"discoverability must be a mapping"),
+ ("discoverability:\n vague_words: {}\n", r"unknown key\(s\) in discoverability: vague_words"),
+ ("discoverability:\n description_too_long: 200\n", r"discoverability\.description_too_long must be a mapping"),
+ (
+ "discoverability:\n description_too_long:\n max_char: 300\n",
+ r"unknown key\(s\) in discoverability\.description_too_long: max_char "
+ r"\(allowed: max_chars, message, points, suggestion\)",
+ ),
+ ("discoverability:\n description_too_long:\n max_chars: 0\n", r"\.max_chars must be a positive integer"),
+ ("discoverability:\n description_too_long:\n max_chars: 200.5\n", r"\.max_chars must be a positive integer"),
+ ("discoverability:\n description_too_long:\n max_chars: true\n", r"\.max_chars must be a positive integer"),
+ (
+ f"discoverability:\n description_too_long:\n max_chars: {_HUGE_HEX}\n",
+ r"\.max_chars must be a positive integer no greater than 1000000000",
+ ),
+ ("discoverability:\n description_too_long:\n points: -5\n", r"\.points must be a non-negative"),
+ ("discoverability:\n description_too_short: 20\n", r"discoverability\.description_too_short must be a mapping"),
+ (
+ "discoverability:\n description_too_short:\n min_char: 30\n",
+ r"unknown key\(s\) in discoverability\.description_too_short: min_char "
+ r"\(allowed: message, min_chars, points, suggestion\)",
+ ),
+ ("discoverability:\n description_too_short:\n min_chars: 0\n", r"\.min_chars must be a positive integer"),
+ ("discoverability:\n description_too_short:\n min_chars: 20.5\n", r"\.min_chars must be a positive integer"),
+ ("discoverability:\n description_too_short:\n min_chars: true\n", r"\.min_chars must be a positive integer"),
+ (
+ f"discoverability:\n description_too_short:\n min_chars: {_HUGE_HEX}\n",
+ r"\.min_chars must be a positive integer no greater than 1000000000",
+ ),
+ ("discoverability:\n description_too_short:\n points: -5\n", r"\.points must be a non-negative"),
+ ],
+)
+def test_quality_config_rejects_invalid_discoverability(tmp_path: Path, body: str, match: str) -> None:
+ config_path = _write_config(tmp_path, body)
+
+ with pytest.raises(QualityConfigError, match=rf"^{tmp_path}.*{match}"):
+ load_quality_config(config_path)
+
+
+def test_custom_digest_declares_only_the_discoverability_keys_the_file_sets(tmp_path: Path) -> None:
+ config_path = tmp_path / "quality.yaml"
+ config_path.write_text("discoverability: {description_too_short: {min_chars: 40}}\n", encoding="utf-8")
+
+ assert _digest(config_path) == quality_config_digest(
+ {"discoverability": {"description_too_short": {"min_chars": 40}}}
+ )
+
+ config_path.write_text("discoverability: {description_too_long: {max_chars: 300}}\n", encoding="utf-8")
+
+ assert _digest(config_path) == quality_config_digest(
+ {"discoverability": {"description_too_long": {"max_chars": 300}}}
+ )
+
+
+PACKAGED_RESERVED_NAME = {
+ "points": 15,
+ "message": "Name contains reserved word",
+ "suggestion": "Remove reserved words from skill name",
+ "terms": ["anthropic", "claude"],
+}
+
+
+def test_packaged_reserved_name_matches_former_hard_coded_values() -> None:
+ rule = load_quality_config()["correctness"]["reserved_name"]
+
+ assert rule == PACKAGED_RESERVED_NAME
+ assert type(rule["points"]) is int
+
+
+def test_custom_file_with_only_reserved_terms_keeps_every_other_packaged_value(tmp_path: Path) -> None:
+ config_path = tmp_path / "quality.yaml"
+ config_path.write_text("correctness:\n reserved_name:\n terms: [acme]\n", encoding="utf-8")
+ packaged = load_quality_config()
+
+ config = load_quality_config(config_path)
+
+ assert config["correctness"]["reserved_name"] == {**PACKAGED_RESERVED_NAME, "terms": ["acme"]}
+ assert {key: value for key, value in config.items() if key != "correctness"} == {
+ key: value for key, value in packaged.items() if key != "correctness"
+ }
+
+
+def test_reserved_terms_are_stored_without_surrounding_whitespace(tmp_path: Path) -> None:
+ config_path = _write_config(tmp_path, 'correctness:\n reserved_name:\n terms: [" Acme ", claude-code]\n')
+
+ assert load_quality_config(config_path)["correctness"]["reserved_name"]["terms"] == ["Acme", "claude-code"]
+ assert _digest(config_path) == quality_config_digest(
+ {"expected_headers": [], "correctness": {"reserved_name": {"terms": ["Acme", "claude-code"]}}}
+ )
+
+
+ ("body", "match"),
+ [
+ ("correctness: []\n", r"correctness must be a mapping"),
+ ("correctness:\n name_format: {}\n", r"unknown key\(s\) in correctness: name_format"),
+ ("correctness:\n reserved_name: [acme]\n", r"correctness\.reserved_name must be a mapping"),
+ (
+ "correctness:\n reserved_name:\n words: [acme]\n",
+ r"unknown key\(s\) in correctness\.reserved_name: words \(allowed: message, points, suggestion, terms\)",
+ ),
+ ("correctness:\n reserved_name:\n terms: []\n", r"correctness\.reserved_name\.terms must be a non-empty list"),
+ ("correctness:\n reserved_name:\n terms: acme\n", r"correctness\.reserved_name\.terms must be a non-empty list"),
+ ('correctness:\n reserved_name:\n terms: [" "]\n', r"correctness\.reserved_name\.terms\[0\] must be a non-blank"),
+ (
+ "correctness:\n reserved_name:\n terms: [Acme, acme]\n",
+ r"duplicate entry 'acme' in correctness\.reserved_name\.terms",
+ ),
+ ("correctness:\n reserved_name:\n points: -1\n", r"correctness\.reserved_name\.points must be a non-negative"),
+ (
+ 'correctness:\n reserved_name:\n terms: [claude, "claude "]\n',
+ r"duplicate entry 'claude' in correctness\.reserved_name\.terms",
+ ),
+ (
+ 'correctness:\n reserved_name:\n terms: [claude, " Claude"]\n',
+ r"duplicate entry 'Claude' in correctness\.reserved_name\.terms",
+ ),
+ (
+ 'correctness:\n reserved_name:\n terms: ["Claude Code"]\n',
+ r"correctness\.reserved_name\.terms\[0\] 'Claude Code' can never match a skill name",
+ ),
+ (
+ "correctness:\n reserved_name:\n terms: [acme, claude_code]\n",
+ r"correctness\.reserved_name\.terms\[1\] 'claude_code' can never match a skill name",
+ ),
+ ("correctness:\n reserved_name:\n terms: [-acme]\n", r"terms\[0\] '-acme' can never match a skill name"),
+ ("correctness:\n reserved_name:\n terms: [acme--corp]\n", r"'acme--corp' can never match a skill name"),
+ ],
+)
+def test_quality_config_rejects_invalid_correctness(tmp_path: Path, body: str, match: str) -> None:
+ config_path = _write_config(tmp_path, body)
+
+ with pytest.raises(QualityConfigError, match=rf"^{tmp_path}.*{match}"):
+ load_quality_config(config_path)
+
+
+def test_custom_digest_declares_only_the_correctness_keys_the_file_sets(tmp_path: Path) -> None:
+ config_path = tmp_path / "quality.yaml"
+ config_path.write_text("correctness: {reserved_name: {terms: [acme]}}\n", encoding="utf-8")
+
+ assert _digest(config_path) == quality_config_digest({"correctness": {"reserved_name": {"terms": ["acme"]}}})
diff --git a/tests/validators/test_quality_score.py b/tests/validators/test_quality_score.py
index 61a28417..c29dcd8c 100644
--- a/tests/validators/test_quality_score.py
+++ b/tests/validators/test_quality_score.py
@@ -620,7 +620,7 @@ class TestQualityScoreValidator:
assert large_findings[0].severity == Severity.MEDIUM
assert "recommended max <5000" in large_findings[0].message
assert "estimated tokens" in large_findings[0].message
- assert "long or unfocused top-level descriptions" in large_findings[0].message
+ assert "long or unfocused top-level descriptions" in large_findings[0].suggestion
assert "Keep required sections concise" in large_findings[0].suggestion
assert "references/" in large_findings[0].suggestion
assert result.passed, result.errors
@@ -957,12 +957,12 @@ class TestQualityScoreDeterministicContracts:
def test_reserved_names_match_complete_name_segments(self, tmp_path: Path):
messages = _finding_messages(_write_issue_skill(tmp_path, name="philanthropic-grant-matcher"))
- assert "Name contains reserved word (anthropic, claude)" not in messages
+ assert not any("reserved word" in message for message in messages)
def test_reserved_name_segment_is_still_reported(self, tmp_path: Path):
messages = _finding_messages(_write_issue_skill(tmp_path, name="anthropic-grant-matcher"))
- assert "Name contains reserved word (anthropic, claude)" in messages
+ assert "Name contains reserved word: anthropic" in messages
def test_person_phrases_do_not_match_inside_words(self, tmp_path: Path):
messages = _finding_messages(
@@ -1694,6 +1694,362 @@ class TestReliabilityErrorHandlingConfig:
assert not _contains_any_word("nothing here", ["error", "failure"])
+def _write_sized_skill(tmp_path: Path, characters: int) -> Path:
+ """Write a skill whose SKILL.md is exactly ``characters`` long, so its estimate is characters // 4."""
+ skill_dir = tmp_path / "sized-skill"
+ skill_dir.mkdir(parents=True)
+ head = (
+ "---\nname: sized-skill\ndescription: A skill of a known size. Use for testing the token budget.\n---\n\n"
+ "# Sized Skill\n\n## Instructions\n\n1. Run the skill\n\n## Examples\n\n```\nexample\n```\n\n"
+ )
+ filler = "".join(f"Filler line number {index} for the token budget.\n" for index in range(characters // 20))
+ (skill_dir / "SKILL.md").write_text((head + filler)[: characters - 1] + "\n", encoding="utf-8")
+ return skill_dir
+
+
+def _token_budget_issues(result) -> list[dict]:
+ issues = result.metadata["quality_scores"]["dimensions"]["efficiency"]["issues"]
+ return [issue for issue in issues if "recommended max" in issue["message"]]
+
+
+class TestEfficiencyTokenBudgetConfig:
+ def test_packaged_budget_fires_only_above_5000_estimated_tokens(self, tmp_path: Path):
+ at_limit = _validate_with(_write_sized_skill(tmp_path / "at", 20003), tmp_path)
+ over_limit = _validate_with(_write_sized_skill(tmp_path / "over", 20004), tmp_path)
+
+ assert at_limit.metadata["quality_scores"]["metrics"]["total_tokens"] == 5000
+ assert _token_budget_issues(at_limit) == []
+ assert over_limit.metadata["quality_scores"]["metrics"]["total_tokens"] == 5001
+ (issue,) = _token_budget_issues(over_limit)
+ assert issue["deduction"] == 15
+ assert issue["severity"] == "warning"
+ assert issue["message"] == (
+ "Large skill: ~5001 estimated tokens at 4 characters per token, "
+ "recommended max <5000; a real tokenizer may count more"
+ )
+ # Report summaries cut a finding message at 160 characters; the estimate and limit must survive.
+ assert len(issue["message"]) <= 160
+ assert issue["suggestion"].startswith("Per agentskills.io, SKILL.md should be concise")
+
+ def test_custom_limit_moves_the_threshold_and_the_reported_limit(self, tmp_path: Path):
+ skill_dir = _write_sized_skill(tmp_path, 24000)
+
+ raised = _validate_with(skill_dir, tmp_path, "efficiency:\n token_budget:\n max_tokens: 8000\n")
+ lowered = _validate_with(skill_dir, tmp_path, "efficiency:\n token_budget:\n max_tokens: 100\n")
+
+ assert _token_budget_issues(raised) == []
+ assert raised.metadata["quality_scores"]["metrics"]["recommended_max_tokens"] == 8000
+ (issue,) = _token_budget_issues(lowered)
+ assert issue["message"].endswith(": ~6000 estimated tokens at 4 characters per token, recommended max <100; a real tokenizer may count more")
+ assert lowered.metadata["quality_scores"]["metrics"]["recommended_max_tokens"] == 100
+
+ def test_report_metric_is_the_packaged_limit_without_a_custom_file(self, tmp_path: Path):
+ result = _validate_with(_write_sized_skill(tmp_path, 400), tmp_path)
+
+ assert result.metadata["quality_scores"]["metrics"]["recommended_max_tokens"] == 5000
+
+ def test_custom_points_message_and_suggestion_are_used(self, tmp_path: Path):
+ config = (
+ "efficiency:\n token_budget:\n points: 40\n"
+ " message: Over the team budget\n suggestion: Split the skill\n"
+ )
+
+ result = _validate_with(_write_sized_skill(tmp_path, 24000), tmp_path, config)
+
+ (issue,) = _token_budget_issues(result)
+ assert issue["message"] == (
+ "Over the team budget: ~6000 estimated tokens at 4"
+ " characters per token, recommended max <5000; a real tokenizer may count more"
+ )
+ assert issue["suggestion"] == "Split the skill"
+ assert issue["deduction"] == 40
+
+ def test_zero_points_turns_the_rule_off_but_keeps_the_metrics(self, tmp_path: Path):
+ skill_dir = _write_sized_skill(tmp_path, 24000)
+ default = _validate_with(skill_dir, tmp_path)
+
+ disabled = _validate_with(skill_dir, tmp_path, "efficiency:\n token_budget:\n points: 0\n")
+
+ assert _token_budget_issues(disabled) == []
+ metrics = disabled.metadata["quality_scores"]["metrics"]
+ assert metrics["total_tokens"] == 6000
+ assert metrics["recommended_max_tokens"] == 5000
+ dimensions = disabled.metadata["quality_scores"]["dimensions"]
+ assert dimensions["efficiency"]["score"] == default.metadata["quality_scores"]["dimensions"]["efficiency"]["score"] + 15
+
+ def test_result_built_without_a_config_omits_the_limit(self):
+ assert "recommended_max_tokens" not in QualityScoreResult(skill_name="test").to_dict()["metrics"]
+
+
+def _write_described_skill(tmp_path: Path, description: str) -> Path:
+ skill_dir = tmp_path / "described-skill"
+ skill_dir.mkdir(parents=True)
+ (skill_dir / "SKILL.md").write_text(
+ f"---\nname: described-skill\ndescription: {description}\n---\n\n"
+ "# Described Skill\n\n## Instructions\n\n1. Run the skill\n",
+ encoding="utf-8",
+ )
+ return skill_dir
+
+
+def _short_description_issues(result) -> list[dict]:
+ issues = result.metadata["quality_scores"]["dimensions"]["discoverability"]["issues"]
+ return [issue for issue in issues if "chars, minimum" in issue["message"]]
+
+
+def _long_description_issues(result) -> list[dict]:
+ issues = result.metadata["quality_scores"]["dimensions"]["discoverability"]["issues"]
+ return [issue for issue in issues if "chars, maximum" in issue["message"]]
+
+
+class TestDiscoverabilityDescriptionTooLongConfig:
+ def test_packaged_rule_fires_only_above_200_characters(self, tmp_path: Path):
+ at_maximum = _validate_with(_write_described_skill(tmp_path / "at", "Use for logs. " + "x" * 186), tmp_path)
+ above = _validate_with(_write_described_skill(tmp_path / "above", "Use for logs. " + "x" * 187), tmp_path)
+
+ assert _long_description_issues(at_maximum) == []
+ (issue,) = _long_description_issues(above)
+ assert issue["message"] == "Description very long (recommend 50-150 chars): 201 chars, maximum 200"
+ assert issue["suggestion"] == "Keep descriptions concise for progressive disclosure"
+ assert issue["deduction"] == 5
+ assert issue["severity"] == "info"
+
+ def test_custom_maximum_moves_the_threshold_in_both_directions(self, tmp_path: Path):
+ config = "discoverability:\n description_too_long:\n max_chars: {}\n"
+ long_skill = _write_described_skill(tmp_path / "long", "Use for logs. " + "x" * 236)
+ short_skill = _write_described_skill(tmp_path / "short", "Use for parsing application logs")
+
+ raised = _validate_with(long_skill, tmp_path, config.format(300))
+ lowered = _validate_with(short_skill, tmp_path, config.format(30))
+
+ assert _long_description_issues(raised) == []
+ (issue,) = _long_description_issues(lowered)
+ assert issue["message"].endswith(": 32 chars, maximum 30")
+ assert _long_description_issues(_validate_with(short_skill, tmp_path)) == []
+
+ @pytest.mark.parametrize("points", [0, 5])
+ def test_maximum_below_the_minimum_keeps_the_short_description_rule(self, tmp_path: Path, points: int):
+ skill_dir = _write_described_skill(tmp_path, "Use for logs")
+ config = f"discoverability:\n description_too_long:\n max_chars: 10\n points: {points}\n"
+
+ result = _validate_with(skill_dir, tmp_path, config)
+
+ (short,) = _short_description_issues(result)
+ assert short["message"].endswith(": 12 chars, minimum 20")
+ if points:
+ (long,) = _long_description_issues(result)
+ assert long["message"].endswith(": 12 chars, maximum 10")
+ else:
+ assert _long_description_issues(result) == []
+
+ def test_custom_points_message_and_suggestion_are_used(self, tmp_path: Path):
+ config = (
+ "discoverability:\n description_too_long:\n points: 3\n"
+ " message: Description runs long\n suggestion: Trim it\n"
+ )
+
+ result = _validate_with(_write_described_skill(tmp_path, "Use for logs. " + "x" * 236), tmp_path, config)
+
+ (issue,) = _long_description_issues(result)
+ assert issue["message"] == "Description runs long: 250 chars, maximum 200"
+ assert issue["suggestion"] == "Trim it"
+ assert issue["deduction"] == 3
+
+ def test_zero_points_turns_the_rule_off_without_changing_other_rules(self, tmp_path: Path):
+ skill_dir = _write_described_skill(tmp_path, "Use for logs. " + "x" * 236)
+ default = _validate_with(skill_dir, tmp_path)
+
+ disabled = _validate_with(skill_dir, tmp_path, "discoverability:\n description_too_long:\n points: 0\n")
+
+ def other_issues(result) -> list[str]:
+ issues = result.metadata["quality_scores"]["dimensions"]["discoverability"]["issues"]
+ return [issue["message"] for issue in issues if "chars, maximum" not in issue["message"]]
+
+ assert _long_description_issues(disabled) == []
+ assert other_issues(disabled) == other_issues(default)
+ scores = [r.metadata["quality_scores"]["dimensions"]["discoverability"]["score"] for r in (default, disabled)]
+ assert scores[1] == scores[0] + 5
+
+
+class TestDiscoverabilityDescriptionTooShortConfig:
+ def test_packaged_rule_fires_only_below_20_characters(self, tmp_path: Path):
+ at_minimum = _validate_with(_write_described_skill(tmp_path / "at", "Use for parsing logs"), tmp_path)
+ below = _validate_with(_write_described_skill(tmp_path / "below", "Use for parsing log"), tmp_path)
+
+ assert _short_description_issues(at_minimum) == []
+ (issue,) = _short_description_issues(below)
+ assert issue["message"] == "Description too short (recommend 50-150 chars): 19 chars, minimum 20"
+ assert issue["suggestion"] == "Add more context: what tasks does this skill handle?"
+ assert issue["deduction"] == 20
+ assert issue["severity"] == "warning"
+
+ def test_length_ignores_surrounding_whitespace(self, tmp_path: Path):
+ result = _validate_with(_write_described_skill(tmp_path, '" Use for logs "'), tmp_path)
+
+ (issue,) = _short_description_issues(result)
+ assert issue["message"].endswith(": 12 chars, minimum 20")
+
+ def test_custom_minimum_moves_the_threshold(self, tmp_path: Path):
+ skill_dir = _write_described_skill(tmp_path, "Use for parsing application logs")
+ config = "discoverability:\n description_too_short:\n min_chars: {}\n"
+
+ raised = _validate_with(skill_dir, tmp_path, config.format(40))
+ default = _validate_with(skill_dir, tmp_path)
+
+ (issue,) = _short_description_issues(raised)
+ assert issue["message"].endswith(": 32 chars, minimum 40")
+ assert _short_description_issues(default) == []
+
+ def test_custom_minimum_below_the_packaged_20_is_honored(self, tmp_path: Path):
+ config = "discoverability:\n description_too_short:\n min_chars: 10\n"
+
+ lowered = _validate_with(_write_described_skill(tmp_path / "lowered", "Use for logs"), tmp_path, config)
+ below = _validate_with(_write_described_skill(tmp_path / "below", "Use for X"), tmp_path, config)
+
+ assert _short_description_issues(lowered) == []
+ (issue,) = _short_description_issues(below)
+ assert issue["message"].endswith(": 9 chars, minimum 10")
+
+ @pytest.mark.parametrize("points", [0, 20])
+ def test_minimum_above_200_keeps_the_long_description_rule(self, tmp_path: Path, points: int):
+ skill_dir = _write_described_skill(tmp_path, "Use for parsing logs. " + "x" * 230)
+ config = f"discoverability:\n description_too_short:\n min_chars: 300\n points: {points}\n"
+
+ default = _validate_with(skill_dir, tmp_path)
+ raised = _validate_with(skill_dir, tmp_path, config)
+
+ def long_issues(result) -> list[str]:
+ issues = result.metadata["quality_scores"]["dimensions"]["discoverability"]["issues"]
+ return [issue["message"] for issue in issues if "chars, maximum" in issue["message"]]
+
+ expected = ["Description very long (recommend 50-150 chars): 252 chars, maximum 200"]
+ assert long_issues(default) == long_issues(raised) == expected
+ if points:
+ (issue,) = _short_description_issues(raised)
+ assert issue["message"].endswith(": 252 chars, minimum 300")
+ else:
+ assert _short_description_issues(raised) == []
+
+ def test_custom_points_message_and_suggestion_are_used(self, tmp_path: Path):
+ config = (
+ "discoverability:\n description_too_short:\n points: 7\n"
+ " message: Description is too thin\n suggestion: Say what it does and when\n"
+ )
+
+ result = _validate_with(_write_described_skill(tmp_path, "Use for logs"), tmp_path, config)
+
+ (issue,) = _short_description_issues(result)
+ assert issue["message"] == "Description is too thin: 12 chars, minimum 20"
+ assert issue["suggestion"] == "Say what it does and when"
+ assert issue["deduction"] == 7
+
+ def test_zero_points_turns_the_rule_off_without_changing_other_rules(self, tmp_path: Path):
+ skill_dir = _write_described_skill(tmp_path, "Use for logs")
+ default = _validate_with(skill_dir, tmp_path)
+
+ disabled = _validate_with(skill_dir, tmp_path, "discoverability:\n description_too_short:\n points: 0\n")
+
+ def other_issues(result) -> list[str]:
+ issues = result.metadata["quality_scores"]["dimensions"]["discoverability"]["issues"]
+ return [issue["message"] for issue in issues if "chars, minimum" not in issue["message"]]
+
+ assert _short_description_issues(disabled) == []
+ assert other_issues(disabled) == other_issues(default)
+ scores = [r.metadata["quality_scores"]["dimensions"]["discoverability"]["score"] for r in (default, disabled)]
+ assert scores[1] == scores[0] + 20
+
+ def test_missing_description_is_not_reported_as_too_short(self, tmp_path: Path):
+ skill_dir = tmp_path / "undescribed-skill"
+ skill_dir.mkdir()
+ (skill_dir / "SKILL.md").write_text("---\nname: undescribed-skill\n---\n\n# Undescribed\n", encoding="utf-8")
+
+ assert _short_description_issues(_validate_with(skill_dir, tmp_path)) == []
+
+ def test_empty_description_is_not_reported_as_too_short(self, tmp_path: Path):
+ assert _short_description_issues(_validate_with(_write_described_skill(tmp_path, '""'), tmp_path)) == []
+
+ def test_description_key_without_a_value_is_counted_as_the_text_none(self, tmp_path: Path):
+ # YAML reads a bare `description:` as null, which the scorer has always turned into "None".
+ # The docs describe this; treating it as empty would change scores, so it is pinned here.
+ result = _validate_with(_write_described_skill(tmp_path, ""), tmp_path)
+
+ (issue,) = _short_description_issues(result)
+ assert issue["message"].endswith(": 4 chars, minimum 20")
+
+
+def _reserved_name_issues(result) -> list[dict]:
+ issues = result.metadata["quality_scores"]["dimensions"]["correctness"]["issues"]
+ return [issue for issue in issues if "reserved" in issue["message"].lower()]
+
+
+class TestCorrectnessReservedNameConfig:
+ def test_padded_and_hyphenated_terms_match_and_are_reported_without_padding(self, tmp_path: Path):
+ config = 'correctness:\n reserved_name:\n terms: [" claude ", claude-code]\n'
+
+ result = _validate_with(_write_issue_skill(tmp_path, name="claude-code-helper"), tmp_path, config)
+
+ (issue,) = _reserved_name_issues(result)
+ assert issue["message"] == "Name contains reserved word: claude, claude-code"
+
+ def test_packaged_rule_reports_the_matched_term_as_a_gate_failure(self, tmp_path: Path):
+ from skillevaluator.models.result import Severity
+
+ result = _validate_with(_write_issue_skill(tmp_path, name="claude-grant-matcher"), tmp_path)
+
+ (issue,) = _reserved_name_issues(result)
+ assert issue["message"] == "Name contains reserved word: claude"
+ assert issue["suggestion"] == "Remove reserved words from skill name"
+ assert issue["deduction"] == 15
+ assert issue["severity"] == "error"
+ assert any(f.severity == Severity.HIGH and "reserved word" in f.message for f in result.findings)
+ assert not result.passed
+
+ def test_every_matched_term_is_listed_once_and_deducted_once(self, tmp_path: Path):
+ result = _validate_with(_write_issue_skill(tmp_path, name="claude-anthropic-helper"), tmp_path)
+
+ (issue,) = _reserved_name_issues(result)
+ assert issue["message"] == "Name contains reserved word: anthropic, claude"
+ assert issue["deduction"] == 15
+
+ def test_custom_terms_replace_the_packaged_list(self, tmp_path: Path):
+ config = "correctness:\n reserved_name:\n terms: [acme, Internal]\n"
+
+ packaged_word = _validate_with(_write_issue_skill(tmp_path, name="claude-helper"), tmp_path, config)
+ custom_word = _validate_with(_write_issue_skill(tmp_path, name="internal-helper"), tmp_path, config)
+ inside_word = _validate_with(_write_issue_skill(tmp_path, name="acmestore-helper"), tmp_path, config)
+
+ assert _reserved_name_issues(packaged_word) == []
+ assert [issue["message"] for issue in _reserved_name_issues(custom_word)] == [
+ "Name contains reserved word: Internal"
+ ]
+ assert _reserved_name_issues(inside_word) == []
+
+ def test_custom_points_message_and_suggestion_are_used(self, tmp_path: Path):
+ config = (
+ "correctness:\n reserved_name:\n points: 30\n"
+ " message: Name uses a vendor name\n suggestion: Pick a neutral name\n"
+ )
+
+ result = _validate_with(_write_issue_skill(tmp_path, name="claude-helper"), tmp_path, config)
+
+ issues = result.metadata["quality_scores"]["dimensions"]["correctness"]["issues"]
+ (issue,) = [issue for issue in issues if issue["message"].startswith("Name uses a vendor name")]
+ assert issue["message"] == "Name uses a vendor name: claude"
+ assert issue["suggestion"] == "Pick a neutral name"
+ assert issue["deduction"] == 30
+
+ def test_zero_points_turns_the_rule_and_its_gate_failure_off(self, tmp_path: Path):
+ skill_dir = _write_issue_skill(tmp_path, name="claude-helper")
+ default = _validate_with(skill_dir, tmp_path)
+
+ disabled = _validate_with(skill_dir, tmp_path, "correctness:\n reserved_name:\n points: 0\n")
+
+ assert _reserved_name_issues(disabled) == []
+ assert not any("reserved word" in finding.message for finding in disabled.findings)
+ scores = [r.metadata["quality_scores"]["dimensions"]["correctness"]["score"] for r in (default, disabled)]
+ assert scores[1] == scores[0] + 15
+
+
@pytest.mark.parametrize("newline", ["\n", "\r\n"])
@pytest.mark.parametrize(
"extra_yaml",