AgentSkillsCN

rune-validator

依据模式规则对 RUNE 规范进行校验与验证。适用于当您收到 .rune 文件或 Markdown 规范章节时,需要检查其完整性、格式是否规范、内部一致性是否良好时使用。

SKILL.md
--- frontmatter
name: rune-validator
description: Validate RUNE specifications against pattern rules. Use when given a .rune file or Markdown spec section that needs checking for completeness, well-formedness, and internal consistency.
license: MIT

How to Use

When asked to validate a RUNE spec, run every check below and return a structured report.

Input: a .rune YAML file or a Markdown section following the RUNE pattern.


Validation Checklist

1. Structure Checks

Run these checks first. If any fail, the spec is invalid.

#RulePass condition
S1Required fields presentSIGNATURE, INTENT, BEHAVIOR, and TESTS all exist
S2YAML meta header (YAML only)meta.name and meta.language are present
S3RUNE header matches meta.name (YAML only)RUNE: value equals meta.name
S4Markdown formatting (Markdown only)Field names are bold (**SIGNATURE:**), code in backticks
S5Valid YAML syntax (YAML only)File parses without YAML errors

2. Content Checks

#RulePass condition
C1SIGNATURE uses real language syntaxNot pseudocode. Uses the target language's actual function declaration syntax
C2INTENT is 1-3 sentencesNo more than 3 sentences. No implementation details (no algorithms, regex, library names)
C3BEHAVIOR uses WHEN/THEN formatEvery rule is a WHEN/THEN clause, with an optional OTHERWISE as the last rule
C4BEHAVIOR rules are ordered correctlyValidations first, business logic second, default (OTHERWISE) last
C5TESTS has at least 3 casesMinimum: 1 happy path, 1 boundary, 1 error case
C6TESTS use correct formatEach test is function(input) == expected or function(input) raises ErrorType

3. Consistency Checks

#RulePass condition
X1Every BEHAVIOR rule has a testEach WHEN/THEN clause maps to at least one test case
X2Every EDGE_CASE has a testIf EDGE_CASES is present, each entry maps to a test
X3CONSTRAINTS have BEHAVIOR rulesEach constraint that requires runtime validation has a corresponding WHEN/THEN rule
X4Error messages matchError messages in BEHAVIOR match the messages expected in TESTS
X5SIGNATURE matches TESTSFunction name and parameter count in TESTS match SIGNATURE

Output Format

Return the report in this format:

markdown
## RUNE Validation Report: `<function_name>`

### Structure
- [PASS] S1: Required fields present
- [PASS] S2: YAML meta header valid
- [FAIL] S3: RUNE header mismatch — RUNE says "validate_email" but meta.name is "email_validator"

### Content
- [PASS] C1: SIGNATURE uses real language syntax
- [WARN] C2: INTENT has 4 sentences (max 3 recommended)
- [PASS] C3: BEHAVIOR uses WHEN/THEN format
...

### Consistency
- [FAIL] X1: BEHAVIOR rule "WHEN code is empty THEN ..." has no corresponding test
- [PASS] X2: All EDGE_CASES have tests
...

### Summary
- **Status:** FAIL (2 errors, 1 warning)
- **Errors:** S3, X1
- **Warnings:** C2
- **Suggestions:**
  - Rename RUNE header to match meta.name
  - Add test: `validate_email('') == (False, "Email cannot be empty")`
  - Consider shortening INTENT to 3 sentences

Severity Levels

  • FAIL — Spec violates a required rule. Must be fixed before implementation.
  • WARN — Spec is technically valid but has a quality issue. Should be fixed.
  • PASS — Rule satisfied.

Rules

  • Always run ALL checks, even if early checks fail
  • Report every issue found, not just the first one
  • For each FAIL or WARN, include a specific suggestion on how to fix it
  • If the spec is valid (all PASS), say so clearly
  • Do not modify the spec — only report findings