{"slug": "what-i-learned-building-a-system-wide-ai-writing-tool-on-macos", "title": "What I learned building a system-wide AI writing tool on macOS", "summary": "A developer built DraftKey, an on-device macOS writing assistant that uses the Accessibility API to read and rewrite text in any focused text field, with autocomplete and rewriting running offline after a one-time 1.12 GB model download. The developer found that app support varies widely depending on how each application exposes its text, so DraftKey limits itself to compatible fields, offers per-app controls, and skips secure password fields entirely. Rewrites are never applied automatically — the user reviews each suggestion before inserting it.", "body_md": "I assumed a Mac app that helps you write in any text field would be the easy part. It wasn't. Here's what I learned building DraftKey, an on-device writing assistant for the apps you already use.\n\nThere's no public API that says \"give me the text the user is typing in whatever app is in front.\" What macOS does have is the Accessibility API, the same layer screen readers like VoiceOver use.\n\nThe basic flow looks like this:\n\n`AXIsProcessTrustedWithOptions` is how you check (and prompt).`AXUIElementCreateSystemWide()` and ask it for `kAXFocusedUIElementAttribute` to find the focused text field.`kAXValueAttribute`, `kAXSelectedTextAttribute`, and `kAXSelectedTextRangeAttribute` to get the text and where the cursor is.`kAXBoundsForRangeParameterizedAttribute` if you want to draw UI near the caret.\nWith standard Cocoa text views, this works well. The problem is everything else.\n\nSupport depends entirely on how each app exposes its text, and some don't expose much at all:\n\nSo I stopped promising \"works everywhere.\" DraftKey works in compatible text fields, has per-app controls so you choose where it runs, and skips secure fields completely. Password fields show up with a secure text field subrole, and you should never touch them.\n\nWriting text back is its own decision. Setting the selected text through Accessibility is clean when an app supports it. The common fallback is going through the pasteboard, which means you're messing with the user's clipboard. Whatever you pick, test it app by app.\n\nThe rewrite panel opens when you tap Command and Option together and let go. A modifier-only shortcut sounds simple, but you're really watching modifier flag changes and deciding \"was that a tap, or was the user holding Command+Option on the way to some other shortcut?\" If any other key goes down in between, it isn't a tap. Get that wrong and the panel pops up mid shortcut, which is the fastest way to get uninstalled.\n\nI wanted writing help that doesn't send your drafts to a cloud AI service. That part works: after a one-time model download of about 1.12 GB, autocomplete and rewriting run offline. The internet is only needed for the download, license activation, and update checks.\n\nBut local has tradeoffs you should be upfront about:\n\nThe upside: it works on a plane, and your draft emails stay on your Mac.\n\nThe design decision I'm most sure about: a rewrite never replaces your text directly. You type an instruction like \"make it shorter,\" it works on the current paragraph (or your selection if you highlighted something), you see the result, and you choose whether to insert it.\n\nLanguage models get things wrong sometimes. They drop a detail or change a meaning. A review step costs one keystroke, saves you from sending something you didn't write, and keeps your voice yours.\n\nAutocomplete, rewrites, local clipboard history (Command+Option+V), and six mechanical keyboard sound profiles all toggle independently. Some people only want the sounds, which work with the AI turned off.\n\nIf you're curious, there's a free typing test with the keyboard sounds on [getdraftkey.com](https://getdraftkey.com). No install needed. And if you've built anything on top of the Accessibility API, I'd love to hear which apps gave you the most trouble.", "url": "https://wpnews.pro/news/what-i-learned-building-a-system-wide-ai-writing-tool-on-macos", "canonical_source": "https://dev.to/godnick/what-i-learned-building-a-system-wide-ai-writing-tool-on-macos-81m", "published_at": "2026-10-08 20:06:42+00:00", "updated_at": "2026-10-08 20:19:46.110469+00:00", "lang": "en", "topics": ["ai-tools", "ai-products", "large-language-models", "developer-tools"], "entities": ["DraftKey", "macOS", "Accessibility API", "VoiceOver"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/what-i-learned-building-a-system-wide-ai-writing-tool-on-macos", "markdown": "https://wpnews.pro/news/what-i-learned-building-a-system-wide-ai-writing-tool-on-macos.md", "text": "https://wpnews.pro/news/what-i-learned-building-a-system-wide-ai-writing-tool-on-macos.txt", "jsonld": "https://wpnews.pro/news/what-i-learned-building-a-system-wide-ai-writing-tool-on-macos.jsonld"}}