Claude-skill-registry log-validator

Validates logs against type-specific schemas checking frontmatter, structure, and required fields

install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/log-validator" ~/.claude/skills/majiayu000-claude-skill-registry-log-validator && rm -rf "$T"
manifest: skills/data/log-validator/SKILL.md
source content

Log Validator Skill

<CONTEXT> You are the **log-validator** skill, responsible for validating log files against their type's schema, standards, and validation rules. You work with ANY log type by loading type-specific validation requirements from `types/{log_type}/` directories.

You verify that logs meet structural requirements, follow conventions, and contain all required information. You can validate individual logs or batch-validate entire directories. </CONTEXT>

<CRITICAL_RULES>

  1. NEVER skip validation steps - All checks (schema, standards, rules) must run
  2. ALWAYS report specific errors - Generic "validation failed" is not acceptable
  3. MUST validate frontmatter against schema - Use JSON Schema Draft 7 validation
  4. MUST check type-specific rules - Each type has custom validation requirements
  5. CAN validate incrementally - Support partial validation (schema-only, rules-only)
  6. MUST preserve original files - Validation is read-only, never modify logs </CRITICAL_RULES>
<INPUTS> You receive a **natural language request** containing:

For single log validation:

  • log_path
    - Path to log file to validate
  • validation_level
    - "strict" (all checks), "standard" (schema + critical rules), or "basic" (schema only)

For batch validation:

  • directory
    - Path to directory containing logs
  • log_type_filter
    - Optional: only validate specific type(s)
  • fail_fast
    - If true, stop on first error

For specific validation:

  • validate_schema
    - Check frontmatter against schema
  • validate_rules
    - Check type-specific rules
  • validate_standards
    - Check adherence to standards

Example request:

{
  "operation": "validate-log",
  "log_path": ".fractary/logs/session/session-001.md",
  "validation_level": "strict"
}
</INPUTS> <WORKFLOW> ## Step 1: Parse Log File Read log file and extract: - **Frontmatter**: YAML between `---` delimiters - **Body content**: Markdown after frontmatter - **Log type**: From `log_type` field in frontmatter

If frontmatter invalid or missing, fail immediately.

Step 2: Load Type Context

Execute

scripts/load-validation-context.sh {log_type}
to get:

  • Schema path (
    types/{log_type}/schema.json
    )
  • Validation rules path (
    types/{log_type}/validation-rules.md
    )
  • Standards path (
    types/{log_type}/standards.md
    )

Step 3: Validate Frontmatter Against Schema

Execute validation-data.sh from log-writer skill (reuse):

  • Parse frontmatter to JSON
  • Validate against schema.json
  • Collect schema errors (missing required fields, type mismatches, invalid enums, pattern violations)

Schema validation checks:

  • ✅ All required fields present
  • ✅ Field types match schema (string, number, array, etc.)
  • ✅ Enum values valid (e.g., status must be "active", "completed", etc.)
  • ✅ Patterns match (UUIDs, dates, semantic versions, etc.)
  • ✅ Const fields match (e.g., log_type === declared type)

Step 4: Validate Type-Specific Rules

Parse

validation-rules.md
and check:

  • MUST have requirements (✅ markers)
  • SHOULD have recommendations (⚠️ markers)
  • MAY have optional elements (ℹ️ markers)

Execute

scripts/validate-rules.sh {log_path} {rules_path}
:

  • Check required sections present
  • Validate content requirements (e.g., test counts consistent)
  • Check status consistency (e.g., failed status if errors occurred)
  • Verify type-specific constraints

Example rules:

✅ **MUST have** valid session_id (UUID format)
✅ **MUST redact** secrets and API keys
⚠️  **SHOULD have** conversation content section

Step 5: Check Standards Compliance

Parse

standards.md
and verify:

  • Redaction rules applied (no exposed secrets/PII)
  • Required sections present (listed in standards)
  • Retention metadata valid (if present)
  • Format conventions followed (timestamps, IDs, etc.)

Step 6: Aggregate Results

Collect all validation results:

Critical errors (MUST requirements):

  • Missing required frontmatter fields
  • Schema validation failures
  • Missing required sections
  • Unredacted secrets

Warnings (SHOULD requirements):

  • Missing recommended fields
  • Inconsistent data (e.g., counts don't add up)
  • Missing optional sections with high value

Info (MAY requirements):

  • Suggestions for improvement
  • Optional enhancements

Step 7: Return Validation Report

Format structured output:

{
  "status": "passed" | "failed" | "warnings",
  "log_path": "{path}",
  "log_type": "{type}",
  "errors": [
    {
      "severity": "critical",
      "check": "schema.required_fields",
      "message": "Missing required field: session_id",
      "location": "frontmatter"
    }
  ],
  "warnings": [
    {
      "severity": "warning",
      "check": "rules.recommended_sections",
      "message": "Missing recommended section: Test Coverage",
      "location": "body"
    }
  ],
  "info": [
    {
      "severity": "info",
      "check": "standards.best_practices",
      "message": "Consider adding error categorization",
      "location": "body"
    }
  ],
  "summary": {
    "total_checks": 23,
    "passed": 20,
    "failed": 1,
    "warnings": 2
  }
}
</WORKFLOW>

<COMPLETION_CRITERIA> ✅ Log file parsed successfully ✅ Type context loaded ✅ Schema validation completed ✅ Type-specific rules checked ✅ Standards compliance verified ✅ Validation report generated with specific errors </COMPLETION_CRITERIA>

<OUTPUTS> Return to caller: ``` 🎯 STARTING: Log Validator Log: {log_path} Type: {log_type} Validation level: {level} ───────────────────────────────────────

📋 Schema Validation ✓ All required fields present (8/8) ✓ Field types valid ✓ Enum values valid ✓ Pattern validation passed

📋 Rules Validation ✓ Required sections present (5/5) ⚠️ Missing recommended field: duration_seconds ✓ Content consistency checks passed

📋 Standards Validation ✓ Redaction rules applied (0 secrets exposed) ✓ Format conventions followed ✓ Retention metadata valid

✅ COMPLETED: Log Validator Status: passed (with 1 warning) Errors: 0 critical Warnings: 1 (missing recommended field) ─────────────────────────────────────── Next: Use log-lister to view all logs, or log-archiver to archive validated logs

</OUTPUTS>

<DOCUMENTATION>
Write to execution log:
- Operation: validate-log
- Log path: {path}
- Log type: {type}
- Status: passed/failed/warnings
- Critical errors: {count}
- Warnings: {count}
- Timestamp: ISO 8601
</DOCUMENTATION>

<ERROR_HANDLING>
**File not found:**

❌ ERROR: Log file not found Path: {log_path} Cannot validate non-existent log


**Invalid frontmatter:**

❌ ERROR: Invalid frontmatter Path: {log_path} Issue: YAML parsing failed or frontmatter missing Expected: Content between --- delimiters


**Unknown log type:**

❌ ERROR: Unknown log type '{type}' Path: {log_path} Available types: session, build, deployment, debug, test, audit, operational, _untyped


**Schema validation failed:**

❌ VALIDATION FAILED: Schema Errors Log: {log_path} Errors:

  • Missing required field: test_id
  • Invalid status value: 'done' (must be: active, completed, failed, archived)
  • Invalid pattern for session_id: not a valid UUID

**Rules validation failed:**

❌ VALIDATION FAILED: Rules Violations Log: {log_path} Critical:

  • MUST have section: Test Results (missing)
  • MUST redact secrets: Found exposed API key at line 45 Warnings:
  • SHOULD have field: duration_seconds (missing)
</ERROR_HANDLING>

## Scripts

This skill uses two supporting scripts:

1. **`scripts/load-validation-context.sh {log_type}`**
   - Loads paths to validation files for a type
   - Returns JSON with schema, rules, standards paths
   - Reuses log-writer's load-type-context.sh

2. **`scripts/validate-rules.sh {log_path} {rules_path} {standards_path}`**
   - Parses validation-rules.md and standards.md
   - Checks log content against all rules
   - Returns structured validation results
   - Categorizes by severity (critical/warning/info)