Skip to content
Back to skills

Safari Extension Expert

ASecurity

Build, port, and debug Safari Web Extensions (Manifest V3) and native Swift app bridges for macOS and iOS. Scope host permissions, handle non-persistent backgrounds, and test native messaging.

  • 50,717 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added December 2, 2026
ai-agentsjavascriptgojavaswiftnoderailstestinggitapidocumentation

Works with

  • api

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned December 2, 2026

npx -y skills add sickn33/agentic-awesome-skills --skill safari-extension-expert --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Safari Extension Expert?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Safari Extension Expert
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/sickn33-safari-extension-expert/badge)](https://www.skillsdirectory.com/skills/sickn33-safari-extension-expert)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: safari-extension-expert
description: "Build, port, and debug Safari Web Extensions (Manifest V3) and native Swift app bridges for macOS and iOS. Scope host permissions, handle non-persistent backgrounds, and test native messaging."
category: development
risk: safe
source: self
source_type: self
date_added: "2026-11-30"
author: ShianMike
tags: [safari, webextension, manifest-v3, swift, macos, ios, browser-extension]
---

# Safari Extension Expert

## When to Use

- Port an existing Chrome/Firefox WebExtension to Safari on macOS or iOS, or create a new Safari Web Extension (Manifest V3).
- Wire native messaging between the extension JavaScript layer and the containing Swift/Objective-C macOS or iOS app (`SafariWebExtensionHandler`).
- Audit `manifest.json`, host permissions, background execution lifetime, and Xcode target entitlements for Safari compatibility.

## Prerequisites

Identify target platforms (macOS, iOS, iPadOS, visionOS), minimum Safari and OS versions, whether an existing WebExtension codebase is being converted via `xcrun safari-web-extension-converter`, and whether the extension requires native messaging or shared App Group storage. Inspect `manifest.json`, background/content scripts, and Xcode extension target `Info.plist` / entitlements before editing.

## Design Safari-compatible Manifest V3 and permissions

1. Target **Manifest V3**. `background` is optional (content-script-only or popup-only extensions do not need a background worker); when declared, it must be non-persistent (`"background": { "service_worker": "background.js", "type": "module" }`, or non-persistent `"scripts"` or `"page"`). Safari suspends idle background contexts aggressively, so persist state in `browser.storage.local` / `browser.storage.session` rather than module globals.
2. Prefer Promise-based `browser.*` APIs (or a small runtime abstraction) and check platform-specific manifest compatibility carefully: Safari supports `chrome_url_overrides.newtab` on macOS, but does not support `bookmarks` or `history` URL overrides (nor `newtab` on iOS), and Chrome-only APIs such as `offscreen` or `sidePanel` behave differently or are unavailable in Safari.
3. Scope `host_permissions` to the narrowest required origins or rely on `activeTab`. Safari prompts users explicitly per website (and per tab on iOS) and treats `<all_urls>` or `*://*/*` with high user friction and App Store review scrutiny.
4. Keep content-script DOM access isolated, declare `web_accessible_resources` narrowly, and validate every message crossing the content-script ↔ background boundary.

## Bridge cleanly to the native Swift host app

- Use `browser.runtime.sendNativeMessage(applicationId, payload)` for request/response native calls (with `"nativeMessaging"` in `permissions`) and handle rejected promises explicitly when the containing app is unavailable, sandboxed, or missing permissions.
- On the native side, inspect incoming messages in `SafariWebExtensionHandler.beginRequest(with:)`, validate expected keys/types before running native work, and share persistent files or `UserDefaults` between the host app and extension target using a matching **App Group** entitlement on both targets.
- Keep `NSExtensionPrincipalClass` and bundle identifiers aligned between the containing app (`com.example.app`) and the extension (`com.example.app.Extension`).

## Verify locally and on macOS/iOS targets

- Run cross-platform automated tests on manifest validation rules, permission guards, and message/native-bridge error handling in Node.js (with a mock `browser.runtime`) before building in Xcode.
- On macOS with Xcode installed, run `xcrun safari-web-extension-converter` (for ports), verify signing and App Group entitlements on both targets, enable Unsigned Extensions only during authorized local Safari Develop-menu testing, and verify per-site permission prompts, background suspension/wake-up, and `SafariWebExtensionHandler` round-trips on the target Safari version.

## Example

> Validate a Safari MV3 `manifest.json` against portability mistakes (`persistent: true`, unsupported `chrome_url_overrides` keys or iOS `newtab`, `<all_urls>`) while allowing valid manifests without a `background` key or with macOS `newtab`, and test a `sendNativeMessage` bridge wrapper across success and unavailable-host paths.

Run the [worked Safari WebExtension contract test](references/webextension-contract.md) with Node.js's built-in test runner (`node --test`).

## Limitations

- Automated Node.js tests verify manifest guardrails and JavaScript message/bridge contracts only; compiling Swift targets, running `xcrun safari-web-extension-converter`, code signing, App Group entitlement checks, and testing live Safari/iOS behavior require macOS and Xcode.
- Legacy Safari App Extensions (pre-WebExtension `SFSafariExtensionHandler` without MV3 WebExtension APIs) follow an older native-only architecture; Apple recommends Safari Web Extensions for new cross-browser work.

## Safety and Side Effects

Request the minimum `permissions` and `host_permissions` needed. Never embed API secrets or signing credentials in extension JS bundles or `manifest.json`. Obtain authorization before modifying Xcode signing identities, provisioning profiles, or App Store Connect submissions.

## Related Skills and Documentation

- For Chrome-specific Manifest V3 extensions (side panel, `declarativeNetRequest`, Chrome APIs), see [Chrome Extension Developer](https://github.com/sickn33/agentic-awesome-skills/blob/main/skills/chrome-extension-developer/SKILL.md).
- For iOS App Store preflight checks, see [iOS App Store Preflight](https://github.com/sickn33/agentic-awesome-skills/blob/main/skills/ios-appstore-preflight/SKILL.md).
- See Apple's official documentation on [Safari Web Extensions](https://developer.apple.com/documentation/safariservices/safari-web-extensions), [Converting a Web Extension for Safari](https://developer.apple.com/documentation/safariservices/converting-a-web-extension-for-safari), and [Messaging Between the App and JavaScript](https://developer.apple.com/documentation/safariservices/messaging-between-the-app-and-javascript-in-a-safari-web-extension).

Files in this skill

  • SKILL.md6 KB
  • references/webextension-contract.md5.6 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.