Finder Quick Action · Finder Actions
Create macOS Finder file quick actions or directory background menu extensions.
Triggers
Activate when
- “Create a macOS Finder file quick action or directory background menu extension.”
- “Create a Finder context menu action.”
Do not activate when
- The request is merely to query this Skill's documentation or asks for a task unrelated to the results above; do not perform any actual business operations.
- The user only wants a preview or review; do not enter the modification, commit, or publishing branch.
Execution boundary
A natural-language request is sufficient to trigger this; no legacy slash path, argument interpolation, or designated assistant is required. Explicitly parse the project, target files, options, and output location from the current request; use the file, search, CLI, and browser capabilities actually provided by the current host.
Project dependency versions and external APIs must be verified at execution time; do not assume that examples represent current configurations. Packaged scripts are resolved from the Skill root, while business files are resolved from the target project root. Read the current state first and protect existing uncommitted changes and the staging area used by other tasks.
Analysis and preview requests remain read-only; modifications, commits, pushes, deployments, and releases proceed only within the explicit scope of the current request.
Do not bypass protections, automatically send messages, forcibly terminate user processes, or take over the foreground. On failure, preserve the original diagnostic error.
Workflow
-
Choose an Automator Quick Action or a Finder Sync Extension based on whether selected files are required; parse the action name, file type, actual processing logic, and target directory.
-
A Quick Action uses a script that receives arguments (
,
) and a workflow plist. Resolve tool paths from the actual installation and handle Chinese characters, spaces, multiple selections, and same-name outputs. Generate the files from the
document.wflow template and
Info.plist template as described under “Quick Action Installation” below, and verify the current system fields.
-
A Finder Extension uses the actual Xcode toolchain, a standalone bundle ID, necessary sandbox permissions, and precisely monitored directories. The menu action must have an explicit target. Verify capabilities against the current Apple documentation and do not require temporary access exceptions for the entire disk.
-
When a cross-process helper is needed, use verifiable structured messages and a fixed set of operations. Do not read arbitrary shell commands from the clipboard or use a helper to bypass system permissions.
-
After generating the build configuration and code, inspect the plist, compile the project, and verify extension registration. Report local ad-hoc signing and distributable signing separately; do not describe the former as a formal release.
-
Do not force
, open Automator, or bring an application to the foreground. Accurately explain the steps required for the user to enable the extension. Mark an actual menu trigger as verified only after observing it.
-
Preserve existing workflows and applications, and clearly identify the installation location and rollback path. Do not overwrite a menu action with the same name.
Quick Action Installation
The
template contains only a Run Shell Script action:
,
, input
com.apple.Automator.fileSystemObject
,
workflowTypeIdentifier=com.apple.Automator.servicesMenu
,
, output
com.apple.Automator.nothing
, with Finder as the service application. The
template retains
(
NSApplicationIdentifier=com.apple.finder
), which is Apple's requirement for a service to appear automatically. However, this alone is insufficient: testing on macOS 26.6 shows that a newly installed service, even with this key, appears under Finder's context menu “Quick Actions” only after the user selects it under the context menu “Quick Actions → Customize…”, and the
preferences record
in
. This preference belongs to System Settings. The Agent must not write it on the user's behalf; instead, guide the user through the single step described under “Enabling” below. Both the
script placeholder and the
menu-name placeholder must be written with
, which automatically handles XML escaping; never concatenate XML manually.
refers to the root of this Skill.
bash
NAME="动作名称" # 菜单显示名,同时是 workflow 包名
DEST="$HOME/Library/Services/$NAME.workflow"
[ -e "$DEST" ] && { echo "同名 workflow 已存在:$DEST" >&2; exit 1; }
bash -n action.sh # 已写好的处理脚本
STAGE="$(mktemp -d)/$NAME.workflow"; mkdir -p "$STAGE/Contents"
cp "$SKILL_DIR/references/automator-template.xml" "$STAGE/Contents/document.wflow"
cp "$SKILL_DIR/references/automator-info-template.xml" "$STAGE/Contents/Info.plist"
plutil -replace actions.0.action.ActionParameters.COMMAND_STRING -string "$(cat action.sh)" "$STAGE/Contents/document.wflow"
plutil -replace NSServices.0.NSMenuItem.default -string "$NAME" "$STAGE/Contents/Info.plist"
plutil -replace NSServices.0.NSSendFileTypes -json '["com.adobe.pdf"]' "$STAGE/Contents/Info.plist" # 按目标 UTI;文件与文件夹通用保留 public.item
plutil -lint "$STAGE/Contents/document.wflow" "$STAGE/Contents/Info.plist"
plutil -extract NSServices.0.NSRequiredContext json -o - "$STAGE/Contents/Info.plist" # 应为 com.apple.finder
diff <(plutil -extract actions.0.action.ActionParameters.COMMAND_STRING raw -o - "$STAGE/Contents/document.wflow") action.sh
mv -n "$STAGE" "$DEST"
/System/Library/CoreServices/pbs -update
- If a workflow with the same name already exists, stop and either change the name or ask the user; do not overwrite or merge it. If lint or diff fails, discard only the staging directory.
- Do not execute or automatically open Automator.
- Rollback path: move to the Trash with , then run again.
- Report the installation path and rollback command. Mark the actual context-menu trigger as verified only after observing it.
Enabling
Immediately after installation, perform a read-only check to determine whether the action appears in the context menu.
reads through cfprefsd, while PlistBuddy is unaffected by Chinese-character escaping:
bash
P="$(mktemp)"; defaults export pbs "$P"
/usr/libexec/PlistBuddy -c "Print ':NSServicesStatus:(null) - $NAME - runWorkflowAsService:presentation_modes:ContextMenu'" "$P" 2>/dev/null || echo "未启用"
rm -f "$P"
- If the output is , the action is enabled; report it directly.
- If it is not enabled, provide only one step in the same reply as the installation result: select the action. When installing multiple actions, list all names and have the user select them together. Include the command that opens the settings page directly. This is the same page opened through Finder's “Quick Actions → Customize…”. You may execute it on the user's behalf after they consent, but do not modify the preferences yourself:
bash
open "x-apple.systempreferences:com.apple.ExtensionsPreferences?extensionPointIdentifier=com.apple.finder-quick-actions"
- After the user confirms that the action has been selected, rerun the check. Report the action as enabled only when the output is .
Composition
Before execution, read capability composition and hand off adjacent capabilities according to explicit artifacts.
Runtime context (shared)
Before execution, read this package's
and
Profile contract. The priority order is the current request, project context, this Skill's records, shared preferences, brand/user Profile, and security defaults.
Read only declared fields. Hosts without a dedicated runtime may use
to read the shared Profile. If configuration is missing, ask only one question that affects the result. Values the user explicitly requests to store long-term are written atomically through this script, and their actual paths must be reported. Do not store inferred information, credentials, or data from other tasks.
General Feedback Loop
When a user provides revision feedback during a Skill-driven task, the following steps must be performed before continuing the current artifact:
- First determine whether the feedback is (for this task only) or (applicable across tasks).
- For feedback, modify only the current task and do not modify the Skill.
- For feedback, first determine its scope. Update the corresponding canonical Skill for domain-specific rules; for rules applicable to all Skills, update the shared specification first.
- Complete the rule update, versioning, linting, and distribution verification before applying the modification to the current task.
- A modification invalidates earlier confirmations such as “confirmed,” “continue,” or “ship it.” After completing the current artifact modifications and read-back, stop and wait for the user's next instruction. Do not automatically proceed to publishing, committing, or other external writes.