nostr cli

A human and bot-friendly command-line interface for the Nostr protocol. Post notes, send encrypted DMs, manage accounts — all from your terminal.

$ brew install xdamman/tap/nostr

Examples

Login
$ nostr login
 
How would you like to log in?
 
> Import existing nsec
Generate new keypair
 
Enter your nsec: nsec1•••••••••••••
 
✓ Logged in as npub1xsp...uvds
Keys stored in ~/.nostr/accounts/npub1xsp.../
Post a public note
$ nostr post "Hello Nostr!"
 
Posting as xavier to 5 relays
 
Signer: npub1xdm...a8f2
Event ID: a1b2c3d4e5f6...
 
relay.damus.io 142ms
nos.lol 89ms
relay.nostr.band 203ms
eden.nostr.land 2001ms
relay.snort.social 312ms
 
✓ Published to 4/5 relays
Saved locally in ~/.nostr/accounts/npub1xdm.../events.jsonl
Pipe content to Nostr
$ echo "Hello from the command line" | nostr
 
Posting as xavier to 5 relays
 
relay.damus.io 128ms
nos.lol 102ms
relay.nostr.band 187ms
eden.nostr.land 245ms
relay.snort.social 156ms
 
✓ Published to 5/5 relays
Send an encrypted DM (NIP-17)
$ nostr dm xavier "See you at the meetup"
 
Protocol: NIP-17 (gift wrap)
Recipient: npub1xdm...a8f2
 
relay.damus.io 89ms
nos.lol 102ms
relay.primal.net 145ms
 
✓ Published to 3/3 relays
Interactive mode — public feed
$ nostr
xavier following 42 7/7 relays
 
23/03 10:15 fiatjaf working on a new relay implementation
23/03 10:18 jb55 zaps are underrated for micropayments
23/03 10:22 odell "fix the money, fix the world"
23/03 10:30 gigi nostr is the social layer bitcoin needed
 
xavier> this is amazing!
✓ Published to 7/7 relays
Interactive mode — DM conversation (with typing indicators)
$ nostr dm xavier
Chatting with xavier (NIP-17 gift wrap)
 
23/03 14:01 xavier Hey, are you coming to the meetup?
23/03 14:05 me Yes! See you there
                                  xavier is typing...
 
me> Can't wait! (Shift+Enter for multiline)
✓ Sent!

Why nostr cli?

Multi-account

Switch between identities like git branches. Each account has its own keys, relays, and aliases.

Human-friendly

Use aliases and NIP-05 usernames instead of raw npubs. nostr dm xavier just works.

Unix-native

Pipes, scripts, cron jobs. echo "hello" | nostr — compose with any tool.

Encrypted DMs

NIP-17 gift-wrapped DMs with typing indicators. NIP-04 legacy supported. Interactive chat with Shift+Enter multiline.

Profile & Events

nostr profile user -n 10 — view profiles with past events, filter by kind, live-stream with --watch.

Interactive shell

Live feed, posting, and slash commands. Multiline with Shift+Enter. Like a tiny Nostr client in your terminal.

Built-in NIP viewer

nostr nip 01 fetches and renders any NIP specification right in your terminal.

Long-form articles

Publish NIP-23 articles from markdown files with YAML frontmatter. nostr post -f article.md

Agent-friendly

--jsonl for streaming, --json for inspection, NIP-05 identities, and bot: true (NIP-24). Built for bots.

Commands

Social
nostr post [message]Post a text note (kind 1). Reads from stdin if piped.
nostr post -f article.mdPublish long-form content (NIP-23, kind 30023)
nostr reply <eventId> [msg]Reply with NIP-10 threading
nostr dm [user] [message]Send NIP-17 gift-wrapped DM, interactive chat, or stream with --watch
nostr events --kinds <n>Query events from relays (filter by kind, time, author)
nostr event new --kind <n>Create and publish a raw event of any kind
nostr follow [user]Follow a user (--alias, --json)
nostr profile [user] -n 10View profile and past events (--kinds, --watch)
nostr [user]View a user's profile and latest notes
nostr [user] --watchLive-stream a user's new notes
nostr --watchStream notes from all followed accounts
Account
nostr loginCreate a new account or import an existing nsec
nostr switch [account]Switch between accounts
nostr profileShow your current profile (kind 0 metadata)
nostr profile updateInteractively update your profile metadata
nostr accountsList all local accounts
Infrastructure
nostr relaysManage relays (add, remove, check status)
nostr syncSync local events with relays
nostr alias [name] [npub|nip05]Create an alias for quick access
nostr generate nip05Generate a NIP-05 nostr.json file (setup guide)
Reference
nostr nip [number]View a NIP specification in the terminal
nostr versionPrint version info
nostr updateCheck for updates and self-update

A <user> can be an alias, npub, or NIP-05 address (e.g. user@domain.com). Most commands support --json, --jsonl, and --raw for machine-readable output. Colors are auto-disabled when stdout is piped.

AI Agent Integration

nostr-cli is designed for bots and AI agents. Colors are auto-disabled when piped. Use --jsonl for streaming, --json for inspection, and --raw for wire-format events. Query events with flexible filters, stream DMs, and create raw events of any kind.

Install the nostr skill in your AI agent
# Claude Code
$ /install-skill https://nostrcli.sh/skill
 
# Codex, Cursor, Windsurf, Aider (via OpenSkills)
$ npx openskills install https://github.com/xdamman/nostr-cli
Bot / Agent recipes
# Stream DMs addressed to you, decrypted
$ nostr events --watch --kinds 4 --me --decrypt --jsonl
 
# Stream DMs and process with jq
$ nostr dm --watch --jsonl | while read -r line; do
    echo "$line" | jq .message
  done
 
# Query and decrypt recent DMs
$ nostr events --kinds 4 --since 1h --decrypt --jsonl
 
# Post from a pipe
$ echo "Hello from a bot" | nostr post --jsonl

An AGENTS.md is included at the repo root for tools that auto-load it (Codex, Cursor, Augment, Gemini). See also: llms.txt · skill/SKILL.md