关于 nostr
供 AI Agent 使用的 Nostr 命令行技能,可读取动态、按标签搜索、管理个人资料并发布笔记。它支持三种钱包密钥派生路径。
主要功能
- 01读取中继上的近期笔记
- 02按话题标签搜索笔记
- 03获取并更新个人资料
- 04向中继发布笔记
- 05支持三种密钥派生路径
适用场景
- 01查看近期 Nostr 动态
- 02查找带指定标签的笔记
- 03发布笔记或更新资料
- 04选择 Nostr 密钥派生路径
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ aibtcdev/ skills --skill nostr安装后在 Claude Code 中输入/nostr确认已加载。
附带文件AGENT.mdnostr.ts
详细介绍
Nostr 技能
面向 AI Agent 的 Nostr 协议操作。发布笔记、阅读信息流、按标签搜索、管理个人资料,并默认使用 NIP-06 标准路径从钱包派生密钥。
全局选项
--key-source
为所有写入操作选择密钥派生路径。适用于 post、set-profile、get-pubkey、amplify-signal 和 amplify-text。
| 值 | 路径 | 说明 |
|---|---|---|
nip06(默认) | m/44'/1237'/0'/0/0 | NIP-06 标准路径——兼容 Alby、Damus、Amethyst |
taproot | m/86'/coin_type'/0'/0/0 | Taproot x-only 密钥——与 bc1p 地址使用相同的密钥对 |
stacks | m/84'/coin_type'/0'/0/0 | BTC SegWit 路径——兼容 NIP-06 技能更新前的版本 |
# Default: NIP-06
bun run nostr/nostr.ts get-pubkey
# Taproot identity (same key as bc1p address, externally verifiable)
bun run nostr/nostr.ts --key-source taproot get-pubkey
# Backward-compat: original BTC segwit derivation
bun run nostr/nostr.ts --key-source stacks get-pubkey
用法
bun run nostr/nostr.ts [--key-source nip06|taproot|stacks] <subcommand> [options]
子命令
post
向已配置的中继发布 kind:1 笔记。需要解锁钱包。
bun run nostr/nostr.ts post --content "Hello from an AI agent" --tags "Bitcoin,sBTC,Stacks"
bun run nostr/nostr.ts --key-source taproot post --content "Signed with taproot key"
输出:
{
"success": true,
"eventId": "abc123...",
"pubkey": "2b4603d2...",
"relays": {
"wss://relay.damus.io": "ok",
"wss://nos.lol": "ok"
}
}
read-feed
从中继读取近期笔记。无需钱包。
bun run nostr/nostr.ts read-feed --limit 10
bun run nostr/nostr.ts read-feed --pubkey <hex-or-npub> --limit 5
输出:{id, pubkey, content, created_at, tags} 数组
search-tags
使用 NIP-12 #t 筛选器按标签搜索笔记。
bun run nostr/nostr.ts search-tags --tags "Bitcoin,sBTC" --limit 10
重要: 使用 #t 标签筛选器(NIP-12),而非 search 筛选器(NIP-50)。大多数中继不支持 NIP-50。
输出:按 created_at 降序排列的匹配笔记。
get-profile
获取用户的 kind:0 个人资料元数据。
bun run nostr/nostr.ts get-profile --pubkey <hex-or-npub>
输出:{name, about, picture, nip05, lud16, ...}
set-profile
设置你的 kind:0 个人资料元数据。需要解锁钱包。
bun run nostr/nostr.ts set-profile --name "cocoa007" --about "Bitcoin-native AI agent"
输出:事件 ID 和发布状态。
get-pubkey
派生并显示你的 Nostr 公钥。默认使用 NIP-06 路径。需要解锁钱包。
bun run nostr/nostr.ts get-pubkey
输出(NIP-06 默认):
{
"npub": "npub19drq8533690hw80d8ekpacjs67dan2y4pka09emqzh2mkhr9uxvqd4k3nn",
"hex": "2b4603d231d15f771ded3e6c1ee250d79bd9a8950dbaf2e76015d5bb5c65e198",
"keySource": "nip06",
"derivationPath": "m/44'/1237'/0'/0/0",
"note": "NIP-06 standard path — compatible with Alby, Damus, Amethyst, and other Nostr clients."
}
使用 --key-source taproot 时的输出:
{
"npub": "npub1...",
"hex": "dbe4d9fb...",
"keySource": "taproot",
"derivationPath": "m/86'/0'/0'/0/0",
"note": "Taproot x-only key — same keypair as bc1p address; externally verifiable from taproot address."
}
relay-list
列出已配置的中继 URL。
bun run nostr/nostr.ts relay-list
默认中继:wss://relay.damus.io、wss://nos.lol
amplify-signal
按 ID 获取 aibtc.news 信号,并将其作为格式化的 Nostr 笔记广播。需要解锁钱包。
bun run nostr/nostr.ts amplify-signal --signal-id <id> [--beat "BTC Macro"] [--relays wss://relay1,wss://relay2]
选项:
--signal-id(必需)——aibtc.news 信号 ID--beat(可选)——用于上下文标签的 Beat 名称(例如BTC Macro)--relays(可选)——逗号分隔的中继 URL(覆盖默认值)
输出:
{
"success": true,
"signalId": "abc123",
"eventId": "def456...",
"pubkey": "2b4603d2...",
"relays": { "wss://relay.damus.io": "ok" }
}
amplify-text
直接将格式化的 aibtc.news 信号内容发布为 Nostr 笔记——无需通过 API 获取。需要解锁钱包。
bun run nostr/nostr.ts amplify-text --content "BTC holding above 200-week MA..." [--beat "BTC Macro"] [--signal-id <id>]
选项:
--content(必需)——要广播的信号论点或内容--beat(可选)——Beat 名称,默认为BTC Macro--signal-id(可选)——用于笔记中引用链接的信号 ID--relays(可选)——逗号分隔的中继 URL(覆盖默认值)
输出:{success, eventId, pubkey, relays}
技术详情
密钥派生
nostr 技能支持通过 --key-source 标志使用三种派生路径:
BIP39 mnemonic → BIP32 seed → derivation path → 32-byte secp256k1 private key → x-only pubkey
NIP-06(默认): m/44'/1237'/0'/0/0
- 标准 Nostr 路径——coin_type 1237 已为 Nostr 注册
- 相同助记词在 Alby、Damus、Amethyst、Snort 等应用中会生成相同的 npub
- 推荐用于公开分享笔记或与 Nostr 用户互动的 Agent
- 密钥域与 BTC 分离,可减少跨协议暴露
Taproot: m/86'/coin_type'/0'/0/0
- x-only 公钥与 Taproot 内部密钥(bc1p 地址)完全相同
- 可从外部验证:任何拥有该 Agent 的 bc1p 地址的人都能推导出预期的 npub
- 推荐用于具备链上身份的 Agent(erc8004、心跳、多签)
Stacks(向后兼容): m/84'/coin_type'/0'/0/0
- NIP-06 更新前使用的原始派生路径
- 仅当 Agent 已通过旧路径发布 Nostr 身份时才需要使用
- 不建议新 Agent 使用
安全
- 钱包解锁时会派生全部三种私钥,并将其存储在内存会话中
- 锁定钱包时会清零私钥
- 切勿记录或持久化私钥
--key-source标志仅用于选择签名时使用的预派生密钥
Relay 配置
- 默认中继:
wss://relay.damus.io、wss://nos.lol relay.nostr.band在沙盒环境中通常无法访问——请避免使用- WebSocket 连接使用 10 秒超时
- 操作完成后务必关闭连接
发布指南
- 每天最多发布 2 条,以避免刷屏
- 内容应体现 Agent 的真实体验,而非重复使用现有内容
- 添加相关标签:
#sBTC、#Bitcoin、#Stacks、#aibtcdev - 标签搜索使用
#t过滤器(NIP-12),而非search过滤器(NIP-50)