Code Guideline Format Check Skill
This skill validates that code guideline documentation format follows the established patterns in docs/__meta__/code.md.
When to Use This Skill
Use this skill when:
- Reviewing a PR that includes guideline doc changes
- After creating or editing a guideline doc
- Before committing changes to
docs/code/ - User requests a guideline doc format review
Review Process
Step 1: Identify Changed Guideline Docs
For recent commits:
git diff --name-only HEAD~1 | grep 'docs/code/.*\.md$'
For staged changes:
git diff --cached --name-only | grep 'docs/code/.*\.md$'
For unstaged changes:
git diff --name-only | grep 'docs/code/.*\.md$'
Step 2: Validate Each Guideline Doc
For each changed guideline doc, verify:
- Frontmatter format
- Content structure
- Discovery compatibility
Format Reference
All format requirements are defined in docs/meta/code.md. Read that file for:
- Frontmatter field requirements (
name,description,type,scope) - Description guidelines ("Load when" triggers, discovery optimization)
- Pattern type definitions (
principle,core,arch,crate,meta) - Scope format rules (
global,crate:<name>) - Naming conventions (kebab-case, flattened crate-specific guidelines)
- Required and optional sections (main content, Checklist)
- Cross-reference rules (relationship types and direction rules)
- No subdirectories rule (all files at
docs/code/root)
For principle-* guideline docs, also read docs/meta/code-principle.md for:
- Required sections specific to principle docs (Rule, Examples, Why It Matters, Pragmatism Caveat, Checklist)
- Example format (Bad/Good code pairs)
- Header format (title with parenthetical clarification)
- Optional sections (References, External References)
Use the Checklist section in docs/__meta__/code.md to validate guideline docs. For principle docs, additionally verify against the structure in docs/__meta__/code-principle.md.
Discovery Validation
Verify frontmatter is extractable:
Primary Method: Use the Grep tool with multiline mode:
- Pattern:
^---\n[\s\S]*?\n--- - Path:
docs/code/<pattern-name>.md - multiline:
true - output_mode:
content
Fallback: Bash command:
grep -Pzo '(?s)^---\n.*?\n---' docs/code/<pattern-name>.md
Cross-platform alternative (macOS compatible):
awk '/^---$/{p=!p; print; next} p' docs/code/<pattern-name>.md
Validation Process
- Identify changed files:
git diff --name-only HEAD~1 | grep 'docs/code/.*\.md$' - Read the guideline doc and Read docs/meta/code.md
- Validate using the checklist in the format specification
- Report findings using format below
Review Report Format
After validation, provide a structured report listing issues found. Use the checklist from docs/meta/code.md as the validation criteria.
## Guideline Doc Format Review: <filename>
### Issues Found
1. <issue description with line number>
2. <issue description with line number>
### Verdict: PASS/FAIL
<If FAIL, provide specific fixes needed referencing docs/__meta__/code.md>
Common Issues
When validation fails, refer to docs/meta/code.md for detailed requirements. Common issues include:
- Invalid frontmatter YAML syntax
namenot in kebab-case or doesn't match filename (minus.md)descriptionmissing "Load when" trigger clausetypenot one of:principle,core,arch,crate,metascopeinvalid format (notglobalorcrate:<name>)- Crate-specific patterns not following
<crate>-<type>.mdnaming - Guideline files in subdirectories (should be flat at
docs/code/root) - Missing required sections (main content, Checklist)
- Empty optional sections
Frontmatter Validation Checklist
Required Fields
-
namefield present and matches filename (minus.md) -
descriptionfield present with "Load when" trigger -
typefield present and valid (principle,core,arch,crate,meta) -
scopefield present and valid (globalorcrate:<name>)
Name Field
- Uses kebab-case
- Exactly matches filename without
.mdextension - For crate-specific: follows
<crate>-<type>format
Description Field
- Includes "Load when" trigger clause
- Clear and concise
- Optimized for AI agent discovery
Type Field
- Valid value:
principle,core,arch,crate, ormeta - Appropriate for guideline category
Scope Field
- Valid format:
globalorcrate:<name> -
principle,core,arch,metapatterns useglobal - Crate-specific patterns use
crate:<name>format
Content Structure Validation
Required Sections
- Title with guideline name
- Applicability statement (bold mandatory line)
- Main content sections with guideline details
- Checklist section for verification
Naming and Organization
- File located at
docs/code/root (no subdirectories) - Filename uses kebab-case
- Crate-specific patterns follow
<crate>-<type>.md
Pre-approved Commands
These tools/commands can run without user permission:
- Discovery command (Grep tool or bash fallback) on
docs/code/ - All
git diffandgit statusread-only commands - Reading files via Read tool
Next Steps
After format review:
- If format issues found - List specific fixes needed
- If format passes - Approve for commit
- Verify discovery - Ensure frontmatter is extractable with Grep tool