Bear notes uses x-callback-url for inter-app communication. Claude can create notes via open "bear://..." but can't read note content back because the response is sent to a callback URL, not stdout. We need a small Swift CLI tool that sends an x-callback-url to Bear, waits for the response, and outputs the note content to stdout.
Rather than reinventing the wheel, we'll build a lightweight Swift CLI tool called bear-cli that:
- Registers a temporary custom URL scheme to receive callbacks
- Sends x-callback-url requests to Bear (with x-success pointing to our scheme)
- Waits (with timeout) for Bear to call back
- Parses the callback parameters and outputs note content to stdout
This follows the same pattern as the open-source xcall tool but purpose-built for Bear.
- Single Swift file as a macOS command-line tool with an embedded app bundle
- Needs an
Info.plistto register a custom URL scheme (e.g.bear-cli-callback) - Location:
~/development/bear-cli/
- CLI receives arguments like
bear-cli open-note --title "My Note" --token TOKEN - Constructs Bear x-callback-url:
bear://x-callback-url/open-note?title=...&x-success=bear-cli-callback://success&x-error=bear-cli-callback://error - Opens the URL via NSWorkspace
- Runs an NSApplication run loop to receive the URL callback
- macOS routes
bear-cli-callback://success?note=...&title=...back to our app - Parses parameters, prints note content to stdout, exits
open-note— read a note by title or IDsearch— search notestags— list all tags
~/development/bear-cli/Package.swift— Swift package manifest~/development/bear-cli/Sources/BearCLI/main.swift— main app logic~/development/bear-cli/Sources/BearCLI/Info.plist— URL scheme registration- Build script / Makefile for easy compilation
After building, add to ~/.claude/CLAUDE.md:
- Path to
bear-clibinary - Usage examples for reading notes
- Build with
swift build - Run
bear-cli open-note --title "test note" --token TOKEN - Verify note content prints to stdout
- Test from Claude Code session to confirm it works in this context