
Computer Use
- 58 installs
- 3 repo stars
- Updated March 26, 2026
- oil-oil/computer-use-skill
Helps with ai & agent building tasks.
About
computer-use is a Claude Code skill for ai & agent building. It helps solo builders move faster with AI-assisted coding.
- computer-use
- AI & Agent Building
- AI-coding skill
Computer Use by the numbers
- 58 all-time installs (skills.sh)
- Ranked #6,517 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/oil-oil/computer-use-skill --skill computer-useAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 58 |
|---|---|
| repo stars | ★ 3 |
| Last updated | March 26, 2026 |
| Repository | oil-oil/computer-use-skill ↗ |
What it does
Helps with ai & agent building tasks.
Files
Computer Use(macOS)
工具组合:screencapture + cliclick + osascript + Swift CGEvent(滚动)
先确认是否真的需要本 skill:
- 操作网页/浏览器 → 用 agent-browser skill,更稳定、更省 token
- 读写文件、调用 API、执行脚本 → 直接用内置工具
- 只有目标是无 API 可用的本地 GUI App(微信、飞书、Figma 等原生应用)时,才继续往下走
---
第一步:运行初始化脚本(每次任务开始执行一次)
bash <skill_dir>/scripts/init.sh初始化做了三件事: 1. 检测 Retina 缩放因子,写入 /tmp/_cu_scale 2. 编译 Swift CGEvent 滚动工具到 /tmp/_cu_scroll 3. 安装截图辅助脚本 /tmp/_cu_snap.sh,并打印当前可见进程名
初始化后可用的命令:
| 命令 | 作用 |
|---|---|
/tmp/_cu_snap.sh out.png | 截全屏(自动缩到逻辑分辨率) |
/tmp/_cu_snap.sh out.png W H x y | 截图后裁剪到 W×H 区域(节省 token) |
/tmp/_cu_scroll x y amount | 滚动(amount < 0 向下,> 0 向上) |
cat /tmp/_cu_scale | 读取缩放因子 |
/tmp 在重启后清空,重启后需重新运行初始化。---
感知-行动循环
1. _cu_snap 截图 → Read 读取
└─ 优先裁剪到目标区域:只截需要看的部分,大幅减少 token 消耗
2. 定位目标
└─ 优先:AX 元素名(osascript)
└─ 其次:截图坐标(cu_snap 输出已是逻辑坐标,直接用于 cliclick)
3. 执行操作
4. sleep 0.3~1.5s 等渲染 → 再截图确认
5. 重复直到完成---
截图
/tmp/_cu_snap.sh /tmp/s.png # 全屏
/tmp/_cu_snap.sh /tmp/s.png 900 600 0 300 # 裁剪:宽900 高600 从(x=0,y=300)开始cu_snap 输出的图像坐标 == cliclick 逻辑坐标,无需再做任何换算。
---
鼠标操作
cliclick c:960,490 # 单击
cliclick dc:960,490 # 双击
cliclick rc:960,490 # 右键
cliclick p # 打印当前坐标(调试)⚠️ cliclick dd:x,y 是开始拖拽,不是滚动。---
滚动
# 向下滚到底部
for i in $(seq 1 8); do /tmp/_cu_scroll 750 400 -20; sleep 0.05; done
# 向上滚
/tmp/_cu_scroll 750 400 5⚠️ 聊天类 App(飞书、微信、Slack)的输入框会抢占键盘焦点,
End / PageDown 键会打字到输入框里。必须用 _cu_scroll,不能用键盘。---
输入文字
# 英文
osascript -e 'tell application "System Events" to tell process "AppName" to keystroke "hello"'
# 中文(直接 keystroke 会乱码,必须走剪贴板)
echo -n "你好世界" | pbcopy
osascript -e 'tell application "System Events" to tell process "AppName" to keystroke "v" using command down'---
按键
cliclick kp:return kp:esc kp:tab kp:delete kp:arrow-down kp:page-down---
激活应用
osascript -e 'tell application "Feishu" to activate'
sleep 0.8进程名必须用系统名,初始化时已打印进程列表。常见易错对:
- 飞书 →
Feishu(不是Lark) - 微信 →
WeChat
⚠️ 不要用 set frontmost to true——会报错 -10006。activate已足够,如需置前可加set bounds of front window to {…}。
---
点击 UI 元素(比坐标更准)
比截图估坐标更可靠的方式:通过 Accessibility 元素名直接点击。
# 按名称点击按钮
osascript -e 'tell application "System Events" to tell process "App" to click button "OK" of window 1'
# 先查有哪些可点元素
osascript -e 'tell application "System Events" to tell process "App" to get every UI element of window 1'---
等待窗口就绪
osascript << 'EOF'
tell application "App" to activate
tell application "System Events"
tell process "App"
set w to 0
repeat until (count of windows) > 0 or w > 10
delay 0.3
set w to w + 0.3
end repeat
end tell
end tell
EOFMIT License
Copyright (c) 2025 oil-oil
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
computer-use — Claude Code Skill
A Claude Code skill that enables Claude to control your Mac: take screenshots, move the mouse, click, type text, and open apps — using only native macOS tools, no Docker, no VM.
中文说明 · Install · Usage · How it works
---
Install
claude skill install oil-oil/computer-use-skillOr manually copy SKILL.md into ~/.claude/skills/computer-use/SKILL.md.
Prerequisites
1. Install cliclick
brew install cliclick2. Grant permissions (System Settings → Privacy & Security)
| Permission | Required for | Grant to |
|---|---|---|
| Screen Recording | Taking screenshots | Terminal / iTerm2 |
| Accessibility | Mouse clicks, keyboard input | Terminal / iTerm2 |
Usage
Once installed, just ask Claude naturally:
- "帮我打开 Safari 搜索 wolfcha"
- "截个屏看看现在屏幕上是什么"
- "帮我点击屏幕上的确认按钮"
- "Open Safari and search for wolfcha"
- "Take a screenshot and tell me what's on screen"
- "Click the confirm button on screen"
How it works
No MCP server needed. This skill uses three native macOS tools:
| Tool | Purpose |
|---|---|
screencapture | Screenshot (built-in) |
cliclick | Mouse move / click (via Homebrew) |
osascript | Keyboard input, app activation (built-in) |
The core loop is: screenshot → analyze → act → screenshot to confirm.
Key insight: always use tell process "AppName" inside System Events when sending keystrokes — not bare keystroke — otherwise input goes to the wrong focused app.
tell application "System Events"
tell process "Safari" -- ← specify the process, not just System Events
keystroke "hello"
end tell
end tell---
中文说明
这是一个 Claude Code skill,让 Claude 可以直接操控你的 Mac:截图、移动鼠标、点击、输入文字、打开应用。
不需要 Docker,不需要虚拟机,只用 macOS 内置工具 + cliclick。
为什么不用 computer-use MCP?
computer-use-mcp 等 MCP server 的工具无法在 Claude Code 中调用(Claude Code 出于安全考虑过滤了桌面控制类工具)。这个 skill 用 Bash 工具直接调用 macOS 原生命令绕过了这个限制,在 Claude Code 里实现了完整的 computer use 能力。
安装
brew install cliclick将 SKILL.md 复制到 ~/.claude/skills/computer-use/SKILL.md,重启 Claude Code 即生效。
使用
直接用自然语言告诉 Claude:
- "帮我打开 Safari 搜索 wolfcha"
- "截个屏看看现在屏幕上有什么"
- "点击屏幕右上角的关闭按钮"
---
License
MIT
#!/bin/bash
# Computer-use init — run once at the start of each task.
# Sets up three things: scale factor, scroll tool, snap helper.
# Safe to re-run; only recompiles scroll tool if source changed.
SKILL_DIR="$(cd "$(dirname "$0")/.." && pwd)"
# ── 1. Retina scale factor ─────────────────────────────────────────────────
# screencapture gives pixel dimensions; cliclick uses logical points.
# On Retina screens these differ (typically 2×). We need the ratio so
# coordinates read from screenshots can be used directly for cliclick.
screencapture -x /tmp/_cu_check.png
PX=$(sips -g pixelWidth /tmp/_cu_check.png | awk '/pixelWidth/{print $2}')
LW=$(osascript -e 'tell application "Finder" to get item 3 of (get bounds of window of desktop)' 2>/dev/null || echo 1512)
SCALE=$(python3 -c "print(round($PX/$LW))")
echo "$SCALE" > /tmp/_cu_scale
echo "scale=$SCALE (screenshot=${PX}px logical=${LW}px)"
# ── 2. Scroll tool ─────────────────────────────────────────────────────────
# cliclick has no scroll wheel command; keyboard shortcuts are stolen by
# chat-app input boxes. We compile a tiny Swift binary using CGEvent instead.
cp "$SKILL_DIR/scripts/scroll.swift" /tmp/_cu_scroll.swift
if [ ! -f /tmp/_cu_scroll ] || [ /tmp/_cu_scroll.swift -nt /tmp/_cu_scroll ]; then
swiftc /tmp/_cu_scroll.swift -o /tmp/_cu_scroll && echo "scroll tool compiled"
else
echo "scroll tool up-to-date"
fi
# ── 3. Snap helper ─────────────────────────────────────────────────────────
# Wraps screencapture + resize-to-logical-resolution + optional crop.
# After cu_snap, coordinates in the image == cliclick logical coordinates.
# Keeping screenshots at logical resolution (rather than retina pixels)
# reduces vision-model token cost by ~30-50%.
#
# Usage:
# /tmp/_cu_snap.sh <out.png>
# /tmp/_cu_snap.sh <out.png> <W> <H> <x_offset> <y_offset> # crop after resize
cat << 'SH' > /tmp/_cu_snap.sh
#!/bin/bash
OUT=${1:-/tmp/cu.png}
S=$(cat /tmp/_cu_scale 2>/dev/null || echo 2)
screencapture -x "$OUT"
PW=$(sips -g pixelWidth "$OUT" | awk '/pixelWidth/{print $2}')
PH=$(sips -g pixelHeight "$OUT" | awk '/pixelHeight/{print $2}')
LW=$((PW / S)); LH=$((PH / S))
sips -z "$LH" "$LW" "$OUT" --out "$OUT" > /dev/null
if [ -n "$2" ]; then
sips "$OUT" --cropToHeightWidth "$3" "$2" --cropOffset "${5:-0}" "${4:-0}" \
--out "$OUT" > /dev/null
fi
echo "snap: ${LW}x${LH}$([ -n "$2" ] && echo " → crop $2×$3") → $OUT"
SH
chmod +x /tmp/_cu_snap.sh
echo "snap helper ready"
# ── 4. Visible processes ───────────────────────────────────────────────────
# Always print so you know the real process name before calling osascript.
# (e.g. Feishu ≠ Lark, WeChat ≠ 微信)
echo "--- visible processes ---"
osascript -e 'tell application "System Events" to get name of every process whose visible is true'
// CGEvent scroll tool — compiled once by init.sh, used as /tmp/_cu_scroll
// Usage: _cu_scroll <x> <y> <amount> (amount < 0 = down, > 0 = up)
import Foundation
import CoreGraphics
let a = CommandLine.arguments
let x = Double(a.count > 1 ? a[1] : "760") ?? 760
let y = Double(a.count > 2 ? a[2] : "400") ?? 400
let n = Int32(a.count > 3 ? a[3] : "-5") ?? -5
// Move cursor to target position first so the scroll lands in the right window
CGEvent(mouseEventSource: nil, mouseType: .mouseMoved,
mouseCursorPosition: CGPoint(x: x, y: y), mouseButton: .left)?
.post(tap: .cghidEventTap)
for _ in 0..<10 {
let e = CGEvent(scrollWheelEvent2Source: nil, units: .line,
wheelCount: 1, wheel1: n, wheel2: 0, wheel3: 0)
e?.location = CGPoint(x: x, y: y)
e?.post(tap: .cghidEventTap)
usleep(16000) // ~60fps
}