Communitygithub.com

エージェントブラウザ

AIエージェント向けブラウザ自動化CLI。Webページの操作、フォーム入力、スクリーンショット、データ抽出など、ブラウザを必要とするあらゆるタスクを自動化します。

エージェントブラウザ とは?

このスキルは、AIエージェントがブラウザを自動操作するためのCLIツール「agent-browser」を提供します。Chrome/ChromiumのCDPを直接利用し、ページ遷移、フォーム入力、クリック、スクリーンショット、データ抽出、Webアプリのテストなど、人間がブラウザで行う操作をプログラムで実行できます。インストールはnpm、brew、cargoから可能で、初回は`agent-browser install`でChromeを自動ダウンロードします。コマンドは`&&`でチェーン可能で、バックグラウンドデーモンによりブラウザセッションが維持されるため効率的な連続操作が可能です。認証情報の保存・復元、ステートファイルによるセッション管理、iOSシミュレーターでのモバイルSafari操作、視覚的なデバッグ機能(ヘッドモード、DevTools、録画)など、多彩な機能を備えています。特にAIエージェント向けに、ページコンテンツに境界マーカーを付与するContent Boundaries機能や、ドメインホワイトリストによるナビゲーション制限など、セキュリティ面でも配慮されています。

対応~Claude Code~Codex CLI✓Cursor
npx skills add https://github.com/LiChangZheng10086/doyin_ai_video/tree/HEAD/.agents/skills/agent-browser

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

agent-browser によるブラウザ自動化

CLIはChrome/ChromiumをCDP経由で直接使用します。インストールは npm i -g agent-browser、brew install agent-browser、または cargo install agent-browser で行います。agent-browser install を実行してChromeをダウンロードしてください。

基本ワークフロー

ブラウザ自動化は以下のパターンに従います。

  1. ナビゲート: agent-browser open <url>
  2. スナップショット: agent-browser snapshot -i(要素参照 @e1、@e2 を取得)
  3. 操作: 参照を使ってクリック、入力、選択
  4. 再スナップショット: ナビゲーション後やDOM変更後に、最新の参照を取得
agent-browser open https://example.com/form
agent-browser snapshot -i
# 出力: @e1 [input type="email"], @e2 [input type="password"], @e3 [button] "Submit"

agent-browser fill @e1 "[email protected]"
agent-browser fill @e2 "password123"
agent-browser click @e3
agent-browser wait --load networkidle
agent-browser snapshot -i  # 結果を確認

コマンドチェーン

コマンドは1回のシェル呼び出しで && を使ってチェーンできます。ブラウザはバックグラウンドデーモンを通じて維持されるため、個別に呼び出すよりも安全で効率的です。

# チェーン: open + wait + snapshot を1回で実行
agent-browser open https://example.com && agent-browser wait --load networkidle && agent-browser snapshot -i

# 複数の操作をチェーン
agent-browser fill @e1 "[email protected]" && agent-browser fill @e2 "password123" && agent-browser click @e3

# ナビゲートしてキャプチャ
agent-browser open https://example.com && agent-browser wait --load networkidle && agent-browser screenshot page.png

チェーンを使うタイミング: 中間コマンドの出力を読み取る必要がない場合は && を使います(例: open + wait + screenshot)。出力をパースする必要がある場合はコマンドを個別に実行します(例: snapshotで参照を取得し、その参照を使って操作)。

認証の扱い

ログインが必要なサイトを自動化する場合、適切な方法を選択してください。

オプション1: ユーザーのブラウザから認証情報をインポート(1回限りのタスクに最速)

# ユーザーの実行中のChromeに接続(ユーザーは既にログイン済み)
agent-browser --auto-connect state save ./auth.json
# その認証状態を使用
agent-browser --state ./auth.json open https://app.example.com/dashboard

ステートファイルにはセッショントークンが平文で含まれます。 .gitignore に追加し、不要になったら削除してください。保存時の暗号化には AGENT_BROWSER_ENCRYPTION_KEY を設定します。

オプション2: 永続プロファイル(繰り返しタスクに最も簡単)

# 初回実行: 手動または自動化でログイン
agent-browser --profile ~/.myapp open https://app.example.com/login
# ... 認証情報を入力、送信 ...

# 以降の実行: 認証済みで起動
agent-browser --profile ~/.myapp open https://app.example.com/dashboard

オプション3: セッション名(クッキー + localStorage を自動保存/復元)

agent-browser --session-name myapp open https://app.example.com/login
# ... ログインフロー ...
agent-browser close  # 状態が自動保存される

# 次回: 状態が自動復元される
agent-browser --session-name myapp open https://app.example.com/dashboard

オプション4: 認証情報保管庫(暗号化して保存、名前でログイン)

echo "$PASSWORD" | agent-browser auth save myapp --url https://app.example.com/login --username user --password-stdin
agent-browser auth login myapp

オプション5: ステートファイル(手動保存/読み込み)

# ログイン後:
agent-browser state save ./auth.json
# 後のセッションで:
agent-browser state load ./auth.json
agent-browser open https://app.example.com/dashboard

OAuth、2FA、Cookieベース認証、トークンリフレッシュパターンについては references/authentication.md を参照してください。

必須コマンド

# ナビゲーション
agent-browser open <url>              # ナビゲート(別名: goto、navigate)
agent-browser close                   # ブラウザを閉じる

# スナップショット
agent-browser snapshot -i             # インタラクティブ要素と参照(推奨)
agent-browser snapshot -i -C          # カーソルインタラクティブ要素を含める(onclickを持つdiv、cursor:pointer)
agent-browser snapshot -s "#selector" # CSSセレクターでスコープ指定

# 操作(snapshotで取得した@refを使用)
agent-browser click @e1               # 要素をクリック
agent-browser click @e1 --new-tab     # クリックして新しいタブで開く
agent-browser fill @e2 "text"         # クリアしてテキスト入力
agent-browser type @e2 "text"         # クリアせずにテキスト入力
agent-browser select @e1 "option"     # ドロップダウンオプションを選択
agent-browser check @e1               # チェックボックスをチェック
agent-browser press Enter             # キーを押す
agent-browser keyboard type "text"    # 現在のフォーカス位置に入力(セレクターなし)
agent-browser keyboard inserttext "text"  # キーイベントなしで挿入
agent-browser scroll down 500         # ページをスクロール
agent-browser scroll down 500 --selector "div.content"  # 特定のコンテナ内でスクロール

# 情報取得
agent-browser get text @e1            # 要素のテキストを取得
agent-browser get url                 # 現在のURLを取得
agent-browser get title               # ページタイトルを取得
agent-browser get cdp-url             # CDP WebSocket URLを取得

# 待機
agent-browser wait @e1                # 要素が現れるまで待機
agent-browser wait --load networkidle # ネットワークがアイドルになるまで待機
agent-browser wait --url "**/page"    # URLパターンに一致するまで待機
agent-browser wait 2000               # ミリ秒待機
agent-browser wait --text "Welcome"    # テキストが現れるまで待機(部分一致)
agent-browser wait --fn "!document.body.innerText.includes('Loading...')"  # テキストが消えるまで待機
agent-browser wait "#spinner" --state hidden  # 要素が消えるまで待機

# ダウンロード
agent-browser download @e1 ./file.pdf          # 要素をクリックしてダウンロードをトリガー
agent-browser wait --download ./output.zip     # ダウンロード完了まで待機
agent-browser --download-path ./downloads open <url>  # デフォルトのダウンロードディレクトリを設定

# ビューポートとデバイスエミュレーション
agent-browser set viewport 1920 1080          # ビューポートサイズ設定(デフォルト: 1280x720)
agent-browser set viewport 1920 1080 2        # 2xレチナ(同一CSSサイズ、高解像度スクリーンショット)
agent-browser set device "iPhone 14"          # デバイスエミュレーション(ビューポート + ユーザーエージェント)

# キャプチャ
agent-browser screenshot              # スクリーンショットをテンポラリに保存
agent-browser screenshot --full       # 全ページスクリーンショット
agent-browser screenshot --annotate   # 要素ラベル付き注釈スクリーンショット
agent-browser screenshot --screenshot-dir ./shots  # カスタムディレクトリに保存
agent-browser screenshot --screenshot-format jpeg --screenshot-quality 80
agent-browser pdf output.pdf          # PDFとして保存

# クリップボード
agent-browser clipboard read                      # クリップボードからテキストを読み込み
agent-browser clipboard write "Hello, World!"     # クリップボードにテキストを書き込み
agent-browser clipboard copy                      # 現在の選択範囲をコピー
agent-browser clipboard paste                     # クリップボードから貼り付け

# 差分比較(ページ状態の比較)
agent-browser diff snapshot                          # 現在のスナップショットと前回を比較
agent-browser diff snapshot --baseline before.txt    # 現在と保存済ファイルを比較
agent-browser diff screenshot --baseline before.png  # 視覚的なピクセル差分
agent-browser diff url <url1> <url2>                 # 2つのページを比較
agent-browser diff url <url1> <url2> --wait-until networkidle  # カスタム待機戦略
agent-browser diff url <url1> <url2> --selector "#main"  # 要素でスコープ

よくあるパターン

フォーム送信

agent-browser open https://example.com/signup
agent-browser snapshot -i
agent-browser fill @e1 "Jane Doe"
agent-browser fill @e2 "[email protected]"
agent-browser select @e3 "California"
agent-browser check @e4
agent-browser click @e5
agent-browser wait --load networkidle

認証情報保管庫による認証(推奨)

# 認証情報を一度保存(AGENT_BROWSER_ENCRYPTION_KEYで暗号化)
# 推奨: パスワードはシェル履歴に残らないようstdin経由で渡す
echo "pass" | agent-browser auth save github --url https://github.com/login --username user --password-stdin

# 保存したプロファイルでログイン(LLMがパスワードを見ることはない)
agent-browser auth login github

# プロファイルの一覧/表示/削除
agent-browser auth list
agent-browser auth show github
agent-browser auth delete github

ステート永続化による認証

# 一度ログインし、状態を保存
agent-browser open https://app.example.com/login
agent-browser snapshot -i
agent-browser fill @e1 "$USERNAME"
agent-browser fill @e2 "$PASSWORD"
agent-browser click @e3
agent-browser wait --url "**/dashboard"
agent-browser state save auth.json

# 後のセッションで再利用
agent-browser state load auth.json
agent-browser open https://app.example.com/dashboard

セッション永続化

# ブラウザ再起動間でクッキーとlocalStorageを自動保存/復元
agent-browser --session-name myapp open https://app.example.com/login
# ... ログインフロー ...
agent-browser close  # 状態が ~/.agent-browser/sessions/ に自動保存される

# 次回、状態は自動読み込みされる
agent-browser --session-name myapp open https://app.example.com/dashboard

# 保存時の暗号化
export AGENT_BROWSER_ENCRYPTION_KEY=$(openssl rand -hex 32)
agent-browser --session-name secure open https://app.example.com

# 保存済み状態の管理
agent-browser state list
agent-browser state show myapp-default.json
agent-browser state clear myapp
agent-browser state clean --older-than 7

データ抽出

agent-browser open https://example.com/products
agent-browser snapshot -i
agent-browser get text @e5           # 特定の要素テキストを取得
agent-browser get text body > page.txt  # 全ページテキストを取得

# 解析用JSON出力
agent-browser snapshot -i --json
agent-browser get text @e1 --json

並列セッション

agent-browser --session site1 open https://site-a.com
agent-browser --session site2 open https://site-b.com

agent-browser --session site1 snapshot -i
agent-browser --session site2 snapshot -i

agent-browser session list

既存のChromeに接続

# リモートデバッグが有効なChromeを自動検出
agent-browser --auto-connect open https://example.com
agent-browser --auto-connect snapshot

# 明示的なCDPポートで接続
agent-browser --cdp 9222 snapshot

カラースキーム(ダークモード)

# フラグで永続的にダークモード(全ページと新規タブに適用)
agent-browser --color-scheme dark open https://example.com

# または環境変数で設定
AGENT_BROWSER_COLOR_SCHEME=dark agent-browser open https://example.com

# またはセッション中に設定(以降のコマンドで持続)
agent-browser set media dark

ビューポートとレスポンシブテスト

# カスタムビューポートサイズを設定(デフォルトは1280x720)
agent-browser set viewport 1920 1080
agent-browser screenshot desktop.png

# モバイル幅のレイアウトをテスト
agent-browser set viewport 375 812
agent-browser screenshot mobile.png

# レチナ/HiDPI: 同一CSSレイアウトを2倍のピクセル密度でレンダリング
# スクリーンショットは論理ビューポートサイズのまま、コンテンツは高DPIで描画
agent-browser set viewport 1920 1080 2
agent-browser screenshot retina.png

# デバイスエミュレーション(ビューポート + ユーザーエージェントを一度に設定)
agent-browser set device "iPhone 14"
agent-browser screenshot device.png

scaleパラメータ(3番目の引数)は window.devicePixelRatio を設定しますが、CSSレイアウトは変更しません。レチナレンダリングのテストや高解像度スクリーンショットの取得に使用します。

ビジュアルブラウザ(デバッグ)

agent-browser --headed open https://example.com
agent-browser highlight @e1          # 要素をハイライト
agent-browser inspect                # アクティブページでChrome DevToolsを開く
agent-browser record start demo.webm # セッションを録画
agent-browser profiler start         # Chrome DevToolsプロファイリング開始
agent-browser profiler stop trace.json # 停止してプロファイル保存(パスはオプション)

環境変数 AGENT_BROWSER_HEADED=1 でヘッドモードを有効にできます。ブラウザ拡張機能はヘッドモードとヘッドレスの両方で動作します。

ローカルファイル(PDF、HTML)

# file:// URLでローカルファイルを開く
agent-browser --allow-file-access open file:///path/to/document.pdf
agent-browser --allow-file-access open file:///path/to/page.html
agent-browser screenshot output.png

iOSシミュレーター(モバイルSafari)

# 利用可能なiOSシミュレーターを一覧表示
agent-browser device list

# 特定のデバイスでSafariを起動
agent-browser -p ios --device "iPhone 16 Pro" open https://example.com

# デスクトップと同様のワークフロー: snapshot、操作、再snapshot
agent-browser -p ios snapshot -i
agent-browser -p ios tap @e1          # タップ(Clickの別名)
agent-browser -p ios fill @e2 "text"
agent-browser -p ios swipe up         # モバイル特有のジェスチャー

# スクリーンショット
agent-browser -p ios screenshot mobile.png

# セッションを閉じる(シミュレーターをシャットダウン)
agent-browser -p ios close

必要条件: macOS + Xcode、Appium(npm install -g appium && appium driver install xcuitest)

実機: 事前設定済みの物理iOSデバイスでも動作します。--device "<UDID>" を使用します。UDIDは xcrun xctrace list devices で取得できます。

セキュリティ

すべてのセキュリティ機能はオプトインです。デフォルトでは、agent-browserはナビゲーション、アクション、出力に制限を設けません。

コンテンツ境界(AIエージェント推奨)

--content-boundaries を有効にすると、ページから取得した出力にマーカーをラップし、LLMがツール出力と信頼できないページコンテンツを区別しやすくなります。

export AGENT_BROWSER_CONTENT_BOUNDARIES=1
agent-browser snapshot
# 出力:
# --- AGENT_BROWSER_PAGE_CONTENT nonce=<hex> origin=https://example.com ---
# [accessibility tree]
# --- END_AGENT_BROWSER_PAGE_CONTENT nonce=<hex> ---

ドメインホワイトリスト

ナビゲーションを信頼できるドメインに制限します。ワイルドカード(例: *.example.com)はベアドメイン example.com にも一致します。許可されていないドメインへのサブリソースリクエスト、WebSocket、EventSource接続もブロックされます。ターゲットページが依存するCDNドメインを含めてください。

export AGENT_BROWSER_ALLOWLIST_DOMAINS="*.example.com,*.auth.com,cdn.example.com"
agent-browser open https://example.com  # 許可
agent-browser open https://evil.com     # ブロック

読み取り専用モード

export AGENT_BROWSER_READONLY=1
agent-browser open https://example.com
agent-browser snapshot -i              # 可能
agent-browser click @e1                # ブロック

参考文献

Individual skills in this repo

This repo contains 12 individual skills — each has its own dedicated page.

LiChangZheng10086/doyin_ai_video

Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER — read BEFORE opening the target file; don't skip because it "looks like a one-liner" — whenever: the prompt names Claude/Anthropic in any form (Claude, Anthropic, Fable, Opus, Sonnet, Haiku, `anthropic`, `@anthropic-ai`, `claude-*`, `us.anthropic.*`, `[1m]`); the user asks about an LLM (pricing/model choice/limits/caching) — never answer from memory; OR the task is LLM-shaped with provider unstated (agent/MCP/tool-definition/multi-agent/RAG/LLM-judge/computer-use; generate/summarize/extract/classify/rewrite/converse over NL; debugging refusals/cutoffs/streaming/tool-calls/tokens). SKIP only when another provider is being worked on (overrides all triggers): OpenAI/GPT/Gemini/Llama/Mistral/Cohere/Ollama named in the query; OR `grep -rE 'openai|langchain_openai|google.generativeai|genai|mistralai|cohere|ollama'` over the project hits (run this grep FIR...

LiChangZheng10086/doyin_ai_video

Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.

LiChangZheng10086/doyin_ai_video

Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.

LiChangZheng10086/doyin_ai_video

Grill me about specs for the workflows I want to build, within this workspace.

LiChangZheng10086/doyin_ai_video

Use this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill.

LiChangZheng10086/doyin_ai_video

智能 PPT 生成器。支持 7 种视觉风格(乐高/波普/黏土/黑白/商务/学术/科技),具备根据内容自动推荐风格、生成大纲、绘制配图并组装成片的全自动能力。

LiChangZheng10086/doyin_ai_video

Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions \"deck,\" \"slides,\" \"presentation,\" or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill.

LiChangZheng10086/doyin_ai_video

Diagnose and fix React codebase health issues. Use when reviewing React code, fixing performance problems, auditing security, or improving code quality.

LiChangZheng10086/doyin_ai_video

Sentry error monitoring and performance tracing patterns for Next.js applications.

LiChangZheng10086/doyin_ai_video

Simplify and refine recently modified code for clarity and consistency. Use after writing code to improve readability without changing functionality.

LiChangZheng10086/doyin_ai_video

✅ "你知道今天所有大模型能读懂你的话,全靠一个叫Transformer的架构吗?"

LiChangZheng10086/doyin_ai_video

Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like \"the xlsx in my downloads\") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.

関連スキル