{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "phase4-workflow/pattern-to-skill/v1.0.0",
  "title": "Pattern to Skill Schema",
  "description": "Schema for pattern detection output (Integration Point 4.1)",
  "type": "object",
  "required": ["pattern_id", "pattern_type", "frequency", "confidence", "template", "variables"],
  "properties": {
    "pattern_id": {
      "type": "string",
      "description": "Unique pattern identifier",
      "pattern": "^pattern-[a-z0-9-]+$"
    },
    "pattern_type": {
      "type": "string",
      "description": "Type of pattern detected",
      "enum": ["code-generation", "debugging", "testing", "deployment", "refactoring"]
    },
    "frequency": {
      "type": "integer",
      "description": "How many times pattern was observed",
      "minimum": 1
    },
    "confidence": {
      "type": "number",
      "description": "Pattern detection confidence",
      "minimum": 0.0,
      "maximum": 1.0
    },
    "template": {
      "type": "string",
      "description": "Skill template file name",
      "pattern": "^.*\\.md$"
    },
    "variables": {
      "type": "object",
      "description": "Template variables",
      "required": ["skill_name", "description"],
      "properties": {
        "skill_name": {
          "type": "string",
          "minLength": 1
        },
        "description": {
          "type": "string",
          "minLength": 10
        }
      },
      "additionalProperties": true
    },
    "detected_at": {
      "type": "string",
      "format": "date-time",
      "description": "When pattern was detected"
    },
    "examples": {
      "type": "array",
      "description": "Example instances of the pattern",
      "items": {
        "type": "object"
      }
    }
  },
  "additionalProperties": false
}
