[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7EBW2VD6N1DTVZ3F1H9AS8H":3,"skill-same:01M7EBW2VD6N1DTVZ3F1H9AS8H":46},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":30,"updatedAt":31,"install":32,"resources":45},"01M7EBW2VD6N1DTVZ3F1H9AS8H","cli-anything-safari",null,"Safari browser automation CLI on macOS via safari-mcp. Controls real Safari (native, keeps logins) by wrapping the safari-mcp MCP server. Every one of the 84 MCP tools is exposed 1:1 with schema-accurate arguments — guaranteed parity, no manual drift.","lza6\u002FArmor-piercing-system-prompts","lza6","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F128880206?v=4","01M7EB3K7WPX5T28EJ2NVHE6EG","Chinese-tingfeng","01M7EB3K97E1KQ16QWKJMFNGX8",11,"MIT","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F03-逆向工程\u002Fcli-anything-safari\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: \"cli-anything-safari\"\ndescription: >-\n  Safari browser automation CLI on macOS via safari-mcp. Controls real Safari\n  (native, keeps logins) by wrapping the safari-mcp MCP server. Every one of\n  the 84 MCP tools is exposed 1:1 with schema-accurate arguments — guaranteed\n  parity, no manual drift.\n---\n\n# cli-anything-safari\n\nA command-line interface for Safari browser automation on macOS. Wraps the\n[`safari-mcp`](https:\u002F\u002Fgithub.com\u002Fachiya-automation\u002Fsafari-mcp) Node.js MCP\nserver in a Python Click CLI.\n\n**Feature parity is guaranteed.** Every Click command is generated\nautomatically from `safari-mcp`'s tool schema (bundled as\n`resources\u002Ftools.json`). All 84 tools are reachable with the exact\nargument names and types the MCP server expects.\n\n## When to use this CLI\n\nEach CLI invocation spawns a fresh subprocess, so there is per-call\noverhead. If your agent speaks MCP natively (Claude Code, Cursor, Cline,\netc.), using `safari-mcp` directly over MCP stdio will be faster.\n\n**Use this CLI when:**\n- Your agent framework does **not** speak MCP (Codex CLI, GitHub Copilot\n  CLI, custom scripts, older agent frameworks).\n- You need to **script browser automation from bash** —\n  `cli-anything-safari --json tool snapshot | jq '...'`.\n- You run in **CI\u002FCD** and want cron-able, subprocess-friendly output.\n- You're **debugging interactively** from Terminal.\n\n## Installation\n\n### Prerequisites\n\n1. **macOS** — Safari MCP is macOS-only.\n2. **Safari** — already installed on macOS.\n3. **Node.js 18+** — `brew install node` or from https:\u002F\u002Fnodejs.org\u002F\n4. **Python 3.10+**\n5. **Enable Apple Events for Safari**: Safari → Develop → Allow JavaScript from Apple Events\n\n### Install the CLI\n\n```bash\ncd safari\u002Fagent-harness\npip install -e .\n```\n\nThe first `tool` call will download the `safari-mcp` npm package (one-time, a few MB).\n\n## Command Structure\n\nThe CLI has 5 top-level commands:\n\n| Command   | Purpose                                                           |\n|-----------|-------------------------------------------------------------------|\n| `tool`    | Call any of safari-mcp's **84 tools** (dynamic, schema-driven)    |\n| `tools`   | Inspect the bundled tool registry (`list`, `describe`, `count`)   |\n| `raw`     | Escape hatch — call a tool by full name with raw JSON args        |\n| `session` | In-memory session state (last URL, current tab)                   |\n| `repl`    | Interactive REPL (default when no subcommand given)               |\n\n## Usage Examples\n\n### Discover the tool surface\n\n```bash\n# Count of tools (sanity check — must match safari-mcp's registered tools)\ncli-anything-safari tools count\n# → 84\n\n# List every tool\ncli-anything-safari tools list\ncli-anything-safari tools list --filter click   # filter by substring\n\n# Full schema for one tool (JSON or human format)\ncli-anything-safari tools describe safari_scroll\ncli-anything-safari --json tools describe safari_click\n```\n\n### Call a tool (schema-driven)\n\n```bash\n# Navigate\ncli-anything-safari tool navigate --url https:\u002F\u002Fexample.com\n\n# Take a snapshot (preferred over screenshot — structured text with ref IDs)\ncli-anything-safari --json tool snapshot\n\n# Click by ref (refs come from snapshot; they expire on the next snapshot!)\ncli-anything-safari tool click --ref 0_5\n\n# Click by selector or visible text\ncli-anything-safari tool click --selector \"#submit\"\ncli-anything-safari tool click --text \"Log in\"\n\n# Fill a field\ncli-anything-safari tool fill --selector \"#email\" --value \"user@example.com\"\n\n# Scroll by direction\u002Famount (NOT x\u002Fy — note the schema!)\ncli-anything-safari tool scroll --direction down --amount 500\n\n# Drag one element onto another\ncli-anything-safari tool drag \\\n    --source-selector \".card\" \\\n    --target-selector \".trash\"\n\n# Screenshot — returns base64 JPEG in stdout. Decode with:\ncli-anything-safari --json tool screenshot --full-page \\\n    | python3 -c \"import sys,json,base64; \\\n        d=json.load(sys.stdin); \\\n        open('\u002Ftmp\u002Fshot.jpg','wb').write(base64.b64decode(d['data']))\"\n\n# Save as PDF (this one writes to disk directly)\ncli-anything-safari tool save-pdf --path \u002Ftmp\u002Fpage.pdf\n\n# Evaluate JavaScript (note: parameter is --script, not --code)\ncli-anything-safari tool evaluate --script \"document.title\"\n```\n\n### Navigate and read in one round-trip\n\n```bash\ncli-anything-safari --json tool navigate-and-read --url https:\u002F\u002Fexample.com\n```\n\n### Form fill (bulk)\n\n`safari_fill_form` takes an **array** of `{selector, value}` objects.\nPass it as a JSON string:\n\n```bash\ncli-anything-safari tool fill-form --fields '[\n  {\"selector\": \"#email\",    \"value\": \"user@example.com\"},\n  {\"selector\": \"#password\", \"value\": \"hunter2\"}\n]'\n```\n\nRun `cli-anything-safari tools describe safari_fill_form` to see the\nexact schema, including any new fields safari-mcp adds upstream.\n\n### Network monitoring\n\n```bash\ncli-anything-safari tool start-network-capture\ncli-anything-safari tool navigate --url https:\u002F\u002Fexample.com\ncli-anything-safari --json tool network\ncli-anything-safari tool performance-metrics\n```\n\n### Storage\n\n```bash\ncli-anything-safari tool get-cookies\ncli-anything-safari tool set-cookie --name session --value abc123 --domain example.com\ncli-anything-safari tool local-storage --key theme\n# export-storage returns JSON to stdout — no --path arg. Pipe to a file:\ncli-anything-safari --json tool export-storage > \u002Ftmp\u002Fstorage.json\n```\n\n### Raw JSON escape hatch\n\nWhen you need to pass a complex nested object or want to drive the CLI from\na pre-built JSON blob:\n\n```bash\ncli-anything-safari raw safari_evaluate \\\n    --json-args '{\"code\":\"[...document.querySelectorAll(\\\"a\\\")].map(a => a.href)\"}'\n```\n\n### Interactive REPL\n\n```bash\ncli-anything-safari\n```\n\nThe REPL banner prints the absolute path to this SKILL.md so agents can\nself-discover capabilities.\n\n## JSON Output\n\nAll commands support `--json` as a global flag:\n\n```bash\ncli-anything-safari --json tool snapshot\ncli-anything-safari --json tool list-tabs\ncli-anything-safari --json tools list\n```\n\n## State Management\n\nThe CLI maintains a small amount of in-memory state for REPL display only:\n\n- **`last_url`** — last URL the CLI navigated to (updated after every\n  successful `tool navigate`, `tool navigate-and-read`, or\n  `tool new-tab`)\n- **`current_tab_index`** — last known active tab index\n\nThere is **no persistent session**, no undo\u002Fredo, no document model.\nEvery CLI invocation starts with fresh state. Safari MCP itself is\nstateless per-call: each `tool` command spawns a fresh\n`npx safari-mcp` subprocess, performs the action, and exits. This is a\ndeliberate design choice; see `HARNESS.md` and `TEST.md` for the\nreasoning behind the deviation from the standard undo\u002Fredo pattern.\n\n## Output Formats\n\nAll commands support dual output modes:\n\n- **Human-readable** (default): indented key-value text for `dict`\n  results, bullet lists for arrays, plain text otherwise\n- **Machine-readable** (`--json` flag): structured JSON for agent\n  consumption\n\n```bash\n# Human output\ncli-anything-safari tool snapshot\n\n# JSON output for agents\ncli-anything-safari --json tool snapshot\ncli-anything-safari --json tools list\ncli-anything-safari --json tools describe safari_click\n```\n\n## For AI Agents\n\nWhen using this CLI programmatically:\n\n1. **Always use `--json` flag** for parseable output.\n2. **Check return codes** — 0 for success, non-zero for errors (URL\n   validation failures, MCP call failures, invalid JSON args).\n3. **Parse stderr** for error messages; use stdout for data.\n4. **File-handling tools have inconsistent path arg names** — always\n   check `tools describe \u003Cname>` first:\n   - `tool save-pdf --path \u002Ftmp\u002Fx.pdf`\n   - `tool upload-file --selector ... --file-path \u002Ftmp\u002Fx.txt` (note: `--file-path`, not `--path`)\n   - `tool export-storage` — no path arg; pipe JSON output to a file\n   - `tool import-storage --path \u002Ftmp\u002Fx.json`\n   - `tool screenshot` \u002F `screenshot-element` — return base64 in\n     the JSON response, no path arg (decode it yourself)\n5. **Snapshot before click** — refs from `tool snapshot` expire on the\n   next snapshot. Always snapshot → find ref → click in close\n   succession.\n6. **Discover tools via `tools list`** — the bundled registry is the\n   source of truth for what's available. Do not hard-code tool names\n   that may change upstream.\n7. **Use `tools describe \u003Cname>`** to learn the exact schema (required\n   args, enum choices, JSON-typed args) before constructing a call.\n   **Never assume parameter names from the description** — for example,\n   `safari_evaluate` takes `--script` (not `--code`) even though the\n   description says \"JavaScript code to execute\".\n\n## Agent-Specific Guidance\n\n### Finding the right tool\n\nUse the introspection commands. The CLI is **guaranteed** to reflect the\nMCP server 1:1:\n\n```bash\n# Find all click-related tools\ncli-anything-safari tools list --filter click\n\n# Get the full schema (including every argument with type, description,\n# required\u002Foptional, enum choices, defaults)\ncli-anything-safari --json tools describe safari_click\n```\n\n### Tool selection strategy\n\n1. **`tool snapshot`** over `tool screenshot` — structured text with ref IDs\n   is orders of magnitude cheaper and carries the refs needed for clicks.\n2. **`tool click --ref`** over `tool click --selector` — refs are stable\n   within a single snapshot, selectors may be brittle.\n3. **`tool navigate-and-read`** over `navigate` + `read-page` — saves one\n   round-trip.\n4. **`tool click-and-read`** over `click` + `read-page` — saves one round-trip.\n5. **`tool native-click`** only when regular click fails with 405\u002F403 (WAF\n   blocks, G2, Cloudflare) — it physically moves the cursor.\n\n### Refs Expire\n\nRefs from `tool snapshot` expire when you take a new snapshot:\n- First snapshot: refs `0_1`, `0_2`, `0_3`...\n- Second snapshot: refs `1_1`, `1_2`, `1_3`...\n\nAlways snapshot → click in close succession. If in doubt, snapshot again.\n\n### Tab Ownership Safety\n\nSafari MCP tracks tab ownership per session. Tools that modify a tab\n(navigate, click, fill) are **blocked** on tabs the session did not open.\nTo operate on a specific page, always start with `tool new-tab --url ...`.\n\n### Error Handling\n\nCommon errors:\n- `npx not found` → install Node.js 18+\n- `safari-mcp package not found on npm registry` → check network\n- `Not macOS` → harness is macOS-only\n- `AppleScript denied` → enable \"Allow JavaScript from Apple Events\" in Safari → Develop\n- `Blocked URL scheme: file` → URL validation rejected the input (by design)\n\n### URL Validation\n\nThe CLI validates URLs before passing them to `safari_navigate`,\n`safari_navigate_and_read`, and `safari_new_tab`. Blocked schemes:\n`file`, `javascript`, `data`, `vbscript`, `about`, `chrome`, `safari`,\n`webkit`, `x-apple`, and other browser-internal schemes. The `raw`\ncommand **also** enforces this for navigation tools.\n\n### Multi-Session Warning\n\nSafari MCP enforces a single active session by killing stale Node.js\nprocesses older than 10 seconds. If you run two CLI instances at once,\none will kill the other's backend. **There is currently no daemon\nmode** — for latency-sensitive workflows, drive the CLI from a\nlong-lived Python script that imports\n``cli_anything.safari.utils.safari_backend.call()`` directly to avoid\nre-spawning the subprocess on every invocation.\n\n## Links\n\n- [Safari MCP GitHub](https:\u002F\u002Fgithub.com\u002Fachiya-automation\u002Fsafari-mcp)\n- [Safari MCP on npm](https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002Fsafari-mcp)\n- [CLI-Anything](https:\u002F\u002Fgithub.com\u002FHKUDS\u002FCLI-Anything)\n- [MCP Backend Pattern Guide](https:\u002F\u002Fgithub.com\u002FHKUDS\u002FCLI-Anything\u002Fblob\u002Fmain\u002Fcli-anything-plugin\u002Fguides\u002Fmcp-backend.md)\n\n## Security Considerations\n\n### URL Validation\n\nAll navigation tools (`tool navigate`, `tool navigate-and-read`, `tool\nnew-tab`, and `raw safari_navigate*`) pass the `url` argument through\n`utils\u002Fsecurity.py` which blocks dangerous schemes and optionally blocks\nprivate networks (set `CLI_ANYTHING_SAFARI_BLOCK_PRIVATE=1`).\n\n### Tab Isolation\n\nSafari MCP enforces per-session tab ownership upstream — tools cannot\noperate on tabs the session did not open.\n\n### Profile Isolation\n\nSet `SAFARI_PROFILE` env var to use a separate Safari profile for\nautomation:\n\n```bash\nexport SAFARI_PROFILE=\"Automation\"\ncli-anything-safari tool navigate --url https:\u002F\u002Fexample.com\n```\n\nThis keeps cookies\u002Flogins\u002Fhistory separate from the user's main browsing.\n\n### JavaScript Execution\n\n`tool evaluate` and `tool run-script` run arbitrary JavaScript in the page\ncontext. Treat untrusted input with the same care as any dynamic code\nexecution path.\n\n### Clipboard\n\n`tool clipboard-read` and `tool clipboard-write` touch the system\nclipboard. Be careful when running inside a user's active session —\noverwriting the clipboard mid-task is disruptive.\n\n## Regenerating the tool registry\n\nIf you upgrade `safari-mcp`, regenerate the bundled schema:\n\n```bash\npython scripts\u002Fextract_tools.py \\\n    \"$(npm root -g)\u002Fsafari-mcp\u002Findex.js\" \\\n    cli_anything\u002Fsafari\u002Fresources\u002Ftools.json\n```\n\nThe parity test (`test_parity.py`) pins the expected tool count; update\nit when the upstream tool list changes.\n\n## More Information\n\n- **Full documentation:** `cli_anything\u002Fsafari\u002FREADME.md` in the package\n- **Test coverage:** `cli_anything\u002Fsafari\u002Ftests\u002FTEST.md` in the package\n- **Architecture analysis:** `safari\u002Fagent-harness\u002FSAFARI.md`\n- **Methodology:** `cli-anything-plugin\u002FHARNESS.md`\n- **MCP backend pattern:** `cli-anything-plugin\u002Fguides\u002Fmcp-backend.md`\n\n## Version\n\n1.0.0 — targets safari-mcp 2.7.8 (84 tools). Bundled tool registry is\nregenerated via `scripts\u002Fextract_tools.py` when safari-mcp upgrades.\n","# cli-anything-safari\n\nA command-line interface for Safari browser automation on macOS. Wraps the\n[`safari-mcp`](https:\u002F\u002Fgithub.com\u002Fachiya-automation\u002Fsafari-mcp) Node.js MCP\nserver in a Python Click CLI.\n\n**Feature parity is guaranteed.** Every Click command is generated\nautomatically from `safari-mcp`'s tool schema (bundled as\n`resources\u002Ftools.json`). All 84 tools are reachable with the exact\nargument names and types the MCP server expects.\n\n## When to use this CLI\n\nEach CLI invocation spawns a fresh subprocess, so there is per-call\noverhead. If your agent speaks MCP natively (Claude Code, Cursor, Cline,\netc.), using `safari-mcp` directly over MCP stdio will be faster.\n\n**Use this CLI when:**\n- Your agent framework does **not** speak MCP (Codex CLI, GitHub Copilot\n  CLI, custom scripts, older agent frameworks).\n- You need to **script browser automation from bash** —\n  `cli-anything-safari --json tool snapshot | jq '...'`.\n- You run in **CI\u002FCD** and want cron-able, subprocess-friendly output.\n- You're **debugging interactively** from Terminal.\n\n## Installation\n\n### Prerequisites\n\n1. **macOS** — Safari MCP is macOS-only.\n2. **Safari** — already installed on macOS.\n3. **Node.js 18+** — `brew install node` or from https:\u002F\u002Fnodejs.org\u002F\n4. **Python 3.10+**\n5. **Enable Apple Events for Safari**: Safari → Develop → Allow JavaScript from Apple Events\n\n### Install the CLI\n\n```bash\ncd safari\u002Fagent-harness\npip install -e .\n```\n\nThe first `tool` call will download the `safari-mcp` npm package (one-time, a few MB).\n\n## Command Structure\n\nThe CLI has 5 top-level commands:\n\n| Command   | Purpose                                                           |\n|-----------|-------------------------------------------------------------------|\n| `tool`    | Call any of safari-mcp's **84 tools** (dynamic, schema-driven)    |\n| `tools`   | Inspect the bundled tool registry (`list`, `describe`, `count`)   |\n| `raw`     | Escape hatch — call a tool by full name with raw JSON args        |\n| `session` | In-memory session state (last URL, current tab)                   |\n| `repl`    | Interactive REPL (default when no subcommand given)               |\n\n## Usage Examples\n\n### Discover the tool surface\n\n```bash\n# Count of tools (sanity check — must match safari-mcp's registered tools)\ncli-anything-safari tools count\n# → 84\n\n# List every tool\ncli-anything-safari tools list\ncli-anything-safari tools list --filter click   # filter by substring\n\n# Full schema for one tool (JSON or human format)\ncli-anything-safari tools describe safari_scroll\ncli-anything-safari --json tools describe safari_click\n```\n\n### Call a tool (schema-driven)\n\n```bash\n# Navigate\ncli-anything-safari tool navigate --url https:\u002F\u002Fexample.com\n\n# Take a snapshot (preferred over screenshot — structured text with ref IDs)\ncli-anything-safari --json tool snapshot\n\n# Click by ref (refs come from snapshot; they expire on the next snapshot!)\ncli-anything-safari tool click --ref 0_5\n\n# Click by selector or visible text\ncli-anything-safari tool click --selector \"#submit\"\ncli-anything-safari tool click --text \"Log in\"\n\n# Fill a field\ncli-anything-safari tool fill --selector \"#email\" --value \"user@example.com\"\n\n# Scroll by direction\u002Famount (NOT x\u002Fy — note the schema!)\ncli-anything-safari tool scroll --direction down --amount 500\n\n# Drag one element onto another\ncli-anything-safari tool drag \\\n    --source-selector \".card\" \\\n    --target-selector \".trash\"\n\n# Screenshot — returns base64 JPEG in stdout. Decode with:\ncli-anything-safari --json tool screenshot --full-page \\\n    | python3 -c \"import sys,json,base64; \\\n        d=json.load(sys.stdin); \\\n        open('\u002Ftmp\u002Fshot.jpg','wb').write(base64.b64decode(d['data']))\"\n\n# Save as PDF (this one writes to disk directly)\ncli-anything-safari tool save-pdf --path \u002Ftmp\u002Fpage.pdf\n\n# Evaluate JavaScript (note: parameter is --script, not --code)\ncli-anything-safari tool evaluate --script \"document.title\"\n```\n\n### Navigate and read in one round-trip\n\n```bash\ncli-anything-safari --json tool navigate-and-read --url https:\u002F\u002Fexample.com\n```\n\n### Form fill (bulk)\n\n`safari_fill_form` takes an **array** of `{selector, value}` objects.\nPass it as a JSON string:\n\n```bash\ncli-anything-safari tool fill-form --fields '[\n  {\"selector\": \"#email\",    \"value\": \"user@example.com\"},\n  {\"selector\": \"#password\", \"value\": \"hunter2\"}\n]'\n```\n\nRun `cli-anything-safari tools describe safari_fill_form` to see the\nexact schema, including any new fields safari-mcp adds upstream.\n\n### Network monitoring\n\n```bash\ncli-anything-safari tool start-network-capture\ncli-anything-safari tool navigate --url https:\u002F\u002Fexample.com\ncli-anything-safari --json tool network\ncli-anything-safari tool performance-metrics\n```\n\n### Storage\n\n```bash\ncli-anything-safari tool get-cookies\ncli-anything-safari tool set-cookie --name session --value abc123 --domain example.com\ncli-anything-safari tool local-storage --key theme\n# export-storage returns JSON to stdout — no --path arg. Pipe to a file:\ncli-anything-safari --json tool export-storage > \u002Ftmp\u002Fstorage.json\n```\n\n### Raw JSON escape hatch\n\nWhen you need to pass a complex nested object or want to drive the CLI from\na pre-built JSON blob:\n\n```bash\ncli-anything-safari raw safari_evaluate \\\n    --json-args '{\"code\":\"[...document.querySelectorAll(\\\"a\\\")].map(a => a.href)\"}'\n```\n\n### Interactive REPL\n\n```bash\ncli-anything-safari\n```\n\nThe REPL banner prints the absolute path to this SKILL.md so agents can\nself-discover capabilities.\n\n## JSON Output\n\nAll commands support `--json` as a global flag:\n\n```bash\ncli-anything-safari --json tool snapshot\ncli-anything-safari --json tool list-tabs\ncli-anything-safari --json tools list\n```\n\n## State Management\n\nThe CLI maintains a small amount of in-memory state for REPL display only:\n\n- **`last_url`** — last URL the CLI navigated to (updated after every\n  successful `tool navigate`, `tool navigate-and-read`, or\n  `tool new-tab`)\n- **`current_tab_index`** — last known active tab index\n\nThere is **no persistent session**, no undo\u002Fredo, no document model.\nEvery CLI invocation starts with fresh state. Safari MCP itself is\nstateless per-call: each `tool` command spawns a fresh\n`npx safari-mcp` subprocess, performs the action, and exits. This is a\ndeliberate design choice; see `HARNESS.md` and `TEST.md` for the\nreasoning behind the deviation from the standard undo\u002Fredo pattern.\n\n## Output Formats\n\nAll commands support dual output modes:\n\n- **Human-readable** (default): indented key-value text for `dict`\n  results, bullet lists for arrays, plain text otherwise\n- **Machine-readable** (`--json` flag): structured JSON for agent\n  consumption\n\n```bash\n# Human output\ncli-anything-safari tool snapshot\n\n# JSON output for agents\ncli-anything-safari --json tool snapshot\ncli-anything-safari --json tools list\ncli-anything-safari --json tools describe safari_click\n```\n\n## For AI Agents\n\nWhen using this CLI programmatically:\n\n1. **Always use `--json` flag** for parseable output.\n2. **Check return codes** — 0 for success, non-zero for errors (URL\n   validation failures, MCP call failures, invalid JSON args).\n3. **Parse stderr** for error messages; use stdout for data.\n4. **File-handling tools have inconsistent path arg names** — always\n   check `tools describe \u003Cname>` first:\n   - `tool save-pdf --path \u002Ftmp\u002Fx.pdf`\n   - `tool upload-file --selector ... --file-path \u002Ftmp\u002Fx.txt` (note: `--file-path`, not `--path`)\n   - `tool export-storage` — no path arg; pipe JSON output to a file\n   - `tool import-storage --path \u002Ftmp\u002Fx.json`\n   - `tool screenshot` \u002F `screenshot-element` — return base64 in\n     the JSON response, no path arg (decode it yourself)\n5. **Snapshot before click** — refs from `tool snapshot` expire on the\n   next snapshot. Always snapshot → find ref → click in close\n   succession.\n6. **Discover tools via `tools list`** — the bundled registry is the\n   source of truth for what's available. Do not hard-code tool names\n   that may change upstream.\n7. **Use `tools describe \u003Cname>`** to learn the exact schema (required\n   args, enum choices, JSON-typed args) before constructing a call.\n   **Never assume parameter names from the description** — for example,\n   `safari_evaluate` takes `--script` (not `--code`) even though the\n   description says \"JavaScript code to execute\".\n\n## Agent-Specific Guidance\n\n### Finding the right tool\n\nUse the introspection commands. The CLI is **guaranteed** to reflect the\nMCP server 1:1:\n\n```bash\n# Find all click-related tools\ncli-anything-safari tools list --filter click\n\n# Get the full schema (including every argument with type, description,\n# required\u002Foptional, enum choices, defaults)\ncli-anything-safari --json tools describe safari_click\n```\n\n### Tool selection strategy\n\n1. **`tool snapshot`** over `tool screenshot` — structured text with ref IDs\n   is orders of magnitude cheaper and carries the refs needed for clicks.\n2. **`tool click --ref`** over `tool click --selector` — refs are stable\n   within a single snapshot, selectors may be brittle.\n3. **`tool navigate-and-read`** over `navigate` + `read-page` — saves one\n   round-trip.\n4. **`tool click-and-read`** over `click` + `read-page` — saves one round-trip.\n5. **`tool native-click`** only when regular click fails with 405\u002F403 (WAF\n   blocks, G2, Cloudflare) — it physically moves the cursor.\n\n### Refs Expire\n\nRefs from `tool snapshot` expire when you take a new snapshot:\n- First snapshot: refs `0_1`, `0_2`, `0_3`...\n- Second snapshot: refs `1_1`, `1_2`, `1_3`...\n\nAlways snapshot → click in close succession. If in doubt, snapshot again.\n\n### Tab Ownership Safety\n\nSafari MCP tracks tab ownership per session. Tools that modify a tab\n(navigate, click, fill) are **blocked** on tabs the session did not open.\nTo operate on a specific page, always start with `tool new-tab --url ...`.\n\n### Error Handling\n\nCommon errors:\n- `npx not found` → install Node.js 18+\n- `safari-mcp package not found on npm registry` → check network\n- `Not macOS` → harness is macOS-only\n- `AppleScript denied` → enable \"Allow JavaScript from Apple Events\" in Safari → Develop\n- `Blocked URL scheme: file` → URL validation rejected the input (by design)\n\n### URL Validation\n\nThe CLI validates URLs before passing them to `safari_navigate`,\n`safari_navigate_and_read`, and `safari_new_tab`. Blocked schemes:\n`file`, `javascript`, `data`, `vbscript`, `about`, `chrome`, `safari`,\n`webkit`, `x-apple`, and other browser-internal schemes. The `raw`\ncommand **also** enforces this for navigation tools.\n\n### Multi-Session Warning\n\nSafari MCP enforces a single active session by killing stale Node.js\nprocesses older than 10 seconds. If you run two CLI instances at once,\none will kill the other's backend. **There is currently no daemon\nmode** — for latency-sensitive workflows, drive the CLI from a\nlong-lived Python script that imports\n``cli_anything.safari.utils.safari_backend.call()`` directly to avoid\nre-spawning the subprocess on every invocation.\n\n## Links\n\n- [Safari MCP GitHub](https:\u002F\u002Fgithub.com\u002Fachiya-automation\u002Fsafari-mcp)\n- [Safari MCP on npm](https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002Fsafari-mcp)\n- [CLI-Anything](https:\u002F\u002Fgithub.com\u002FHKUDS\u002FCLI-Anything)\n- [MCP Backend Pattern Guide](https:\u002F\u002Fgithub.com\u002FHKUDS\u002FCLI-Anything\u002Fblob\u002Fmain\u002Fcli-anything-plugin\u002Fguides\u002Fmcp-backend.md)\n\n## Security Considerations\n\n### URL Validation\n\nAll navigation tools (`tool navigate`, `tool navigate-and-read`, `tool\nnew-tab`, and `raw safari_navigate*`) pass the `url` argument through\n`utils\u002Fsecurity.py` which blocks dangerous schemes and optionally blocks\nprivate networks (set `CLI_ANYTHING_SAFARI_BLOCK_PRIVATE=1`).\n\n### Tab Isolation\n\nSafari MCP enforces per-session tab ownership upstream — tools cannot\noperate on tabs the session did not open.\n\n### Profile Isolation\n\nSet `SAFARI_PROFILE` env var to use a separate Safari profile for\nautomation:\n\n```bash\nexport SAFARI_PROFILE=\"Automation\"\ncli-anything-safari tool navigate --url https:\u002F\u002Fexample.com\n```\n\nThis keeps cookies\u002Flogins\u002Fhistory separate from the user's main browsing.\n\n### JavaScript Execution\n\n`tool evaluate` and `tool run-script` run arbitrary JavaScript in the page\ncontext. Treat untrusted input with the same care as any dynamic code\nexecution path.\n\n### Clipboard\n\n`tool clipboard-read` and `tool clipboard-write` touch the system\nclipboard. Be careful when running inside a user's active session —\noverwriting the clipboard mid-task is disruptive.\n\n## Regenerating the tool registry\n\nIf you upgrade `safari-mcp`, regenerate the bundled schema:\n\n```bash\npython scripts\u002Fextract_tools.py \\\n    \"$(npm root -g)\u002Fsafari-mcp\u002Findex.js\" \\\n    cli_anything\u002Fsafari\u002Fresources\u002Ftools.json\n```\n\nThe parity test (`test_parity.py`) pins the expected tool count; update\nit when the upstream tool list changes.\n\n## More Information\n\n- **Full documentation:** `cli_anything\u002Fsafari\u002FREADME.md` in the package\n- **Test coverage:** `cli_anything\u002Fsafari\u002Ftests\u002FTEST.md` in the package\n- **Architecture analysis:** `safari\u002Fagent-harness\u002FSAFARI.md`\n- **Methodology:** `cli-anything-plugin\u002FHARNESS.md`\n- **MCP backend pattern:** `cli-anything-plugin\u002Fguides\u002Fmcp-backend.md`\n\n## Version\n\n1.0.0 — targets safari-mcp 2.7.8 (84 tools). Bundled tool registry is\nregenerated via `scripts\u002Fextract_tools.py` when safari-mcp upgrades.\n",{"name":5,"description":7},"main","d69096e239f2a89aabc2cd078c47664a9d3b1e11","03-逆向工程\u002Fcli-anything-safari",3,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts","https:\u002F\u002Fgithub.com\u002Flza6","个人vx：Tf00798\r\n个人✈：@TFGY999","2026-10-08 14:29:22",{"source":8,"skillName":5,"commands":33,"prompt":43,"zipAvailable":44},[34,37,40],{"tool":35,"command":36},"npx","npx skills add lza6\u002FArmor-piercing-system-prompts --skill cli-anything-safari",{"tool":38,"command":39},"bunx","bunx skills add lza6\u002FArmor-piercing-system-prompts --skill cli-anything-safari",{"tool":41,"command":42},"pnpm","pnpm dlx skills add lza6\u002FArmor-piercing-system-prompts --skill cli-anything-safari","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F03-逆向工程\u002Fcli-anything-safari\u002FSKILL.md",true,[],[47,55,60,67,74,81],{"skillNo":48,"name":49,"nameZh":6,"description":50,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":51,"categories":52,"keywords":53,"publishedAt":54},"01M7FFG485KY83TD6HSC4YPCMC","obsidian-clipper-template-creator","Guide for creating templates for the Obsidian Web Clipper. Use when you want to create a new clipping template, understand available variables, or format clipped content.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator\u002FSKILL.md",[],[],"2026-11-16 10:05:34",{"skillNo":56,"name":49,"nameZh":6,"description":50,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":54},"01M7FFG0T6AZ0STEJPSB3CX84K","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator-antigravity-awesome-skills-main\u002FSKILL.md",[],[],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":54},"01M7FFFY0QEM14SKWPDYGMXM2P","python-api","Programmatic Object-Detection-Metrics API guidance for BoundingBox, BoundingBoxes, Evaluator, enums, coordinate conversion, AP\u002FmAP semantics, and source-style import diagnostics.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Fpython-api\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":54},"01M7FFFVZQZ2GJ0C0TGP7JHD20","file-evaluation","Folder-based PASCAL VOC AP\u002FmAP evaluation from ground-truth and detection text files.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Ffile-evaluation\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":54},"01M7FFFSFNYSE77SJ6PE1CK2DA","object-detection-metrics","Guides legacy Object-Detection-Metrics PASCAL VOC AP\u002FmAP evaluation from detection text folders and direct Python API classes.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":54},"01M7FFFP0GCK1RVXBCPQ8APBMT","nx-workspace-patterns","Configure and optimize Nx monorepo workspaces. Use when setting up Nx, configuring project boundaries, optimizing build caching, or implementing affected commands.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fnx-workspace-patterns\u002FSKILL.md",[],[]]