Skip to content

chansty/backspace-bro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Backspace Bro

A macOS menu bar app that fixes your typos in real time — across every app on your Mac, including browser-based editors like Slack, Linear, Notion, and Gmail.

Instant corrections for obvious typos. Cloud LLM for everything else. Works system-wide via macOS Accessibility APIs with a Chrome extension bridge for web apps.

Features

  • System-wide correction — works in any text field on macOS: native apps, Electron apps, and browser-based editors
  • 3-tier correction engine
    • Tier 1: Instant — SymSpell dictionary lookup corrects obvious typos in <1ms (tehthe, recievereceive)
    • Tier 2: Confidence routing — ambiguous corrections (edit distance 2, multiple candidates) are held for sentence context
    • Tier 3: Cloud LLM — full sentences are sent to a cloud LLM (Anthropic, OpenAI, or Gemini) for context-aware correction
  • Configurable aggressiveness — Cautious (sentence-only), Balanced (instant + LLM), or Aggressive (correct everything as you type)
  • BYOK (Bring Your Own Key) — use your own API key for Anthropic, OpenAI, or Google Gemini
  • Chrome extension bridge — corrects text inside browser-based editors (Slack, Linear, Notion, Gmail) via a local HTTP bridge and DOM replacement
  • Quick undo — press ⌥Z (configurable) to instantly revert the last correction. Corrections expire after 30 seconds or ~80 characters of typing
  • Poof animation — subtle sparkle animation appears at the corrected word

How It Works

User types in any text field
         │
         ▼
┌─────────────────────────┐
│  macOS Accessibility API │ ◄── Observes text value changes system-wide
│  (AXObserver + polling)  │
└──────────┬──────────────┘
           │
           ▼
┌─────────────────────────┐
│      Word Buffer         │ ◄── Detects word/sentence boundaries, handles
│  (trailing by 1 word)   │     batched AX notifications
└──────────┬──────────────┘
           │
     ┌─────┴──────┐
     ▼            ▼
┌──────────┐ ┌──────────────┐
│ SymSpell │ │  Cloud LLM   │
│  (word)  │ │  (sentence)  │
│  <1ms    │ │  200-800ms   │
└────┬─────┘ └──────┬───────┘
     │              │
     ▼              ▼
┌─────────────────────────┐
│     Text Replacer        │
│  ┌─────────┐ ┌────────┐ │
│  │Native AX│ │Browser │ │ ◄── AX for native apps, HTTP bridge + Chrome
│  │ replace │ │ bridge │ │     extension for web apps
│  └─────────┘ └────────┘ │
└─────────────────────────┘

Tech Stack

Component Technology
App Swift, SwiftUI, macOS Accessibility APIs
Spell check SymSpell (edit distance 1-2, 82K word dictionary)
LLM Cloud API — Anthropic Claude, OpenAI GPT, Google Gemini
Browser bridge NWListener HTTP server (localhost:9876)
Chrome extension Manifest V3, content script + service worker
API key storage macOS Keychain (Security.framework)
Animation SwiftUI overlay windows (floating, borderless)

Getting Started

Prerequisites

Build & Run

# Clone the repo
git clone https://github.com/chansty/backspace-bro.git
cd backspace-bro

# Open in Xcode
open BackspaceBro/BackspaceBro.xcodeproj

# Build and run (⌘R)

On first launch, macOS will prompt you to grant Accessibility permissions in System Settings → Privacy & Security → Accessibility.

Configure the LLM

  1. Click the menu bar icon → Settings
  2. Pick your provider (Anthropic / OpenAI / Gemini)
  3. Paste your API key
  4. Click Save & Test

Install the Chrome Extension (for browser apps)

  1. Open chrome://extensions in Chrome
  2. Enable Developer mode (top right)
  3. Click Load unpacked → select the chrome-extension/ folder
  4. The extension connects automatically when BackspaceBro is running

Project Structure

BackspaceBro/
├── App/                    # AppState, entry point
├── Monitor/                # AX observer, WordBuffer, AccessibilityHelper
├── Correction/             # CorrectionRouter, CorrectionPipeline, SymSpell
├── LLM/                    # CloudLLMService (Anthropic/OpenAI/Gemini)
├── Replacement/            # TextReplacer (AX + browser bridge paths)
├── Browser/                # BrowserBridge HTTP server
├── Undo/                   # CorrectionHistory, GlobalHotkeyManager
├── Animation/              # OverlayWindow, poof + toast animations
├── Utilities/              # KeychainHelper, CoordinateConverter
├── Views/                  # SettingsView, MenuBarView, HotkeyRecorder
└── Resources/              # SymSpell frequency dictionary (82K words)

chrome-extension/
├── manifest.json           # MV3 manifest
├── content.js              # DOM text replacement, polls native app
└── background.js           # Service worker, proxies HTTP to localhost

Configuration

Setting Options Default
LLM Provider Anthropic, OpenAI, Gemini OpenAI
Correction Style Cautious, Balanced, Aggressive Balanced
Undo Hotkey Any modifier+key combo ⌥Z
Excluded Apps Per-app toggle Terminal, iTerm2

Cost

At typical usage (~500 corrections/day), cloud LLM costs are negligible:

Provider Model ~Monthly Cost
Gemini Flash gemini-2.0-flash ~$0.30
GPT-4o Mini gpt-4o-mini ~$0.45
Claude Haiku claude-haiku-4-5 ~$2.76

License

This project is for personal/educational use.

About

macOS menu bar app that fixes typos in real time — system-wide, including browser apps like Slack and Linear

Topics

Resources

Stars

Watchers

Forks

Contributors