Логотип Mac Watchdog

Mac Watchdog

ОрганизацияПопулярный
udecode
mac-watchdog

Keep a Mac from freezing under agent workloads. A user launchd job records memory every 10 seconds, per process and per Claude Code session, and stops any process that grows past 40% of RAM, and a root job restarts fseventsd when its memory leak passes 1 GB. Use to install, check or remove them, after a Mac freezes, swaps hard or logs the user out, when fseventsd holds GBs of memory, or to find which session or process used the memory.

Обзор

Издательudecode
Репозиторийustack
Название навыкаmac-watchdog
Звёзды
1.2K
Форки
82
Файлы в комплекте
7
Ссылки
  • Инструкции в формате Markdown

    Модель загружает файл SKILL.md по мере необходимости, поэтому токены расходуются только при подходящем запросе.

  • Работает с любой большой языковой моделью

    Навыки ИИ — это обычный Markdown, а не код для конкретного поставщика, поэтому они работают с GPT, Claude, Gemini, Grok и локальными моделями.

  • Файлы в комплекте: 7

    Скрипты, шаблоны и справочные материалы, которые модель может читать во время работы. Файлы доступны только для чтения и никогда не выполняются.

  • Открытый исходный код

    Издатель навыка на GitHub — udecode. Перед установкой изучите исходные материалы.

Установка

Установите навык ИИ Mac Watchdog в TypingMind, чтобы использовать его с любой LLM, или добавьте его в другой агент, который умеет читать SKILL.md.

1

Установка в TypingMind

TypingMind устанавливает навык прямо из его папки на GitHub: читает SKILL.md, собирает файлы ресурсов и сохраняет результат локально.

  1. Откройте приложение и перейдите в раздел «Плагины → Навыки».
  2. Выберите «Установить из GitHub».
  3. Вставьте указанную ниже ссылку на папку навыка и подтвердите установку.
    https://github.com/udecode/ustack/tree/main/skills/mac-watchdog
  4. Включите навык в каждом чате, где хотите его использовать.
Плагины → Навыки → Добавить навык → По ссылке GitHub, затем вставьте ссылку на папку и нажмите «Продолжить».
2

Установка в другом агенте

Любой агент с поддержкой формата Agent Skills может использовать этот навык — скопируйте папку в каталог навыков этого агента.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/udecode/ustack.git /tmp/ustack
mkdir -p .claude/skills
cp -r /tmp/ustack/skills/mac-watchdog .claude/skills/mac-watchdog
После копирования перезапустите Claude Code, чтобы загрузить новый навык.

Использование в TypingMind

Включите навык Mac Watchdog в любом чате TypingMind, и дальше модель всё сделает сама. Его название и описание хранятся в системном промпте, а при появлении подходящего запроса модель сама загружает полные инструкции. Вам не нужно вызывать навык вручную, и до фактического использования он не расходует токены.

Модель сама загружает навык Mac Watchdog, как только появляется подходящий для него запрос.

Работает с любой моделью ИИ

Навыки ИИ — это обычные инструкции в Markdown, а не код для конкретного поставщика, поэтому навык Mac Watchdog не привязан к модели, для которой он был создан. Установите его один раз в TypingMind и используйте с GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama или локальной моделью, которую запускаете самостоятельно, — со своими ключами API.

  • Загружается только при необходимости

    Системный промпт содержит только название и описание. Инструкции загружаются при первом подходящем запросе, поэтому неиспользуемый навык не расходует токены.

  • Меняйте модели прямо в чате

    Навык состоит из инструкций, а не кода, поэтому смена модели не нарушает его работу: новая модель читает тот же файл SKILL.md.

Инструкции навыка

Это содержимое файла SKILL.md, которое загружает модель. Прочитайте его перед установкой: навык — это инструкции, которым будет следовать ваша модель.

mac-watchdog

A frozen Mac leaves almost nothing behind. macOS logs that memory ran out, not what used it, and a long enough freeze makes it kill WindowServer, which logs the user out and closes every app. This skill runs two launchd jobs that record what happens and step in before the freeze.

JobRuns asDoes
dev.ustack.mac-watchdogthe userRecords memory every 10 seconds and stops runaway processes
dev.ustack.mac-watchdog.fseventsdrootRestarts fseventsd when its leak passes 1 GB

They are two jobs because restarting fseventsd needs root, and a root job must never run a file the user can edit, such as Node or the recorder. Both write to ~/Library/Logs/mac-watchdog/.

<skill> is this skill's base directory.

Install, update or remove

  1. To install the recorder, or to apply an edit to scripts/recorder.mjs, run zsh <skill>/scripts/install.sh. It needs no sudo. It copies the recorder to ~/Library/Application Support/mac-watchdog, compiles the footprint helper with cc, writes ~/Library/LaunchAgents/dev.ustack.mac-watchdog.plist with the node on PATH, starts the job and prints the first sample. It refuses when another recorder already runs, and when cc is missing, which xcode-select --install fixes. It also removes the job of mem-log, this skill's old name, and moves its logs here. Done when it prints a sample line.
  2. To install the fseventsd watchdog, or to apply an edit to scripts/fseventsd.sh, the user runs sudo zsh <skill>/scripts/install-fseventsd.sh, because it needs root; give them the command. It copies the watchdog to /usr/local/sbin as root-owned, writes /Library/LaunchDaemons/dev.ustack.mac-watchdog.fseventsd.plist, removes the job of fseventsd-watchdog, this part's old name, starts the job, then prints its log, fseventsd's memory and the leak's onset line from the last 7 days (event table has grown too large).
  3. To remove them, run zsh <skill>/scripts/install.sh uninstall and sudo zsh <skill>/scripts/install-fseventsd.sh uninstall. The logs stay.

Check

  • launchctl print gui/$(id -u)/dev.ustack.mac-watchdog and launchctl print system/dev.ustack.mac-watchdog.fseventsd show each job and its last exit code.
  • node <skill>/scripts/report.mjs --last 3 prints the latest samples. A sample older than a minute means the recorder stopped, and ~/Library/Logs/mac-watchdog/stderr.log says why, such as a node path that moved after a Node upgrade, which a new install fixes.

The recorder

The recorder writes one JSON line every 10 seconds to ~/Library/Logs/mac-watchdog/<UTC day>.jsonl, and keeps 10 days, about 30 MB a day. Each line holds the kernel's free-memory level and pressure, swap use and swap traffic, the compressor's size, and the processes grouped by the Claude Code session or top-level program they run under, with each group's footprint. Every sixth line adds top's view, which alone sees root daemons such as fseventsd and WindowServer. A gapS well over 10 means the recorder itself was starved. It reads footprint, not RSS, because swapped and compressed pages drop out of RSS, and it names sessions from the Claude desktop app's session records.

Runaway processes

When one of the user's processes passes the kill limit, the recorder sends it SIGTERM, then SIGKILL if it is still over the limit 10 seconds later. The limit is 40% of RAM, 51 GB on a 128 GB Mac. A leaking test once grew to 214 GB on such a Mac, and no healthy process gets near the limit. Apps and system programs are never signalled: a command under an .app bundle, /System, /usr, /bin, /sbin or /Library/Apple, so Claude, Chrome and the virtual machines are safe.

Each kill posts a notification and appends a line to ~/Library/Logs/mac-watchdog/kills.jsonl, with the process's command line, its footprint and the Claude session that started it. report.mjs prints it as a kill: line under its sample. Tell that session what was stopped, so it fixes the leak before it runs the same command again.

To change the limit, reinstall with MAC_WATCHDOG_KILL_GB=<GB> zsh <skill>/scripts/install.sh. 0 turns the guard off.

The fseventsd leak

macOS 15.6 to 27.x has an fseventsd leak. The sweeper that prunes its event table keeps its place in a 32-bit counter, which stops advancing after about 8.4 million runs. Once the table is at its 262,144-bucket maximum, every newly changed path leaks about 350 bytes, lookups slow down, and event delivery can stop without an error. Apple budgets fseventsd 30 MB. A leaking one reaches tens of GB within days on a Mac that installs node_modules into many worktrees, each about 170,000 new paths. Turning Spotlight off and no_log files do not stop it. A restart does, because a fresh fseventsd starts with a small table. Sources: Hixie/contraptions fseventsd-watchdog, Apple developer forums thread 849819, anthropics/claude-code#98769.

The root job checks fseventsd every 2 minutes, in about 50 ms. At 1 GB resident memory it logs the evidence, sends SIGTERM, then SIGKILL after 10 s, and waits for launchd to respawn it, at most once an hour. SIP refuses launchctl kickstart -k for this service, which is why it signals. Each restart writes a restarting line to ~/Library/Logs/mac-watchdog/fseventsd.log with the RSS, uptime and swap it saw, then a restarted line with the new pid and Docker's state. A skip: line says why a check could not read fseventsd.

To see where a leaking fseventsd's memory sits and which processes generate its events, the user runs sudo zsh <skill>/scripts/fseventsd-diag.sh. It changes nothing and writes a report into the log folder.

Docker Desktop's file sharing holds FSEvents streams, and one report says it fails after a restart. After each restart the watchdog runs docker info and logs docker=ok or docker=FAILED. On a failure it posts a notification to restart Docker Desktop.

Read a freeze

  1. Find when it happened. After a forced restart, sysctl -n kern.boottime gives the boot time, and the last sample before it is where the recorder stopped. When the user was logged out but the Mac did not restart, look for a WindowServer_*.userspace_watchdog_timeout.spin report and use its time. A freeze the Mac came back from shows as a large gap=.
  2. Print the 15 minutes before it: node <skill>/scripts/report.mjs --from <HH:MM> --to <HH:MM> --detail, in local time, with --day <YYYY-MM-DD> for another day. Each line shows free memory, pressure, swap, swap in and out in MB/s, the compressor, the gap, the user's total footprint, the Claude session count and the three largest groups. --detail adds every large group, each process over 1.5 GB and top's rows.
  3. List what macOS wrote at that time: ls -lt /Library/Logs/DiagnosticReports ~/Library/Logs/DiagnosticReports, looking for JetsamEvent, panic, .hang, .shutdownStall and userspace_watchdog_timeout files.
  4. Name the cause: the group or process whose footprint climbs before the freeze, and the session it belongs to, or fseventsd at several GB in top's rows. Done when the cause names a process or session and the samples that show it climbing.

The report names sessions and shows command lines, so read it before sharing it.

Файлы в комплекте

Модель читает эти файлы по мере необходимости, пока навык загружен. Они доступны только для чтения и никогда не выполняются.

Часто задаваемые вопросы

Что делает навык ИИ Mac Watchdog?

Keep a Mac from freezing under agent workloads. A user launchd job records memory every 10 seconds, per process and per Claude Code session, and stops any process that grows past 40% of RAM, and a root job restarts fseventsd when its memory leak passes 1 GB. Use to install, check or remove them, after a Mac freezes, swaps hard or logs the user out, when fseventsd holds GBs of memory, or to find which session or process used the memory.

Зачем использовать Mac Watchdog в TypingMind?

Потому что вы устанавливаете навык один раз и используете его с любой моделью. Mac Watchdog — это обычный текст в формате Markdown, а не код для конкретного поставщика, поэтому один и тот же навык работает с GPT-5, Claude, Gemini, Grok или локальной моделью. Вы можете менять модель прямо во время чата, и навык продолжит работать. TypingMind использует ваши собственные ключи API, поэтому вы платите поставщикам напрямую, а не оформляете подписку с оплатой за каждое место. Ваши навыки и чаты остаются в вашем собственном хранилище.

Как установить Mac Watchdog в TypingMind?

В TypingMind откройте «Плагины → Навыки → Установить из GitHub» и вставьте https://github.com/udecode/ustack/tree/main/skills/mac-watchdog. TypingMind прочитает файл SKILL.md, включит сопутствующие файлы в пакет и установит навык, который можно включать отдельно для каждого чата.

Какие модели ИИ могут использовать Mac Watchdog?

Любая модель, которую вы подключите в TypingMind. Навыки ИИ — это обычные инструкции в формате Markdown, а не код для конкретного поставщика, поэтому GPT, Claude, Gemini, Grok и локальные модели могут загружать этот навык, когда запрос ему соответствует.

Со сколькими моделями ИИ можно использовать Mac Watchdog?

С любым количеством. В TypingMind вы можете использовать Mac Watchdog с любой моделью, которая поддерживает навыки, в том числе с GPT, Claude, Gemini, Grok, DeepSeek, Mistral и Llama. Для этого вы используете собственные ключи API.

Бесплатен ли навык ИИ Mac Watchdog?

Навык опубликован на GitHub. Издатель — udecode. Условия лицензии можно найти в репозитории. Вы платите только своему поставщику ИИ за использованные токены.

Что такое навыки ИИ?

Навык ИИ — это набор инструкций, которыми модель ИИ может пользоваться каждый раз, когда ей нужно выполнить конкретную задачу. Он соответствует открытому формату Agent Skills: файл SKILL.md с названием и описанием, а также любые скрипты, шаблоны или справочные файлы, которые могут понадобиться модели. Модель читает инструкции, только когда ваш запрос соответствует навыку, поэтому установленный навык ничего не стоит, пока не используется.

Чем навыки ИИ отличаются от плагинов и серверов MCP?

Плагин или сервер MCP даёт модели новые инструменты, которые она может вызывать: при вызове где-то выполняется код и возвращает результат. Навык ИИ, напротив, даёт модели знания и описывает порядок действий: как подойти к задаче, какие шаги выполнить и каким должен быть хороший результат. Навыки — это обычный текст в формате Markdown, поэтому им не нужны сервер, ключ API или среда выполнения, и они работают с любой моделью.

Все

Создайте своё рабочее пространство с ИИ прямо сейчас

Подпишитесь на нашу рассылку, чтобы узнавать о новых функциях и предстоящих розыгрышах 👇