{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "BMad Manifest Schema",
  "description": "Unified schema for all BMad skill manifest files (agents, workflows, skills)",

  "type": "object",

  "properties": {
    "$schema": {
      "description": "JSON Schema identifier",
      "type": "string"
    },

    "module-code": {
      "description": "Short code for the module this skill belongs to (e.g., bmb, cis). Omit for standalone skills.",
      "type": "string",
      "pattern": "^[a-z][a-z0-9-]*$"
    },

    "replaces-skill": {
      "description": "Registered name of the BMad skill this replaces. Inherits metadata during bmad-init.",
      "type": "string",
      "minLength": 1
    },

    "persona": {
      "description": "Succinct distillation of the agent's essence — who they are, how they operate, what drives them. Presence of this field indicates the skill is an agent. Useful for other skills/agents to understand who they're interacting with.",
      "type": "string",
      "minLength": 1
    },

    "has-memory": {
      "description": "Whether this skill persists state across sessions via sidecar memory.",
      "type": "boolean"
    },

    "capabilities": {
      "description": "What this skill can do. Every skill has at least one capability.",
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "description": "Capability identifier (kebab-case)",
            "type": "string",
            "pattern": "^[a-z][a-z0-9-]*$"
          },
          "menu-code": {
            "description": "2-3 uppercase letter shortcut for interactive menus",
            "type": "string",
            "pattern": "^[A-Z]{2,3}$"
          },
          "description": {
            "description": "What this capability does and when to suggest it",
            "type": "string"
          },
          "supports-headless": {
            "description": "Whether this capability can run without user interaction",
            "type": "boolean"
          },

          "prompt": {
            "description": "Relative path to the prompt file for internal capabilities (e.g., build-process.md). Omit if handled by SKILL.md directly or if this is an external skill call.",
            "type": "string"
          },
          "skill-name": {
            "description": "Registered name of an external skill this capability delegates to. Omit for internal capabilities.",
            "type": "string"
          },

          "phase-name": {
            "description": "Which module phase this capability belongs to (e.g., planning, design, anytime). For module sequencing.",
            "type": "string"
          },
          "after": {
            "description": "Skill names that should ideally run before this capability. If is-required is true on those skills, they block this one.",
            "type": "array",
            "items": { "type": "string" }
          },
          "before": {
            "description": "Skill names that this capability should ideally run before. Helps the module sequencer understand ordering.",
            "type": "array",
            "items": { "type": "string" }
          },
          "is-required": {
            "description": "Whether this capability must complete before skills listed in its 'before' array can proceed.",
            "type": "boolean"
          },
          "output-location": {
            "description": "Where this capability writes its output. May contain config variables (e.g., {bmad_builder_output_folder}/agents/).",
            "type": "string"
          }
        },
        "required": ["name", "menu-code", "description"],
        "additionalProperties": false
      }
    }
  },

  "required": ["capabilities"],
  "additionalProperties": false
}
