A powerful command-line interface for Bear that enables programmatic interaction with your notes. Perfect for automation, scripts, and integration with tools like Claude Code.
- ✅ Create notes with title, content, tags, and file attachments
- ✅ Read notes by ID or title with optional header extraction
- ✅ Update notes with append, prepend, or replace modes
- ✅ Archive notes to Bear's trash
- ✅ Manage tags - list, rename, and delete tags
- ✅ Search notes by content (with API token)
- ✅ JSON output for easy parsing and integration
- ✅ Token management for persistent API credentials
- macOS (Bear is macOS-only)
- Go 1.21 or later
- Bear app installed
# Clone or download the repository
cd bear-cli
# Build the binary
make build
# Install to /usr/local/bin/bear
make install
# Or install to ~/.local/bin without sudo
make install-userAfter installation, verify it works:
bear --helpbear create --title "Meeting Notes" --content "Discussed Q1 roadmap" --tags "work,important"Output:
{
"success": true,
"data": {
"note_id": "7E4B681B-...",
"title": "Meeting Notes",
"created_at": "2024-01-15T10:30:00Z"
}
}# By ID
bear read --id "7E4B681B-..."
# By title
bear read --title "Meeting Notes"# Append content (default)
bear update --id "7E4B681B-..." --content "New item added"
# Replace entire note
bear update --id "7E4B681B-..." --content "Completely new content" --mode replace_all
# Append with timestamp
bear update --id "7E4B681B-..." --content "Final notes" --timestampbear list --tag "work"bear archive --id "7E4B681B-..."Some operations (search, tags list) require your Bear API token.
- Open Bear
- Go to Settings → Account → API Token
- Generate or copy your token
bear config set-token --token "your-api-token-here"This securely stores your token in ~/.bear-cli/config.json (permissions: 0600).
bear config showbear create [OPTIONS]
Options:
-t, --title STRING Note title
-c, --content STRING Note content
-g, --tags STRING Comma-separated tags (e.g., "work,urgent")
-f, --file PATH File to attach
-p, --pin Pin note to top
--timestamp Prepend current date/timebear read [OPTIONS]
Options:
-i, --id STRING Note ID
-t, --title STRING Note title
-h, --header STRING Extract specific header section
--exclude-trashed Skip trashed notesbear update [OPTIONS]
Options:
-i, --id STRING Note ID (required)
-c, --content STRING Content to add/update
-f, --file PATH File to attach
-m, --mode STRING Update mode (default: append)
Values: append, prepend, replace, replace_all
-h, --header STRING Target specific header section
-g, --tags STRING Comma-separated tags to add
--new-line Add content on new line (append mode)
--timestamp Prepend date/timebear list [OPTIONS]
Options:
-t, --tag STRING Filter by tag
-s, --search STRING Search by content (requires token)
-f, --filter STRING Filter type (all, untagged, todo, today, locked)
-k, --token STRING API token (uses config if not provided)bear archive [OPTIONS]
Options:
-i, --id STRING Note ID (required)
--no-window Don't show Bear window# List all tags
bear tags list --token "YOUR_TOKEN"
# Rename a tag
bear tags rename --name "old-tag" --new-name "new-tag"
# Delete a tag
bear tags delete --name "old-tag"# Set API token
bear config set-token --token "YOUR_TOKEN"
# View stored token (masked)
bear config get-token
# Show full configuration
bear config showAll commands return JSON in this format:
{
"success": true,
"data": {
// Command-specific data
}
}{
"success": false,
"error": "Human-readable error message",
"error_code": "MACHINE_READABLE_CODE",
"details": "Additional technical details"
}The bear CLI is designed for seamless integration with Claude Code:
// In Claude Code
const { execSync } = require('child_process');
function createNote(title, content, tags) {
const cmd = `bear create --title "${title}" --content "${content}" --tags "${tags}"`;
const output = execSync(cmd, { encoding: 'utf-8' });
return JSON.parse(output);
}
function readNote(noteId) {
const cmd = `bear read --id "${noteId}"`;
const output = execSync(cmd, { encoding: 'utf-8' });
return JSON.parse(output);
}
// Usage
const note = createNote("Claude's Analysis", "Key findings...", "ai,analysis");
console.log(note.data.note_id);Configuration is stored in ~/.bear-cli/config.json:
{
"token": "your-api-token",
"callback_port": 8765,
"callback_timeout_seconds": 10,
"show_window": false,
"output_format": "json",
"last_updated": "2024-01-15T10:30:00Z"
}BEAR_TOKEN- Override token from configBEAR_CLI_CONFIG- Custom config file pathBEAR_SHOW_WINDOW- Force show Bear window (true/false)
- Verify the note ID or title is correct
- Use
--exclude-trashedif the note might be in trash
- Set token with:
bear config set-token --token "YOUR_TOKEN" - Or pass with:
--token "YOUR_TOKEN"
- Ensure Bear is running
- Check that port 8765 is available (or set a custom port in config)
- Use absolute paths or paths with
~for home directory - Ensure file exists and is readable
- Each command creates a temporary local HTTP server to receive callbacks
- Network latency depends on Bear's response time
- Large files may take longer to attach
- macOS Only - Bear is only available on macOS
- No Direct Delete - Notes cannot be deleted via CLI (only archived)
- Encrypted Notes - Cannot access encrypted notes without unlocking Bear
- Token in Plaintext - Token stored in
~/.bear-cli/config.json(file permission 0600) - Batch Operations - Each command is separate (no bulk operations yet)
# Development build with verbose output
make dev
# Run linter
make lint
# Format code
make fmt
# Run tests
make test
# Show all make targets
make helpbear-cli/
├── main.go # CLI entry point
├── cmd/commands.go # All command implementations
├── pkg/
│ ├── bear/
│ │ ├── client.go # URL scheme client
│ │ ├── callback.go # HTTP callback server
│ │ └── models.go # Data structures
│ ├── formatter/
│ │ └── json.go # JSON output formatting
│ └── util/
│ ├── encoding.go # URL/file encoding
│ └── config.go # Configuration management
├── go.mod # Go module definition
├── Makefile # Build automation
└── README.md # This file
INVALID_ARGUMENTS- Missing or invalid command-line argumentsNOTE_NOT_FOUND- Note doesn't existBEAR_ERROR- Bear app returned an errorCALLBACK_TIMEOUT- No response from Bear within timeoutCONFIG_ERROR- Configuration file issueCLIENT_ERROR- Failed to initialize Bear clientFORMAT_ERROR- Failed to format response
- Token Storage - Tokens are stored in
~/.bear-cli/config.jsonwith restricted permissions (0600) - Token Display -
bear config get-tokenmasks tokens for security (shows first 6 and last 6 chars) - URL Encoding - All parameters are properly URL-encoded to prevent injection
- Local Callback - Responses are received via localhost only, not exposed to network
This project is provided as-is. Bear is a product of Shiny Frog.
Contributions welcome! Areas for expansion:
- Batch operations
- Additional filters and search options
- Better error handling for edge cases
- Performance optimizations
- Test coverage
For issues or questions:
- Check the troubleshooting section above
- Review the Bear x-callback-url documentation: https://bear.app/faq/x-callback-url-scheme-documentation/
- Check your Bear installation is up to date
- Verify API token is correct (if needed)
Made with ❤️ for Bear note enthusiasts and automation fans.