# ClamGuard (mac-clamshell-mcp): Complete Technical Specification

> Source: https://clamguard.eatingdream.dev/ | Directory: https://clamguard.eatingdream.dev/llms.txt | Search: https://clamguard.eatingdream.dev/.well-known/search?q={query}

## Overview

- **Category**: macOS clamshell and thermal guard / macOS 合盖与温控护卫
- **Platform**: macOS (Apple Silicon and Intel)
- **Canonical URL**: https://clamguard.eatingdream.dev/
- **Repository**: https://github.com/eatingDream-antigravity-plugins/ClamGuard
- **Releases**: https://github.com/eatingDream-antigravity-plugins/ClamGuard/releases
- **AI Guide**: https://github.com/eatingDream-antigravity-plugins/ClamGuard/blob/main/docs/ai-guide.md
- **License**: MIT

**Summary (EN)**: Work on an external display with the lid shut. ClamGuard watches fans and heat, and eases heavy builds when closed.
**简介 (ZH)**: 合盖接外接显示器时，ClamGuard 帮你盯着风扇和温度，合盖后自动给重型编译降温限流。

**What It Is**: A native Rust macOS MCP server, live Antigravity dashboard, and CLI wrapper that watches lid state, power source, and thermal pressure to throttle heavy commands and guard closed-lid display state.
**定位说明**: 原生 Rust 编写的 macOS MCP 服务、实时面板与 CLI 包装器：感知合盖、供电与热压力，自动节流重型构建并守护合盖屏幕状态。

**What It Is Not**: Not a fan-curve writer, kernel extension, or global pmset modifier. It never asks for sudo and leaves dedicated fan managers untouched.
**边界声明**: 不是风扇曲线写入器、内核扩展或全局 pmset 修改工具。全程无需 sudo，也绝不干扰第三方风扇管理软件。

## Quick Start

Install native binary and Antigravity plugin:

```sh
curl -fsSL https://raw.githubusercontent.com/eatingDream-antigravity-plugins/ClamGuard/main/scripts/install.sh | sh
```

Add portable Agent Skill (`agentskills.io`):

```sh
npx skills add eatingDream-antigravity-plugins/ClamGuard
```

## MCP Tools

- `clamshell_panel`: Opens the live dashboard and reports lid, power, thermal, fan, display guard, and active throttle tier.
- `clamshell_set_brightness`: Sets built-in display brightness (0-100%) when open, or queues wake-restore target while closed.
- `clamshell_lock_screen`: Locks the screen via SACLockScreenImmediate without sleeping background agent jobs.
- `clamshell_refresh`: App-only ETag-deduplicated telemetry polling after UI capability negotiation.
- `clamshell_configure`: App-only policy, display guard, thermal brightness cap, and language persistence.

## CLI Subcommands

- `mac-clamshell-mcp status [--json]`
- `mac-clamshell-mcp run [--mode <auto|normal|utility|eco|strict>] [--jobs <n>] -- <cmd> [args...]`
- `mac-clamshell-mcp brightness get | set <0..100>`
- `mac-clamshell-mcp lock`
- `mac-clamshell-mcp guard install | uninstall | status`
- `mac-clamshell-mcp watch [--daemon] [--interval <secs>]`

## How It Works

### See fan speed and heat at a glance (风扇和温度，一眼看清)

Closing the lid traps heat under the keyboard. ClamGuard reads the real fan speeds and thermal state from the SMC without an admin password, and eases heavy builds when things warm up.

合上盖子，热量就闷在键盘底下。ClamGuard 不用管理员密码，直接从 SMC 读出真实的风扇转速和热压力，升温时顺手给重型编译限流。

### Guard the screen without disturbing your monitor (护住内建屏，也不打扰外接大屏)

Without an external display, ClamGuard puts the screen to sleep when you shut the lid. When docked on a monitor, it leaves your big screen awake and queues your saved brightness for when you open up.

没接外接屏时，合盖就让内屏安心休眠；接了外接显示器时则绝不打扰大屏，只记下原本亮度，等你重新开盖再恢复。

### Gets along with Macs Fan Control (和 Macs Fan Control 和平共处)

If you already use Macs Fan Control or TG Pro, ClamGuard notices right away and never clashes with it. It only reads fan speeds and never writes to the SMC or touches your fan curves.

如果你已经在用 Macs Fan Control 或 TG Pro，ClamGuard 会一眼认出来且绝不冲突。它只读取转速，从不写入 SMC，也不碰你的风扇曲线。

## Dynamic Thermal and Clamshell Throttle Profiles

| Profile | Trigger Condition | QoS and Concurrency Cap |
| --- | --- | --- |
| Normal | Lid open and nominal thermal pressure | Full speed, no throttling |
| Utility | Lid closed on AC power | Utility QoS (nice 10), E-core cap (2-4 jobs) |
| Eco | Lid closed on battery | Background QoS (nice 15), max 2 jobs (1 at <=20%) |
| Strict | Serious or critical thermal pressure | Lowest priority (taskpolicy -b, nice 19), 1 job |

## Safety and Privacy Boundaries

1. Zero root and zero SMC writes: never requires sudo, never writes SMC/NVRAM/kexts, and stores state in owner-only 0700/0600 files.
   - 中文：零 root 与零 SMC 写入：绝不索要 sudo，不修改 SMC/NVRAM/内核扩展，本地状态严格采用 0700/0600 权限。
2. Hardware-confirmed brightness guard: refuses brightness writes unless hardware confirms the lid is open and internal display is awake.
   - 中文：硬件确认式亮度守卫：仅当硬件确认已开盖且内屏唤醒时才写入亮度，避免异常状态误操作。
3. Compile-time #[cfg(test)] hardware refusal: unit and integration tests can never lock your screen, sleep displays, or spawn daemons.
   - 中文：编译期 #[cfg(test)] 硬件隔离：自动化测试绝不会锁屏、息屏或拉起真实守护进程。
4. Zero outbound network traffic: 100% local Rust binary communicating exclusively over local MCP stdio.
   - 中文：零外部网络流量：纯本地原生 Rust 二进制，仅通过本地 MCP stdio 通信。

## Suite Navigation

- **eatingDream Hub**: https://eatingdream.dev/
- **ContextRadar** (context-radar-mcp): https://contextradar.eatingdream.dev/ (Shows which turns are filling your context window and why the prompt cache went cold, so you can wrap up before things slow down.)
- **RemoteCast** (chrome-stream-mcp): https://remotecast.eatingdream.dev/ (Puts Chrome right in your sidebar over loopback or your own SSH tunnel, so you can watch and click through it without leaving the editor.)
- **ColabDeck** (colab-mcp): https://colabdeck.eatingdream.dev/ (Lists every Colab GPU you have running and what it has cost so far from live rates, then stops the ones you forgot about.)
