skillchecker 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ """skillchecker: a data-driven linter for agent skill and context files."""
@@ -0,0 +1,5 @@
1
+ import sys
2
+
3
+ from .cli import main
4
+
5
+ sys.exit(main())
@@ -0,0 +1,43 @@
1
+ """Baseline: suppress reviewed findings by fingerprint; every entry must say why."""
2
+ import os
3
+ from pathlib import Path
4
+
5
+ import yaml
6
+
7
+ from .config import parse_yaml, read_text, validate
8
+ from .frontmatter import PARSERS, line_number, split_lines
9
+ from .model import Finding, Rule, Severity
10
+
11
+ MISSING_REASON = Rule(
12
+ id="repo.baseline-reason", host="repo", severity=Severity.ERROR,
13
+ source="https://github.com/yaooqinn/skillchecker#baseline (a baseline must not hide a "
14
+ "finding nobody reviewed)",
15
+ message="baseline entry has no reason, so it suppresses nothing", check=None)
16
+
17
+
18
+ def apply(findings: list[Finding], root: Path, path: Path, within: Path | None) -> list[Finding]:
19
+ """Drop findings whose fingerprint has a reasoned entry; report entries without a reason.
20
+ Like the findings, those reports have a path relative to `root`. `within` as for
21
+ config.read_text."""
22
+ rel = Path(os.path.relpath(path, root)).as_posix()
23
+ text = read_text(path, within) # one read: the values and their lines come from the same text
24
+ raw = parse_yaml(text, rel)
25
+ validate(raw, "baseline", rel)
26
+ # Each entry's line, read from the nodes. No node budget applies: a baseline may hold any
27
+ # number of entries, and its schema accepts only flat entries, so validation never walks
28
+ # into what an alias expands to.
29
+ node = yaml.compose(text, Loader=PARSERS["pyyaml"])
30
+ # As building `raw` does: expand '<<' merge keys, then the last 'entries' key wins.
31
+ PARSERS["pyyaml"]("").flatten_mapping(node)
32
+ entries = [v for k, v in node.value if k.value == "entries"][-1]
33
+ entry_lines = [line_number(text, item.start_mark.index) for item in entries.value]
34
+ lines = split_lines(text)
35
+ reviewed, errors = set(), []
36
+ for i, entry in enumerate(raw["entries"]):
37
+ if (entry.get("reason") or "").strip():
38
+ reviewed.add(entry["fingerprint"])
39
+ else:
40
+ errors.append(Finding.make(MISSING_REASON, rel, entry_lines[i],
41
+ lines, entry["fingerprint"]))
42
+ kept = [f for f in findings if f.fingerprint not in reviewed]
43
+ return sorted(kept + errors, key=Finding.sort_key)
skillchecker/cli.py ADDED
@@ -0,0 +1,102 @@
1
+ """Command line: skillchecker lint PATH... [--hosts h1,h2] [--format FORMAT] [--fail-on LEVEL]."""
2
+ import argparse
3
+ import itertools
4
+ import os
5
+ import posixpath
6
+ import sys
7
+ from dataclasses import replace
8
+ from pathlib import Path
9
+
10
+ from . import baseline
11
+ from .config import CONFIG_NAME, ConfigError, load_config, load_profiles
12
+ from .emit import EMITTERS, azure_error, github_error, plain
13
+ from .engine import lint
14
+ from .model import Finding, Severity
15
+
16
+ # --fail-on LEVEL: the severities that make the exit code 1.
17
+ FAIL_ON = {
18
+ "error": frozenset({Severity.ERROR}),
19
+ "warning": frozenset({Severity.ERROR, Severity.WARNING}),
20
+ "info": frozenset(Severity),
21
+ "never": frozenset(),
22
+ }
23
+
24
+
25
+ def run(root: Path, hosts: list[str] | None = None, config: Path | None = None) -> list[Finding]:
26
+ """Lint `root` for the selected hosts (default: the config's), after the baseline.
27
+ Finding paths are relative to `root`."""
28
+ if not root.is_dir():
29
+ raise ConfigError(f"{root}: not a directory")
30
+ cfg = load_config(root, config)
31
+ if hosts:
32
+ cfg = replace(cfg, hosts=tuple(hosts))
33
+ if not cfg.hosts:
34
+ raise ConfigError("no hosts selected: pass --hosts or set 'hosts' in the config")
35
+ profiles = load_profiles(list(cfg.host_dirs), cfg.data_root)
36
+ unknown = [h for h in cfg.hosts if h not in profiles]
37
+ if unknown:
38
+ raise ConfigError(f"unknown hosts {unknown}; known: {sorted(profiles)}")
39
+ findings = lint(root, cfg, profiles)
40
+ if cfg.baseline is None:
41
+ return findings
42
+ return baseline.apply(findings, root, cfg.baseline, cfg.data_root)
43
+
44
+
45
+ def _identities(path: Path) -> list[tuple[int, int]]:
46
+ """(device, inode) of the directory and of each directory above it; empty if it cannot be
47
+ read, which run() reports. Not path strings: on a case-insensitive volume pkg and PKG are
48
+ one directory."""
49
+ real = Path(os.path.realpath(path))
50
+ try:
51
+ return [(st.st_dev, st.st_ino) for st in map(os.stat, [real, *real.parents])]
52
+ except OSError:
53
+ return []
54
+
55
+
56
+ def _under(root: Path, finding: Finding) -> Finding:
57
+ """Prefix the root as given, so the path is relative to the working directory, as CI
58
+ annotations need. The fingerprint stays root-relative, so a baseline does not depend on it.
59
+ A baseline next to a shared config is '../' from the root; normpath folds that away."""
60
+ return replace(finding, path=posixpath.normpath(f"{root.as_posix()}/{finding.path}"))
61
+
62
+
63
+ def main(argv: list[str] | None = None) -> int:
64
+ parser = argparse.ArgumentParser(prog="skillchecker", description=__doc__)
65
+ commands = parser.add_subparsers(dest="command", required=True)
66
+ cmd = commands.add_parser("lint", help="lint one or more directory trees")
67
+ cmd.add_argument("paths", nargs="+", type=Path, metavar="PATH",
68
+ help=f"directory to lint; each one is a root with its own {CONFIG_NAME}")
69
+ cmd.add_argument("--hosts", help="comma-separated host profiles, e.g. spec,claude-code")
70
+ cmd.add_argument("--format", choices=list(EMITTERS), default="text")
71
+ cmd.add_argument("--config", type=Path,
72
+ help=f"config file for every PATH (default: PATH/{CONFIG_NAME} if present)")
73
+ cmd.add_argument("--fail-on", choices=list(FAIL_ON), default="error",
74
+ help="exit 1 when a finding has this severity or a higher one "
75
+ "(default: error)")
76
+ args = parser.parse_args(argv)
77
+ for stream in (sys.stdout, sys.stderr):
78
+ # CI logs are UTF-8 whatever the code page; a byte of a non-UTF-8 file name prints
79
+ # as an escape.
80
+ if hasattr(stream, "reconfigure"):
81
+ stream.reconfigure(encoding="utf-8", errors="backslashreplace")
82
+ hosts = [h.strip() for h in args.hosts.split(",") if h.strip()] if args.hosts else None
83
+ findings: list[Finding] = []
84
+ try:
85
+ # Each root applies its own config: a file under two roots would get two verdicts.
86
+ for (a, ids_a), (b, ids_b) in itertools.combinations(
87
+ [(p, _identities(p)) for p in args.paths], 2):
88
+ if ids_a and ids_b and (ids_a[0] in ids_b or ids_b[0] in ids_a):
89
+ raise ConfigError(f"{a} and {b} overlap; lint each directory once")
90
+ for root in args.paths:
91
+ findings += [_under(root, f) for f in run(root, hosts, args.config)]
92
+ except ConfigError as exc:
93
+ # The message can quote file names and config text from the checkout.
94
+ error = {"github": github_error, "azure": azure_error}.get(args.format)
95
+ print(error(f"skillchecker: {exc}") if error else plain(f"skillchecker: {exc}"),
96
+ file=sys.stderr)
97
+ return 2
98
+ # A shared config's baseline is read once per root; report each of its findings once.
99
+ # Roots do not overlap, so no other two findings share a path.
100
+ findings = sorted({f.sort_key(): f for f in findings}.values(), key=Finding.sort_key)
101
+ sys.stdout.write(EMITTERS[args.format](findings))
102
+ return 1 if any(f.severity in FAIL_ON[args.fail_on] for f in findings) else 0
skillchecker/config.py ADDED
@@ -0,0 +1,274 @@
1
+ """Load and validate the data: host profiles shipped with the tool and the repository config."""
2
+ import json
3
+ import os
4
+ from pathlib import Path
5
+ from collections.abc import Iterable, Iterator
6
+ from typing import Any
7
+
8
+ import yaml
9
+ from jsonschema import Draft202012Validator, FormatChecker
10
+ from jsonschema.exceptions import SchemaError
11
+
12
+ from . import files
13
+ from .frontmatter import PARSERS
14
+ from .model import HostProfile, KindProfile, RepoConfig, Rule, Severity
15
+
16
+ DATA = Path(__file__).parent / "data"
17
+ CONFIG_NAME = ".skillchecker.yaml"
18
+ _META = json.loads((DATA / "meta.schema.json").read_text(encoding="utf-8"))
19
+
20
+
21
+ class ConfigError(ValueError):
22
+ """A data file (profile, config, baseline) is unreadable or malformed."""
23
+
24
+
25
+ def validate(doc: Any, definition: str, where: str) -> None:
26
+ validator = Draft202012Validator({**_META, "$ref": f"#/$defs/{definition}"},
27
+ format_checker=FormatChecker())
28
+ try:
29
+ # By path as text: a YAML mapping may mix int and str keys, which do not compare.
30
+ error = min(validator.iter_errors(doc), key=lambda e: [str(p) for p in e.path], default=None)
31
+ except RecursionError as exc: # aliases can nest a value past Python's recursion limit
32
+ raise ConfigError(f"{where}: nested too deeply") from exc
33
+ if error is not None:
34
+ raise ConfigError(f"{where}: {_json_path(doc, error.absolute_path)}: {error.message}")
35
+
36
+
37
+ def _json_path(doc: Any, keys: Iterable) -> str:
38
+ """'$' and the keys to a value: [i] for a list index, ['a.b'] for a key whose text has a
39
+ dot, .key for any other key. jsonschema's json_path reads a YAML int key as an index and
40
+ fails on a key like 1.5."""
41
+ at = "$"
42
+ for key in keys:
43
+ at += f"[{key}]" if isinstance(doc, list) else f"[{key!r}]" if "." in str(key) else f".{key}"
44
+ doc = doc[key]
45
+ return at
46
+
47
+
48
+ def read_text(path: Path, within: Path | None = None) -> str:
49
+ """A data file's text, decoded as UTF-8 whatever the locale. With `within`, the checkout
50
+ chose the file, so it is read like a linted file: a regular file inside `within`, up to
51
+ 1 MiB. Without, the user named it (--config) or it ships with the tool."""
52
+ try:
53
+ if within is None:
54
+ data = path.read_bytes()
55
+ elif not files.inside(os.path.abspath(path), os.path.abspath(within)):
56
+ raise ConfigError(f"{path}: outside the lint root")
57
+ else:
58
+ data = files.read(path, within)
59
+ if isinstance(data, str):
60
+ raise ConfigError(f"{path}: {data}")
61
+ return data.decode("utf-8")
62
+ except OSError as exc:
63
+ raise ConfigError(f"{path}: {exc.strerror or exc}") from exc
64
+ except UnicodeDecodeError as exc:
65
+ raise ConfigError(f"{path}: not UTF-8 (byte {exc.start})") from exc
66
+
67
+
68
+ def parse_yaml(text: str, where: object) -> Any:
69
+ """yaml.safe_load, but a value PyYAML cannot build (2024-02-31) or too deep a nesting is a
70
+ YAML error at its line, as in frontmatter."""
71
+ try:
72
+ return yaml.load(text, Loader=PARSERS["pyyaml"])
73
+ except yaml.YAMLError as exc:
74
+ raise ConfigError(f"{where}: {exc}") from exc
75
+
76
+
77
+ def read_yaml(path: Path, within: Path | None = None) -> Any:
78
+ return parse_yaml(read_text(path, within), path)
79
+
80
+
81
+ # Keywords that raise a validation error of their own; the others only apply subschemas,
82
+ # whose own keywords raise the error. A keyword that applies a subschema raises one itself
83
+ # when that subschema is `false`, which _subschemas rejects.
84
+ _ASSERTIONS = frozenset({
85
+ "type", "enum", "const", "multipleOf", "maximum", "exclusiveMaximum", "minimum",
86
+ "exclusiveMinimum", "maxLength", "minLength", "pattern", "format", "maxItems", "minItems",
87
+ "uniqueItems", "contains", "maxContains", "minContains", "maxProperties", "minProperties",
88
+ "required", "dependentRequired", "not", "anyOf", "oneOf", "unevaluatedItems",
89
+ "unevaluatedProperties"})
90
+
91
+
92
+ # Subschemas whose errors never reach the result: their keyword reports one error itself.
93
+ _SILENT = frozenset({"not", "if", "anyOf", "oneOf", "contains", "unevaluatedItems",
94
+ "unevaluatedProperties"})
95
+ # Keywords whose value is one subschema, a list of them, or a map of names to them.
96
+ _ONE = frozenset({"not", "if", "then", "else", "items", "contains", "additionalProperties",
97
+ "propertyNames", "unevaluatedItems", "unevaluatedProperties"})
98
+ _LIST = frozenset({"allOf", "anyOf", "oneOf", "prefixItems"})
99
+ _MAP = frozenset({"properties", "patternProperties", "dependentSchemas"})
100
+
101
+
102
+ def _subschemas(schema: dict, where: str, surfacing: bool = False) -> Iterator[dict]:
103
+ """Every schema object a validation can reach, and those under `$defs` and
104
+ `contentSchema`; with `surfacing`, only those whose own errors reach the result. A `false`
105
+ subschema is rejected: it cannot name a rule, and jsonschema reports it without its path."""
106
+
107
+ def walk(node: Any, at: str) -> Iterator[dict]:
108
+ if node is False:
109
+ raise ConfigError(f"{at}: a 'false' subschema cannot name a rule; use {{\"not\": {{}}}}")
110
+ if not isinstance(node, dict):
111
+ return
112
+ yield node
113
+ for key, value in node.items():
114
+ if surfacing and key in _SILENT:
115
+ continue
116
+ if key in _MAP or (key == "$defs" and not surfacing):
117
+ for name, sub in value.items():
118
+ yield from walk(sub, f"{at}/{key}/{name}")
119
+ elif key in _LIST:
120
+ for i, sub in enumerate(value):
121
+ yield from walk(sub, f"{at}/{key}/{i}")
122
+ elif key in _ONE or (key == "contentSchema" and not surfacing):
123
+ yield from walk(value, f"{at}/{key}")
124
+
125
+ yield from walk(schema, where)
126
+
127
+
128
+ _DIALECT = "https://json-schema.org/draft/2020-12/schema"
129
+
130
+
131
+ def check_schema(schema: dict, where: str) -> None:
132
+ try:
133
+ json.dumps(schema) # YAML can build what JSON cannot: a schema that contains itself
134
+ except (TypeError, ValueError, RecursionError) as exc:
135
+ raise ConfigError(f"{where}: the schema is not JSON data, contains itself or nests "
136
+ "too deeply") from exc
137
+ try:
138
+ Draft202012Validator.check_schema(schema)
139
+ except SchemaError as exc:
140
+ raise ConfigError(f"{where}: invalid JSON Schema: {exc.message}") from exc
141
+ subs = list(_subschemas(schema, where))
142
+ # A reference could reach a value that is not a schema, or loop, only at lint time; and
143
+ # a lint run must not fetch a file or a URL.
144
+ if any("$ref" in sub or "$dynamicRef" in sub for sub in subs):
145
+ raise ConfigError(f"{where}: $ref and $dynamicRef are not supported")
146
+ # Another dialect brings keywords the walk above does not visit.
147
+ if any(sub.get("$schema", _DIALECT) not in (_DIALECT, _DIALECT + "#") for sub in subs):
148
+ raise ConfigError(f"{where}: only JSON Schema draft 2020-12 is supported")
149
+
150
+
151
+ def check_x_rules(schema: dict, where: str) -> None:
152
+ """Every keyword that can fail names its rule, so a schema error always maps to a rule."""
153
+ for sub in _subschemas(schema, where, surfacing=True):
154
+ ref = sub.get("x-rule")
155
+ keywords = sorted(_ASSERTIONS & sub.keys())
156
+ missing = [k for k in keywords if ref is None or (isinstance(ref, dict) and k not in ref)]
157
+ if missing:
158
+ raise ConfigError(f"{where}: no x-rule names the rule for {missing} in {sub}")
159
+
160
+
161
+ def _rule(raw: dict, host: str) -> Rule:
162
+ return Rule(raw["id"], host, Severity(raw["severity"]), raw["source"], raw["message"],
163
+ raw.get("check"))
164
+
165
+
166
+ def schema_rule_ids(node: object) -> set[str]:
167
+ """Every rule id named by an x-rule annotation anywhere in a JSON Schema."""
168
+ found: set[str] = set()
169
+ if isinstance(node, dict):
170
+ ref = node.get("x-rule")
171
+ if isinstance(ref, str):
172
+ found.add(ref)
173
+ elif isinstance(ref, dict):
174
+ found.update(ref.values())
175
+ for value in node.values():
176
+ found |= schema_rule_ids(value)
177
+ elif isinstance(node, list):
178
+ for value in node:
179
+ found |= schema_rule_ids(value)
180
+ return found
181
+
182
+
183
+ def load_profile(directory: Path, within: Path | None = None) -> HostProfile:
184
+ """The host profile in `directory`; `within` as for read_text."""
185
+ raw = read_yaml(directory / "profile.yaml", within)
186
+ validate(raw, "profile", str(directory / "profile.yaml"))
187
+ host = raw["host"]
188
+ if host != directory.name:
189
+ raise ConfigError(f"{directory}: host '{host}' must equal the directory name")
190
+ prefix = "spec." if host == "spec" else f"host.{host}."
191
+ kinds = {}
192
+ for kind, spec in raw["kinds"].items():
193
+ rules = tuple(_rule(r, host) for r in spec["rules"])
194
+ for rule in rules:
195
+ if rule.check and rule.check["type"] == "schema":
196
+ check_schema(rule.check["schema"], f"{directory}: rule {rule.id}")
197
+ stray = [r.id for r in rules if not r.id.startswith(prefix)]
198
+ if stray:
199
+ raise ConfigError(f"{directory}: rule ids must start with '{prefix}': {stray}")
200
+ schema = None
201
+ if "schema" in spec:
202
+ schema_path = directory / spec["schema"]
203
+ try:
204
+ schema = json.loads(read_text(schema_path, within))
205
+ except (json.JSONDecodeError, RecursionError) as exc:
206
+ raise ConfigError(f"{schema_path}: {exc}") from exc
207
+ check_schema(schema, str(schema_path))
208
+ check_x_rules(schema, str(schema_path))
209
+ # Each schema-raised rule must be named by the schema and vice versa, so no schema
210
+ # error lacks an id, severity and source, and no declared rule is dead.
211
+ named = schema_rule_ids(schema) if schema else set()
212
+ declared = {r.id for r in rules if r.check is None}
213
+ if named != declared:
214
+ raise ConfigError(f"{directory}/{kind}: x-rule ids {sorted(named)} != rules "
215
+ f"without a check {sorted(declared)}")
216
+ kinds[kind] = KindProfile(schema, rules)
217
+ return HostProfile(host, kinds, raw.get("yaml", "pyyaml"))
218
+
219
+
220
+ def load_profiles(extra_dirs: list[Path], within: Path | None = None) -> dict[str, HostProfile]:
221
+ """The shipped profiles and those in `extra_dirs`, read as read_text reads with `within`."""
222
+ dirs = [(p, None) for p in sorted((DATA / "hosts").iterdir()) if p.is_dir()]
223
+ for extra in extra_dirs:
224
+ # Where a link leads, before listing it: a listing reads the directory.
225
+ try:
226
+ real = os.path.realpath(extra)
227
+ except ValueError as exc: # such as a NUL in the path
228
+ raise ConfigError(f"host-dirs: {extra!r}: {exc}") from exc
229
+ if within is not None and not files.inside(real, os.path.realpath(within)):
230
+ raise ConfigError(f"host-dirs: {extra} is outside the lint root")
231
+ if not extra.is_dir():
232
+ raise ConfigError(f"host-dirs: {extra} is not a directory")
233
+ try:
234
+ dirs += [(p, within) for p in sorted(extra.iterdir()) if p.is_dir()]
235
+ except OSError as exc:
236
+ raise ConfigError(f"host-dirs: {extra}: {exc.strerror or exc}") from exc
237
+ profiles: dict[str, HostProfile] = {}
238
+ for directory, data_root in dirs:
239
+ profile = load_profile(directory, data_root)
240
+ if profile.host in profiles:
241
+ raise ConfigError(f"{directory}: host '{profile.host}' is defined twice")
242
+ profiles[profile.host] = profile
243
+ return profiles
244
+
245
+
246
+ def load_config(root: Path, path: Path | None = None) -> RepoConfig:
247
+ """Read <root>/.skillchecker.yaml, or `path` for every root; a missing default file means
248
+ the defaults. The config's paths are relative to its own directory."""
249
+ within = root if path is None else None
250
+ if path is None:
251
+ path = root / CONFIG_NAME
252
+ raw: Any = read_yaml(path, within) if os.path.lexists(path) else {"version": 1}
253
+ else:
254
+ raw = read_yaml(path)
255
+ validate(raw, "config", str(path))
256
+ kinds = raw["kinds"] if "kinds" in raw else read_yaml(DATA / "kinds.yaml")
257
+ rules: dict[str, list[Rule]] = {kind: [] for kind in kinds}
258
+ for item in raw.get("rules", []):
259
+ rule = _rule(item, "repo")
260
+ if rule.check["type"] == "schema":
261
+ check_schema(rule.check["schema"], f"rule {rule.id}")
262
+ for kind in item["kinds"]:
263
+ if kind not in rules:
264
+ raise ConfigError(f"rule {rule.id}: unknown kind '{kind}' (known: {list(kinds)})")
265
+ rules[kind].append(rule)
266
+ return RepoConfig(
267
+ hosts=tuple(raw.get("hosts", ())),
268
+ host_dirs=tuple(path.parent / d for d in raw.get("host-dirs", ())),
269
+ kinds={k: tuple(v) for k, v in kinds.items()},
270
+ allowed_keys={k: frozenset(v) for k, v in raw.get("allowed-keys", {}).items()},
271
+ rules={k: tuple(v) for k, v in rules.items()},
272
+ baseline=path.parent / raw["baseline"] if "baseline" in raw else None,
273
+ data_root=within,
274
+ )
@@ -0,0 +1,20 @@
1
+ # Claude Code skills (https://code.claude.com/docs/en/skills). All fields optional; unknown
2
+ # fields are ignored without an error, so an unknown key is info, not an error.
3
+ host: claude-code
4
+ title: Claude Code skills docs
5
+ kinds:
6
+ skill:
7
+ schema: skill.schema.json
8
+ rules:
9
+ - id: host.claude-code.not-in-root
10
+ severity: warning
11
+ message: Claude Code does not load a skill outside .claude/skills or a plugin's skills
12
+ source: "https://code.claude.com/docs/en/skills#where-skills-live (project: .claude/skills/<skill-name>/SKILL.md; nested: <subdir>/.claude/skills/<skill-name>/SKILL.md; plugin: <plugin>/skills/<skill-name>/SKILL.md); https://code.claude.com/docs/en/plugins/components#skills (a plugin's manifest is .claude-plugin/plugin.json; each skill in its own directory under skills/); https://github.com/NVIDIA/SkillEvaluator/blob/v1.3.1/src/skillevaluator/harness/profiles/claude-code.yaml#L10-L11 (CC-ROOT; CC-GROUPING: grouping folders are not searched)"
13
+ check:
14
+ type: in-root
15
+ roots: ["**/.claude/skills/*/SKILL.md"]
16
+ plugin-roots: ["skills/*/SKILL.md"]
17
+ - id: host.claude-code.unknown-key
18
+ severity: info
19
+ message: key not in the Claude Code frontmatter reference; ignored
20
+ source: "https://code.claude.com/docs/en/skills#frontmatter-reference (Claude Code ignores a field it does not recognize without reporting an error)"
@@ -0,0 +1,28 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "propertyNames": {
4
+ "enum": [
5
+ "name",
6
+ "description",
7
+ "when_to_use",
8
+ "argument-hint",
9
+ "arguments",
10
+ "disable-model-invocation",
11
+ "user-invocable",
12
+ "allowed-tools",
13
+ "disallowed-tools",
14
+ "model",
15
+ "effort",
16
+ "context",
17
+ "agent",
18
+ "background",
19
+ "hooks",
20
+ "paths",
21
+ "shell",
22
+ "metadata",
23
+ "license",
24
+ "compatibility"
25
+ ],
26
+ "x-rule": "host.claude-code.unknown-key"
27
+ }
28
+ }
@@ -0,0 +1,54 @@
1
+ # OpenAI Codex CLI skills, from NVIDIA/SkillEvaluator v1.3.1 src/skillevaluator/harness/profiles/codex.yaml
2
+ # (verified there against Codex 0.166.0). Rules without 'check' are raised by skill.schema.json.
3
+ host: codex
4
+ title: OpenAI Codex CLI 0.166.0 (SkillEvaluator v1.3.1 codex profile)
5
+ kinds:
6
+ skill:
7
+ schema: skill.schema.json
8
+ rules:
9
+ - id: host.codex.not-in-root
10
+ severity: warning
11
+ message: Codex does not load a project skill outside .agents/skills or .codex/skills
12
+ source: "https://github.com/NVIDIA/SkillEvaluator/blob/v1.3.1/src/skillevaluator/harness/profiles/codex.yaml#L10 (CX-ROOT, not loaded); https://github.com/NVIDIA/SkillEvaluator/blob/v1.3.1/src/skillevaluator/harness/profiles/codex.yaml#L16-L17 (CX-NESTED, CX-DEPTH: a skill at most 5 grouping folders below the root loads)"
13
+ check:
14
+ type: in-root
15
+ roots: [".agents/skills/*/SKILL.md", ".agents/skills/*/*/SKILL.md", ".agents/skills/*/*/*/SKILL.md", ".agents/skills/*/*/*/*/SKILL.md", ".agents/skills/*/*/*/*/*/SKILL.md", ".agents/skills/*/*/*/*/*/*/SKILL.md", ".codex/skills/*/SKILL.md", ".codex/skills/*/*/SKILL.md", ".codex/skills/*/*/*/SKILL.md", ".codex/skills/*/*/*/*/SKILL.md", ".codex/skills/*/*/*/*/*/SKILL.md", ".codex/skills/*/*/*/*/*/*/SKILL.md"]
16
+ - id: host.codex.bom
17
+ severity: error
18
+ message: Codex drops a SKILL.md that starts with a UTF-8 BOM
19
+ source: "https://github.com/NVIDIA/SkillEvaluator/blob/v1.3.1/src/skillevaluator/harness/profiles/codex.yaml#L15 (CX-BOM, not loaded)"
20
+ check: {type: bom}
21
+ - id: host.codex.symlink-file
22
+ severity: error
23
+ message: Codex skips a SKILL.md that is a symbolic link; a linked skill folder loads
24
+ source: "https://github.com/NVIDIA/SkillEvaluator/blob/v1.3.1/src/skillevaluator/harness/profiles/codex.yaml#L18 (CX-SYMLINK-FILE, not loaded)"
25
+ check: {type: symlink}
26
+ - id: host.codex.duplicate-key
27
+ severity: error
28
+ message: Codex drops a skill whose frontmatter repeats a key
29
+ source: "https://github.com/NVIDIA/SkillEvaluator/blob/v1.3.1/src/skillevaluator/harness/profiles/codex.yaml#L14 (CX-STRICT-YAML, not loaded)"
30
+ check: {type: duplicate-keys}
31
+ - id: host.codex.description-required
32
+ severity: error
33
+ message: Codex drops a skill without a non-empty string description
34
+ source: "https://github.com/NVIDIA/SkillEvaluator/blob/v1.3.1/src/skillevaluator/harness/profiles/codex.yaml#L13 (CX-DESC-MISSING, not loaded)"
35
+ - id: host.codex.description-cut
36
+ severity: warning
37
+ message: Codex cuts a description over 1,024 code points in the skill list
38
+ source: "https://github.com/NVIDIA/SkillEvaluator/blob/v1.3.1/src/skillevaluator/harness/profiles/codex.yaml#L11 (CX-DESC-CUT, degraded)"
39
+ - id: host.codex.allowed-tools-ignored
40
+ severity: info
41
+ message: Codex ignores allowed-tools
42
+ source: "https://github.com/NVIDIA/SkillEvaluator/blob/v1.3.1/src/skillevaluator/harness/profiles/codex.yaml#L23 (CX-ALLOWED-TOOLS, advisory)"
43
+ - id: host.codex.dmi-ignored
44
+ severity: info
45
+ message: Codex ignores disable-model-invocation; the model can still pick this skill
46
+ source: "https://github.com/NVIDIA/SkillEvaluator/blob/v1.3.1/src/skillevaluator/harness/profiles/codex.yaml#L25 (CX-DMI-IGNORED, degraded, unless agents/openai.yaml sets policy.allow_implicit_invocation false); https://github.com/NVIDIA/SkillEvaluator/blob/v1.3.1/src/skillevaluator/harness/overlay.py#L412-L413 (true or 'true')"
47
+ check:
48
+ type: field-true
49
+ field: disable-model-invocation
50
+ unless: {file: agents/openai.yaml, path: [policy, allow_implicit_invocation], equals: false}
51
+ - id: host.codex.claude-only-field
52
+ severity: info
53
+ message: Claude Code only field; Codex ignores it
54
+ source: "https://github.com/NVIDIA/SkillEvaluator/blob/v1.3.1/src/skillevaluator/harness/profiles/codex.yaml#L28 (CX-CLAUDE-ONLY, advisory); field list https://github.com/NVIDIA/SkillEvaluator/blob/v1.3.1/src/skillevaluator/harness/overlay.py#L39-L46"
@@ -0,0 +1,49 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "required": [
4
+ "description"
5
+ ],
6
+ "x-rule": {
7
+ "required": "host.codex.description-required"
8
+ },
9
+ "properties": {
10
+ "description": {
11
+ "type": "string",
12
+ "pattern": "\\S",
13
+ "maxLength": 1024,
14
+ "x-rule": {
15
+ "type": "host.codex.description-required",
16
+ "pattern": "host.codex.description-required",
17
+ "maxLength": "host.codex.description-cut"
18
+ }
19
+ },
20
+ "allowed-tools": {
21
+ "not": {},
22
+ "x-rule": "host.codex.allowed-tools-ignored"
23
+ },
24
+ "argument-hint": {
25
+ "not": {},
26
+ "x-rule": "host.codex.claude-only-field"
27
+ },
28
+ "when_to_use": {
29
+ "not": {},
30
+ "x-rule": "host.codex.claude-only-field"
31
+ },
32
+ "context": {
33
+ "not": {},
34
+ "x-rule": "host.codex.claude-only-field"
35
+ },
36
+ "agent": {
37
+ "not": {},
38
+ "x-rule": "host.codex.claude-only-field"
39
+ },
40
+ "model": {
41
+ "not": {},
42
+ "x-rule": "host.codex.claude-only-field"
43
+ },
44
+ "hooks": {
45
+ "not": {},
46
+ "x-rule": "host.codex.claude-only-field"
47
+ }
48
+ }
49
+ }
@@ -0,0 +1,40 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "required": [
4
+ "description"
5
+ ],
6
+ "x-rule": {
7
+ "required": "host.copilot.agent-required-field"
8
+ },
9
+ "propertyNames": {
10
+ "enum": [
11
+ "name",
12
+ "description",
13
+ "tools",
14
+ "model",
15
+ "disable-model-invocation",
16
+ "user-invocable",
17
+ "reasoning-effort",
18
+ "model-policy",
19
+ "mcp-servers",
20
+ "skills",
21
+ "hooks",
22
+ "include-custom-instructions",
23
+ "strict-tools-list",
24
+ "deferred-tool-loading",
25
+ "github",
26
+ "infer",
27
+ "models",
28
+ "modelPolicy",
29
+ "reasoningEffort",
30
+ "sidekick"
31
+ ],
32
+ "x-rule": "host.copilot.agent-unknown-key"
33
+ },
34
+ "properties": {
35
+ "description": {
36
+ "type": "string",
37
+ "x-rule": "host.copilot.agent-description-type"
38
+ }
39
+ }
40
+ }
@@ -0,0 +1,33 @@
1
+ # GitHub Copilot CLI 1.0.121 ('copilot help skills', 'copilot help agents') and the Copilot docs.
2
+ # Neither says what happens to an unknown SKILL.md field, so the skill kind has no key schema;
3
+ # the agents help says any other agent field is ignored with a warning.
4
+ host: copilot
5
+ title: GitHub Copilot CLI 1.0.121
6
+ kinds:
7
+ skill:
8
+ rules:
9
+ - id: host.copilot.not-in-root
10
+ severity: warning
11
+ message: Copilot CLI does not load a skill outside .github/skills, .agents/skills or .claude/skills
12
+ source: "https://docs.github.com/en/copilot/how-tos/copilot-cli/customize-copilot/add-skills (project skills: .github/skills, .claude/skills or .agents/skills); https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-command-reference#skill-locations (parent .github/skills: monorepo parent directory support); Copilot CLI 1.0.121 'copilot help skills' (in the current folder and each parent up to the repository root); https://github.com/NVIDIA/SkillEvaluator/blob/v1.3.1/src/skillevaluator/harness/profiles/copilot-cli.yaml#L9 (CP-ROOT)"
13
+ check: {type: in-root, roots: ["**/.github/skills/*/SKILL.md", "**/.agents/skills/*/SKILL.md", "**/.claude/skills/*/SKILL.md"]}
14
+ agent:
15
+ schema: agent.schema.json
16
+ rules:
17
+ - id: host.copilot.agent-not-in-root
18
+ severity: warning
19
+ message: Copilot CLI does not load an agent outside .github/agents or .claude/agents
20
+ source: "https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-command-reference#custom-agent-locations (project agents: .github/agents and .claude/agents, from the working directory up to the Git root)"
21
+ check: {type: in-root, roots: ["**/.github/agents/**", "**/.claude/agents/**"]}
22
+ - id: host.copilot.agent-required-field
23
+ severity: error
24
+ message: description is required
25
+ source: "https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-command-reference#custom-agent-frontmatter-fields (description is required)"
26
+ - id: host.copilot.agent-description-type
27
+ severity: error
28
+ message: description must be a string
29
+ source: "https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-command-reference#custom-agent-frontmatter-fields (description: string, required)"
30
+ - id: host.copilot.agent-unknown-key
31
+ severity: warning
32
+ message: key not in the Copilot CLI agent fields; ignored with a warning
33
+ source: "https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-command-reference#custom-agent-frontmatter-fields (field table); https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-command-reference#sidekick-agents (sidekick, on any agent); Copilot CLI 1.0.121 'copilot help agents' (the kebab-case spellings, and any other field is ignored with a warning)"