Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,8 @@
"orchestrate:status": "node scripts/orchestration-status.js",
"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",
"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-skill-quality.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",
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
"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
189 changes: 189 additions & 0 deletions scripts/ci/validate-skill-quality.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
#!/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 DEFAULT_SKILLS_DIR = path.join(__dirname, '../../skills');
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
const STRICT = process.argv.includes('--strict') || process.env.CI_STRICT_SKILLS === '1';

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,
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
/sk_(?:live|test)_[A-Za-z0-9]+/i,
/ghp_[A-Za-z0-9]{20,}/i,
/xox[baprs]-[A-Za-z0-9-]+/i,
];

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) {
return null;
}
}

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

const body = match[1];
const result = {};
const lines = body.split(/\r?\n/);
for (const line of lines) {
const m = line.match(/^([A-Za-z0-9_-]+):\s*(.*)$/);
if (!m) continue;
const [, key, rawValue] = m;
const value = rawValue.trim().replace(/^['"]|['"]$/g, '');
result[key] = value;
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}

return result;
}

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 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(rootDir) {
if (!fs.existsSync(rootDir)) return [];

const files = [];

function walk(currentDir) {
const entries = fs.readdirSync(currentDir, { withFileTypes: true });
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(rootDir);
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.name) {
logError(`${relativePath} is missing a name field`);
ok = false;
}
if (!frontmatter.description) {
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;
}

const badSecrets = scanSecrets(contents);
if (badSecrets.length > 0) {
logError(`${relativePath} contains secret-like patterns: ${badSecrets.slice(0, 3).join(', ')}`);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
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 skillsDir = process.env.ECC_SKILLS_DIR || DEFAULT_SKILLS_DIR;
const files = getSkillFiles(skillsDir);

if (files.length === 0) {
console.log(`No skill files found under ${skillsDir}`);
process.exit(0);
}

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

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

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

main();
168 changes: 168 additions & 0 deletions tests/ci/skill-quality-validator.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
/**
* Tests for the skill quality validator.
*/

const assert = require('assert');
const fs = require('fs');
const os = require('os');
const path = require('path');
const { spawnSync } = require('child_process');

const SCRIPT_PATH = path.join(__dirname, '..', '..', 'scripts', 'ci', 'validate-skill-quality.js');

function runValidator(files, extraArgs = []) {
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-skill-quality-'));
try {
for (const [name, contents] of Object.entries(files)) {
const filePath = path.join(tempDir, name);
fs.mkdirSync(path.dirname(filePath), { recursive: true });
fs.writeFileSync(filePath, contents, 'utf8');
}

const result = spawnSync('node', [SCRIPT_PATH, ...extraArgs], {
encoding: 'utf8',
env: {
...process.env,
ECC_SKILLS_DIR: tempDir,
},
});

return {
status: result.status ?? 1,
stdout: result.stdout || '',
stderr: result.stderr || '',
};
} finally {
fs.rmSync(tempDir, { recursive: true, force: true });
}
}

function run() {
console.log('\n=== Testing skill quality validation ===\n');

let passed = 0;
let failed = 0;

const check = (name, fn) => {
try {
fn();
console.log(` ✓ ${name}`);
passed += 1;
} catch (error) {
console.log(` ✗ ${name}`);
console.log(` Error: ${error.message}`);
failed += 1;
}
};

check('accepts a valid skill', () => {
const result = runValidator({
'skills/good-skill/SKILL.md': `---
name: good-skill
description: Useful workflow for validating a good skill.
---
# Good Skill

## When to Activate
Use when you need a good example.

## Core Concepts
Keep it practical.

## Examples
\`\`\`bash
node scripts/validate-skill-quality.js
\`\`\`

## Anti-Patterns
Avoid generic advice.

## Best Practices
- Keep it concrete.
`,
});
assert.strictEqual(result.status, 0, `${result.stderr || result.stdout}`);
});

check('reports missing activation section', () => {
const result = runValidator({
'skills/weak-skill/SKILL.md': `---
name: weak-skill
description: A weak skill.
---
# Weak Skill

## Core Concepts
No activation section.

## Examples
Example only.
`,
});
assert.notStrictEqual(result.status, 0, 'Expected validator to fail');
assert.match(result.stderr || result.stdout, /When to Activate/i);
});

check('rejects hardcoded secrets in examples', () => {
const result = runValidator({
'skills/secret-skill/SKILL.md': `---
name: secret-skill
description: Demo skill.
---
# Secret Skill

## When to Activate
Use when you need a secret example.

## Core Concepts
Check for credentials.

## Examples
\`\`\`bash
export API_KEY=sk_live_1234567890
\`\`\`

## Anti-Patterns
Avoid leaked variables.

## Best Practices
- Avoid secrets.
`,
});
assert.notStrictEqual(result.status, 0, 'Expected validator to fail');
assert.match(result.stderr || result.stdout, /secret|token|API_KEY/i);
});

check('supports --strict mode for missing anti-patterns', () => {
const result = runValidator({
'skills/no-anti-patterns/SKILL.md': `---
name: no-anti-patterns
description: A basic skill.
---
# No Anti-Patterns

## When to Activate
Use when the task is simple.

## Core Concepts
Keep it simple.

## Examples
\`\`\`bash
echo hello
\`\`\`

## Best Practices
- Keep it simple.
`,
}, ['--strict']);
assert.notStrictEqual(result.status, 0, 'Expected strict mode to fail');
assert.match(result.stderr || result.stdout, /Anti-Patterns/i);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
});

console.log(`\nPassed: ${passed}`);
console.log(`Failed: ${failed}`);
process.exit(failed > 0 ? 1 : 0);
}

run();