{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://claude-context.dev/schemas/workflow.schema.json",
  "title": "Claude Context Workflow",
  "description": "Schema for workflow documentation files (YAML frontmatter)",
  "type": "object",
  "required": ["name", "description", "complexity"],
  "properties": {
    "name": {
      "type": "string",
      "pattern": "^[a-z0-9-]+$",
      "minLength": 1,
      "maxLength": 50,
      "description": "Workflow identifier"
    },
    "displayName": {
      "type": "string",
      "maxLength": 100,
      "description": "Human-readable workflow name"
    },
    "description": {
      "type": "string",
      "maxLength": 500,
      "description": "Brief description of the workflow"
    },
    "complexity": {
      "type": "string",
      "enum": ["low", "medium", "high"],
      "description": "Workflow complexity level"
    },
    "estimated_lines": {
      "type": "integer",
      "minimum": 1,
      "description": "Estimated lines of code in this workflow"
    },
    "estimated_tokens": {
      "type": "integer",
      "minimum": 100,
      "description": "Estimated documentation tokens"
    },
    "category": {
      "type": "string",
      "description": "Workflow category (e.g., 'authentication', 'payment')"
    },
    "entry_points": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "file": { "type": "string" },
          "line": { "type": "integer" },
          "function": { "type": "string" },
          "description": { "type": "string" }
        },
        "required": ["file", "function"]
      },
      "description": "Entry points into this workflow"
    },
    "files": {
      "type": "array",
      "items": { "type": "string" },
      "description": "Files involved in this workflow"
    },
    "sub_workflows": {
      "type": "array",
      "items": { "type": "string" },
      "description": "Related sub-workflows"
    },
    "database_tables": {
      "type": "array",
      "items": { "type": "string" },
      "description": "Database tables accessed"
    },
    "external_apis": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "service": { "type": "string" },
          "endpoint": { "type": "string" },
          "auth_method": { "type": "string" }
        },
        "required": ["service"]
      },
      "description": "External APIs called"
    },
    "test_files": {
      "type": "array",
      "items": { "type": "string" },
      "description": "Related test files"
    },
    "related_agents": {
      "type": "array",
      "items": { "type": "string" },
      "description": "Agents that specialize in this workflow"
    },
    "gotchas": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "issue": { "type": "string" },
          "solution": { "type": "string" },
          "severity": {
            "type": "string",
            "enum": ["low", "medium", "high", "critical"]
          }
        },
        "required": ["issue", "solution"]
      },
      "description": "Known gotchas and their solutions"
    },
    "last_verified": {
      "type": "string",
      "format": "date",
      "description": "Date of last documentation verification"
    },
    "accuracy_score": {
      "type": "integer",
      "minimum": 0,
      "maximum": 100,
      "description": "Line number accuracy percentage"
    }
  },
  "additionalProperties": false
}
