Skip to main content

shortcutkit

Build, validate, and sign Apple Shortcuts (.shortcut) files from Python.

License: MIT CI

A shortcut that asks your name and says hello:

from shortcutkit import Shortcut, actions, ref, text

s = Shortcut("Greeting")
name = s.action(actions.ASK, WFAskActionPrompt="What's your name?")
s.action(actions.SHOWRESULT, Text=text("Hello, ", ref(name), "!"))

s.write()  # Greeting.shortcut
Shortcut.sign("Greeting.shortcut", "Greeting-signed.shortcut")

Open Greeting-signed.shortcut and Shortcuts adds it to your library. Shortcuts only imports signed files, and signing needs a Mac with an iCloud login; everything else runs on any OS.

Why

The action catalog is extracted from the Shortcuts app's own frameworks, not written by hand, and one command refreshes it after a macOS update. Earlier libraries kept hand-written lists and are archived (python-shortcuts, shortcuts-js); Cherri is a separate language with its own compiler.

  • All 449 built-in actions as constants, so a typo is an AttributeError.
  • 1,265 actions from Apple's apps: Reminders, Notes, Messages, Settings, and 70 more. Only actions the Shortcuts editor offers: the Siri-only intents the app refuses to import are left out.
  • Third-party app actions, named by app and intent.
  • Checked conditions for 153 Find actions, the 14 built-in ones (Filter Files, Find Photos, Find Contacts, ...) and 139 in Apple's apps (Find Messages, Find Notes, ...), from the engine's own rules, and the properties of what they find.
  • If, Repeat, Repeat with Each, and Choose from Menu blocks.
  • A wrong key or value raises ValueError before anything is written.
  • Pure Python, no dependencies.

A TypeScript package with the same name and data adds compile-time checks.

Install

pip install shortcutkit   # Python 3.9+

Usage

These examples build on the one at the top.

Share sheet

from shortcutkit import shortcut_input

s = Shortcut("Page Links", types=["ActionExtension"], input_classes=["WFSafariWebPageContentItem"])
links = s.action(actions.RUNJAVASCRIPTONWEBPAGE, WFInput=shortcut_input(), WFJavaScript="completion(document.links.length)")
s.action(actions.SHOWRESULT, Text=text("Links: ", ref(links)))

Control flow

gid = s.if_(ref(name), "has_any_value")
s.action(actions.SHOWRESULT, Text=text("Hello, ", ref(name)))
s.otherwise(gid)
s.action(actions.SHOWRESULT, Text=text("Hello, stranger"))
s.end_if(gid)

Apple's apps

r = s.action(actions.REMINDERS_CREATE_REMINDER, title=text("Buy milk"), priorityLevel="high")
s.action(actions.NOTES_CREATE_NOTE, name="Shopping", contents=text("Added ", ref(r)))

Finding things

A Find action for Apple's apps takes conditions checked against what it finds: its properties, their operators, and the units of a date range. property_() reads one property of the results.

from shortcutkit import where, property_

found = s.action(actions.MESSAGES_FIND_MESSAGE,
                 WFContentItemFilter=where(("author", "is", "+15555550100"), ("date", "is_in_the_last", 7, "days")))
s.action(actions.SHOWRESULT, Text=text(property_(found, "body")))

Dictionaries and types

A dictionary parameter takes a plain dict: strings, text() and references are text items, and numbers, booleans, lists and nested dicts keep their type, as the editor's item type menu sets it. coerce() reads a value as one content type, as the variable "Type" menu does, and property_() on the result takes that class's properties, the menu's "Get" list (CONTENT_ITEM_PROPERTIES): property_(coerce(file, "WFGenericFileContentItem"), "File Size"), checked at run time. An output the catalogue types, by class or by the object class it wraps (CONTENT_ITEM_TYPES), is checked the same way without a coercion: property_(asked_number, "Name"). Where a choice decides the output, the literal you pass narrows it: s.action(actions.ASK, WFInputType="Number") outputs a Number, so only Name is accepted.

from shortcutkit import coerce

d = s.action(actions.DICTIONARY, WFItems={"name": ref(name), "greeted": True, "tags": ["a", "b"]})
gid = s.if_(coerce(d, "WFStringContentItem"), "contains", "a")
s.end_if(gid)

Other apps

Name the app and the intent: the identifier is the bundle identifier followed by the intent name, as the catalogue identifies an app's own intents, and the descriptor is written as the catalogue's are. The parameters are not checked: their keys are the intent's parameter names, from Metadata.appintents/extract.actionsdata in the app bundle.

from shortcutkit import app_intent

app = {"BundleIdentifier": "com.example.app", "Name": "Example", "TeamIdentifier": "ABCDE12345"}
note = s.action(app_intent(app, "CreateNoteIntent", "Note"), title=text("Hello"), body=ref(name))
s.action(actions.SHOWRESULT, Text=ref(note))

Shared catalogue

CATALOG exposes the same generated snapshot as the TypeScript package. Each action records its inputs, outputs, parameters, choice-dependent output classes, and evidence for missing descriptions or unprobed references. The package also includes the readable data/catalog.txt alongside data/catalog.json.

from shortcutkit import CATALOG, CatalogAction

record: CatalogAction = CATALOG["actions"][actions.ASK]
reference_evidence = record["parameters"]["WFAskActionPrompt"]["refs"]

The catalogue has structural type annotations. Shortcut.action() continues to check action-specific arguments at runtime; the Python package does not yet provide static types for each action's keyword arguments.

API

Export What it does
Shortcut(name, color=, glyph=, types=, input_classes=) A shortcut.
s.action(id, **params) Appends an action and returns it.
s.if_(subject, condition, value=None), s.otherwise(gid), s.end_if(gid) An If block.
s.repeat_each(items), s.end_repeat_each(gid) A Repeat with Each block.
s.repeat_count(n), s.end_repeat_count(gid) A Repeat block.
s.choose_from_menu(prompt, items), s.menu_item(gid, title), s.end_menu(gid) A Choose from Menu block.
s.write(path=None) Writes the unsigned file and returns its path.
Shortcut.sign(src, dst, mode="anyone") Signs a file with shortcuts sign.
s.to_plist() The shortcut as a plist dictionary.
ref(action) An action's output.
text(*parts) A string with references in it.
variable(name), repeat_item(), repeat_index() Named and repeat variables.
shortcut_input(), clipboard(), current_date(), ask(), device_details(), current_app() Special variables.
where(*rows), where_any(*rows) Conditions for a Find action's WFContentItemFilter.
property_(source, name) One property of an action's output or a variable.
coerce(source, class) A value read as one content type, the editor's "Type" menu (CONTENT_ITEM_CLASSES).
dictionary(items) A dictionary parameter's items; action() encodes a plain dict itself.
app_intent(app, intent, output=None) Another app's action, for s.action().
FILTERS, ENTITIES, ENTITY_PROPERTIES, FILTER_OPERATORS, CALENDAR_UNITS, CONTENT_ITEM_CLASSES What each Find action can filter on, each entity type (name, app, Find action, typed properties), and the content types a coercion can name.
actions, ACTIONS, get_action(id) Action identifiers and their catalog entries: parameters and kinds, output and input types, keywords, description, flags, the rules under which the editor shows each parameter, and its labels, descriptions and choice titles.
accepted_by(type), produced_by(type) Which actions take a content type as input or as an entity parameter, and which output it.
PARAM_KINDS, PARAM_CHOICES, PARAM_VARIABLE_TYPES What each parameter accepts.
PARAM_LABELS, PARAM_DESCRIPTIONS, PARAM_CHOICE_TITLES How the editor labels each parameter and each enumeration choice.
CONDITION, ICON_COLORS, PROVENANCE If conditions, icon colors, and the build the data came from.

Documentation

Contributing

Issues and pull requests are welcome. See CONTRIBUTING.md.

License

MIT.

Metadata

Release files for shortcutkit 3.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for shortcutkit 3.2.0
File Size Uploaded Provenance Actions
shortcutkit-3.2.0.tar.gz 938.7 kB With provenance Details for shortcutkit-3.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for shortcutkit 3.2.0
File Interpreter ABI Platform Actions
shortcutkit-3.2.0-py3-none-any.whl Python 3 none any Details for shortcutkit-3.2.0-py3-none-any.whl

Total release size: 1.9 MB

Release files / shortcutkit-3.2.0.tar.gz

Download URL shortcutkit-3.2.0.tar.gz
Size 938.7 kB
Tags Source
SHA-256 checksum
How to use checksums
fda74470fd15410f985bdc65798483683cdaf07a6617a93fbdce2f0b2d03e55d
BLAKE2b-256 checksum
How to use checksums
6bf36d99b0eea7a748af31c2d2269d5fff75e2a1465afb92bf79d83c30d6678c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Release files / shortcutkit-3.2.0-py3-none-any.whl

Download URL shortcutkit-3.2.0-py3-none-any.whl
Size 963.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7b7a65e12454549b4f3c9cc96baef7bf6cf89979d41f9f234a572538102064a6
BLAKE2b-256 checksum
How to use checksums
878f0bc55bc14c39602a61dacde8819e10f8ae3ba8802309b340c0caea99f5dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Security for shortcutkit 3.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for shortcutkit-3.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page