Deck
DocumentationSmart rules and script plugins

Smart rules and script plugins

Process clipboard items automatically with smart rules, built-in text transforms and JavaScript script plugins.

A smart rule has conditions and actions. When something new reaches your clipboard, Deck checks the rules from top to bottom. For each rule whose conditions match, Deck runs its actions.

Create a rule

  1. Open Settings › Smart Rules.
  2. Select Add Rule (the plus button), or Add First Rule if the list is empty.
  3. Enter a Rule Name.
  4. Choose how conditions combine: Match All (every condition must match) or Match Any (one is enough).
  5. Select Add condition and Add action until the rule does what you want, then select Save.

Rules run in list order. Drag a rule to change its priority. Two preset rules, Detect API Key and Detect Password, are created the first time you use the feature. They are off until you turn them on.

Conditions

ConditionWhat it checks
Content containsThe item's text contains the value you enter.
Content matches regexThe item's text matches a regular expression.
Content TypeThe item is Text, Images, File, Links, Code or Colors.
Source AppThe name of the app the item was copied from.
Has Custom TitleThe item has a title you gave it. This condition has no value.
Content LengthThe number of characters is Greater than, Less than or Equals the number you enter.

Actions

ActionWhat it does
Add TagAdds a tag with the name you enter. Deck creates the tag if it does not exist.
Mark as SensitiveMarks the item as sensitive.
Auto DeleteDeletes the item after the number of minutes you choose. Items that already have a tag are skipped.
TransformRewrites the text with one of the built-in transforms below, before the item is saved.
Script PluginsRewrites the text with an installed script plugin.
AI AutomationRuns an AI prompt on the item. See below.
Don't SaveKeeps the item out of your history.

AI automation

An AI Automation action needs a prompt. It runs on its own each time the rule matches, and Deck does not ask for confirmation. When you add the action, the app warns you about this high-permission mode.

  • The AI can work only on the item that triggered the rule, not on other items.
  • It can search the web and read web pages.
  • It cannot create, change or delete script plugins or smart rules.

Write the prompt narrowly, and treat text fetched from the web as data, not as instructions.

Share rules

  • To export rules, use the export option on a rule. Deck saves a .deckrule file.
  • To import rules, select Import Rules and choose a .deckrule file. Deck shows how many rules the file holds and asks you to confirm.
  • A rule can also be shared as a deck://install-rule?payload=… link. Opening the link in Deck offers to install the rule.

Built-in text transforms

These 18 transforms are available as a rule action and in the item menu. To use one by hand, right-click a text item and choose Convert and Paste. Deck pastes the transformed text.

TransformWhat it does
JSON FormatPretty-prints JSON with sorted keys.
JSON MinifyRemoves whitespace from JSON.
URL EncodePercent-encodes text.
URL DecodeDecodes percent-encoded text.
Base64 EncodeEncodes UTF-8 text as Base64.
Base64 DecodeDecodes Base64 into text.
Camel to Snake CaseuserName becomes user_name.
Snake to Camel Caseuser_name becomes userName.
Timestamp to DateTurns a Unix timestamp in seconds or milliseconds into yyyy-MM-dd HH:mm:ss in your time zone.
UppercaseConverts to uppercase.
LowercaseConverts to lowercase.
Trim WhitespaceRemoves whitespace at both ends.
Escape HTMLReplaces HTML special characters with entities.
Unescape HTMLTurns HTML entities back into characters.
MD5 HashReturns the MD5 hash in lowercase hexadecimal.
Sort LinesSorts the lines.
Remove Duplicate LinesRemoves repeated lines.
Reverse TextReverses the text.

If a transform cannot apply, for example JSON Format on text that is not JSON, the item is left unchanged.

Script plugins

A script plugin is a small JavaScript program that turns the text of an item into new text. Deck installs a few examples the first time it runs, such as word count and remove empty lines.

Plugin folder

Each plugin is a folder in ~/.deck/scripts/. The folder name is the plugin ID.

~/.deck/scripts/my-plugin/
  manifest.json
  index.js

Deck watches the folder, so new and edited plugins load without a restart.

manifest.json

{
  "name": "Sample Plugin",
  "description": "Processes input text",
  "author": "Your Name",
  "version": "1.0.0",
  "main": "index.js",
  "icon": "wand.and.stars",
  "permissions": {
    "network": false
  }
}
FieldMeaning
name, description, author, versionShown in the plugin list.
mainThe script file, inside the plugin folder.
iconThe name of an SF Symbol.
permissions.networktrue if the plugin needs to make web requests. The default is false.

index.js

The script defines transform(input). It receives the item's text and returns the new text as a string.

function transform(input) {
  var text = String(input || "");
  var lines = text.split("\n")
    .map(function (line) { return line.trim(); })
    .filter(function (line) { return line.length > 0; });
  return lines.join("\n");
}

Available inside a plugin:

APIWhat it does
Deck.detectURLs(text)Returns the URLs found in the text, one per line.
Deck.detectEmails(text)Returns the email addresses found in the text, one per line.
Deck.shouldStop() and Deck.checkInterrupt()Return whether Deck wants the script to stop. Check them in long loops.
btoa(text) and atob(text)Base64 encode and decode.
console.log, console.warn, console.errorWrite log messages.
fetch(url, options)Makes a web request. Needs network permission.

fetch is synchronous. It returns an object with status, text() and, on failure, error.

function transform(input) {
  var response = fetch(String(input || "").trim(), {
    method: "GET",
    headers: { "accept": "application/json" }
  });
  if (!response || response.error) {
    return "Request failed: " + ((response && response.error) || "Unknown error");
  }
  return "status: " + response.status + "\n" + response.text();
}

Network permission

A plugin can use fetch only when both of these are true:

  1. Its manifest.json sets "network": true.
  2. You authorized network access for that plugin in Deck's script plugin settings.

Authorization applies to the script you reviewed. If the script changes, authorize it again. Only http and https addresses work, a response can be about 2 MB at most, and requests do not share cookies with any app.

A rule cannot run a network plugin you have not authorized.

Limits

  • Each run starts in a clean environment. Nothing is kept between runs.
  • A run is stopped after 5 seconds by default.
  • Input and output are limited to 100,000 characters each.
  • manifest.json can be about 64 KB and the script about 1 MB.
  • Plugins cannot read or write files or run system commands.

Use a plugin

  • Right-click a text item, choose Convert and Paste, and pick the plugin from the list under the built-in transforms.
  • Add a Script Plugins action to a smart rule.
  • Run it from the command line: deckclip ai transform "prompt" --plugin my-plugin. See The deckclip command line.
  • Let an AI tool use it. See AI assistant and MCP.

To install a plugin someone shared as a deck://install-plugin?… link, open the link in Deck.