← Back to DevBytes

macOS Shortcuts for Developers

Introduction to macOS Shortcuts for Developers

macOS Shortcuts, introduced in macOS Monterey and significantly enhanced in subsequent releases, is Apple's automation framework that allows users to create custom workflows without writing traditional code. For developers, Shortcuts represents a powerful tool that can streamline repetitive tasks, integrate with APIs, and bridge the gap between system-level operations and custom applications. Whether you want to automate your development environment setup, trigger CI/CD pipelines, or interact with your own REST APIs, macOS Shortcuts provides a surprisingly capable platform.

What Are macOS Shortcuts?

Shortcuts is the evolution of Apple's Workflow app and the successor to Automator. It uses a visual, drag-and-drop interface where you chain together "actions" to build multi-step workflows. Each action performs a specific task — such as fetching a URL, parsing JSON, running a shell script, or manipulating text. Shortcuts can be triggered from the Shortcuts app, the menu bar, Siri, Spotlight, keyboard hotkeys, or even programmatically via URL schemes and the Shortcuts command-line tool.

For developers, the most compelling aspects are the ability to run shell scripts, make HTTP requests, process structured data, and expose these workflows as services that other applications can invoke.

Why Shortcuts Matter for Developers

Bridging System and Custom Automation

As a developer, you likely already use shell scripts, Makefiles, and task runners. Shortcuts complements these tools by providing a layer that can interact with macOS-native features — such as Calendar, Reminders, Files, and system services — while still calling out to your existing scripts and APIs. This makes it ideal for workflows that span both the operating system and your development tooling.

Quick Prototyping and Personal Tooling

Shortcuts allows you to rapidly prototype automation ideas without spinning up a full project. Need to quickly hit a webhook when you finish a task? Want to parse a JSON response from your staging API and format it into a Markdown file? Shortcuts can do this in minutes with no compilation step.

Accessibility and Shareability

Shortcuts can be exported and shared as .shortcut files. This means you can distribute useful automations to teammates who may not be comfortable with shell scripting. A Shortcut that sets up a local development environment, for example, can be shared across a team and run with a single click.

Getting Started with the Shortcuts App

Creating Your First Shortcut

Open the Shortcuts app from your Applications folder or via Spotlight. Click the "+" button in the top-right corner to create a new shortcut. You will see an action library on the right side, a canvas in the middle, and a toolbar at the top where you can name your shortcut and configure how it is triggered.

Let's build a simple first shortcut that fetches the public IP address of your machine and copies it to the clipboard.

  1. Add the "Get Contents of URL" action.
  2. Set the URL to https://api.ipify.org?format=json.
  3. Add the "Get Dictionary Value" action, with the key ip.
  4. Add the "Copy to Clipboard" action.

Run the shortcut and your public IP will be copied to your clipboard. This simple example demonstrates the core pattern: fetch data, process it, and output it somewhere useful.

Running Shell Scripts Inside Shortcuts

One of the most powerful actions for developers is "Run Shell Script." This action lets you execute arbitrary shell commands and pass data in and out. You can choose your shell (bash, zsh, etc.), pass input as arguments or stdin, and capture stdout as output.

Here is an example of a shell script action that lists all Git repositories in your home directory that have uncommitted changes:

#!/bin/zsh

find ~ -maxdepth 3 -name ".git" -type d 2>/dev/null | while read gitdir; do
  repo=$(dirname "$gitdir")
  if [ -n "$(cd "$repo" && git status --porcelain)" ]; then
    echo "$repo"
  fi
done

Place this in a "Run Shell Script" action and the output will be a list of repository paths with pending changes. You can then pipe this into a "Choose from List" action to pick a repo and open it in your editor of choice.

Working with APIs and JSON

Making HTTP Requests

The "Get Contents of URL" action is your gateway to interacting with REST APIs. It supports GET, POST, PUT, PATCH, and DELETE methods. You can set headers, provide a JSON body, and even handle authentication via headers.

For example, to trigger a GitHub Actions workflow via the GitHub API, configure the action as follows:

{
  "event_type": "deploy_staging",
  "client_payload": {
    "environment": "staging",
    "initiator": "shortcut"
  }
}

This allows you to trigger deployments directly from a menu bar shortcut or a keyboard hotkey, without opening a browser or terminal.

Parsing and Transforming JSON

Shortcuts includes several actions for working with dictionaries and lists, which map to JSON objects and arrays. The "Get Dictionary Value" action retrieves a value by key, while "Repeat with Each" lets you iterate over arrays. You can also use the "Dictionary" action to construct new JSON structures.

For more complex transformations, it is often easier to use jq inside a shell script action:

#!/bin/zsh

# Input passed as stdin
input=$(cat)
echo "$input" | jq '[.items[] | {title: .name, url: .html_url}]'

This pattern gives you the full power of jq for filtering and reshaping API responses before passing them to subsequent Shortcut actions.

Integrating with Your Development Workflow

Project Bootstrap Shortcut

A common use case is a shortcut that scaffolds a new project. The following shell script, placed in a "Run Shell Script" action, creates a new directory, initializes a Git repository, and sets up a basic Node.js project structure:

#!/bin/zsh

PROJECT_NAME="$1"
BASE_DIR="$HOME/Projects"

mkdir -p "$BASE_DIR/$PROJECT_NAME"
cd "$BASE_DIR/$PROJECT_NAME"

git init
npm init -y
mkdir -p src test
touch src/index.js test/index.test.js
echo "node_modules/" > .gitignore
echo "# $PROJECT_NAME" > README.md

git add .
git commit -m "Initial commit"

echo "Project created at $BASE_DIR/$PROJECT_NAME"

Precede this with a "Ask for Input" action (text type) to capture the project name, pass it as an argument to the shell script, and follow it with an "Open File" action to open the new directory in your editor.

Daily Standup Prep Shortcut

Another practical shortcut gathers information for your daily standup. It can pull your recent Git commits, check your calendar for upcoming meetings, and compile everything into a single note. Here is the shell script portion that retrieves yesterday's commits across all branches:

#!/bin/zsh

cd "$1"
git log --since="yesterday" --author="$(git config user.name)" \
  --pretty=format:"%h - %s" --no-merges

Chain this with a "Get Upcoming Events" action (from Calendar) and a "Create Note" action to compile a standup summary in Apple Notes.

Triggering and Running Shortcuts Programmatically

The shortcuts Command-Line Tool

macOS includes a shortcuts CLI tool that lets you run shortcuts from the terminal or within other scripts. This is invaluable for integrating Shortcuts into your existing development workflows.

# List all available shortcuts
shortcuts list

# Run a shortcut by name
shortcuts run "Deploy to Staging"

# Run a shortcut and provide input via stdin
echo '{"repo":"my-app","branch":"main"}' | shortcuts run "Create PR" -i -

# View a shortcut's details
shortcuts view "Deploy to Staging"

You can use this in Makefiles, package.json scripts, or CI pipelines running on a macOS machine.

URL Schemes

Shortcuts also supports URL schemes, allowing you to trigger them from browsers, notes, or any application that handles URLs. The format is:

shortcuts://run-shortcut?name=Deploy%20to%20Staging&input=text&text=hello

This is useful for creating clickable links in documentation or internal wikis that trigger specific developer workflows.

Best Practices

Keep Shortcuts Focused

Each shortcut should do one thing well. Rather than building a monolithic shortcut that handles project creation, deployment, and cleanup, create separate shortcuts and chain them using the "Run Shortcut" action. This makes individual components easier to test, debug, and reuse.

Handle Errors Gracefully

Network requests fail, shell scripts encounter edge cases, and APIs return unexpected responses. Use the "If" action to check for error conditions and the "Show Alert" or "Show Notification" actions to inform yourself when something goes wrong. In shell scripts, always check exit codes:

#!/bin/zsh

response=$(curl -sf https://api.example.com/health)
if [ $? -ne 0 ]; then
  echo "ERROR: API health check failed"
  exit 1
fi
echo "$response"

Shortcuts will surface non-zero exit codes as errors, which you can then handle with the "If" action in the visual flow.

Use Variables for Reusable Values

Define variables for API tokens, base URLs, and file paths that you reference multiple times. This makes your shortcuts easier to maintain and update. Use the "Set Variable" action early in your shortcut and reference the variable throughout.

Version Control Your Shortcuts

While shortcuts are binary files, you can export them and store them in a Git repository for versioning and sharing. Use the CLI to streamline this:

# Export a shortcut
shortcuts export "Deploy to Staging" -o ./shortcuts/deploy-staging.shortcut

# Import a shortcut
shortcuts import ./shortcuts/deploy-staging.shortcut

This enables team collaboration and provides a history of changes to critical automation workflows.

Document Your Shortcuts

Use the "Comment" action to document what each section of your shortcut does. This is especially important for shortcuts that contain complex shell scripts or multi-step API interactions. Future you will thank you.

Conclusion

macOS Shortcuts is a versatile automation tool that deserves a place in every developer's toolkit. By combining visual workflow building with the ability to run shell scripts and make HTTP requests, it bridges the gap between system-level automation and custom development tooling. Start small with simple utilities like IP lookups or Git status checks, then gradually build more sophisticated workflows that integrate with your APIs, CI/CD pipelines, and project scaffolding processes. With thoughtful organization, error handling, and version control, Shortcuts can become a reliable and powerful extension of your development environment that saves you time every single day.

— Ad —

Google AdSense will appear here after approval

← Back to all articles