ClawTV
AI-powered Apple TV remote that can see the screen and navigate any app autonomously using vision + remote control.
When to use (trigger phrases)
Use this skill immediately when the user asks:
- - "play [movie/show] on Apple TV"
- "search for [content] on [Netflix/Plex/YouTube/etc]"
- "open [app] on the TV"
- "turn on subtitles" / "go to TV settings"
- "what's playing on Apple TV?"
- "take a screenshot of the TV"
- Any Apple TV navigation or control task
Quick start
CODEBLOCK0
Required Credentials
ANTHROPICAPIKEY (Required for AI/Vision Mode)
The do command (AI agent mode) requires an Anthropic API key to access Claude's vision API for screenshot analysis and navigation decisions.
CODEBLOCK1
Or add to your shell profile (~/.zshrc, ~/.bashrc).
Note: This is only required for the do command. Manual commands (cmd, type, launch) and plex direct control do not use the API.
Plex Credentials (Optional)
For instant Plex playback without the vision loop, add these to ~/.clawtv/config.json:
CODEBLOCK2
- - plexurl: Your Plex server address (local or remote)
- plextoken: Authentication token from your Plex account
- plex_client: Name of the Plex client on your Apple TV
Get your Plex token: https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/
Privacy & Data
What Data is Collected and Sent
Screenshots:
- - ClawTV captures screenshots of your Apple TV screen using QuickTime Player or Xcode
- Screenshots are saved locally to
~/.clawtv/screenshots/ with timestamps - When using the
do command (AI agent mode), screenshots are sent to Anthropic's Claude API for vision analysis - Screenshots may contain sensitive on-screen content including:
- Content you're watching (movie/show titles, thumbnails)
- Search queries
- Account information visible in app UIs
- Any other content displayed on your TV screen
Anthropic API:
- - Only the
do command sends data to Anthropic - Data sent: screenshots (JPEG compressed) + your goal/instruction + conversation history
- Anthropic's data retention policy: https://support.anthropic.com/en/articles/7996885-how-long-do-you-store-personal-data
- Manual commands (
cmd, type, launch) and Plex direct control do NOT send any data to external APIs
Credential Storage
Apple TV Pairing Credentials:
- - Stored unencrypted in
~/.clawtv/config.json in your home directory - Contains device identifiers and pairing tokens for remote control
- File permissions: readable only by your user account (standard Unix permissions)
Plex Tokens (if configured):
- - Stored unencrypted in the same
~/.clawtv/config.json file - Grants full access to your Plex server and library
- Can be used to play, pause, search, and control any Plex client
Anthropic API Key:
- - Stored in environment variables or your shell profile
- Grants access to your Anthropic account and incurs API usage charges
Recommendations
- 1. Use a budget-limited API key: Set spending limits on your Anthropic account to prevent unexpected charges
- Review config file permissions: Ensure
~/.clawtv/config.json is only readable by your user - Be aware of screenshot content: Screenshots are sent to Anthropic's API and may contain sensitive information
- Monitor API usage: The
do command can make multiple API calls per task (5-20 steps typical) - Use manual commands when possible:
cmd, type, and launch have zero API cost and send no data externally
Security Considerations
Plaintext Credential Storage
- - Apple TV pairing credentials and Plex tokens are stored in plaintext in INLINECODE20
- The file is in your user home directory (
~/.clawtv/) with standard Unix file permissions - Any process running as your user can read these credentials
- If your Mac is compromised, these credentials are accessible
- Consider this when deciding whether to configure Plex integration
Screenshot Privacy
- - Screenshots may contain sensitive content visible on your TV screen
- Screenshots are saved locally to
~/.clawtv/screenshots/ and persist until manually deleted - When using AI agent mode (
do), screenshots are transmitted to Anthropic's servers - DRM content (Netflix, Disney+, etc.) cannot be captured via QuickTime, but works with Xcode method
- Review screenshot history periodically and delete sensitive captures
API Cost and Autonomous Behavior
- - The
do command runs in a loop (up to 20 steps) and makes Claude API calls automatically - Each step = 1 API call with screenshot (~$0.01-0.02 per step depending on model)
- A stuck or confused agent could consume all 20 steps before giving up
- Cost implications: Complex tasks can cost $0.10-0.20; monitor your Anthropic usage dashboard
- Recommendation: Set spending limits on your Anthropic account
Manual Commands are API-Free
- -
cmd, type, launch, and plex commands do not use the Claude API - No screenshots are sent externally when using these commands
- Zero cost, zero external data transmission
- Use these for privacy-sensitive operations
Network Exposure
- - ClawTV communicates with your Apple TV over your local network using the Companion protocol
- Plex integration (if configured) communicates with your Plex server (local or remote)
- No external network access except:
- Anthropic API (when using
do command)
- Plex server (if remote URL configured)
Setup (first-time only)
1. Install dependencies
CODEBLOCK3
For QuickTime screenshot method (recommended):
CODEBLOCK4
2. Pair with Apple TV (remote control)
CODEBLOCK5
Pairing credentials are saved to ~/.clawtv/config.json.
3. Set up screenshots
QuickTime (recommended):
CODEBLOCK6
- - QuickTime Player opens and selects your Apple TV as video source
- Accept the AirPlay pairing on your TV (one-time PIN)
- Subsequent runs reuse the existing mirror instantly (~0.6s per screenshot)
Xcode (fallback for DRM apps):
- 1. On Apple TV: Settings > Privacy & Security → enable "Share with App Devs"
- Then Settings > Remotes and Devices > Remote App and Devices
- On Mac: Open Xcode, press Cmd+Shift+2 (Devices)
- Click your Apple TV in sidebar, enter pairing code
- Keep Xcode Devices window open while using ClawTV
4. Set API key
CODEBLOCK7
Or add to your shell profile (~/.zshrc, ~/.bashrc).
5. Optional: Plex direct control setup
For instant Plex playback without vision loop, add to ~/.clawtv/config.json:
CODEBLOCK8
Get your Plex token: https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/
Commands
AI Agent Mode (do)
Tell ClawTV what you want and it figures out the rest using vision + reasoning.
CODEBLOCK9
How it works:
- 1. Takes screenshot of Apple TV
- Sends to Claude vision API to analyze UI
- Decides what to do (navigate, select, type, launch app)
- Sends remote commands
- Takes another screenshot to verify
- Repeats until goal is accomplished (max 20 steps)
Examples:
CODEBLOCK10
Token optimizations (automatic):
- - Plex goals bypass vision entirely via direct API (instant, pennies)
- Sliding window: only last 2 screenshots kept in context (~70% token reduction)
- Images compressed to JPEG 800px q50 (~40% fewer image tokens)
- System prompt cached via
cache_control (90% savings on steps 2+) - Haiku 4.5 for routine steps, auto-escalates to Sonnet 4.5 when stuck
Playback pattern: Navigate → start playback → verify playing → skip intro if visible → disconnect → report done
Remote Commands (cmd)
Send direct remote control commands without AI.
CODEBLOCK11
Available commands:
up, down, left, right, select, menu, home, play, pause, play_pause, next, previous, volume_up, volume_down, INLINECODE50
Examples:
CODEBLOCK12
Timing: Insert sleep:X between commands to add delays (in seconds).
Type Text (type)
Type text into a focused search/text field on the TV.
CODEBLOCK13
Example:
CODEBLOCK14
Note: The text field must already be focused. Use cmd to navigate to search first, or use do for full automation.
Launch App (launch)
Launch an app by bundle ID.
CODEBLOCK15
Example:
CODEBLOCK16
Common bundle IDs:
| App | Bundle ID |
|---|
| Plex | INLINECODE56 |
| YouTube |
com.google.ios.youtube |
| HBO Max |
com.wbd.stream |
| Prime Video |
com.amazon.aiv.AIVApp |
| Apple TV |
com.apple.TVWatchList |
| Spotify |
com.spotify.client |
| ESPN |
com.espn.ScoreCenter |
| Twitch |
tv.twitch |
| Pluto TV |
tv.pluto.ios |
| NFL |
com.nfl.gamecenter |
| Disney+ |
com.disney.disneyplus |
| Hulu |
com.hulu.plus |
| Netflix |
com.netflix.Netflix |
Use python3 ~/Developer/clawtv/clawtv.py apps for the full list on your device.
Plex Direct Control (plex)
Bypass the entire vision loop using Plex API directly. Searches your library and tells the Plex client on Apple TV to play. Instant playback, zero vision cost.
CODEBLOCK17
Requirements:
- -
plex_url, plex_token, and plex_client in INLINECODE74 - Plex server running and accessible from Mac
- Plex client running on Apple TV
Auto-detection: The do command automatically detects Plex goals (e.g., "play Fight Club on Plex") and routes through this path without any vision API calls.
Screenshot (screenshot)
Take a screenshot of the Apple TV and save to ~/.clawtv/screenshots/.
CODEBLOCK18
Screenshot methods:
| Method | Speed | DRM Apps | Requires |
|---|
| QuickTime (default) | ~0.6s | ❌ Kills mirror (DRM) | QuickTime Player, pyobjc-framework-Quartz |
| Lookout |
~0.1s | ❌ Only captures Lookout app |
Lookout tvOS app running on Apple TV |
|
Xcode (legacy) | ~2.5s | ✅ Works with all apps | Xcode Devices window open |
DRM apps (YouTube, Netflix, Disney+, HBO Max) enforce HDCP and terminate the QuickTime AirPlay mirror entirely. Use Xcode method for these apps, or use Lookout for its own UI.
Configuration: Set default method in ~/.clawtv/config.json:
CODEBLOCK19
Values: auto (tries quicktime → lookout → xcode), quicktime, lookout, INLINECODE82
Disconnect QuickTime (disconnect)
Close the QuickTime mirror and auto-resume playback on the TV.
CODEBLOCK20
Why: QuickTime mirroring shows a red recording border on the TV and routes audio to the Mac. After starting playback, always disconnect to remove the border and restore audio to the TV.
Auto-resume: Sends play command twice to ensure playback resumes.
Status Commands
CODEBLOCK21
Important Notes
DRM Limitations
DRM apps (YouTube, Netflix, Disney+, HBO Max) terminate the QuickTime AirPlay mirror entirely. When this happens:
- - QuickTime method shows a black screen
- ClawTV auto-detects the disconnection in
auto mode - Falls back to Xcode method automatically
- Or manually use: INLINECODE87
Apps that work with QuickTime: Plex (local media), Settings, home screen, Apple TV+, most non-DRM apps.
QuickTime Side Effects
When QuickTime mirror is active:
- - Red recording border appears on TV
- Audio routes to Mac instead of TV speakers
- DRM apps may refuse to play
Solution: Always run disconnect after starting playback. The do command does this automatically.
Cost
Vision loop (AI agent mode): Uses Claude API for every see-think-act step. Each step = 1 API call with screenshot.
- - Typical task: 5-10 steps = few cents
- Complex navigation: up to 20 steps = ~$0.10-0.20
- Uses Haiku 4.5 (cheap) with auto-escalation to Sonnet 4.5 when stuck
Plex direct control: 2 API calls total (pennies) — no vision loop.
Manual commands (cmd, type, launch): Zero API cost.
Config File
INLINECODE93 stores:
CODEBLOCK22
Companion Project
Lookout — tvOS app with built-in HTTP screenshot server at port 8080. Fastest possible screenshot method (~100ms) but only captures Lookout's own UI, not other apps.
Requirements
- - macOS (uses AppleScript for automation)
- Apple TV 4K (gen 2 or later, tvOS 16+) on same network as Mac
- Python 3.9+
- Anthropic API key for Claude vision
- QuickTime Player (built-in) or Xcode (free from App Store)
Troubleshooting
"No Apple TV found"
- - Run
python3 ~/Developer/clawtv/clawtv.py scan to verify device is on network - Check that Apple TV and Mac are on same WiFi/LAN
- Verify Apple TV is awake (not in sleep mode)
"QuickTime mirror disconnected"
- - DRM app killed the mirror — use
--method xcode instead - Or use Plex direct control to bypass vision entirely
"Screenshot failed"
- - QuickTime: Ensure AirPlay pairing is accepted on TV
- Xcode: Verify Devices window is open and Apple TV is connected
- Try
--method auto to fall back automatically
"API key not found"
- - Set
export ANTHROPIC_API_KEY=sk-ant-... in your shell - Or add to ~/.zshrc or ~/.bashrc
"Plex not found"
- - Verify
plex_url, plex_token, and plex_client in config - Run
python3 ~/Developer/clawtv/clawtv.py plex clients to verify client name - Ensure Plex server is running and accessible
Architecture
CODEBLOCK23
Stack:
- - pyatv — Apple TV remote control (Companion protocol)
- QuickTime Player — AirPlay mirror for screenshots (primary)
- Xcode — Developer device screenshots (fallback)
- Claude — Vision + reasoning for autonomous navigation
- python-plexapi — Plex direct control
License
MIT — see LICENSE
ClawTV
一款由AI驱动的Apple TV遥控器,能够通过视觉和遥控功能自主查看屏幕并导航任何应用。
使用时机(触发短语)
当用户提出以下请求时,请立即使用此技能:
- - 在Apple TV上播放[电影/节目]
- 在[Netflix/Plex/YouTube等]上搜索[内容]
- 在电视上打开[应用]
- 打开字幕 / 进入电视设置
- Apple TV上正在播放什么?
- 截取电视屏幕截图
- 任何Apple TV导航或控制任务
快速开始
bash
AI代理模式 — 用自然语言告诉它你想要什么
python3 ~/Developer/clawtv/clawtv.py do 打开Plex并播放搏击俱乐部
python3 ~/Developer/clawtv/clawtv.py do 在Netflix上搜索怪奇物语
python3 ~/Developer/clawtv/clawtv.py do 进入设置并打开字幕
直接Plex控制(即时,无需视觉循环)
python3 ~/Developer/clawtv/clawtv.py plex play 搏击俱乐部
python3 ~/Developer/clawtv/clawtv.py plex play 西部世界 -s 2 -e 6
手动遥控命令
python3 ~/Developer/clawtv/clawtv.py cmd up down select
python3 ~/Developer/clawtv/clawtv.py type 绝命毒师
python3 ~/Developer/clawtv/clawtv.py launch com.plexapp.plex
屏幕截图
python3 ~/Developer/clawtv/clawtv.py screenshot
状态
python3 ~/Developer/clawtv/clawtv.py playing
所需凭证
ANTHROPICAPIKEY(AI/视觉模式必需)
do命令(AI代理模式)需要Anthropic API密钥,用于访问Claude的视觉API进行屏幕截图分析和导航决策。
bash
export ANTHROPICAPIKEY=sk-ant-...
或添加到你的shell配置文件(~/.zshrc,~/.bashrc)中。
注意: 仅do命令需要此配置。手动命令(cmd、type、launch)和plex直接控制不使用API。
Plex凭证(可选)
如需即时Plex播放而无需视觉循环,请将这些添加到~/.clawtv/config.json:
json
{
plex_url: http://192.168.1.100:32400,
plex_token: your-plex-token,
plex_client: 客厅
}
- - plexurl:你的Plex服务器地址(本地或远程)
- plextoken:来自你Plex账户的认证令牌
- plex_client:Apple TV上Plex客户端的名称
获取你的Plex令牌:https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/
隐私与数据
收集和发送的数据
屏幕截图:
- - ClawTV使用QuickTime Player或Xcode捕获Apple TV的屏幕截图
- 屏幕截图以时间戳命名保存在本地~/.clawtv/screenshots/目录中
- 使用do命令(AI代理模式)时,屏幕截图会发送到Anthropic的Claude API进行视觉分析
- 屏幕截图可能包含敏感的屏幕内容,包括:
- 你正在观看的内容(电影/节目标题、缩略图)
- 搜索查询
- 应用界面中可见的账户信息
- 电视屏幕上显示的任何其他内容
Anthropic API:
- - 仅do命令会向Anthropic发送数据
- 发送的数据:屏幕截图(JPEG压缩)+ 你的目标/指令 + 对话历史
- Anthropic的数据保留政策:https://support.anthropic.com/en/articles/7996885-how-long-do-you-store-personal-data
- 手动命令(cmd、type、launch)和Plex直接控制不会向外部API发送任何数据
凭证存储
Apple TV配对凭证:
- - 以未加密形式存储在用户主目录的~/.clawtv/config.json中
- 包含设备标识符和遥控配对令牌
- 文件权限:仅你的用户账户可读(标准Unix权限)
Plex令牌(如已配置):
- - 以未加密形式存储在同一个~/.clawtv/config.json文件中
- 授予对你Plex服务器和媒体库的完全访问权限
- 可用于播放、暂停、搜索和控制任何Plex客户端
Anthropic API密钥:
- - 存储在环境变量或shell配置文件中
- 授予对你Anthropic账户的访问权限,并产生API使用费用
建议
- 1. 使用预算限制的API密钥:在Anthropic账户上设置消费限额,防止意外费用
- 检查配置文件权限:确保~/.clawtv/config.json仅你的用户可读
- 注意屏幕截图内容:屏幕截图会发送到Anthropic的API,可能包含敏感信息
- 监控API使用量:do命令每个任务可能多次调用API(通常5-20步)
- 尽可能使用手动命令:cmd、type和launch零API成本,不向外部发送数据
安全考虑
明文凭证存储
- - Apple TV配对凭证和Plex令牌以明文形式存储在~/.clawtv/config.json中
- 文件位于用户主目录(~/.clawtv/),使用标准Unix文件权限
- 任何以你的用户身份运行的进程都可以读取这些凭证
- 如果你的Mac被入侵,这些凭证将可被访问
- 在决定是否配置Plex集成时请考虑这一点
屏幕截图隐私
- - 屏幕截图可能包含敏感内容,这些内容在电视屏幕上可见
- 屏幕截图保存在本地~/.clawtv/screenshots/目录中,直到手动删除
- 使用AI代理模式(do)时,屏幕截图会传输到Anthropic的服务器
- DRM内容(Netflix、Disney+等)无法通过QuickTime捕获,但可通过Xcode方法实现
- 定期查看屏幕截图历史记录,删除敏感截图
API费用和自主行为
- - do命令在循环中运行(最多20步),自动调用Claude API
- 每一步 = 1次API调用(含屏幕截图),根据模型不同约$0.01-0.02/步
- 卡住或困惑的代理可能在放弃前消耗全部20步
- 费用影响:复杂任务可能花费$0.10-0.20;请监控你的Anthropic使用仪表板
- 建议:在Anthropic账户上设置消费限额
手动命令无需API
- - cmd、type、launch和plex命令不使用Claude API
- 使用这些命令时不会向外部发送屏幕截图
- 零成本,零外部数据传输
- 在涉及隐私敏感操作时使用这些命令
网络暴露
- - ClawTV通过Companion协议在本地网络上与Apple TV通信
- Plex集成(如已配置)与你的Plex服务器(本地或远程)通信
- 无需外部网络访问,除了:
- Anthropic API(使用do命令时)
- Plex服务器(如配置了远程URL)
设置(仅首次使用)
1. 安装依赖
bash
cd ~/Developer/clawtv
pip install -r requirements.txt
对于QuickTime截图方法(推荐):
bash
pip install pyobjc-framework-Quartz
2. 与Apple TV配对(遥控功能)
bash
python3 ~/Developer/clawtv/clawtv.py scan # 在网络中查找你的Apple TV
python3 ~/Developer/clawtv/clawtv.py pair # 输入电视上显示的4位PIN码
配对凭证将保存到~/.clawtv/config.json。
3. 设置屏幕截图
QuickTime(推荐):
bash
python3 ~/Developer/clawtv/clawtv.py screenshot --method quicktime
- - QuickTime Player打开并选择你的Apple TV作为视频源
- 在电视上接受AirPlay配对(一次性PIN码)
- 后续运行会立即重用现有镜像(约0.6秒/张截图)
Xcode(DRM应用的备用方案):
- 1. 在Apple TV上:设置 > 隐私与安全性 → 启用与应用开发者共享
- 然后设置 > 遥控器与设备 > 遥控应用与设备
- 在Mac上:打开Xcode,按Cmd+Shift+2(设备)
- 在侧边栏中点击你的Apple TV,输入配对码
- 使用ClawTV时保持Xcode设备