{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://claude-context.dev/schemas/settings.schema.json",
  "title": "Claude Context Engineering Settings",
  "description": "Configuration schema for Claude Code context engineering system",
  "type": "object",
  "required": ["version", "context_engineering"],
  "properties": {
    "$schema": {
      "type": "string",
      "description": "JSON Schema reference"
    },
    "version": {
      "type": "string",
      "pattern": "^\\d+\\.\\d+\\.\\d+$",
      "description": "Semantic version of the configuration format"
    },
    "context_engineering": {
      "type": "object",
      "description": "Core context engineering settings",
      "required": ["enabled", "max_context_tokens"],
      "properties": {
        "enabled": {
          "type": "boolean",
          "default": true,
          "description": "Enable context engineering features"
        },
        "max_context_tokens": {
          "type": "integer",
          "minimum": 1000,
          "maximum": 200000,
          "default": 200000,
          "description": "Maximum context window size in tokens"
        },
        "max_output_tokens": {
          "type": "integer",
          "minimum": 1000,
          "maximum": 30000,
          "default": 30000,
          "description": "Maximum output tokens per response"
        },
        "target_utilization": {
          "type": "number",
          "minimum": 0.1,
          "maximum": 1.0,
          "default": 0.40,
          "description": "Target context utilization (0.0-1.0)"
        },
        "compact_trigger": {
          "type": "number",
          "minimum": 0.1,
          "maximum": 1.0,
          "default": 0.35,
          "description": "Context utilization threshold to trigger compaction"
        }
      }
    },
    "rpi_workflow": {
      "type": "object",
      "description": "Research-Plan-Implement workflow settings",
      "properties": {
        "enabled": {
          "type": "boolean",
          "default": true,
          "description": "Enable RPI workflow commands"
        },
        "phases": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": ["research", "plan", "implement"]
          },
          "default": ["research", "plan", "implement"],
          "description": "Enabled RPI phases"
        },
        "require_human_approval": {
          "type": "boolean",
          "default": true,
          "description": "Require human approval before implementation"
        },
        "auto_doc_update": {
          "type": "boolean",
          "default": true,
          "description": "Automatically update documentation after changes"
        },
        "research_timeout_minutes": {
          "type": "integer",
          "minimum": 5,
          "maximum": 120,
          "default": 30,
          "description": "Timeout for research phase in minutes"
        },
        "plan_timeout_minutes": {
          "type": "integer",
          "minimum": 5,
          "maximum": 60,
          "default": 20,
          "description": "Timeout for plan phase in minutes"
        }
      }
    },
    "documentation": {
      "type": "object",
      "description": "Documentation maintenance settings",
      "properties": {
        "self_maintaining": {
          "type": "boolean",
          "default": true,
          "description": "Enable self-maintaining documentation features"
        },
        "verify_after_changes": {
          "type": "boolean",
          "default": true,
          "description": "Verify documentation after code changes"
        },
        "line_number_tolerance": {
          "type": "integer",
          "minimum": 1,
          "maximum": 50,
          "default": 10,
          "description": "Acceptable line number drift tolerance"
        },
        "auto_commit_docs": {
          "type": "boolean",
          "default": false,
          "description": "Automatically commit documentation updates"
        }
      }
    },
    "agents": {
      "type": "object",
      "description": "Agent configuration",
      "properties": {
        "default": {
          "type": "string",
          "default": "context-engineer",
          "description": "Default agent for initialization tasks"
        },
        "auto_select": {
          "type": "boolean",
          "default": true,
          "description": "Automatically select appropriate agent for task"
        },
        "fallback": {
          "type": "string",
          "description": "Fallback agent when auto-selection fails"
        }
      }
    },
    "commands": {
      "type": "object",
      "description": "Command configuration",
      "properties": {
        "rpi_commands": {
          "type": "array",
          "items": { "type": "string" },
          "default": ["/rpi-research", "/rpi-plan", "/rpi-implement"],
          "description": "RPI workflow commands"
        },
        "validation_commands": {
          "type": "array",
          "items": { "type": "string" },
          "default": ["/verify-docs-current", "/validate-all"],
          "description": "Validation commands"
        }
      }
    },
    "validation": {
      "type": "object",
      "description": "Validation settings",
      "properties": {
        "on_commit": {
          "type": "boolean",
          "default": true,
          "description": "Run validation on commit"
        },
        "line_accuracy_threshold": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100,
          "default": 60,
          "description": "Minimum line number accuracy percentage"
        },
        "link_check_external": {
          "type": "boolean",
          "default": false,
          "description": "Check external links (slower)"
        }
      }
    },
    "logging": {
      "type": "object",
      "description": "Logging configuration",
      "properties": {
        "level": {
          "type": "string",
          "enum": ["debug", "info", "warn", "error"],
          "default": "info",
          "description": "Minimum log level"
        },
        "file": {
          "type": "string",
          "default": ".ai-context/logs/claude.log",
          "description": "Log file path"
        },
        "max_size_mb": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100,
          "default": 10,
          "description": "Maximum log file size in MB"
        }
      }
    },
    "telemetry": {
      "type": "object",
      "description": "Optional telemetry settings (opt-in only)",
      "properties": {
        "enabled": {
          "type": "boolean",
          "default": false,
          "description": "Enable telemetry (opt-in)"
        },
        "events": {
          "type": "object",
          "properties": {
            "command_usage": { "type": "boolean", "default": true },
            "agent_usage": { "type": "boolean", "default": true },
            "context_metrics": { "type": "boolean", "default": true },
            "error_reports": { "type": "boolean", "default": true }
          }
        },
        "privacy": {
          "type": "object",
          "properties": {
            "anonymize_paths": { "type": "boolean", "default": true },
            "exclude_content": { "type": "boolean", "default": true }
          }
        }
      }
    }
  },
  "additionalProperties": false
}
