02 · Writing rules

Writing rules

A rule has two parts: a match condition that decides which text it reacts to, and an action that decides what happens. Turn the strings you see every day at work, ticket keys or order numbers, into rules and they open with a single selection.

Opening Settings

Click the Pluck icon in the menu bar and choose "Settings…". The Rules tab holds the rule list and the editor.

Adding a rule needs an active trial or a licence. Once the trial ends without a purchase, the + button is disabled. Editing existing rules, and turning them on and off, still works.

The rule list

Rules are listed on the left, in two sections: rules for text and rules for images.

Each row shows the rule's name with its match condition underneath. Rules with an empty match condition show "(always shown)"; Replace All and Paste Image, which have no match condition, show a short description. Disabled rules are labelled "Disabled".

Suggestions appear in the order of this list. A new rule goes to the end.

There are three buttons under the list.

The Rules tab of Settings, with the sidebar split into Rules for text and Rules for images
The Rules tab. The list is split into text and image sections, and each row shows its match condition.

Choosing an action

Select or add a rule and the editor appears on the right. Start with the Type menu in the Action section, which decides what the rule does. It has three sections, and choosing one shows only the fields that type needs.

Presets

Common URL actions you can pick as ready-made rules. There are three, and all of them are of type Open URL. They're for handing the selected text straight to an AI chat or a search.

To use one:

  1. Press + to add a rule, or select an existing rule you don't mind overwriting.
  2. Open the Type menu and pick one from the Presets section.
  3. The name, icon and URL to open are filled in. The match condition is cleared and "URL-encode inserted values" is turned on.
  4. Press Save.

What each preset fills in, and what it does:

PresetURL to openIconWhat it does
Send to Claudehttps://claude.ai/new?q=$0quote.bubble.fillOpens a new Claude chat with the selected text as the prompt.
Send to ChatGPThttps://chatgpt.com/?prompt=$0message.fillOpens a new ChatGPT chat with the selected text as the prompt.
Research with Perplexityhttps://www.perplexity.ai/search?q=$0magnifyingglassSearches Perplexity for the selected text.

Each one opens that service's website in your default browser. Services that require an account may show their sign-in page first.

Worth knowing once you've picked one:

Basic

Five types where you write the match condition and template yourself.

Built-in Features

Replace All and Paste Image. Their behaviour is fixed and they have no match condition or template. You can change only the name, icon, and whether they're enabled. One of each always exists and can't be deleted, and other rules can't be switched to these types.

Each action's settings are described in Actions and recipes.

The fields of a rule

Basics

Action Settings

As you type, an "Example:" line appears underneath, restating your template with the placeholders spelled out in words. Use it to check the URL or string is what you meant before saving.

Nothing changes until you press Save. If you move to another rule with unsaved changes, you're asked whether to save or discard them. Revert takes you back to the saved version.

The rule editor showing the Basics, Action and Action Settings sections and an example of the expanded template
"Open GitHub Issue/PR" open in the editor. The "Example:" line near the bottom shows what the template expands to.

Match conditions

A match condition is a regular expression in ICU syntax. Pluck looks through the selected or copied text for every place it matches and makes one suggestion per match.

To react toMatch condition
A Jira ticket key such as WT-1234[A-Z]{2,10}-\d+
A URLhttps?://[^\s]+
An email address[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}
GitHub's owner/repo#123([\w.-]+)/([\w.-]+)#(\d+)
An 8-digit order number\b\d{8}\b

Templates and captures

Inside a template, these placeholders insert what was matched.

PlaceholderInserts
$0The whole match. With an empty match condition, the whole selection.
$1, $2 …The groups in ( ) in your match condition, counted from the left starting at 1. A group that didn't take part inserts nothing.
${name}A named group, written (?<name>…) in the match condition.

With the match condition ([\w.-]+)/([\w.-]+)#(\d+) and the URL https://github.com/$1/$2/issues/$3, selecting anthropics/claude-code#42 sets $1 to anthropics, $2 to claude-code and $3 to 42, and opens https://github.com/anthropics/claude-code/issues/42.

Insertion rules

When it won't save

When Save is disabled, the reason is shown to the left of the button.

MessageFix
Enter a name.The name is empty.
The regular expression is invalid.The match condition doesn't parse. Check for an unclosed parenthesis or bracket.
Enter an action template.Open URL, Web Search and Run Command all require a template.
The template refers to a capture group that does not exist.The template uses $3 but the match condition has two groups, or a named group is misspelled.
Choose two different languages.Language 1 and Language 2 are the same on a Translate rule.
The URL must start with a scheme such as https:.The URL to open doesn't start with https:, mailto: or another scheme. A template of just $0 passes, since the selection is taken to be the URL itself.

Where rules live

Rules are stored in ~/Library/Application Support/Pluck/rules.json. Editing in Settings updates this file, so you don't normally need to open it. Copy it to back up your rules or move them to another Mac.

When an update adds a new type of action, its default rule is added the next time Pluck launches. Rules you already have aren't changed.

To remove every rule you've made and go back to the initial set, use "Reset to Defaults" under the list.