"""Claude Code config catalog.

A complete inventory of every configurable surface in Claude Code 2.1.x:
- environment variables (extracted from the binary)
- settings.json keys (documented + discovered)
- CLI flags
- slash commands
- hook events

Each entry has a description, a use case ("when you want X"), and an
example value. Categories chosen for the TUI sidebar.
"""

# Source: claude binary 2.1.148 strings extraction + Anthropic docs +
# Marco's deployment experience.

CATEGORIES = [
    "Auth & API",
    "Models",
    "Thinking & Effort",
    "Permissions & Sandbox",
    "Hooks",
    "Skills & Plugins",
    "MCP",
    "Background Agents",
    "Cache & Compaction",
    "Bash Tool",
    "UI & TUI",
    "Telemetry & Privacy",
    "Updates & Install",
    "Cloud Providers",
    "Limits & Timeouts",
    "Debug & Logging",
    "Experimental & Beta",
    "Network & Proxy",
    "Compliance & Enterprise",
    "Disable Flags",
    "Settings.json Keys",
    "CLI Flags",
    "Slash Commands",
    "Hook Events",
]

# Format: each entry is a dict with:
#   id (env var name or settings.json key)
#   category
#   kind: "env" | "settings" | "cli" | "slash" | "event"
#   summary: one-line description
#   description: longer
#   usecase: "use this when..." (optional)
#   example: example value (optional)
#   default: documented default if known
#   docs: True if officially documented

# The detailed entries: the high-leverage configs every Claude Code user
# should know about. ~120 of these. The remaining 300+ env vars are listed
# as "reference" with shorter auto-generated descriptions in the catalog
# extension below.

ENTRIES = [

# ============================================================
# AUTH & API
# ============================================================
{
    "id": "ANTHROPIC_API_KEY", "kind": "env", "category": "Auth & API", "docs": True,
    "summary": "Primary Anthropic API key used for direct API access.",
    "description": "When set, Claude Code uses this key instead of OAuth. With --bare mode, this is the strictly required auth path.",
    "usecase": "CI runs, scripts, headless deploys, or when you need to share auth across machines.",
    "example": "sk-ant-api03-...",
},
{
    "id": "ANTHROPIC_AUTH_TOKEN", "kind": "env", "category": "Auth & API", "docs": True,
    "summary": "Bearer token alternative to ANTHROPIC_API_KEY.",
    "description": "Equivalent to API_KEY but sent as Bearer auth. Useful when your provider expects a token rather than an x-api-key header.",
    "usecase": "OAuth-style integrations with custom Anthropic-compatible endpoints.",
},
{
    "id": "ANTHROPIC_BASE_URL", "kind": "env", "category": "Auth & API", "docs": True,
    "summary": "Base URL for Anthropic API calls.",
    "description": "Override to point at a different Anthropic endpoint (gateway, proxy, internal mirror, or Bedrock-style endpoint).",
    "usecase": "Internal API gateways, regional endpoints, or testing against staging.",
    "example": "https://api.anthropic.com",
},
{
    "id": "ANTHROPIC_CONFIG_DIR", "kind": "env", "category": "Auth & API",
    "summary": "Alternate location for Anthropic config files.",
    "description": "Override the ~/.anthropic config directory.",
    "usecase": "Multi-account setups or sandboxed test runs.",
},
{
    "id": "ANTHROPIC_CUSTOM_HEADERS", "kind": "env", "category": "Auth & API",
    "summary": "Additional HTTP headers attached to every API request.",
    "description": "JSON object of header name to value. Useful for routing through proxies that require specific headers.",
    "example": '{"X-Org-Id":"acme-engineering"}',
},
{
    "id": "ANTHROPIC_BETAS", "kind": "env", "category": "Auth & API",
    "summary": "Comma-separated beta feature flags for API requests.",
    "description": "Pass beta header values directly. Equivalent to --betas CLI flag.",
    "example": "prompt-caching-2024-07-31,computer-use-2024-10-22",
},
{
    "id": "CLAUDE_CODE_API_BASE_URL", "kind": "env", "category": "Auth & API",
    "summary": "Override for Claude Code's primary API base URL.",
    "description": "Distinct from ANTHROPIC_BASE_URL: this is Claude Code's own meta-API (account/usage/etc.).",
},
{
    "id": "CLAUDE_CODE_API_KEY_HELPER_TTL_MS", "kind": "env", "category": "Auth & API",
    "summary": "How long to cache results from apiKeyHelper, in milliseconds.",
    "description": "When using apiKeyHelper (a script that fetches the API key dynamically), Claude caches the returned key for this duration.",
    "example": "300000",
    "default": "60000",
},
{
    "id": "CLAUDE_CODE_CUSTOM_OAUTH_URL", "kind": "env", "category": "Auth & API",
    "summary": "Override OAuth login URL.",
    "description": "Point Claude Code's OAuth flow at a non-default endpoint. Used by enterprise SSO bridges.",
},
{
    "id": "apiKeyHelper", "kind": "settings", "category": "Auth & API", "docs": True,
    "summary": "Shell command that prints the API key on stdout.",
    "description": "Lets you keep keys out of files. Claude runs this command, reads the key, and caches it for CLAUDE_CODE_API_KEY_HELPER_TTL_MS.",
    "usecase": "Vault integrations, 1Password CLI, AWS Secrets Manager, or any secret broker.",
    "example": '"apiKeyHelper": "/usr/local/bin/get-anthropic-key.sh"',
},
{
    "id": "forceLoginMethod", "kind": "settings", "category": "Auth & API",
    "summary": "Force a specific login method (oauth, api_key, etc.).",
    "description": "Prevents Claude from auto-selecting auth method. Useful in managed enterprise rollouts.",
},
{
    "id": "customApiKeyResponses", "kind": "settings", "category": "Auth & API",
    "summary": "How to handle errors from apiKeyHelper.",
    "description": "Lets you tune retry behavior when the helper fails.",
},

# ============================================================
# MODELS
# ============================================================
{
    "id": "ANTHROPIC_DEFAULT_OPUS_MODEL", "kind": "env", "category": "Models",
    "summary": "Override the model used when Opus is requested.",
    "description": "Point 'Opus' at a specific model ID like claude-opus-4-7. Useful for pinning a stable version.",
    "example": "claude-opus-4-7",
},
{
    "id": "ANTHROPIC_DEFAULT_SONNET_MODEL", "kind": "env", "category": "Models",
    "summary": "Override the model used when Sonnet is requested.",
    "example": "claude-sonnet-4-6",
},
{
    "id": "ANTHROPIC_DEFAULT_HAIKU_MODEL", "kind": "env", "category": "Models",
    "summary": "Override the model used when Haiku is requested.",
    "example": "claude-haiku-4-5",
},
{
    "id": "ANTHROPIC_CUSTOM_MODEL_OPTION", "kind": "env", "category": "Models",
    "summary": "Register a custom model name in the picker.",
    "description": "Adds a custom entry to the model selector. Useful for routing to a fine-tuned mirror or experimental ID.",
},
{
    "id": "ANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTION", "kind": "env", "category": "Models",
    "summary": "Description shown next to the custom model in the picker.",
},
{
    "id": "ANTHROPIC_CUSTOM_MODEL_OPTION_NAME", "kind": "env", "category": "Models",
    "summary": "Display name for the custom model.",
},
{
    "id": "ANTHROPIC_CUSTOM_MODEL_OPTION_SUPPORTED_CAPABILITIES", "kind": "env", "category": "Models",
    "summary": "Comma-separated capabilities the custom model supports.",
    "example": "vision,tools,thinking",
},
{
    "id": "CLAUDE_CODE_DISABLE_LEGACY_MODEL_REMAP", "kind": "env", "category": "Models",
    "summary": "Disable the automatic remap from old model names to newer ones.",
    "description": "By default, Claude Code remaps legacy IDs like claude-3-sonnet to the closest current model. Set this to 1 to disable that.",
    "usecase": "Reproducibility, or when you genuinely need to refuse non-explicit models.",
},
{
    "id": "model", "kind": "settings", "category": "Models", "docs": True,
    "summary": "Default model when no other override is set.",
    "example": '"model": "claude-sonnet-4-6"',
},
{
    "id": "defaultModel", "kind": "settings", "category": "Models",
    "summary": "Alternate spelling used in some setups; same effect as model.",
},

# ============================================================
# THINKING & EFFORT
# ============================================================
{
    "id": "CLAUDE_CODE_EFFORT_LEVEL", "kind": "env", "category": "Thinking & Effort", "docs": True,
    "summary": "Effort level for the session (low, medium, high, xhigh, max).",
    "description": "Higher effort = more thinking tokens, slower but more thorough. Equivalent to --effort CLI flag.",
    "example": "high",
},
{
    "id": "CLAUDE_CODE_DISABLE_THINKING", "kind": "env", "category": "Thinking & Effort",
    "summary": "Disable extended thinking entirely.",
    "description": "Useful for latency-sensitive sessions where you do not want the model to spend tokens reasoning.",
},
{
    "id": "CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING", "kind": "env", "category": "Thinking & Effort",
    "summary": "Disable the model's adaptive choice of when to think.",
    "description": "Forces the model to think only when explicitly requested.",
},
{
    "id": "CLAUDE_CODE_ALWAYS_ENABLE_EFFORT", "kind": "env", "category": "Thinking & Effort",
    "summary": "Always show the effort dial in the UI even when not applicable.",
},
{
    "id": "DISABLE_INTERLEAVED_THINKING", "kind": "env", "category": "Thinking & Effort",
    "summary": "Disable interleaved thinking (thinking mixed with tool calls).",
    "description": "When set, thinking happens before tool calls only, not between them.",
},

# ============================================================
# PERMISSIONS & SANDBOX
# ============================================================
{
    "id": "permissions", "kind": "settings", "category": "Permissions & Sandbox", "docs": True,
    "summary": "Allow/deny/ask rules for tools and Bash commands.",
    "description": "Object with allow, deny, and ask arrays. Pattern-matched against tool names and Bash command prefixes.",
    "example": '"permissions": { "allow": ["Bash(git *)", "Read(*)"], "deny": ["Bash(rm -rf *)"], "ask": ["Write(*)"] }',
},
{
    "id": "defaultMode", "kind": "settings", "category": "Permissions & Sandbox", "docs": True,
    "summary": "Default permission mode (default, acceptEdits, plan, auto, dontAsk, bypassPermissions).",
    "description": "Sets the baseline permission posture per session.",
    "example": '"defaultMode": "acceptEdits"',
},
{
    "id": "disableBypassPermissionsMode", "kind": "settings", "category": "Permissions & Sandbox", "docs": True,
    "summary": "Block the user from ever using --dangerously-skip-permissions.",
    "description": "Managed setting for enterprise rollouts. Cannot be overridden by the user.",
},
{
    "id": "CLAUDE_CODE_BUBBLEWRAP", "kind": "env", "category": "Permissions & Sandbox",
    "summary": "Path to or toggle for the bubblewrap sandbox (Linux).",
    "description": "When set, Bash commands run inside a bwrap sandbox for additional isolation.",
    "usecase": "Linux deployments where Bash tool needs hard isolation.",
},
{
    "id": "CLAUDE_CODE_BASH_SANDBOX_SHOW_INDICATOR", "kind": "env", "category": "Permissions & Sandbox",
    "summary": "Show a UI indicator when the Bash sandbox is active.",
},
{
    "id": "CLAUDE_CODE_ADDITIONAL_PROTECTION", "kind": "env", "category": "Permissions & Sandbox",
    "summary": "Toggle extra protection layers (varies by deployment).",
},
{
    "id": "allowManagedHooksOnly", "kind": "settings", "category": "Permissions & Sandbox", "docs": True,
    "summary": "Only allow hooks defined in managed (org-level) settings.",
    "description": "Locks down hook configuration to IT/admin. User-level hooks are ignored.",
},
{
    "id": "allowManagedMcpServersOnly", "kind": "settings", "category": "Permissions & Sandbox", "docs": True,
    "summary": "Only allow MCP servers defined in managed settings.",
},
{
    "id": "allowManagedPermissionRulesOnly", "kind": "settings", "category": "Permissions & Sandbox", "docs": True,
    "summary": "Only allow permission rules defined in managed settings.",
},
{
    "id": "strictPluginOnlyCustomization", "kind": "settings", "category": "Permissions & Sandbox", "docs": True,
    "summary": "Restrict which customization surfaces users may modify.",
    "description": "Array form like [\"skills\", \"hooks\"] locks specific surfaces. Used in enterprise to prevent shadow IT.",
},
{
    "id": "hasTrustDialogAccepted", "kind": "settings", "category": "Permissions & Sandbox",
    "summary": "Internal flag: whether the user accepted the workspace trust dialog.",
},

# ============================================================
# HOOKS
# ============================================================
{
    "id": "hooks", "kind": "settings", "category": "Hooks", "docs": True,
    "summary": "Hook definitions keyed by event name.",
    "description": "Object: event name -> array of matchers -> array of hooks (type, command, timeout).",
    "example": '"hooks": { "PostToolUse": [{ "matcher": "Edit|Write", "hooks": [{"type":"command","command":"./lint.sh"}] }] }',
},
{
    "id": "disableAllHooks", "kind": "settings", "category": "Hooks", "docs": True,
    "summary": "Disable all hooks at the session level.",
},
{
    "id": "CLAUDE_HOOKS_PATH", "kind": "env", "category": "Hooks",
    "summary": "Alternate location to look for hook configurations.",
},
{
    "id": "PreToolUse", "kind": "event", "category": "Hook Events", "docs": True,
    "summary": "Fires before a tool call. Can decide: allow, deny, ask, defer.",
},
{
    "id": "PostToolUse", "kind": "event", "category": "Hook Events", "docs": True,
    "summary": "Fires after a tool call. Cannot block. Used for linting, formatting, audit.",
},
{
    "id": "SessionStart", "kind": "event", "category": "Hook Events", "docs": True,
    "summary": "Fires at session start. Can inject context, set initial user message, define watchPaths.",
},
{
    "id": "SessionEnd", "kind": "event", "category": "Hook Events",
    "summary": "Fires when the session ends.",
},
{
    "id": "Stop", "kind": "event", "category": "Hook Events", "docs": True,
    "summary": "Fires when Claude tries to stop. Can block to keep going.",
},
{
    "id": "SubagentStart", "kind": "event", "category": "Hook Events", "docs": True,
    "summary": "Fires when a subagent is invoked. Matchable on agent type name.",
},
{
    "id": "SubagentStop", "kind": "event", "category": "Hook Events", "docs": True,
    "summary": "Fires when a subagent stops.",
},
{
    "id": "UserPromptSubmit", "kind": "event", "category": "Hook Events", "docs": True,
    "summary": "Fires when the user submits a prompt. 30s timeout. Can block, inject context.",
},
{
    "id": "Notification", "kind": "event", "category": "Hook Events", "docs": True,
    "summary": "Fires on UI notifications. Cannot block. Can emit terminal escape sequences.",
},
{
    "id": "PreCompact", "kind": "event", "category": "Hook Events",
    "summary": "Fires before context compaction. Useful for backups or hand-rolled summaries.",
},

# ============================================================
# SKILLS & PLUGINS
# ============================================================
{
    "id": "skills", "kind": "settings", "category": "Skills & Plugins",
    "summary": "Configuration object for the skill system.",
},
{
    "id": "skillListingBudgetFraction", "kind": "settings", "category": "Skills & Plugins", "docs": True,
    "summary": "Fraction of context window allocated to skill listings.",
    "description": "Defaults to 0.01 (1% of model context). Raise to surface more skills, lower to free context.",
    "example": '"skillListingBudgetFraction": 0.02',
    "default": "0.01",
},
{
    "id": "SLASH_COMMAND_TOOL_CHAR_BUDGET", "kind": "env", "category": "Skills & Plugins",
    "summary": "Character budget for slash-command tool listings.",
},
{
    "id": "CLAUDE_CODE_DISABLE_POLICY_SKILLS", "kind": "env", "category": "Skills & Plugins",
    "summary": "Disable policy-style skills.",
},
{
    "id": "CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL", "kind": "env", "category": "Skills & Plugins",
    "summary": "Block automatic install of plugins from the official marketplace.",
    "usecase": "Enterprise environments that need to curate which official plugins are available.",
},
{
    "id": "CLAUDE_CODE_SYNC_PLUGIN_INSTALL", "kind": "env", "category": "Skills & Plugins",
    "summary": "Run plugin installs synchronously instead of in background.",
},
{
    "id": "CLAUDE_CODE_ENABLE_BACKGROUND_PLUGIN_REFRESH", "kind": "env", "category": "Skills & Plugins",
    "summary": "Allow plugins to refresh in the background between sessions.",
},
{
    "id": "CLAUDE_API_SKILL_DESCRIPTION", "kind": "env", "category": "Skills & Plugins",
    "summary": "Override the description shown for the Claude API skill.",
},
{
    "id": "CLAUDE_CODE_DISABLE_CLAUDE_API_SKILL", "kind": "env", "category": "Skills & Plugins",
    "summary": "Disable the built-in Claude API skill.",
},

# ============================================================
# MCP
# ============================================================
{
    "id": "mcpServers", "kind": "settings", "category": "MCP", "docs": True,
    "summary": "Object mapping server name -> MCP server config.",
    "description": "Where you register HTTP, stdio, or SSE MCP servers. Used by /mcp commands and by the agent.",
    "example": '"mcpServers": { "notion": { "type": "http", "url": "https://mcp.notion.com" } }',
},
{
    "id": "enableAllProjectMcpServers", "kind": "settings", "category": "MCP", "docs": True,
    "summary": "Allow project-level MCP servers without prompting.",
    "description": "When true, .mcp.json files in projects auto-enable. When false, the user is prompted.",
},
{
    "id": "enabledMcpjsonServers", "kind": "settings", "category": "MCP",
    "summary": "Explicit allowlist of .mcp.json server names that are enabled.",
},
{
    "id": "disabledMcpjsonServers", "kind": "settings", "category": "MCP",
    "summary": "Explicit denylist of .mcp.json server names.",
},
{
    "id": "MCP_TIMEOUT", "kind": "env", "category": "MCP", "docs": True,
    "summary": "Startup timeout for MCP servers (milliseconds).",
    "description": "If an MCP server does not respond within this window at session start, the connection fails.",
    "example": "30000",
},
{
    "id": "MAX_MCP_OUTPUT_TOKENS", "kind": "env", "category": "MCP", "docs": True,
    "summary": "Cap on tokens returned per MCP tool call.",
    "description": "When an MCP tool returns more than this, Claude shows a warning. Raise to allow larger responses through.",
    "example": "20000",
    "default": "10000",
},

# ============================================================
# BACKGROUND AGENTS
# ============================================================
{
    "id": "CLAUDE_BG_BACKEND", "kind": "env", "category": "Background Agents",
    "summary": "Backend for background agents (e.g. local, vm).",
    "description": "Controls how /bg agents are dispatched.",
},
{
    "id": "CLAUDE_BG_ISOLATION", "kind": "env", "category": "Background Agents",
    "summary": "Isolation strategy for background agents.",
    "description": "Controls whether background agents run in worktrees, containers, or shared filesystems.",
},
{
    "id": "CLAUDE_ASYNC_AGENT_STALL_TIMEOUT_MS", "kind": "env", "category": "Background Agents",
    "summary": "How long an async agent can stall before being considered hung.",
},
{
    "id": "CLAUDE_AUTO_BACKGROUND_TASKS", "kind": "env", "category": "Background Agents",
    "summary": "Automatically convert long-running tasks into background agents.",
},
{
    "id": "CLAUDE_CODE_DISABLE_BACKGROUND_TASKS", "kind": "env", "category": "Background Agents",
    "summary": "Disable background task creation entirely.",
},
{
    "id": "CLAUDE_CODE_DISABLE_AGENT_VIEW", "kind": "env", "category": "Background Agents",
    "summary": "Hide the agent view UI (claude agents dashboard).",
},
{
    "id": "CLAUDE_CODE_DISABLE_CRON", "kind": "env", "category": "Background Agents",
    "summary": "Disable scheduled-cron behaviour for background agents.",
},
{
    "id": "CLAUDE_BG_RENDEZVOUS_SOCK", "kind": "env", "category": "Background Agents",
    "summary": "Path to the rendezvous socket for background agent IPC.",
},

# ============================================================
# CACHE & COMPACTION
# ============================================================
{
    "id": "CLAUDE_CODE_AUTO_COMPACT_WINDOW", "kind": "env", "category": "Cache & Compaction",
    "summary": "Window size (tokens) at which auto-compaction kicks in.",
},
{
    "id": "CLAUDE_AUTOCOMPACT_PCT_OVERRIDE", "kind": "env", "category": "Cache & Compaction",
    "summary": "Override the percentage at which auto-compaction triggers.",
    "example": "85",
},
{
    "id": "DISABLE_AUTO_COMPACT", "kind": "env", "category": "Cache & Compaction",
    "summary": "Disable automatic context compaction.",
    "description": "Useful if you want to manage compaction manually with /compact.",
},
{
    "id": "DISABLE_COMPACT", "kind": "env", "category": "Cache & Compaction",
    "summary": "Disable both manual and automatic compaction.",
},
{
    "id": "DISABLE_PROMPT_CACHING", "kind": "env", "category": "Cache & Compaction", "docs": True,
    "summary": "Disable Anthropic prompt caching for all models.",
    "description": "Prompt caching reduces cost when prompts share prefixes. Disable only when you need to bypass cache (debugging cache poisoning).",
},
{
    "id": "DISABLE_PROMPT_CACHING_HAIKU", "kind": "env", "category": "Cache & Compaction",
    "summary": "Disable prompt caching for Haiku model only.",
},
{
    "id": "DISABLE_PROMPT_CACHING_SONNET", "kind": "env", "category": "Cache & Compaction",
    "summary": "Disable prompt caching for Sonnet model only.",
},
{
    "id": "DISABLE_PROMPT_CACHING_OPUS", "kind": "env", "category": "Cache & Compaction",
    "summary": "Disable prompt caching for Opus model only.",
},
{
    "id": "CLAUDE_AFTER_LAST_COMPACT", "kind": "env", "category": "Cache & Compaction",
    "summary": "Timestamp of last compaction (internal).",
},
{
    "id": "CLAUDE_CODE_COLD_COMPACT", "kind": "env", "category": "Cache & Compaction",
    "summary": "Force a cold compaction (drop cached prefixes).",
},
{
    "id": "CLAUDE_CODE_DISABLE_PRECOMPACT_SKIP", "kind": "env", "category": "Cache & Compaction",
    "summary": "Disable the optimisation that skips pre-compact processing.",
},

# ============================================================
# BASH TOOL
# ============================================================
{
    "id": "BASH_DEFAULT_TIMEOUT_MS", "kind": "env", "category": "Bash Tool", "docs": True,
    "summary": "Default timeout for Bash tool commands (milliseconds).",
    "example": "120000",
    "default": "120000",
},
{
    "id": "BASH_MAX_TIMEOUT_MS", "kind": "env", "category": "Bash Tool", "docs": True,
    "summary": "Maximum timeout the user can request for Bash commands.",
    "example": "600000",
    "default": "600000",
},
{
    "id": "BASH_MAX_OUTPUT_LENGTH", "kind": "env", "category": "Bash Tool", "docs": True,
    "summary": "Maximum characters of Bash output Claude sees per command.",
    "description": "Beyond this, output is truncated. Raise if commands have large logs you want Claude to actually read.",
    "example": "300000",
},
{
    "id": "CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR", "kind": "env", "category": "Bash Tool",
    "summary": "Keep Bash cwd anchored to the project directory between calls.",
},

# ============================================================
# UI & TUI
# ============================================================
{
    "id": "CLAUDE_CODE_ACCESSIBILITY", "kind": "env", "category": "UI & TUI",
    "summary": "Enable accessibility mode (screen reader friendly, simplified output).",
},
{
    "id": "CLAUDE_CODE_DISABLE_MOUSE", "kind": "env", "category": "UI & TUI",
    "summary": "Disable mouse interaction in the TUI.",
    "usecase": "Terminals where mouse interferes with native copy/paste.",
},
{
    "id": "CLAUDE_CODE_DISABLE_ALTERNATE_SCREEN", "kind": "env", "category": "UI & TUI",
    "summary": "Disable the alternate-screen buffer (keep output in scrollback).",
    "usecase": "tmux/screen users who want session output preserved.",
},
{
    "id": "CLAUDE_CODE_ALT_SCREEN_FULL_REPAINT", "kind": "env", "category": "UI & TUI",
    "summary": "Force full repaint on alternate screen transitions.",
},
{
    "id": "CLAUDE_CODE_DISABLE_TERMINAL_TITLE", "kind": "env", "category": "UI & TUI",
    "summary": "Stop Claude from updating the terminal window title.",
},
{
    "id": "CLAUDE_CODE_DISABLE_VIRTUAL_SCROLL", "kind": "env", "category": "UI & TUI",
    "summary": "Disable virtual scrollback (slower terminals).",
},
{
    "id": "CLAUDE_CODE_DEBUG_REPAINTS", "kind": "env", "category": "UI & TUI",
    "summary": "Visualise screen repaint regions for debugging UI.",
},
{
    "id": "CLAUDE_CODE_BS_AS_CTRL_BACKSPACE", "kind": "env", "category": "UI & TUI",
    "summary": "Treat backspace as ctrl+backspace.",
    "usecase": "Terminals that send DEL on BS.",
},
{
    "id": "CLAUDE_CODE_DECSTBM", "kind": "env", "category": "UI & TUI",
    "summary": "Use DECSTBM scrolling region escape sequences.",
},
{
    "id": "CLAUDE_CODE_FORCE_FULL_LOGO", "kind": "env", "category": "UI & TUI",
    "summary": "Force the full ASCII logo at startup.",
},
{
    "id": "theme", "kind": "settings", "category": "UI & TUI",
    "summary": "UI theme (dark, light, etc.).",
    "example": '"theme": "dark"',
},
{
    "id": "outputStyle", "kind": "settings", "category": "UI & TUI",
    "summary": "Output formatting style for terminal output.",
},
{
    "id": "spinnerTipsEnabled", "kind": "settings", "category": "UI & TUI",
    "summary": "Show rotating tips while waiting for model responses.",
},
{
    "id": "preferredNotifChannel", "kind": "settings", "category": "UI & TUI",
    "summary": "Preferred channel for OS notifications (terminal, system, none).",
},

# ============================================================
# TELEMETRY & PRIVACY
# ============================================================
{
    "id": "DISABLE_TELEMETRY", "kind": "env", "category": "Telemetry & Privacy", "docs": True,
    "summary": "Disable Claude Code telemetry.",
    "description": "Stops anonymous usage telemetry to Anthropic.",
},
{
    "id": "DISABLE_ERROR_REPORTING", "kind": "env", "category": "Telemetry & Privacy", "docs": True,
    "summary": "Disable error reporting to Anthropic.",
},
{
    "id": "DISABLE_GROWTHBOOK", "kind": "env", "category": "Telemetry & Privacy",
    "summary": "Disable the GrowthBook feature-flag client.",
    "usecase": "Air-gapped or strict-no-egress environments.",
},
{
    "id": "DISABLE_FEEDBACK_COMMAND", "kind": "env", "category": "Telemetry & Privacy",
    "summary": "Hide the /feedback command.",
},
{
    "id": "CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY", "kind": "env", "category": "Telemetry & Privacy",
    "summary": "Suppress periodic feedback surveys.",
},
{
    "id": "CLAUDE_CODE_ENABLE_FEEDBACK_SURVEY_FOR_OTEL", "kind": "env", "category": "Telemetry & Privacy",
    "summary": "Allow feedback surveys to emit OpenTelemetry signals.",
},
{
    "id": "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC", "kind": "env", "category": "Telemetry & Privacy",
    "summary": "Block all non-essential outbound traffic.",
    "usecase": "Maximum-privacy mode or restrictive networks.",
},
{
    "id": "CLAUDE_CODE_BYOC_ENABLE_DATADOG", "kind": "env", "category": "Telemetry & Privacy",
    "summary": "BYOC (Bring Your Own Cloud): enable Datadog integration.",
},
{
    "id": "CLAUDE_CODE_DATADOG_FLUSH_INTERVAL_MS", "kind": "env", "category": "Telemetry & Privacy",
    "summary": "How often to flush metrics to Datadog (milliseconds).",
},

# ============================================================
# UPDATES & INSTALL
# ============================================================
{
    "id": "DISABLE_AUTOUPDATER", "kind": "env", "category": "Updates & Install", "docs": True,
    "summary": "Disable auto-updates.",
    "description": "Useful in CI or pinned-version environments.",
},
{
    "id": "DISABLE_UPDATES", "kind": "env", "category": "Updates & Install",
    "summary": "Disable update checks entirely.",
},
{
    "id": "DISABLE_UPGRADE_COMMAND", "kind": "env", "category": "Updates & Install",
    "summary": "Hide the /upgrade command.",
},
{
    "id": "DISABLE_INSTALLATION_CHECKS", "kind": "env", "category": "Updates & Install",
    "summary": "Skip installation integrity checks at startup.",
},
{
    "id": "autoUpdates", "kind": "settings", "category": "Updates & Install",
    "summary": "Whether to auto-update Claude Code.",
},
{
    "id": "autoUpdatesChannel", "kind": "settings", "category": "Updates & Install",
    "summary": "Release channel for auto-updates (stable, latest, beta).",
},
{
    "id": "autoUpdatesProtectedForNative", "kind": "settings", "category": "Updates & Install",
    "summary": "Protect native builds from auto-update overwrites.",
},
{
    "id": "CLAUDE_CODE_PACKAGE_MANAGER_AUTO_UPDATE", "kind": "env", "category": "Updates & Install",
    "summary": "Let the package manager handle auto-updates instead of Claude Code.",
},

# ============================================================
# CLOUD PROVIDERS
# ============================================================
{
    "id": "ANTHROPIC_AWS_API_KEY", "kind": "env", "category": "Cloud Providers", "docs": True,
    "summary": "API key for AWS Bedrock backend.",
},
{
    "id": "ANTHROPIC_AWS_BASE_URL", "kind": "env", "category": "Cloud Providers",
    "summary": "Bedrock endpoint base URL.",
},
{
    "id": "ANTHROPIC_AWS_WORKSPACE_ID", "kind": "env", "category": "Cloud Providers",
    "summary": "Workspace ID for Anthropic on AWS.",
},
{
    "id": "ANTHROPIC_BEDROCK_BASE_URL", "kind": "env", "category": "Cloud Providers",
    "summary": "AWS Bedrock base URL.",
},
{
    "id": "ANTHROPIC_BEDROCK_SERVICE_TIER", "kind": "env", "category": "Cloud Providers",
    "summary": "Bedrock service tier (standard, priority).",
},
{
    "id": "ANTHROPIC_FOUNDRY_API_KEY", "kind": "env", "category": "Cloud Providers",
    "summary": "Azure Foundry API key.",
},

# ============================================================
# LIMITS & TIMEOUTS
# ============================================================
{
    "id": "CLAUDE_CODE_BLOCKING_LIMIT_OVERRIDE", "kind": "env", "category": "Limits & Timeouts",
    "summary": "Override the blocking-limit threshold for prompt/output.",
},
{
    "id": "cleanupPeriodDays", "kind": "settings", "category": "Limits & Timeouts", "docs": True,
    "summary": "How many days to keep transcripts before cleanup (minimum 1).",
    "description": "Set 3650 for ~10 years. To disable cleanup entirely, remove the setting and use --no-session-persistence.",
    "example": '"cleanupPeriodDays": 365',
},

# ============================================================
# DEBUG & LOGGING
# ============================================================
{
    "id": "CLAUDE_DEBUG", "kind": "env", "category": "Debug & Logging", "docs": True,
    "summary": "Enable debug mode (verbose output, additional logs).",
},
{
    "id": "CLAUDE_CODE_DEBUG_LOG_LEVEL", "kind": "env", "category": "Debug & Logging",
    "summary": "Debug log level (e.g. info, warn, error, trace).",
},
{
    "id": "CLAUDE_CODE_DEBUG_LOGS_DIR", "kind": "env", "category": "Debug & Logging",
    "summary": "Directory to write debug logs to.",
},
{
    "id": "CLAUDE_CODE_DIAGNOSTICS_FILE", "kind": "env", "category": "Debug & Logging",
    "summary": "Path to a diagnostics file written at session end.",
},
{
    "id": "verbose", "kind": "settings", "category": "Debug & Logging",
    "summary": "Verbose output by default.",
},

# ============================================================
# EXPERIMENTAL & BETA
# ============================================================
{
    "id": "CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS", "kind": "env", "category": "Experimental & Beta",
    "summary": "Enable experimental Agent Teams feature.",
    "example": "1",
},
{
    "id": "CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS", "kind": "env", "category": "Experimental & Beta",
    "summary": "Disable all experimental beta features.",
},
{
    "id": "CLAUDE_CODE_ENABLE_EXPERIMENTAL_ADVISOR_TOOL", "kind": "env", "category": "Experimental & Beta",
    "summary": "Enable the experimental advisor tool.",
},
{
    "id": "CLAUDE_CODE_DISABLE_ADVISOR_TOOL", "kind": "env", "category": "Experimental & Beta",
    "summary": "Disable the advisor tool entirely.",
},
{
    "id": "CLAUDE_CODE_ENABLE_AWAY_SUMMARY", "kind": "env", "category": "Experimental & Beta",
    "summary": "Enable the 'away summary' feature (recap when you return).",
},

# ============================================================
# Disable Flags (top-level convenience toggles)
# ============================================================
{
    "id": "DISABLE_AUTO_COMPACT", "kind": "env", "category": "Disable Flags", "docs": True,
    "summary": "Same as above; also lives here for discoverability.",
},
{
    "id": "DISABLE_BRIEF_MODE_STOP_HOOK", "kind": "env", "category": "Disable Flags",
    "summary": "Disable the stop-hook that runs in brief mode.",
},
{
    "id": "DISABLE_BUG_COMMAND", "kind": "env", "category": "Disable Flags",
    "summary": "Hide the /bug command.",
},
{
    "id": "DISABLE_COST_WARNINGS", "kind": "env", "category": "Disable Flags",
    "summary": "Suppress cost-related warning prompts.",
},
{
    "id": "DISABLE_DOCTOR_COMMAND", "kind": "env", "category": "Disable Flags",
    "summary": "Hide the /doctor command.",
},
{
    "id": "DISABLE_EXTRA_USAGE_COMMAND", "kind": "env", "category": "Disable Flags",
    "summary": "Hide the additional /usage commands.",
},
{
    "id": "DISABLE_INSTALL_GITHUB_APP_COMMAND", "kind": "env", "category": "Disable Flags",
    "summary": "Hide the GitHub App install command.",
},
{
    "id": "DISABLE_LOGIN_COMMAND", "kind": "env", "category": "Disable Flags",
    "summary": "Disable the /login command (managed-auth deployments).",
},
{
    "id": "DISABLE_LOGOUT_COMMAND", "kind": "env", "category": "Disable Flags",
    "summary": "Disable the /logout command.",
},

# ============================================================
# CLI FLAGS (selected high-impact ones)
# ============================================================
{
    "id": "--bare", "kind": "cli", "category": "CLI Flags",
    "summary": "Minimal mode: skip hooks, LSP, plugins, attribution, auto-memory, keychain.",
    "description": "Sets CLAUDE_CODE_SIMPLE=1. Anthropic auth is strictly ANTHROPIC_API_KEY or apiKeyHelper. Use for CI, deterministic runs, debugging harness issues.",
    "usecase": "Run Claude Code in CI or scripts without all the user-environment overhead.",
},
{
    "id": "--effort", "kind": "cli", "category": "CLI Flags",
    "summary": "Effort level (low, medium, high, xhigh, max).",
    "example": "claude --effort high \"refactor this module\"",
},
{
    "id": "--dangerously-skip-permissions", "kind": "cli", "category": "CLI Flags", "docs": True,
    "summary": "Bypass all permission checks (sandbox-only).",
    "description": "Use only in disposable sandboxes with no internet. Forbidden by disableBypassPermissionsMode in managed settings.",
},
{
    "id": "--max-budget-usd", "kind": "cli", "category": "CLI Flags",
    "summary": "Maximum dollar amount to spend per --print run.",
    "example": "claude --print --max-budget-usd 0.50 \"summarize this file\"",
},
{
    "id": "--fallback-model", "kind": "cli", "category": "CLI Flags",
    "summary": "Auto-fallback model when default is overloaded (only with --print).",
    "example": "claude --print --fallback-model haiku \"...\"",
},
{
    "id": "--mcp-config", "kind": "cli", "category": "CLI Flags",
    "summary": "Load MCP servers from JSON files or strings.",
    "example": "claude --mcp-config ./mcp.json",
},
{
    "id": "--ide", "kind": "cli", "category": "CLI Flags",
    "summary": "Auto-connect to IDE on startup if one is available.",
},
{
    "id": "--fork-session", "kind": "cli", "category": "CLI Flags",
    "summary": "Create a new session ID when resuming (preserves the original).",
},
{
    "id": "--from-pr", "kind": "cli", "category": "CLI Flags",
    "summary": "Resume a session linked to a PR by number/URL or open interactive picker.",
},
{
    "id": "-c, --continue", "kind": "cli", "category": "CLI Flags",
    "summary": "Continue the most recent conversation in the current directory.",
},
{
    "id": "--debug", "kind": "cli", "category": "CLI Flags",
    "summary": "Enable debug mode with optional category filter.",
    "example": "claude --debug \"api,hooks\"",
},
{
    "id": "--include-hook-events", "kind": "cli", "category": "CLI Flags",
    "summary": "Include all hook lifecycle events in stream-json output.",
},
{
    "id": "--json-schema", "kind": "cli", "category": "CLI Flags",
    "summary": "JSON schema for structured output validation.",
},
{
    "id": "--exclude-dynamic-system-prompt-sections", "kind": "cli", "category": "CLI Flags",
    "summary": "Move per-machine sections out of system prompt (better cache reuse).",
    "description": "Improves cross-user prompt-cache reuse. Only applies with default system prompt.",
},

# ============================================================
# SLASH COMMANDS (high-impact picks)
# ============================================================
{
    "id": "/config", "kind": "slash", "category": "Slash Commands", "docs": True,
    "summary": "The built-in config UI (this tool is a more complete alternative).",
},
{
    "id": "/agents", "kind": "slash", "category": "Slash Commands", "docs": True,
    "summary": "Background agents dashboard.",
},
{
    "id": "/bg", "kind": "slash", "category": "Slash Commands",
    "summary": "Dispatch a task as a background agent.",
},
{
    "id": "/clear", "kind": "slash", "category": "Slash Commands", "docs": True,
    "summary": "Clear conversation context.",
},
{
    "id": "/compact", "kind": "slash", "category": "Slash Commands", "docs": True,
    "summary": "Manually compact the context window.",
},
{
    "id": "/effort", "kind": "slash", "category": "Slash Commands",
    "summary": "Change effort level for this session.",
},
{
    "id": "/fast", "kind": "slash", "category": "Slash Commands",
    "summary": "Toggle Fast mode (Opus with faster output).",
},
{
    "id": "/doctor", "kind": "slash", "category": "Slash Commands", "docs": True,
    "summary": "Health check for Claude Code installation.",
},
{
    "id": "/feedback", "kind": "slash", "category": "Slash Commands", "docs": True,
    "summary": "Send feedback to Anthropic.",
},
{
    "id": "/mcp", "kind": "slash", "category": "Slash Commands", "docs": True,
    "summary": "Configure and manage MCP servers.",
},
{
    "id": "/plugin", "kind": "slash", "category": "Slash Commands", "docs": True,
    "summary": "Manage Claude Code plugins.",
},
]


# ============================================================
# Reference list: every other env var discovered in the binary,
# with auto-derived category from name pattern.
# ============================================================

def _classify(name):
    """Auto-bucket an env var by name pattern."""
    n = name.upper()
    if any(x in n for x in ["BEDROCK", "AWS_", "VERTEX", "GCP_", "FOUNDRY", "AZURE"]): return "Cloud Providers"
    if "BYOC" in n: return "Compliance & Enterprise"
    if any(x in n for x in ["TELEMETRY", "OTEL", "DATADOG", "ANALYTICS", "GROWTHBOOK", "FEEDBACK", "ERROR_REPORTING", "METRICS"]): return "Telemetry & Privacy"
    if "HOOK" in n: return "Hooks"
    if any(x in n for x in ["PLUGIN", "SKILL", "MARKETPLACE"]): return "Skills & Plugins"
    if "MCP" in n: return "MCP"
    if any(x in n for x in ["BG_", "BACKGROUND", "DAEMON", "BRIDGE", "CRON", "AGENT_VIEW"]): return "Background Agents"
    if any(x in n for x in ["AGENT", "SUBAGENT"]): return "Background Agents"
    if any(x in n for x in ["MODEL", "HAIKU", "SONNET", "OPUS", "MYTHOS"]): return "Models"
    if any(x in n for x in ["THINKING", "EFFORT", "INTERLEAVED"]): return "Thinking & Effort"
    if any(x in n for x in ["CACHE", "COMPACT"]): return "Cache & Compaction"
    if "BASH" in n: return "Bash Tool"
    if any(x in n for x in ["ACCESSIBILITY", "MOUSE", "ALT_SCREEN", "TERMINAL_TITLE", "VIRTUAL_SCROLL", "REPAINT", "BS_AS", "DECSTBM", "KEYBOARD"]): return "UI & TUI"
    if any(x in n for x in ["PERMISSION", "BYPASS", "DANGEROUS", "SANDBOX", "BUBBLEWRAP", "TRUST"]): return "Permissions & Sandbox"
    if any(x in n for x in ["UPDATE", "INSTALL", "VERSION", "PACKAGE_MANAGER", "UPGRADE"]): return "Updates & Install"
    if any(x in n for x in ["LIMIT", "MAX_", "BUDGET", "TIMEOUT", "TTL_MS"]): return "Limits & Timeouts"
    if any(x in n for x in ["DEBUG", "LOG", "VERBOSE", "DIAGNOSTICS", "TRACE"]): return "Debug & Logging"
    if any(x in n for x in ["EXPERIMENTAL", "BETA", "PREVIEW"]): return "Experimental & Beta"
    if any(x in n for x in ["HTTP", "PROXY", "URL", "REQUEST", "RESPONSE", "CERT", "TLS"]): return "Network & Proxy"
    if any(x in n for x in ["FEDERATION", "MANAGED", "ENTERPRISE", "BYOC", "COMPLIANCE"]): return "Compliance & Enterprise"
    if n.startswith("DISABLE_"): return "Disable Flags"
    if any(x in n for x in ["AUTH", "API_KEY", "OAUTH", "CREDENTIAL", "TOKEN"]): return "Auth & API"
    return "Disable Flags" if "DISABLE" in n else "Network & Proxy"


def load_all_env_vars():
    """Load the master list and return entries for those not in ENTRIES."""
    import os
    path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                        "..", "data", "all-env-vars.txt")
    if not os.path.exists(path):
        return []
    existing_ids = {e["id"] for e in ENTRIES}
    items = []
    with open(path) as f:
        for line in f:
            name = line.strip()
            if not name or name in existing_ids:
                continue
            cat = _classify(name)
            items.append({
                "id": name,
                "kind": "env",
                "category": cat,
                "summary": _summary_from_name(name),
                "description": "Discovered in Claude Code binary, not yet richly documented.",
                "auto": True,
            })
    return items


def _summary_from_name(name):
    """Derive a short summary from the env var name."""
    n = name
    if n.startswith("CLAUDE_CODE_DISABLE_"):
        return f"Disable: {n[len('CLAUDE_CODE_DISABLE_'):].lower().replace('_', ' ')}"
    if n.startswith("CLAUDE_CODE_ENABLE_"):
        return f"Enable: {n[len('CLAUDE_CODE_ENABLE_'):].lower().replace('_', ' ')}"
    if n.startswith("CLAUDE_CODE_"):
        return f"Setting: {n[len('CLAUDE_CODE_'):].lower().replace('_', ' ')}"
    if n.startswith("CLAUDE_"):
        return f"Setting: {n[len('CLAUDE_'):].lower().replace('_', ' ')}"
    if n.startswith("ANTHROPIC_"):
        return f"Anthropic: {n[len('ANTHROPIC_'):].lower().replace('_', ' ')}"
    if n.startswith("DISABLE_"):
        return f"Disable: {n[len('DISABLE_'):].lower().replace('_', ' ')}"
    return n.lower().replace('_', ' ')


def get_all_entries():
    """Return the full catalog: explicit entries + auto-discovered ones."""
    return ENTRIES + load_all_env_vars()
