Skip to main content

/component-validate

Validate CODITECT components against schema requirements, naming conventions, and quality standards.

Syntax

/component-validate [path] [options]

Options

OptionDescriptionExample
--type <type>Validate only specific type--type agent
--strictFail on warnings (not just errors)--strict
--fixAuto-fix simple issues--fix
--schemaValidate frontmatter schema--schema
--linksCheck for broken links--links
--orphansFind orphaned components--orphans
--duplicatesCheck for duplicate IDs--duplicates
--format <fmt>Output format: text, json, sarif--format json
--output <file>Write results to file--output report.json
--verboseShow detailed validation--verbose

Validation Checks

Schema Validation

CheckDescriptionSeverity
frontmatter_requiredYAML frontmatter existsERROR
title_requiredTitle field presentERROR
component_type_validValid component_typeERROR
version_formatSemantic version formatWARNING
status_validStatus in allowed valuesWARNING
summary_lengthSummary under 200 charsINFO

Naming Conventions

CheckDescriptionSeverity
lowercase_filenameFilename is lowercaseERROR
kebab_caseUses kebab-caseWARNING
no_special_charsNo special charactersERROR
skill_structureSkills use SKILL.mdERROR
unique_idNo duplicate IDsERROR

Quality Standards

CheckDescriptionSeverity
description_presentHas descriptionWARNING
examples_presentHas usage examplesINFO
tags_presentHas tags arrayINFO
created_dateHas creation dateINFO
no_todo_markersNo TODO/FIXME markersINFO

Examples

Basic Validation

# Validate all components
/component-validate

# Validate specific directory
/component-validate agents/

# Validate single file
/component-validate commands/component-search.md

Type-Specific

# Validate only agents
/component-validate --type agent

# Validate only skills
/component-validate --type skill --strict

Quality Checks

# Check for broken links
/component-validate --links

# Find orphaned components (not indexed)
/component-validate --orphans

# Find duplicate component IDs
/component-validate --duplicates

Auto-Fix

# Fix simple issues automatically
/component-validate --fix

# Dry-run fix
/component-validate --fix --dry-run

CI/CD Integration

# Strict mode for CI
/component-validate --strict --format sarif --output validation.sarif

# JSON output for processing
/component-validate --format json | jq '.errors'

Output

Text Format (Default)

Component Validation Report
===========================

Validating 3,027 components...

ERRORS (3):
agents/bad-agent.md:1
✗ frontmatter_required: Missing YAML frontmatter

commands/my command.md:1
✗ no_special_chars: Filename contains spaces

skills/nested/deep/SKILL.md:1
✗ skill_structure: Skills cannot be nested (Claude Code requirement)

WARNINGS (12):
agents/legacy-agent.md:5
⚠ version_format: Invalid version "v1" (use semantic: 1.0.0)
...

INFO (45):
commands/old-cmd.md:10
ℹ no_todo_markers: Contains TODO marker

Summary:
Total: 3,027
Valid: 3,024
Errors: 3
Warnings: 12
Info: 45

Status: FAILED (3 errors)

JSON Format

{
"summary": {
"total": 3027,
"valid": 3024,
"errors": 3,
"warnings": 12,
"info": 45
},
"issues": [
{
"file": "agents/bad-agent.md",
"line": 1,
"severity": "error",
"rule": "frontmatter_required",
"message": "Missing YAML frontmatter",
"fixable": false
}
],
"status": "failed"
}

Auto-Fix Capabilities

The --fix option can automatically fix:

IssueFix Applied
Missing frontmatterAdd template frontmatter
Invalid statusSet to "active"
Missing created dateAdd current date
Uppercase filenameRename to lowercase
Missing newline at EOFAdd newline

Exit Codes

CodeMeaning
0All validations passed
1Errors found
2Warnings found (with --strict)
3Validation system error

Implementation

# Underlying script
python3 scripts/component-db-cli.py validate [path] [options]

# Python API
from scripts.component_validator import validate_components
results = validate_components(path="agents/", strict=True)

Pre-Commit Hook

Add to .git/hooks/pre-commit:

#!/bin/bash
# Validate changed component files
CHANGED=$(git diff --cached --name-only | grep -E '\.(md|json)$')
if [ -n "$CHANGED" ]; then
python3 scripts/component-db-cli.py validate $CHANGED --strict
if [ $? -ne 0 ]; then
echo "Component validation failed. Fix errors before committing."
exit 1
fi
fi
CommandPurpose
/component-indexRebuild index
/component-searchSearch components
/component-statsView statistics
/classifyAuto-classify documents

Script: scripts/component-db-cli.py Config: ~/.coditect/config/validation-rules.json