{
  "schema_version": 1,
  "type": "skill",
  "slug": "hydrogen-monitor",
  "title": "Hydrogen Monitor",
  "brief": "Use when the AI needs to watch the Hydrogen workspace in real-time — react to tab changes, sharing state, user actions, or any workspace mutation as it happens.",
  "version": "1.0.0",
  "tags": [],
  "license": "MIT",
  "source_path": "SKILL.md",
  "readme": "# Hydrogen Real-Time Monitoring\n\nWatch the Hydrogen workspace in real-time using Claude Code's Monitor tool + Hydrogen's SSE event stream. React to user actions as they happen — no polling, no \"tell me when you're done.\"\n\n## When to use\n\n- You need to **wait for the user to do something** (enable sharing, open a panel, switch tabs)\n- You want to **react to workspace changes** as they happen (auto-screenshot new panels, navigate web views)\n- You're running a **multi-step demo** and need to know when the user is ready for the next step\n- You want to **watch for errors** or state changes during a long-running task\n\n## When NOT to use\n\n- **One-shot waits** → use `--wait-for-sharing` on screenshot commands instead\n- **Checking current state** → use `workspace tabs` or `screenshot status` directly\n- **Short operations** → just run the command and check the result\n\n## The SSE endpoint\n\n```\nGET /api/workspaces/editor/{owner}/{repo}/current/events\nHeader: X-Api-Key: <token>\n```\n\nEmits:\n- `{\"type\": \"connected\"}` — once on connect\n- `{\"type\": \"workspace_updated\"}` — on every workspace mutation (tab add/remove, split, resize, active tab change, panel state change)\n\nThe events don't include details about *what* changed — query `workspace tabs` or other endpoints after receiving an event to see the current state.\n\n## Basic monitor: watch for workspace changes\n\n```bash\n# Monitor tool script — reports tab changes in real-time\nAPI_KEY=$(cat /var/run/adom/api-key)\nSLUG=$(echo \"$VSCODE_PROXY_URI\" | sed 's|.*-\\([^.]*\\)\\.adom\\.cloud.*|\\1|')\nINFO=$(curl -s -H \"Authorization: Bearer $API_KEY\" \"https://carbon.adom.inc/containers/$SLUG\")\nOWNER=$(echo \"$INFO\" | python3 -c \"import sys,json; print(json.load(sys.stdin)['repository']['owner']['name'])\")\nREPO=$(echo \"$INFO\" | python3 -c \"import sys,json; print(json.load(sys.stdin)['repository']['name'])\")\nBASE=\"https://hydrogen.adom.inc/api/workspaces/editor/$OWNER/$REPO/current\"\nLAST=\"\"\n\ncurl -s -N -H \"X-Api-Key: $API_KEY\" \"$BASE/events\" 2>/dev/null | while IFS= read -r line; do\n  cleaned=$(echo \"$line\" | sed 's/^data: //')\n  [ -z \"$cleaned\" ] && continue\n  type=$(echo \"$cleaned\" | python3 -c \"import sys,json; print(json.load(sys.stdin).get('type',''))\" 2>/dev/null)\n  [ -z \"$type\" ] && continue\n\n  if [ \"$type\" = \"workspace_updated\" ]; then\n    NOW=$(curl -s -H \"X-Api-Key: $API_KEY\" \"$BASE/tabs\" 2>/dev/null | python3 -c \"\nimport sys,json\ntabs=json.load(sys.stdin).get('tabs',[])\nnames=[t['name'] for t in tabs]\nactive=[t['name'] for t in tabs if t.get('isActive')]\nprint(f'tabs: {len(names)} — {\\\", \\\".join(names)} | active: {\\\", \\\".join(active)}')\n\" 2>/dev/null)\n    if [ \"$NOW\" != \"$LAST\" ] && [ -n \"$NOW\" ]; then\n      echo \"[workspace] $NOW\"\n      LAST=\"$NOW\"\n    fi\n  elif [ \"$type\" = \"connected\" ]; then\n    echo \"[connected] Monitoring $OWNER/$REPO\"\n  fi\ndone\n```\n\nUse with the Monitor tool:\n```\nMonitor(description: \"Hydrogen workspace events\", persistent: true, command: \"<script above>\")\n```\n\n## Simpler: use adom-cli in the monitor\n\nFor lighter-weight monitoring, use `adom-cli` commands inside a poll loop instead of the SSE stream:\n\n```bash\n# Poll sharing status every 5s until it activates\nwhile true; do\n  STATUS=$(adom-cli hydrogen screenshot status 2>/dev/null)\n  ACTIVE=$(echo \"$STATUS\" | python3 -c \"import sys,json; print(json.load(sys.stdin).get('sharing',{}).get('active',False))\" 2>/dev/null)\n  if [ \"$ACTIVE\" = \"True\" ]; then\n    echo \"[sharing] Screen sharing activated\"\n    break\n  fi\n  sleep 5\ndone\n```\n\n```bash\n# Watch for a specific tab to appear\nwhile true; do\n  adom-cli hydrogen workspace find-tab \"Schematic Editor\" >/dev/null 2>&1 && {\n    echo \"[found] Schematic Editor tab is open\"\n    break\n  }\n  sleep 2\ndone\n```\n\n## Reactive patterns\n\n### Auto-screenshot new panels\nWhen the monitor detects a new tab, automatically screenshot it:\n\n```bash\n# In your monitor's workspace_updated handler:\nif [ \"$NOW\" != \"$LAST\" ]; then\n  # A new tab appeared — find it and screenshot\n  NEW_TAB=$(diff <(echo \"$LAST\") <(echo \"$NOW\") | grep \"^>\" | head -1)\n  echo \"[new] $NEW_TAB — taking screenshot\"\n  adom-cli hydrogen screenshot workspace >/dev/null 2>&1\nfi\n```\n\n### Wait for sharing then capture\nInstead of `--wait-for-sharing`, use a monitor for more control:\n\n```bash\n# Monitor until sharing activates, then take all the screenshots you need\nwhile true; do\n  ACTIVE=$(adom-cli hydrogen screenshot status 2>/dev/null | python3 -c \"import sys,json; print(json.load(sys.stdin).get('sharing',{}).get('active',False))\" 2>/dev/null)\n  if [ \"$ACTIVE\" = \"True\" ]; then\n    echo \"[ready] Sharing active — capturing\"\n    adom-cli hydrogen screenshot workspace\n    adom-cli hydrogen screenshot panel --name \"Schematic Editor\"\n    break\n  fi\n  sleep 2\ndone\n```\n\n## Best practices\n\n1. **Use `persistent: true`** for session-length watches (workspace monitoring, demo flows)\n2. **Filter events** — don't echo every `workspace_updated`, only report when state actually changes (diff against last known state)\n3. **Use `--line-buffered`** with grep in pipes so events arrive immediately\n4. **Handle connection drops** — the SSE stream can timeout; wrap in a reconnect loop if needed\n5. **Prefer `--wait-for-sharing`** for simple \"wait then screenshot\" — Monitor is for when you need to react to multiple events or do complex logic\n6. **Don't spam** — if the monitor emits too many events, Claude Code auto-stops it. Keep output selective\n\n## Monitor vs other approaches\n\n| Need | Approach |\n|------|----------|\n| Wait for sharing, then screenshot | `screenshot workspace --wait-for-sharing 30` |\n| Check current state once | `screenshot status`, `workspace tabs`, `audio status` |\n| React to workspace changes in real-time | **Monitor + SSE stream** |\n| Run a multi-step demo with user interaction | **Monitor** — watch for user actions between steps |\n| Poll until a condition is met | **Monitor** with a poll loop + `break` |\n| Long-running background task with status | `Bash` with `run_in_background` |",
  "author": {
    "name": "Kyle Bergstedt",
    "email": "[email protected]"
  },
  "visibility": {
    "public": true
  },
  "hero": null,
  "sample_prompts": [],
  "discovery_triggers": [],
  "discovery_pitch": null,
  "metadata": {},
  "created_at": "2026-05-28T05:29:49.293Z",
  "updated_at": "2026-05-28T05:29:49.293Z",
  "sub_skills": [],
  "parent_app": null
}