Token导航 LogoToken导航

Agent Skill · 前端设计

iterm2-driver(iterm2 驱动程序)

iterm2-driver 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

iterm2-driver 是前端设计类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为执行命令;许可证信息还不明确,第三方扫描已通过,按安装量在前端设计类的 10,216 个 Skill 里排第 9,472。

总安装 214周安装 9GitHub Stars 3下载 75核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:iterm2-driver(iterm2 驱动程序)
来源仓库:https://github.com/indrasvat/claude-code-skills
仓库路径:skills/iterm2-driver
安装命令:
npx skills add https://github.com/indrasvat/claude-code-skills --skill iterm2-driver
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/indrasvat/claude-code-skills --skill iterm2-driver

这个 Skill 是做什么的

前端设计类 Skill 关注页面结构、视觉规范和组件写法,输出通常是可运行的界面代码。

用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息。适合围绕仓库状态、代码变更或协作事项进行整理。可结合来源仓库和原始 README 核验具体用法。安装前建议确认权限范围和维护状态,以及是否会触发联网或文件读写。注意检查是否会触发命令执行或高风险操作。

iterm2-driver 属于前端设计类 Skill,可作为该场景下的辅助能力补充。

来源仓库内路径:skills/iterm2-driver

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/indrasvat/claude-code-skills --skill iterm2-dr…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要执行命令,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

iterm2-driver 怎么安装?

在终端执行 npx skills add https://github.com/indrasvat/claude-code-skills --skill iterm2-driver。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

iterm2-driver 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

iterm2-driver 需要什么权限?

权限级别是执行命令。安装流程涉及命令执行,可能通过 npx skills add https://github.com/indrasvat/claude-code-skills --skill iterm2-driver 联网下载 Skill 或依赖。用户安装前应确认命令来源、仓库内容和执行环境。

iterm2-driver 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

iterm2-driver 用的人多吗?

公开数据是累计安装 214 次,近一周安装 9 次,下载 75 次,GitHub 3 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

iterm2-driver 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 需要执行命令,装到常用环境前要先评估影响面。
  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理前端设计类任务、又不想每次都手写提示词的人。

不太适合

  • 不能接受 Skill 在你机器上执行命令的人。
  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

前端设计类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
frontend-design

前端设计 · Codex、Claude

8,823,360126,072只读MIT通过
vercel-composition-patterns

Vercel 组合模式 · Codex、Claude

3,858,81625,893需要联网MIT通过
vercel-react-native-skills

Vercel React native skills 前端 · Codex、Claude

2,468,66425,878只读MIT通过
adapt

adapt 搜索 · Codex、Claude

2,027,04023,125操作浏览器未明确通过
bolder

bolder 分析 · Codex、Claude

2,004,28823,130只读未明确通过
iterm2-driver

iterm2 驱动程序 · 本页

2143执行命令未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

iTerm2 Driver Skill

Drive the iTerm2 terminal emulator via its Python API. Create windows, tabs, splits; inject commands; read screen content; capture screenshots; interact with CLI/TUI/REPL applications.

IMPORTANT: When Building or Modifying CLI/TUI Apps

When the user is building a new CLI/TUI, adding a feature, fixing a bug, or creating a PRD/plan for a terminal app, always include iTerm2 visual testing in:

  • PRDs: Add an "L4 Visual Testing" section with specific visual test cases
  • Plans: Include a phase/task for creating .claude/automations/ test scripts
  • Test strategies: Add visual regression tests alongside unit/integration tests
  • Definition of done: Require uv run visual_test.py passing before marking complete

This applies to any project using BubbleTea, Charm, tview, termui, crossterm, ratatui, Ink, blessed, or similar TUI frameworks. Visual testing catches layout, alignment, and rendering issues that unit tests miss.

Prerequisites

  • macOS — iTerm2 is macOS-only (no Linux/cloud support; see references/cloud-and-limitations.md)
  • iTerm2 installed with Python API enabled (Preferences > General > Magic > Enable Python API)
  • Python 3.14+ and uv package manager
  • Screen Recording permission — required for screencapture -l screenshots
  • iTerm2 must be running and not minimized for screenshots to work

CRITICAL: Script Format

Every Python script MUST use uv with inline metadata:

# /// script
# requires-python = ">=3.14"
# dependencies = [
#   "iterm2",
#   "pyobjc",
# ]
# ///

For screenshots, add "pyobjc-framework-Quartz" to dependencies.

Execution: uv run script_name.py

CRITICAL: Docstring Planning

Every script MUST begin with a comprehensive docstring covering: Tests, Verification Strategy, Screenshots, Key Bindings, and Usage. See examples/00-comprehensive-template.py.

Connection Architecture

  • Python API connects via WebSocket over Unix domain socket
  • Socket path: ~/Library/Application Support/iTerm2/private/socket
  • Protocol: Google Protocol Buffers over WebSocket
  • Multiple simultaneous connections supported — each gets a unique auth cookie
  • Authentication: auto via ITERM2_COOKIE env var (set by iTerm2 AppleScript)
  • If connection fails, check: socket exists, not stale, iTerm2 running with API enabled
  • Use retry=True in run_until_complete() for automatic reconnection

Core Concepts

  • Hierarchy: App → Window → Tab → Session
  • Connection: iterm2.run_until_complete(main) for standalone scripts
  • Window creation: await iterm2.Window.async_create(connection) — creates a new window
  • Session targeting: Always use session IDs, never rely on "current" references in parallel

Quick Reference

TaskCode
Get appapp = await iterm2.async_get_app(connection)
Create windowwindow = await iterm2.Window.async_create(connection)
Get sessionsession = window.current_tab.current_session
New tabtab = await window.async_create_tab()
Send textawait session.async_send_text("ls\n")
Read screenscreen = await session.async_get_screen_contents()
Get linescreen.line(i).string
Split panes2 = await session.async_split_pane(vertical=True)
Set nameawait session.async_set_name("worker")
Set window sizeawait window.async_set_frame(iterm2.Frame(point, size))
Get window frameframe = await window.async_get_frame()
Close sessionawait session.async_close()
Ctrl+Cawait session.async_send_text("\x03")
Enter (TUI)await session.async_send_text("\r")

CRITICAL: Window Creation (Parallel-Safe)

Never use app.current_terminal_window — it returns whichever window is frontmost, causing race conditions when multiple agents run simultaneously.

Always create your own window using the pattern below. This is the single most important pattern in this skill — get it wrong and every script will fail intermittently.

The Stale Window Problem

Window.async_create() returns a window object before iTerm2 finishes initializing it. The returned object's current_tab will be None, causing AttributeError: 'NoneType' object has no attribute 'current_session'. This is the #1 cause of iTerm2 automation failures.

The fix: Sleep briefly, then refresh via async_get_app() to get the fully-initialized window object:

async def create_window(connection, name="test", x_pos=100, width=700, height=500):
    """Create an isolated window. Handles the stale-window-object bug.

    IMPORTANT: Window.async_create() returns BEFORE iTerm2 finishes init.
    The returned object's current_tab is None. We MUST refresh via
    async_get_app() to get the real, initialized window object.
    """
    window = await iterm2.Window.async_create(connection)
    await asyncio.sleep(0.5)  # REQUIRED: let iTerm2 init the window

    # REQUIRED: refresh — the returned window object is stale
    app = await iterm2.async_get_app(connection)
    if window.current_tab is None:
        for w in app.terminal_windows:
            if w.window_id == window.window_id:
                window = w
                break

    # Readiness probe — wait for tab/session
    for _ in range(20):
        if window.current_tab and window.current_tab.current_session:
            break
        await asyncio.sleep(0.2)

    if not window.current_tab or not window.current_tab.current_session:
        raise RuntimeError(f"Window '{name}' not ready after refresh + probe")

    session = window.current_tab.current_session
    await session.async_set_name(name)

    # Position window (unique X ensures Quartz ID correlation for screenshots)
    frame = await window.async_get_frame()
    await window.async_set_frame(iterm2.Frame(
        iterm2.Point(x_pos, frame.origin.y),
        iterm2.Size(width, height)
    ))
    await asyncio.sleep(0.3)

    return window, session

Copy this function into every script. Do not skip the asyncio.sleep(0.5) or the async_get_app() refresh — both are required.

See references/parallel-patterns.md for full parallel agent patterns.

CRITICAL: Orphaned Window Prevention

Automation scripts that crash mid-run leave orphaned iTerm2 windows. This is the #2 pain point from real-world usage. Every script MUST:

  1. Track all created windows/sessions in a list at the top of main()
  2. Clean up in a finally block — even on crash, close what you can
  3. Run the cleanup janitor at the START of each run to close stale windows from previous crashes:
async def cleanup_stale_windows(connection, prefix="agent-"):
    """Close windows from previous crashed runs. Call at script start."""
    app = await iterm2.async_get_app(connection)
    for window in app.terminal_windows:
        for tab in window.tabs:
            for session in tab.sessions:
                if session.name and session.name.startswith(prefix):
                    try:
                        await session.async_send_text("exit\n")
                        await asyncio.sleep(0.1)
                        try: await session.async_close()
                        except Exception: pass
                    except Exception: pass

CRITICAL: Multi-Level Cleanup

Always use try-except-finally with multi-level cleanup. Track all resources globally:

created_sessions = []
try:
    window, session = await create_window(connection, "test")
    created_sessions.append(session)
    # ... test logic ...
except Exception as e:
    print(f"ERROR: {e}")
    raise
finally:
    for s in created_sessions:
        try:
            await s.async_send_text("\x03")
            await asyncio.sleep(0.1)
            await s.async_send_text("exit\n")
            await asyncio.sleep(0.1)
            await s.async_close()
        except Exception:
            pass

Screenshot Capture (Parallel-Safe)

Use position-based Quartz correlation to capture the correct window — name-based matching fails when commands change the window title:

import Quartz, subprocess

async def capture_screenshot(window, output_path):
    """Capture screenshot of a specific window (no focus required)."""
    frame = await window.async_get_frame()
    window_list = Quartz.CGWindowListCopyWindowInfo(
        Quartz.kCGWindowListOptionOnScreenOnly
        | Quartz.kCGWindowListExcludeDesktopElements,
        Quartz.kCGNullWindowID,
    )
    best_id, best_score = None, float("inf")
    for w in window_list:
        if "iTerm" not in w.get("kCGWindowOwnerName", ""):
            continue
        b = w.get("kCGWindowBounds", {})
        score = (abs(float(b.get("X", 0)) - frame.origin.x) * 2
                 + abs(float(b.get("Width", 0)) - frame.size.width)
                 + abs(float(b.get("Height", 0)) - frame.size.height))
        if score < best_score:
            best_score, best_id = score, w.get("kCGWindowNumber")
    if best_id and best_score < 30:
        subprocess.run(["screencapture", "-x", "-l", str(best_id), output_path])
        return output_path
    return None

Key facts:

  • screencapture -l works for non-frontmost windows — no focus required
  • Minimized windows cannot be captured (excluded by kCGWindowListOptionOnScreenOnly)
  • Each agent needs its own window (not tab) for independent screenshots
  • Tabs share the same Quartz window ID — screenshot shows the active tab only

TUI Layout Verification

TUI elements frequently misalign. Always verify layout integrity. See references/verification-patterns.md for complete helpers including box integrity, modal boundaries, and status bar checks.

Test Reporting

Track results with a results dict containing passed, failed, and tests list. See references/reporting.md for JSON/JUnit export patterns.

Special Keys Reference

KeyCodeNotes
Enter\rPrefer over \n in TUIs
Esc\x1b
Ctrl+C\x03
Ctrl+D\x04EOF
Ctrl+X\x18
Tab\t
Up Arrow\x1b[A
Down Arrow\x1b[B
Right Arrow\x1b[C
Left Arrow\x1b[D

Guidelines

  1. Always use uv run — never run Python directly
  2. Create your own window — never use app.current_terminal_window
  3. Use readiness probes — never rely on fixed sleep() for initialization
  4. Track all resources — close all created sessions/windows in finally blocks
  5. Use \r for Enter in TUIs — safer than \n for prompts
  6. Dump screen on failure — always show what went wrong
  7. Verify layout — check box-drawing characters connect properly
  8. Use suppress_broadcast=True when broadcast input may be enabled (prevents text leaking to other sessions)

Script Storage

ScopeLocationGit
Project-specific./.claude/automations/{script}.py or ./.agent/automations/{script}.pyCOMMIT — these are project assets
General utility~/.claude/automations/{script}.pyN/A (user home)
Screenshots./.claude/screenshots/GITIGNORE — local verification only

Important: Automation scripts SHOULD be committed to the repository. They are project assets that enforce test coverage and enable reproducible testing across machines and agents. Use .claude/automations/ or the agent-neutral .agent/automations/ folder.

No PII in scripts: Since scripts are committed and shareable, they MUST NOT contain:

  • Hardcoded usernames, hostnames, or paths specific to one developer
  • API keys, tokens, or credentials
  • Personal file paths (use ~, $HOME, or relative paths)
  • Machine-specific configurations (use environment variables)

Screenshots MUST NOT be committed. Add to .gitignore:

.claude/screenshots/
.agent/screenshots/
screenshots/

Examples & References

Examples (examples/ directory):

  • 00-comprehensive-template.py — Complete template with all patterns
  • 01-basic-tab.py — Simple tab creation and command execution
  • 02-dev-layout.py — Multi-pane development layout
  • 03-repl-driver.py — REPL automation with verification
  • 04-nano-automation.py — TUI editor interaction with cleanup
  • 05-screen-monitor.py — ScreenStreamer for real-time monitoring
  • 06-environment-vars.py — Environment variable handling
  • 07-cleanup-sessions.py — Session cleanup patterns
  • 08-badge-control.py — Badge and tab control
  • 09-special-keys.py — Special key sequences for TUI navigation
  • 10-session-reuse.py — Get-or-create session reuse pattern
  • 11-layout-verification.py — TUI layout alignment checks
  • 12-parallel-agents.py — Multiple concurrent agents with independent screenshots
  • 13-connection-diagnostics.py — Pre-flight checks and troubleshooting

References (references/ directory):

  • templates.md — Copy-paste script templates (single + parallel)
  • verification-patterns.md — All verification helpers including layout checks
  • reporting.md — Test reporting patterns, JSON/JUnit export
  • parallel-patterns.md — Parallel agent patterns, Quartz correlation, cleanup
  • cloud-and-limitations.md — Platform support matrix, cloud alternatives

Links

平台分布

Codex

34.31%
按下载量换算26

Claude

30.98%
按下载量换算23

Cursor

20.71%
按下载量换算16

Gemini CLI

10.04%
按下载量换算8

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

执行命令

安装流程涉及命令执行,可能通过 npx skills add https://github.com/indrasvat/claude-code-skills --skill iterm2-driver 联网下载 Skill 或依赖。用户安装前应确认命令来源、仓库内容和执行环境。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills