shortcutkit
Build, validate and sign Apple Shortcuts (.shortcut) files from Python.
About
Apple has never documented the .shortcut format or what its actions accept. shortcutkit
does not guess at either. Its data was produced by loading WorkflowKit and ActionKit, the private
frameworks behind the Shortcuts app, and asking their own classes to describe and serialize
every built-in action, plus the Shortcuts app's own action index for the App Intents of
Apple's apps. Every identifier, parameter key and value encoding came out of the engine, not from a
person reading files, so the package cannot disagree with the app.
All 434 built-in actions and 1,581 Apple App Intents actions are bundled with the value kind
each parameter accepts, and
action() checks your call against them before anything is written. A wrong key or a string
where a boolean belongs raises ValueError. A file built from plain code signs, imports and
runs. Pure Python, no dependencies. Signing shells out to the macOS shortcuts command;
everything else runs anywhere.
The data regenerates in about a minute after any macOS update, with a diff of what Apple
changed and the semver bump it deserves. PROVENANCE records which macOS and Shortcuts build
produced the bundled files.
A TypeScript package of the same name shares the same data and adds compile-time checking. Both live at https://github.com/frontboat/shortcutkit.
Features
- Every built-in action, as a constant.
actions.SETSTOREDCONTENTand 433 more, so a typo is anAttributeErrorrather than a silent bad file. - Apple's apps too.
actions.REMINDERS_CREATE_REMINDER,actions.NOTES_CREATE_NOTEand 1,579 more App Intents actions from 80 Apple apps and system components, with theAppIntentDescriptorthe file needs added for you. - Parameters checked before you write anything.
ACTIONS[identifier]gives the name, parameter keys and output name;PARAM_KINDS[identifier]gives the value kind each key accepts. Unknown keys and wrong kinds raiseValueError. Attachments and token strings are accepted wherever a plain value is, because that is how Shortcuts works. - Value helpers that match the engine's serialization.
ref()to another action's output,variable(),shortcut_input(),clipboard(),current_date(),ask(),text()for strings with embedded references, andpicker()for variable-picker parameters. - Control flow.
if_()/otherwise()/end_if(),repeat_each()/end_repeat_each(),repeat_count()/end_repeat_count()andchoose_from_menu()/menu_item()/end_menu()manage the grouping identifiers for you. - App Intents from installed apps. Any identifier outside the built-in set is accepted and its parameters are passed through as given.
- Reference tables.
CONDITIONcodes,ICON_COLORS,PARAM_CHOICES, andPROVENANCErecording which macOS and Shortcuts build the bundled data came from.
How it compares
Earlier libraries kept their action lists by hand, and the two most used ones are archived:
python-shortcuts (the shortcuts
package on PyPI, archived 2024) and shortcuts-js
(archived 2023). Cherri is the active project in this
space and is a programming language with its own compiler rather than a library.
shortcutkit is a plain Python library whose action catalogue comes from the Shortcuts engine rather than from a maintainer. All 434 built-in actions and 1,581 Apple App Intents are covered, and the data regenerates after each macOS update.
Installation
pip install shortcutkit
Requirements
- Python 3.9 or newer.
- A Mac signed into iCloud for
Shortcut.sign(). It runsshortcuts sign, which refuses to work without an iCloud login even inanyonemode. Building and writing the unsigned file works on any platform.
Usage
from shortcutkit import Shortcut, actions, ref, text
s = Shortcut("Greeting", color="Teal")
got = s.action(actions.GETSTOREDCONTENT, WFStoredContentKey="greeting")
s.action(actions.SHOWRESULT, Text=text("Stored: ", ref(got)))
s.write() # Greeting.shortcut (unsigned)
Shortcut.sign("Greeting.shortcut", "Greeting-signed.shortcut") # macOS
Open the signed file and Shortcuts imports it.
Control flow
if_() returns a grouping identifier that the matching otherwise() and end_if() calls
take back:
gid = s.if_(ref(got), "has_any_value")
s.action(actions.SHOWRESULT, Text=text("Stored value: ", ref(got)))
s.otherwise(gid)
s.action(actions.SHOWRESULT, Text=text("Nothing stored"))
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", content=text("Added ", ref(r)))
Actions from other apps
Third-party App Intents actions are not in the catalogue, so pass the identifier as a string:
s.action("com.example.app.CreateNote", title=text("Hello"), body=ref(got))
Demo
The package ships a demo that builds a working shortcut with storage, an If/Otherwise block and output, then signs it:
python -m shortcutkit demo out.shortcut
Documentation
- Shortcut file format:
the
.shortcutformat end to end, every field. - Built-in actions reference: all 434 built-in actions with their parameters.
- Apple App Intents reference: the 1,581 App Intents actions of Apple's apps, by app.
- Parameter encodings: how each parameter class is serialized.
- Extraction notes: how the data was obtained and what remains approximate.
Development
From a checkout of the repository:
git clone https://github.com/frontboat/shortcutkit.git && cd shortcutkit/python
uv venv .venv && uv pip install -e . --python .venv/bin/python # or: python3 -m venv .venv && .venv/bin/pip install -e .
.venv/bin/python -m shortcutkit demo /tmp/Demo.shortcut
actions.py and data/ are generated by the repository's extraction tools from the Shortcuts
engine on a Mac. Do not edit them; change the generator or the data and run bun run extract
at the repository root. The Python and TypeScript packages are versioned together with the
data, and are kept in feature parity.
License
shortcutkit is licensed under the MIT license. See LICENSE for details.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file shortcutkit-0.5.0.tar.gz.
File metadata
- Download URL: shortcutkit-0.5.0.tar.gz
- Upload date:
- Size: 249.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38bc0f76a652f1da052bb8e820240d07fad1ff9e30db5420a971408771008756
|
|
| MD5 |
e31c17f93eba5b2a99969ffe46e46b3d
|
|
| BLAKE2b-256 |
0f0cbc895b033a34e7f50b6d8db2a02481a388a08ca50dd215e3f3c6abc5bb26
|
File details
Details for the file shortcutkit-0.5.0-py3-none-any.whl.
File metadata
- Download URL: shortcutkit-0.5.0-py3-none-any.whl
- Upload date:
- Size: 249.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b40c168d6fd3e501a29634a06586ae4da41622a50d1cc0141475dc09178f2e9e
|
|
| MD5 |
734a2c72dc70f56526a1d0a467062d70
|
|
| BLAKE2b-256 |
5a9a4a91398a796fd1feb5ae51b4a9b07c6bbc3607b68d88a681960afdb95ec6
|