Command line interface for Drafts on macOS.
IMPORTANT: This CLI only works on macOS with Drafts running.
| Requirement | Details |
|---|---|
| Operating System | macOS only (uses AppleScript) |
| Drafts App | Must be installed AND running |
| Drafts Pro | Required for automation features |
| Go | 1.21+ (for installation) |
This CLI will NOT work if:
- You're on Linux or Windows
- Drafts app is not installed
- Drafts app is not running (it must be open)
- You don't have Drafts Pro subscription
The CLI communicates with Drafts via AppleScript (osascript). This means:
- Drafts must be running on your Mac for any command to work
- Commands execute in the context of the running Drafts app
- All data stays local on your Mac
go install github.com/nerveband/drafts/cmd/drafts@latestgit clone https://github.com/nerveband/drafts
cd drafts
go build ./cmd/drafts
# Optionally move to PATH
mv drafts /usr/local/bin/Download from Releases (macOS only).
# Make sure Drafts is running first!
open -a Drafts
# Create a draft
drafts create "Hello from the CLI"
# List your drafts
drafts list
# Get a specific draft
drafts get <uuid>$ drafts --help
Drafts CLI - Interact with Drafts.app from the command line
Requires: macOS, Drafts.app running, Drafts Pro subscription
Usage: drafts [--plain] <command> [<args>]
Options:
--plain output plain text instead of JSON
--help, -h display this help and exit
Commands:
new, create create new draft
prepend prepend to draft
append append to draft
replace replace content of draft
edit edit draft in $EDITOR
get get content of draft
select select active draft using fzf
list list drafts
flag flag a draft
unflag unflag a draft
syntax set language grammar/syntax
workspace show/list workspaces
run run a Drafts action
info show environment info and diagnostics
schema output tool-use schema for LLM integration
upgrade upgrade to the latest version
version show version information
Documentation:
Repository: https://github.com/nerveband/drafts-applescript-cli
Report issues: https://github.com/nerveband/drafts-applescript-cli/issues
Drafts docs: https://docs.getdrafts.com
Create a new draft.
drafts create "Content here" [options]
Options:
-t, --tag TAG Add tag (can be used multiple times)
-a, --archive Create in archive folder
-f, --flagged Create as flagged
--action ACTION Run action after creationExamples:
drafts create "Meeting notes"
drafts create "Shopping list" -t groceries -t todo
drafts create "Important!" -fGet a draft by UUID.
drafts get [UUID] # Omit UUID to get active draftList drafts with optional filtering.
drafts list [options]
Options:
-f, --filter FILTER Filter: inbox|flagged|archive|trash|all (default: inbox)
-t, --tag TAG Filter by tag (can be used multiple times)
-s, --search TEXT Search draft content
-w, --workspace NAME Filter by workspace nameExamples:
drafts list # List inbox
drafts list -f archive # List archived
drafts list -t work # Filter by tag
drafts list -s "meeting" # Search content
drafts list -w "My Workspace" # Filter by workspaceToggle flagged status on a draft.
drafts flag [UUID] # Flag (omit UUID for active draft)
drafts unflag [UUID] # Unflag (omit UUID for active draft)Set the language grammar / syntax highlighting of a draft.
drafts syntax "JavaScript" [-u UUID]
drafts syntax "Markdown" # Set on active draftShow current workspace or list all workspaces.
drafts workspace # Show current workspace
drafts workspace --list # List all workspacesAdd content to an existing draft.
drafts prepend "Text" -u UUID [options]
drafts append "Text" -u UUID [options]
Options:
-u, --uuid UUID Target draft UUID (omit to use active draft)
-t, --tag TAG Add tag
--action ACTION Run action after modificationReplace entire content of a draft.
drafts replace "New content" -u UUIDOpen draft in your $EDITOR.
drafts edit [UUID] # Omit UUID to edit active draftRun a Drafts action.
drafts run "Action Name" "Text to process"
drafts run "Action Name" -u UUID # Run on existing draftShow environment information and diagnostics. Run this first to verify your setup.
drafts info # Basic info
drafts info --verbose # Include full lists of actions, tags, workspaces
drafts info --test-permissions # Test what operations workExample output:
{
"success": true,
"data": {
"cli": {"version": "2.1.0", "os": "darwin", "arch": "arm64"},
"drafts_app": {"running": true, "version": "47.1", "pro": true},
"counts": {"inbox": 142, "flagged": 8, "archive": 1203, "trash": 12, "all": 1357},
"available_tags": ["work", "personal", "ideas"],
"recent_drafts": [{"uuid": "ABC123", "title": "Meeting notes", "modified": "..."}]
}
}Output tool-use schema for LLM integration.
drafts schema # Full schema
drafts schema create # Schema for specific commandUpgrade to the latest version from GitHub releases.
drafts upgrade # Check for and install updatesShow version information.
drafts version # Display current versionJSON (default) - Structured output for programmatic use:
{
"success": true,
"data": {
"uuid": "ABC-123",
"content": "Note content",
"title": "Note title",
"tags": ["tag1"],
"isFlagged": false,
"isArchived": false,
"isTrashed": false,
"folder": "inbox",
"createdAt": "2026-01-29 10:00:00",
"modifiedAt": "2026-01-29 10:30:00",
"permalink": "drafts://open?uuid=ABC-123"
}
}Plain text - Human-readable output:
drafts list --plainThis CLI is designed for LLM tool use:
- JSON output by default - Easy to parse
- Structured errors - Error code, message, and recovery hints
- Tool-use schema - Get schema with
drafts schema - Full metadata - All draft properties returned
- Self-diagnostics -
drafts infoshows environment status - Auto-update notifications - CLI notifies when updates available
Before starting any workflow:
# 1. Check environment status
drafts info
# 2. If issues or missing features, upgrade
drafts upgrade
# 3. Verify version
drafts versionWhen to run drafts upgrade:
- Before starting new tasks or workflows
- After encountering unexpected errors
- When documentation mentions features not available in your version
- When you see "Update available" notification
- Periodically to stay up to date with latest improvements
When to run drafts info:
- At the start of any session to verify Drafts is running
- After errors to diagnose environment issues
- To discover available actions, tags, and workspaces
- To verify Pro subscription is active
Error handling workflow:
# If a command fails unexpectedly:
1. Run 'drafts info' to check environment
2. Check if Drafts.app is running
3. Run 'drafts upgrade' to get latest fixes
4. Retry the command| Code | Meaning | Resolution |
|---|---|---|
DRAFT_NOT_FOUND |
UUID doesn't match any draft | Use drafts list to find valid UUIDs |
DRAFTS_NOT_RUNNING |
Drafts.app not running | Run open -a Drafts |
PERMISSION_DENIED |
Automation permission denied | Check System Settings > Privacy > Automation |
ACTION_NOT_FOUND |
Named action doesn't exist | Use drafts info --verbose to list actions |
PRO_REQUIRED |
Feature requires Drafts Pro | Subscribe to Drafts Pro |
An AI agent skill file is included in this repo at skills/SKILL.md. This skill teaches AI agents (Claude Code, ClawdBot, etc.) how to use the Drafts CLI.
To install:
# Copy to your skills directory
cp skills/SKILL.md ~/.config/skillshare/skills/drafts/SKILL.md
# Or for ClawdBot
cp skills/SKILL.md ~/.clawdbot/skills/drafts/SKILL.mdQuick diagnosis: Run drafts info to see environment status and identify issues.
- Is Drafts running? The app must be open:
open -a Drafts - Is Drafts Pro active? Automation requires Pro subscription
- Permissions granted? Go to System Settings > Privacy & Security > Automation and ensure Terminal (or your app) can control Drafts
Automated check:
drafts info --test-permissionsAdd to your PATH:
export PATH="$PATH:$(go env GOPATH)/bin"Drafts may be showing a dialog. Check the Drafts app window.
# Check current version
drafts version
# Upgrade to latest
drafts upgrade
# Verify environment
drafts info# Test what permissions you have
drafts info --test-permissionsIf permissions fail:
- Open System Settings > Privacy & Security > Automation
- Find your terminal app (Terminal, iTerm, etc.)
- Ensure "Drafts" is checked
- Restart your terminal
┌─────────────┐ AppleScript ┌─────────────┐
│ drafts CLI │ ──────────────────▶ │ Drafts.app │
└─────────────┘ (osascript) └─────────────┘
- No network requests
- No helper apps
- No Drafts actions to install
- Pure local AppleScript communication
go build ./cmd/drafts # Build
go test ./... # Run tests
go vet ./... # LintMIT
Forked from ernstwi/drafts. Refactored to use AppleScript backend (no helper app required).
