Project Info
Inspiration
Tone shapes how people understand our intentions. A message meant to be direct can sound harsh, and a quick reply can unintentionally feel negative. We built ToneGuard to help people communicate more thoughtfully while keeping their conversations private.
What it does
ToneGuard detects toxic, negative, or off-tone language in text and highlights it before it is shared. It runs entirely on-device, with no internet access or cloud processing, so user text remains private.
How we built it
We built ToneGuard as a native macOS app using Swift and integrated an on-device ML model to analyze text locally. The app provides real-time feedback by identifying language that may be interpreted negatively or differently than intended.
Challenges we ran into
The main challenge was building for Swift and macOS, since this was a new ecosystem for us. Understanding native app development, UI integration, and on-device model inference took time. Codex helped bridge this gap: we defined the problem and product direction, while Codex supported the implementation details.
Accomplishments we're proud of
We are proud to have created a working privacy-first communication tool that does not rely on the internet. ToneGuard demonstrates that helpful AI does not need to collect or send sensitive user data to be effective.
What we learned
We learned how to build a macOS app, integrate an ML model for local inference, and design around privacy from the start. We also learned that AI products are most valuable when they support people at the exact moment they need help—in this case, before a message is sent.
What's next
ToneGuard currently supports English. Next, we plan to improve tone detection, provide clearer rewrite suggestions, and extend support to other languages—while preserving its privacy-first, on-device approach.
ToneGuard
A native, local-first macOS MVP that watches the focused accessibility text field, detects toxic language in real time, and shows a transparent highlight over the matching words. No text leaves the device.
Run
chmod +x Scripts/build-app.sh
pkill -x ToneGuard 2>/dev/null || true
Scripts/build-app.sh
open -n dist/ToneGuard.app
ToneGuard prompts for Accessibility permission immediately on launch. Grant it
in System Settings → Privacy & Security → Accessibility; it will appear as
ToneGuard because it runs as a native .app bundle. Click inside an editable
field in another app and type a configured term such as idiot or hate.
swift run ToneGuard remains useful for development, but is not the recommended
way to request Accessibility access because it does not launch a stable .app
bundle identity.
Diagnostics
The menu-bar command Preview overlay (5 seconds) draws a large red rectangle without reading any other app. If it is not visible, the macOS overlay window is being blocked before text-range geometry is involved. Diagnostic metadata (never typed text) is also written to:
~/Library/Application Support/ToneGuard/Logs/toneguard.log
MVP controls
Choose Detection Settings from the menu-bar popover to enable categories, adjust sensitivity, or add local custom blocked words. A detection includes its category, confidence, and a short explanation. These settings are stored only in your local macOS user defaults.
ToneGuard also uses macOS's built-in, on-device NaturalLanguage sentiment model to flag strongly negative sentences that do not contain an exact blocked word. Those detections highlight the full sentence; direct rule matches remain word-level highlights.
Privacy
ToneGuard has no networking code or remote model calls: detection rules, custom words, and the system-provided sentiment model run only on the Mac. The main app must remain outside the restrictive App Sandbox because macOS uses that sandbox to block the cross-app Accessibility API ToneGuard needs. A production-grade network guarantee therefore requires a separately sandboxed, no-network helper or an outbound firewall policy; it cannot coexist with direct cross-app Accessibility in one sandboxed process.
Validation
The detector has unit tests in Tests/ToneGuardTests. Run them in Xcode (or with
swift test on a full Xcode installation). Manual acceptance checks: grant
Accessibility access to ToneGuard.app, then verify the terms idiot, shut up, and a custom blocked word in TextEdit, Notes, and a browser editor. Some
apps intentionally do not expose text bounds through Accessibility; ToneGuard
will continue monitoring without drawing an overlay in those editors.
Notes
- macOS only exposes text from apps that support the Accessibility API. Secure text fields and some third-party apps intentionally do not expose their contents.
- Terminal and iTerm transcripts are intentionally skipped in this MVP because macOS reports their entire scrollback as a single Accessibility text region.
- The MVP uses a small local rules engine, deliberately kept behind
ToxicityDetectorso it can be replaced by a bundled Core ML model later without changing the UI or accessibility pipeline. - The Swift package makes it easy to develop without an Xcode project. For signing and distribution, open the folder in Xcode and use a Developer ID / sandbox configuration with the Accessibility entitlement workflow.
Analysis
View
Metric
- 4
Figures cover GitHub contributors during the hackathon window. A co-authored commit counts in full for each author, so per-member totals add up to more than the whole-team figures.
Technology
- SwiftIn code
1 of 1 appear in the indexed code.
AI coding agents
No AI coding agent signals were found in this repository.
Detected from committed agent config files and commit authorship. Absence of a signal is not proof an agent was unused.
Codebase size
Source size
62 KB
Source files
19
Counts recognized source files only; vendored directories, binaries and lockfiles are excluded, so this is smaller than the repository on disk.
Repository
vivekjain202/ToneGuard
22 files · 684 KB · @ dc3210c
Structure
Application logic
16 files · 73%Domain rules, services and shared utilities.
Supporting
Layers are inferred from where files sit in the tree, not from reading the code. A project that names its directories unconventionally will read oddly here — open the file browser to check anything the diagram implies.
Languages
- Swift88%
- Markdown9%
- Shell3%
Share of indexed source by file size. Binary and vendored files are excluded.
This project’s features have not been analysed yet.
Export this project's context (description, README, evidence, key source files) to chat with an AI agent elsewhere.