{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://claude-context.dev/schemas/command.schema.json",
  "title": "Claude Context Command",
  "description": "Schema for command manifest files",
  "type": "object",
  "required": ["name", "version", "description"],
  "properties": {
    "$schema": {
      "type": "string",
      "description": "JSON Schema reference"
    },
    "name": {
      "type": "string",
      "pattern": "^[a-z0-9-]+$",
      "minLength": 1,
      "maxLength": 50,
      "description": "Command identifier (without leading slash)"
    },
    "version": {
      "type": "string",
      "pattern": "^\\d+\\.\\d+\\.\\d+$",
      "description": "Command version (semver)"
    },
    "displayName": {
      "type": "string",
      "maxLength": 100,
      "description": "Human-readable command name"
    },
    "description": {
      "type": "string",
      "maxLength": 500,
      "description": "Brief description of command purpose"
    },
    "category": {
      "type": "string",
      "enum": [
        "rpi-orchestration",
        "validation",
        "system",
        "debugging",
        "documentation",
        "extension-management",
        "collaboration",
        "custom"
      ],
      "description": "Command category"
    },
    "syntax": {
      "type": "string",
      "description": "Command syntax pattern (e.g., '/command [arg1] [--flag]')"
    },
    "arguments": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": { "type": "string" },
          "type": {
            "type": "string",
            "enum": ["string", "number", "boolean", "file", "directory"]
          },
          "required": { "type": "boolean", "default": false },
          "description": { "type": "string" },
          "default": {}
        },
        "required": ["name", "type", "description"]
      },
      "description": "Command arguments"
    },
    "flags": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": { "type": "string" },
          "short": { "type": "string", "maxLength": 1 },
          "type": { "type": "string", "enum": ["boolean", "string", "number"] },
          "description": { "type": "string" },
          "default": {}
        },
        "required": ["name", "description"]
      },
      "description": "Command flags/options"
    },
    "context_budget_estimate": {
      "type": "string",
      "description": "Estimated token usage (e.g., '50K tokens')"
    },
    "typical_context_usage": {
      "type": "string",
      "pattern": "^\\d+%$",
      "description": "Typical usage as percentage (e.g., '25%')"
    },
    "prerequisites": {
      "type": "array",
      "items": { "type": "string" },
      "description": "Required conditions before running"
    },
    "outputs": {
      "type": "array",
      "items": { "type": "string" },
      "description": "What this command produces"
    },
    "next_commands": {
      "type": "array",
      "items": { "type": "string" },
      "description": "Suggested follow-up commands"
    },
    "related_agents": {
      "type": "array",
      "items": { "type": "string" },
      "description": "Related agents"
    },
    "examples": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "command": { "type": "string" },
          "description": { "type": "string" }
        },
        "required": ["command", "description"]
      },
      "description": "Usage examples"
    },
    "exit_criteria": {
      "type": "array",
      "items": { "type": "string" },
      "description": "Checklist for command completion"
    }
  },
  "additionalProperties": false
}
