Community程式設計與開發github.com

1Password CLI 整合

設定與使用 1Password CLI,支援登入、桌面應用程式整合,以及讀取或注入機密資料。

1Password CLI 整合 是什麼?

本技能提供 1Password CLI 的完整整合指引,讓 AI 代理程式(如 Claude Code、Cursor、Codex)能安全地存取與管理機密資料。根據使用環境,支援三種驗證模式:服務帳號(適合無頭伺服器與 CI/CD 環境,直接使用環境變數)、桌面應用程式整合(依賴系統 IPC 通道,需直接執行 op 指令)、以及獨立登入(互動式密碼輸入,需要 tmux 保持 session 狀態)。技能詳細說明每種模式的執行方式、常見問題排解,以及瀏覽器端 1Password for Claude 的金鑰自動填入最佳實務。透過明確的保護措施,確保機密不會外洩至日誌、對話或程式碼中,並優先使用 op run / op inject 而非寫入磁碟。支援 macOS、Windows、Linux 等平台。

相容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/clawdbot/clawdbot/tree/main/skills/1password

Installed? Explore more 程式設計與開發 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

1Password CLI

請遵循官方 CLI 入門步驟。不要猜測安裝指令。

參考資料

  • references/get-started.md(安裝 + 應用程式整合 + 登入流程)
  • references/cli-examples.md(實際 op 範例)

工作流程

  1. 確認作業系統與 shell。
  2. 檢查 CLI 是否存在:op --version。
  3. 偵測使用者已設定的驗證模式:
    • 服務帳號: 已設定 OP_SERVICE_ACCOUNT_TOKEN(典型用於無頭設定、CI、閘道器)。
    • 桌面應用程式整合: 1Password 桌面應用程式正在執行,且已啟用 CLI 整合(典型用於 macOS / Windows / Linux 桌面)。
    • 獨立登入: 以上皆非 — 每次登入時 op signin 都會要求輸入帳號密碼。
  4. 根據驗證模式執行 op(詳見下方)。
  5. 驗證存取:讀取機密前,應先確認 op whoami 執行成功。
  6. 若有多個帳號:使用 --account 或 OP_ACCOUNT。

依驗證模式執行 op

服務帳號(無頭 / 閘道器環境首選)

直接執行。不需要 tmux,不需要登入步驟。

export OP_SERVICE_ACCOUNT_TOKEN="ops_..."
op vault list
op read op://app-prod/db/password

桌面應用程式整合

直接執行。不要在 tmux 中包裝 — 桌面應用程式整合使用每個使用者的 IPC 通道,該通道在閘道器的執行環境中已建立,但從 tmux 子 shell(執行於不同環境上下文)不一定能可靠連接。傳輸方式因平台而異(macOS 上透過 1Password Browser Helper 使用 XPC,Linux 上使用 Unix domain socket,Windows 上使用 named pipe);對代理程式而言,三個平台的實用規則相同:直接執行 op。在 macOS 上,一個有用的症狀指標是 1Password 整合群組容器位於 ~/Library/Group Containers/2BUA8C4S2C.com.1password/t/。

op vault list      # 首次呼叫可能觸發 Touch ID / Windows Hello / 系統驗證
op whoami

如果指令返回 1Password CLI couldn't connect to the 1Password desktop app,不要切換到 tmux。請確認桌面應用程式正在執行且已解鎖,然後重試直接執行。

獨立登入(無應用程式,互動式密碼)

這是唯一需要 tmux 的模式。op signin 會輸出一個 eval 風格的匯出語句,用來設定 OP_SESSION_* token(適用於 POSIX shell);後續在同一個 shell 中執行的指令會透過該環境變數進行驗證。閘道器的逐指令 shell 會在每次呼叫之間失去該狀態,因此一個持久的 tmux pane 可以保持 session token — 但前提是必須在 POSIX shell 中透過 eval 實際套用該匯出。如果以純指令方式發送 op signin,則 stdout 只會列印在 pane 中,而 op whoami 將會失敗。

tmux 流程僅在 macOS/Linux 主機上有效(需已安裝 tmux)。此範例刻意開啟 /bin/sh,以便 eval "$(op signin ...)" 的輸出有效,即使使用者的平常 shell 是 fish。在 Windows 上,建議使用桌面應用程式整合或服務帳號驗證。如果使用者在 Windows 上只有獨立互動式登入,請停止並要求他們提供持久的 PowerShell session 機制,或切換為桌面應用程式整合/服務帳號驗證;請勿直接翻譯 tmux 指令。

SOCKET_DIR="${OPENCLAW_TMUX_SOCKET_DIR:-${TMPDIR:-/tmp}/openclaw-tmux-sockets}"
mkdir -p "$SOCKET_DIR"
chmod 700 "$SOCKET_DIR"
SOCKET="$SOCKET_DIR/openclaw-op.sock"
SESSION="op-auth-$(date +%Y%m%d-%H%M%S)"

tmux -S "$SOCKET" new -d -s "$SESSION" -n shell /bin/sh
tmux -S "$SOCKET" send-keys -t "$SESSION":0.0 -- 'eval "$(op signin --account my.1password.com)"' Enter
tmux -S "$SOCKET" capture-pane -t "$SESSION":0.0 -p -S - | tail -40

不要在登入提示時排入後續指令。請輪詢 pane(使用 capture-pane),直到登入完成且 shell 提示符號已返回,或明顯在等待人工輸入。如果提示要求密碼、MFA 或選擇帳號,請暫停並要求使用者在其自己的終端機中完成登入;提供 socket 和 session 值,以便使用者可以在本地端附加。代理程式不應從 exec 執行 tmux attach,因為 attach 會佔用目前的 TTY 並阻止腳本化的 send-keys / capture-pane 控制。

在 shell 提示符號返回後,透過將檢查指令發送到同一個 pane 來進行驗證:

tmux -S "$SOCKET" send-keys -t "$SESSION":0.0 -- 'op whoami' Enter
tmux -S "$SOCKET" send-keys -t "$SESSION":0.0 -- 'op vault list' Enter
tmux -S "$SOCKET" capture-pane -t "$SESSION":0.0 -p -S - | tail -80

讓 tmux session 保持執行,以便後續的 op read / op run 指令能重複使用同一個已驗證的 shell。

對於獨立登入流程中的每一個後續指令,請使用相同的 SOCKET 和 SESSION 值。-S "$SOCKET" 旗標用於選擇 tmux 伺服器 socket;將其存放在使用者擁有的 0700 目錄中,不要在使用者之間共用,並為每次新的登入嘗試選擇一個新的 session 名稱。

瀏覽器登入(1Password for Claude)

如果 session 在 Chrome 憑證工具(request_credentials、autofill_credential、enter_verification_code)中暴露了 Claude,則應優先使用這些工具而非 op 來登入網站:1Password 會直接填寫頁面,且機密不會進入上下文。規則如下:

  • 在導航之前,透過一次 request_credentials 呼叫請求任務所需的所有憑證。
  • 核准是閘道器主機上的 1Password 提示。如果提示處於待處理狀態,請告知使用者哪個主機需要解鎖(「1Password 正在等待此 Mac 上的核准」),而不是重試。
  • 絕不要要求使用者透過聊天傳送密碼或一次性代碼;代碼僅透過 enter_verification_code 傳送。
  • 不要因為瀏覽器流程需要核准就退而使用 op read 來讀取網站密碼;這會破壞無暴露的設計。對於指令和設定所使用的機密,請使用 op;對於存在瀏覽器流程的網頁登入,則不要這樣做。

保護措施

  • 絕不要將機密貼入日誌、聊天或程式碼中。
  • 優先使用 op run / op inject,而不是將機密寫入磁碟。
  • 如果需要無應用程式整合的登入,請先使用 op account add。
  • 如果指令返回「account is not signed in」:
    • 服務帳號:重新匯出 OP_SERVICE_ACCOUNT_TOKEN
    • 桌面應用程式:確認應用程式正在執行且已啟用整合
    • 獨立登入:在同一個 tmux session 中重新執行 op signin 並授權

Individual skills in this repo

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

acp-router

Route plain-language requests for Claude Code, Cursor, Copilot, OpenClaw ACP, OpenCode, Gemini CLI, Qwen, Kiro, Kimi, iFlow, Factory Droid, Kilocode, or explicit ACP harness work into either OpenClaw ACP runtime sessions or direct acpx-driven sessions ("telephone game" flow). For coding-agent thread requests, read this skill first, then use only `sessions_spawn` for thread creation. Codex chat binding defaults to the native Codex app-server plugin unless ACP is explicit or background spawn needs ACP.

add-model-provider

Add and live-prove a model provider with non-interactive config one-liners, without exposing credentials.

agent-transcript

Requested GitHub PR/issue agent transcripts: redact, trim, preview, and insert safely.

apple-notes

Create, view, edit, delete, search, move, or export Apple Notes via the memo CLI on macOS.

apple-reminders

List, add, edit, complete, or delete Apple Reminders and reminder lists via remindctl.

auto-qa

Run OpenClaw-wide autonomous QA and live/stress campaigns across independent subsystem lanes, with verified fixes and a resumable evidence report.

autoreview

Structured code review through the shared OpenClaw agent-skills installation.

bear-notes

Create, search, and manage Bear notes via grizzly CLI.

blacksmith-testbox

Run Blacksmith Testbox for CI-parity checks, secrets, hosted services, migrations, or builds local cannot reproduce.

block-kit

Use proactively for structured or interactive Slack replies, and when asked to author or validate native Slack Block Kit JSON.

blogwatcher

Monitor blogs and RSS/Atom feeds for updates using the blogwatcher CLI.

blucli

BluOS CLI (blu) for discovery, playback, grouping, and volume.

bluebubbles

Send and manage iMessages via BlueBubbles, including attachments, tapbacks, edits, replies, and groups.

browser-automation

Use when controlling web pages with the OpenClaw browser tool, especially multi-step flows, login checks, tab management, or recovery from stale refs/timeouts.

camsnap

Capture frames or clips from RTSP/ONVIF cameras and local webcams, including USB pan/tilt/zoom control.

canvas

Present HTML on connected OpenClaw node canvases, navigate/eval/snapshot, and debug canvas host URLs.

channel-message-flows

Use when running QA Lab channel message flow evidence.

clawdtributor

Clawtributor PRs here, last week or another window: discover conversation refs, recheck GitHub, rank by impact.

clawhub

Search ClawHub for plugins by default, or skills when explicitly requested; install, verify, update, uninstall, publish, or sync skills.

claw-score

Audit or refresh OpenClaw maturity scorecard docs from root taxonomy, maturity scores, and QA evidence artifacts without using maintainer discrawl data or committed inventory reports.

相關技能