Sub topic 3
Testing and Debugging Your Shortcut
Assume you know basic Finder and System Settings use, and that you have a multi-step shortcut with at least two actions. Debugging means finding where the shortcut's actual data or control flow differs from what you expected.
Test one action at a time
Run the shortcut from the editor while developing it. Temporarily add Show Result after an important action. This displays the value that action produced. Check both the value and its type, such as text, a file, or a list.
Use a small, predictable test input first. For a shortcut that processes files, test one copy of a file. Remove temporary Show Result actions after you understand the problem.
A common error is assuming that an action receives the original input. By default, it receives the previous action's output. Insert a variable or Show Result action to inspect that boundary.
Run automatically with automations
An automation runs a shortcut when a trigger occurs, such as a time, a calendar event, or a device condition. Create an automation in the Shortcuts app, choose its trigger, and select the shortcut. Test the trigger manually when possible before relying on it.
Keep automatic shortcuts safe to repeat. For example, avoid creating duplicate files each time unless that is intentional. Review notification and confirmation settings so a background run does not silently perform an unwanted action.
Call a shell script
The Run Shell Script action passes data to a shell program. Choose whether the shortcut sends input through standard input or as arguments. For text sent through standard input, use:
tr '[:lower:]' '[:upper:]'For received file paths passed as arguments, use:
for f in "$@"; do
wc -c < "$f"
doneQuote file paths because spaces are valid in macOS filenames.
Run it from Terminal
First inspect the exact shortcut name:
shortcuts listThen run it with a file as input:
shortcuts run "Uppercase Text" --input-path ~/Desktop/note.txtUse the same test input from the editor so you can compare results.
Share and review permissions
Before sharing, remove unnecessary actions and inspect permissions requested by the shortcut. A shortcut may access files, other apps, or network services. Share only shortcuts whose behavior and permissions you understand. Recipients may receive permission prompts when they run it.
Exercise
A shortcut works in the editor but fails from Terminal. What should you check first?
Show answer
Check the exact name from shortcuts list, then verify that Terminal passes input in the form the shortcut expects.