Skip to content
Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
2b072a0
feat: add skill quality validator
Rupam0710 Sep 8, 2026
8ed3e47
fix: resolve skill-quality validator review comments
Rupam0710 Sep 8, 2026
7ecef04
fix: tighten strict skill section validation
Rupam0710 Sep 8, 2026
346a28d
fix: resolve skill validator lint and strict checks
Rupam0710 Sep 8, 2026
bbc30bf
fix: address skill validator review feedback
Rupam0710 Sep 8, 2026
fdd769c
fix: replace unsupported end-of-input assertion
Rupam0710 Sep 8, 2026
11eb2c7
fix: finalize skill validator guardrails
Rupam0710 Sep 9, 2026
7cd34d9
fix: resolve final review comments
Rupam0710 Sep 9, 2026
f1f9173
fix: handle unreadable skill directories
Rupam0710 Sep 9, 2026
f277946
Merge branch 'main' into feat/skill-quality-validator
Rupam0710 Sep 19, 2026
e03e011
refactor: merge quality checks into validate-skills with rules-based …
Rupam0710 Sep 23, 2026
f71bddf
fix: resolve Greptile review feedback for skill-quality-validator
Rupam0710 Sep 23, 2026
bac0e47
fix: eliminate collection mutations in skill-quality-validator
Rupam0710 Sep 23, 2026
04036ae
fix: reduce credential detection minimum and eliminate collection mut…
Rupam0710 Sep 23, 2026
7c58b9c
fix: restore section boundary state in extractSectionBody to prevent …
Rupam0710 Sep 23, 2026
9378b64
test: add standalone validator regression coverage for untrusted CLI …
Rupam0710 Sep 23, 2026
f66454e
fix: unify skill quality validation rules
Rupam0710 Oct 2, 2026
b768cc7
Merge upstream/main into feat/skill-quality-validator
Rupam0710 Oct 2, 2026
412f898
fix: enforce skill quality checks on changed skills in CI
Rupam0710 Oct 3, 2026
75d9f79
fix: handle non-ASCII skill paths and push events in changed-skill qu…
Rupam0710 Oct 3, 2026
f8a71eb
fix: diff new-branch and force pushes against the default branch in s…
Rupam0710 Oct 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@
"orchestrate:worker": "bash scripts/orchestrate-codex-worker.sh",
"orchestrate:tmux": "node scripts/orchestrate-worktrees.js",
"test": "node scripts/ci/check-unicode-safety.js && node scripts/ci/validate-agents.js && node scripts/ci/validate-commands.js && node scripts/ci/validate-rules.js && node scripts/ci/validate-skills.js && node scripts/ci/validate-hooks.js && node scripts/ci/validate-install-manifests.js && node scripts/ci/validate-no-personal-paths.js && npm run catalog:check && npm run command-registry:check && node tests/run-all.js",
"validate:skill-quality": "node scripts/ci/validate-skill-quality.js",
"coverage": "c8 --all --include=\"scripts/**/*.js\" --include=\"scripts/**/*.mjs\" --check-coverage --lines 80 --functions 80 --branches 79 --statements 80 --reporter=text --reporter=lcov node tests/run-all.js",
"build:opencode": "node scripts/build-opencode.js",
"prepack": "npm run build:opencode",
Expand Down
288 changes: 288 additions & 0 deletions scripts/ci/validate-skill-quality.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,288 @@
#!/usr/bin/env node
/**
* Validate the quality of curated skill files.
*
* Checks for the minimum structure and safety bar expected by ECC before a
* contribution is merged, without overblocking contributors during initial
* onboarding.
*/

const fs = require('fs');
const path = require('path');
const yaml = require('js-yaml');

const STRICT = process.argv.includes('--strict') || process.env.CI_STRICT_SKILLS === '1';

function parseFrontmatter(content) {
const cleaned = content.replace(/^\uFEFF/, '');
const match = cleaned.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/);
if (!match) return null;

try {
const parsed = yaml.load(match[1]);
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
return { __invalid: true };
}
return parsed;
} catch (error) {
const message = error && error.message ? error.message : 'unknown YAML parse error';
logError(`YAML frontmatter parse failed: ${message}`);
return { __invalid: true };
}
}

const REQUIRED_SECTIONS = [
'When to Activate',
'Core Concepts',
'Examples',
'Anti-Patterns',
'Best Practices',
];

const SECRET_PATTERNS = [
/(?:api[_-]?key|token|secret|passwd|password|access[_-]?key)[\s:="']+[A-Za-z0-9_-]{8,}/i,
/sk_(?:live|test)_[A-Za-z0-9]+/i,
/ghp_[A-Za-z0-9]{20,}/i,
/xox[baprs]-[A-Za-z0-9-]+/i,
];

function logInfo(message) {
console.info(message);
}

function logError(message) {
console.error(`ERROR: ${message}`);
}

function logWarning(message) {
console.warn(`WARN: ${message}`);
}

function readFileSafe(filePath) {
try {
return fs.readFileSync(filePath, 'utf8');
} catch (error) {
const message = error && error.message ? error.message : 'unknown read error';
logError(`${filePath} could not be read: ${message}`);
return null;
}
}

function extractSectionBody(markdown, sectionTitle) {
const headingPattern = new RegExp(`^#{1,3}\\s*${sectionTitle.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\s*$`);
const sectionHeadings = new Set(REQUIRED_SECTIONS.map((title) => title.trim()));
const lines = markdown.split(/\r?\n/);
let inTargetSection = false;
const bodyLines = [];

for (const line of lines) {
const trimmed = line.trim();
if (!inTargetSection) {
if (headingPattern.test(trimmed)) {
inTargetSection = true;
}
continue;
}

const nextHeadingMatch = trimmed.match(/^#{1,3}\s*(.+?)\s*$/);
if (nextHeadingMatch && sectionHeadings.has(nextHeadingMatch[1].trim())) {
break;
}

bodyLines.push(line);
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
}

return bodyLines.join('\n').trim();
}

function findMissingSections(markdown) {
const missing = [];
for (const section of REQUIRED_SECTIONS) {
const heading = new RegExp(`^##?\\s*${section.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`, 'm');
if (!heading.test(markdown)) {
missing.push(section);
}
}
return missing;
}
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved

function findEmptySections(markdown) {
const empty = [];
for (const section of REQUIRED_SECTIONS) {
const body = extractSectionBody(markdown, section);
const normalized = body.replace(/[`*_~>#\-\s]/g, '').toLowerCase();
if (!normalized || ['todo', 'tbd', 'n/a', 'na', 'placeholder'].includes(normalized)) {
const heading = new RegExp(`^##?\\s*${section.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`, 'm');
if (heading.test(markdown)) {
empty.push(section);
}
}
}
return empty;
}

function scanSecrets(markdown) {
const matches = [];
for (const pattern of SECRET_PATTERNS) {
const result = markdown.match(pattern);
if (result) {
matches.push(result[0]);
}
}
return matches;
}

function getSkillFiles(targetPath) {
if (!targetPath || !fs.existsSync(targetPath)) return [];

let targetStat;
try {
targetStat = fs.statSync(targetPath);
} catch (error) {
logError(`Unable to inspect target path ${targetPath}: ${error && error.message ? error.message : 'unknown filesystem error'}`);
return [];
}

if (targetStat.isFile()) {
return path.basename(targetPath) === 'SKILL.md' ? [targetPath] : [];
}

if (!targetStat.isDirectory()) return [];

const files = [];

function walk(currentDir) {
let entries;
try {
entries = fs.readdirSync(currentDir, { withFileTypes: true });
} catch (error) {
logError(`Unable to read directory ${currentDir}: ${error && error.message ? error.message : 'unknown filesystem error'}`);
return;
}
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved

for (const entry of entries) {
const fullPath = path.join(currentDir, entry.name);
if (entry.isDirectory()) {
walk(fullPath);
} else if (entry.isFile() && entry.name === 'SKILL.md') {
files.push(fullPath);
}
}
}

walk(targetPath);
return files.sort();
}

function validateSkillFile(skillFile) {
const relativePath = path.relative(process.cwd(), skillFile) || skillFile;
const contents = readFileSafe(skillFile);
if (!contents) {
logError(`${relativePath} could not be read`);
return false;
}

const frontmatter = parseFrontmatter(contents);
let ok = true;

if (!frontmatter) {
logError(`${relativePath} is missing YAML frontmatter`);
ok = false;
} else if (frontmatter.__invalid) {
logError(`${relativePath} has invalid YAML frontmatter`);
ok = false;
} else {
if (typeof frontmatter.name !== 'string' || !frontmatter.name.trim()) {
logError(`${relativePath} is missing a name field`);
ok = false;
}
if (typeof frontmatter.description !== 'string' || !frontmatter.description.trim()) {
logError(`${relativePath} is missing a description field`);
ok = false;
}

const dirName = path.basename(path.dirname(skillFile));
if (frontmatter.name && frontmatter.name !== dirName) {
logError(`${relativePath} has name "${frontmatter.name}" but directory is "${dirName}"`);
ok = false;
}
}

const missingSections = findMissingSections(contents);
if (missingSections.length > 0) {
const missingText = missingSections.join(', ');
logError(`${relativePath} is missing required sections: ${missingText}`);
ok = false;
}

if (STRICT) {
const emptySections = findEmptySections(contents);
if (emptySections.length > 0) {
const emptyText = emptySections.join(', ');
logError(`${relativePath} has empty or placeholder-only required sections: ${emptyText}`);
ok = false;
}
}

const badSecrets = scanSecrets(contents);
if (badSecrets.length > 0) {
logError(`${relativePath} contains ${badSecrets.length} secret-like pattern(s)`);
ok = false;
}

const trimmed = contents.trim();
if (trimmed.length < 200) {
const message = `${relativePath} is very short and may not provide enough guidance`;
if (STRICT) {
logError(message);
} else {
logWarning(message);
}
ok = ok && !STRICT;
}

return ok;
}

function main() {
const cliArgs = process.argv.slice(2).filter((arg) => !arg.startsWith('--'));
const explicitTarget = cliArgs[0] || process.env.ECC_SKILLS_DIR || 'skills';
const targetPath = path.resolve(process.cwd(), explicitTarget);

if (!fs.existsSync(targetPath)) {
logError(`Target does not exist: ${targetPath}`);
process.exit(1);
}

const targetStat = fs.statSync(targetPath);
if (!targetStat.isFile() && !targetStat.isDirectory()) {
logError(`Unsupported target type: ${targetPath}. Provide a SKILL.md file or a directory of skill files.`);
process.exit(1);
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

if (targetStat.isFile() && path.basename(targetPath) !== 'SKILL.md') {
logError(`Unsupported target file: ${targetPath}. Provide a SKILL.md file.`);
process.exit(1);
}

const files = getSkillFiles(targetPath);

if (files.length === 0) {
logInfo(`No skill files found under ${targetPath}`);
process.exit(0);
}

let hasErrors = false;
for (const file of files) {
const isValid = validateSkillFile(file);
if (!isValid) hasErrors = true;
}

if (hasErrors) {
process.exit(1);
}

logInfo(`Validated ${files.length} skill file(s) successfully.`);
}

main();
Loading