AI SummaryOperate the user's real Safari browser on macOS via AppleScript () and . This provides full access to the user's actual browser session — including login state, cookies, and open tabs — without any extensions or additional software. Before first use, verify two settings are enabled. Run this check a
Install
Copy this and paste it into Claude Code, Cursor, or any AI assistant:
I want to install the "claude-for-safari" skill in my project. Please run this command in my terminal: # Install skill into your project mkdir -p .claude/skills/claude-for-safari && curl --retry 3 --retry-delay 2 --retry-all-errors -o .claude/skills/claude-for-safari/SKILL.md "https://raw.githubusercontent.com/SDLLL/claude-for-safari/main/SKILL.md" Then restart Claude Code (or reload the window in Cursor) so the skill is picked up.
Description
Control the user's real Safari browser on macOS using AppleScript and screencapture. This skill should be used when the user asks to interact with Safari, browse websites, read web pages, automate browser tasks, take screenshots of web content, or when any task would benefit from seeing or interacting with what's in their browser. Triggers on keywords like "safari", "browser", "web page", "open tab", "screenshot the page", "read this site", "browse", "click on", "fill in the form".
Prerequisites
Before first use, verify two settings are enabled. Run this check at the start of every session: `bash osascript -e 'tell application "Safari" to get name of front window' 2>&1 ` If this fails, instruct the user to enable: • System Settings > Privacy & Security > Automation — grant terminal app permission to control Safari • Safari > Settings > Advanced — enable "Show features for web developers", then Develop menu > Allow JavaScript from Apple Events
Claude for Safari
Operate the user's real Safari browser on macOS via AppleScript (osascript) and screencapture. This provides full access to the user's actual browser session — including login state, cookies, and open tabs — without any extensions or additional software.
1. List All Open Tabs
`bash osascript -e ' tell application "Safari" set output to "" repeat with w from 1 to (count of windows) repeat with t from 1 to (count of tabs of window w) set tabName to name of tab t of window w set tabURL to URL of tab t of window w set output to output & "W" & w & "T" & t & " | " & tabName & " | " & tabURL & linefeed end repeat end repeat return output end tell' `
2. Read Page Content
Read the full text content of the current tab: `bash osascript -e ' tell application "Safari" do JavaScript "document.body.innerText" in current tab of front window end tell' ` Read structured content (title, URL, meta description, headings): `bash osascript -e ' tell application "Safari" do JavaScript "JSON.stringify({ title: document.title, url: location.href, description: document.querySelector(\"meta[name=description]\")?.content || \"\", h1: [...document.querySelectorAll(\"h1\")].map(e => e.textContent).join(\" | \"), h2: [...document.querySelectorAll(\"h2\")].map(e => e.textContent).join(\" | \") })" in current tab of front window end tell' ` Read a simplified DOM (similar to Chrome ACP's browser_read): `bash osascript -e ' tell application "Safari" do JavaScript " (function() { const walk = (node, depth) => { let result = \"\"; for (const child of node.childNodes) { if (child.nodeType === 3) { const text = child.textContent.trim(); if (text) result += text + \"\\n\"; } else if (child.nodeType === 1) { const tag = child.tagName.toLowerCase(); if ([\"script\",\"style\",\"noscript\",\"svg\"].includes(tag)) continue; const style = getComputedStyle(child); if (style.display === \"none\" || style.visibility === \"hidden\") continue; if ([\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\"].includes(tag)) result += \"#\".repeat(parseInt(tag[1])) + \" \"; if (tag === \"a\") result += \"[\"; if (tag === \"img\") result += \"[Image: \" + (child.alt || \"\") + \"]\\n\"; else if (tag === \"input\") result += \"[Input \" + child.type + \": \" + (child.value || child.placeholder || \"\") + \"]\\n\"; else if (tag === \"button\") result += \"[Button: \" + child.textContent.trim() + \"]\\n\"; else result += walk(child, depth + 1); if (tag === \"a\") result += \"](\" + child.href + \")\\n\"; if ([\"p\",\"div\",\"li\",\"tr\",\"br\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\"].includes(tag)) result += \"\\n\"; } } return result; }; return walk(document.body, 0).substring(0, 50000); })() " in current tab of front window end tell' `
Discussion
Health Signals
My Fox Den
Community Rating
Sign in to rate this booster