Skip to content

feat(tools): add deterministic skill validator for CI#2051

Merged
alexeyv merged 8 commits intomainfrom
feat-deterministic-skill-validator
Mar 18, 2026
Merged

feat(tools): add deterministic skill validator for CI#2051
alexeyv merged 8 commits intomainfrom
feat-deterministic-skill-validator

Conversation

@alexeyv
Copy link
Copy Markdown
Collaborator

@alexeyv alexeyv commented Mar 18, 2026

Summary

  • Add tools/validate-skills.js — Node CLI that checks 13 deterministic rules (SKILL-01–06, WF-01–02, PATH-02, STEP-01/06/07, SEQ-02) across all skill directories in under 1 second
  • Add validate:skills npm script to quality chain and push gate
  • Update tools/skill-validator.md with first-pass integration instructions so the inference validator skips already-verified rules
  • Includes review hardening: empty value guards, nested YAML protection, safe file reading with error recovery

Test plan

  • node tools/validate-skills.js --strict exits 0 (3 true-positive MEDIUM/LOW findings)
  • node tools/validate-skills.js --json produces valid JSON
  • npm run quality includes and passes validate:skills
  • Full test suite (232 tests), ESLint, Prettier, markdownlint all pass
  • Verify CI quality workflow passes

🤖 Generated with Claude Code

Add tools/validate-skills.js — a Node CLI that checks 13 deterministic
rules (SKILL-01–06, WF-01–02, PATH-02, STEP-01/06/07, SEQ-02) across
all skill directories. Runs in under a second, exits non-zero on HIGH+
findings in strict mode, and outputs JSON for the inference validator.

- Add validate:skills npm script to quality chain
- Update skill-validator.md with first-pass integration instructions
- Update AGENTS.md push gate documentation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 18, 2026

📝 Walkthrough

Walkthrough

This PR introduces a deterministic skill validator script (tools/validate-skills.js) as a first-pass validation layer, integrates it into the build pipeline via npm scripts, updates documentation to describe a two-pass validation workflow combining deterministic and inference-based checks, and updates references to the validation process.

Changes

Cohort / File(s) Summary
Documentation
AGENTS.md, tools/skill-validator.md
Updated to reflect new deterministic validation workflow. AGENTS.md replaced outdated skill-validator reference with npm script info. skill-validator.md expanded with two-pass validation guidance (deterministic first-pass + inference second-pass), 13 enumerated rules, rule-specific detection/fix details, and restructured formatting for reports and cheatsheet.
Build Configuration
package.json
Added validate:skills npm script and integrated it into the quality script to run deterministic checks during builds.
Deterministic Validator
tools/validate-skills.js
New 705-line validator implementing 13 deterministic validation rules (SKILL-01 through STEP-07, SEQ-02, WF-01/WF-02, PATH-02). Includes skill discovery, frontmatter parsing (single-line and multiline), rule-based validation, and dual output formats (human-readable and JSON with GitHub Actions integration). Exports four public functions: parseFrontmatter, parseFrontmatterMultiline, validateSkill, and discoverSkillDirs.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

  • PR #1996: Applies fixes for installed_path and intra-skill path variables that the new deterministic validator rules explicitly forbid.
  • PR #1991: Removes installed_path and intra-skill variables to satisfy PATH-02/PATH-04 checks implemented in the new validator.
  • PR #1981: Updates skill validation tooling documentation; this PR integrates the new deterministic validator into the two-pass validation workflow.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat-deterministic-skill-validator
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
tools/validate-skills.js (1)

211-229: Consider adding error handling for directory read failures.

Unlike discoverSkillDirs (which checks fs.existsSync before reading), collectSkillFiles doesn't guard against readdirSync failures. If a directory becomes inaccessible mid-walk (e.g., permission change, symlink target removed), this would throw an unhandled exception.

🛡️ Optional: wrap readdirSync in try-catch
 function collectSkillFiles(skillDir) {
   const files = [];

   function walk(dir) {
+    let entries;
+    try {
+      entries = fs.readdirSync(dir, { withFileTypes: true });
+    } catch {
+      return; // Skip inaccessible directories
+    }
-    const entries = fs.readdirSync(dir, { withFileTypes: true });
     for (const entry of entries) {
       if (entry.name === 'node_modules' || entry.name === '.git') continue;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tools/validate-skills.js` around lines 211 - 229, The collectSkillFiles
function currently calls fs.readdirSync inside the nested walk function without
handling errors, so a mid-walk permission or IO failure will throw; wrap the
fs.readdirSync(dir, { withFileTypes: true }) call in a try-catch inside walk (or
check fs.existsSync/permissions before reading) to catch and log or silently
skip unreadable directories, and ensure the walk continues for other entries;
update collectSkillFiles/walk to handle and optionally report errors (e.g.,
using console.warn or the existing logger) while still returning the collected
files.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tools/validate-skills.js`:
- Around line 211-229: The collectSkillFiles function currently calls
fs.readdirSync inside the nested walk function without handling errors, so a
mid-walk permission or IO failure will throw; wrap the fs.readdirSync(dir, {
withFileTypes: true }) call in a try-catch inside walk (or check
fs.existsSync/permissions before reading) to catch and log or silently skip
unreadable directories, and ensure the walk continues for other entries; update
collectSkillFiles/walk to handle and optionally report errors (e.g., using
console.warn or the existing logger) while still returning the collected files.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: adc86a9f-0e0a-4565-99ff-8f68de7fdbd3

📥 Commits

Reviewing files that changed from the base of the PR and between 0380656 and 5a1f356.

📒 Files selected for processing (4)
  • AGENTS.md
  • package.json
  • tools/skill-validator.md
  • tools/validate-skills.js

@augmentcode
Copy link
Copy Markdown

augmentcode Bot commented Mar 18, 2026

🤖 Augment PR Summary

Summary: This PR introduces a fast, deterministic skill validator to complement the existing inference-based validation and make CI enforcement more consistent.

Changes:

  • Added tools/validate-skills.js, a Node CLI that validates 13 deterministic rules (SKILL-01–06, WF-01–02, PATH-02, STEP-01/06/07, SEQ-02) across all discovered skills.
  • Implemented both human-readable and --json output modes, plus --strict behavior that fails the process only on CRITICAL/HIGH findings.
  • Integrated the new validator into the quality chain via npm run validate:skills and appended it to npm run quality.
  • Updated tools/skill-validator.md to document the deterministic “first pass” and how to skip already-verified rules during inference-based review.
  • Documented the new deterministic validation entrypoint in AGENTS.md.

Technical Notes: The validator discovers skill directories under src/core/skills, src/core/tasks, src/bmm/workflows, and src/bmm/agents, and emits GitHub Actions annotations/step summaries when running in CI.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 3 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread tools/validate-skills.js
Comment thread tools/validate-skills.js
Comment thread tools/validate-skills.js
alexeyv and others added 7 commits March 18, 2026 00:11
Replace SKILL_LOCATIONS array and AGENT_LOCATION constant with a single
walk from SRC_DIR. Any directory under src/ containing SKILL.md is a
skill — no need to enumerate locations.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Require \n---\n (not just \n---) for closing frontmatter delimiter
  in both parseFrontmatter and parseFrontmatterMultiline, with fallback
  for files ending in \n---
- Add SKILL-07: SKILL.md must have non-empty body content after
  frontmatter (L2 instructions are required)
- Update rule count to 14

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…en names

- SKILL-04: require bmad- prefix, enforce single dashes via regex
  ^bmad-[a-z0-9]+(-[a-z0-9]+)*$, drop FORBIDDEN_NAME_SUBSTRINGS
- WF-01/WF-02: check all .md files (not just workflow.md) for stray
  name/description frontmatter, with tech-writer exception
- Update skill-validator.md prompt to match all rule changes

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Guard against YAML comment lines in parseFrontmatterMultiline
- Broaden PATH-02 to detect any installed_path mention, not just variable refs

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The deterministic skill validator was in the npm quality chain but
missing from the GitHub Actions workflow.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@alexeyv alexeyv merged commit 1a0da02 into main Mar 18, 2026
5 checks passed
@alexeyv alexeyv deleted the feat-deterministic-skill-validator branch March 18, 2026 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant