- name
Add Discord bot channel integration via Chat SDK.
SKILL.md
The skill file stays in the publisher's repository.
Paste the copied command in a terminal. It installs this SKILL.md into that agent.
npx skills add nanocoai/nanoclaw --skill add-discord -a cursor -yPaste the copied command in a terminal. It installs this SKILL.md into that agent.
npx skills add nanocoai/nanoclaw --skill add-discord -a claude-code -yPaste the copied command in a terminal. It installs this SKILL.md into that agent.
npx skills add nanocoai/nanoclaw --skill add-discord -a codex -yPaste the copied command in a terminal. It installs this SKILL.md into that agent.
npx skills add nanocoai/nanoclaw --skill add-discord -a grok -ySend the copied message in a Grok Bot chat. The Bot fetches this SKILL.md from GitHub and adds it to the skills all your Bots share.
Install this skill: https://github.com/nanocoai/nanoclaw/tree/HEAD/.claude/skills/add-discordFrom the publisher
Adds Discord bot support via the Chat SDK bridge. NanoClaw doesn't ship channels
in trunk — this skill copies the Discord adapter in from the channels branch.
The mechanical steps under Apply carry nc: directive fences: an agent
reads the prose and applies them, and a parser can apply them deterministically
from the same document. Every directive is idempotent, so the whole skill is
safe to re-run; anything a parser can't apply falls back to the prose beside it.
Fetch the channels branch and copy the Discord adapter, its registration test
and its gateway test into src/channels/ (overwrite — the branch is canonical):
src/channels/discord.ts
src/channels/discord-registration.test.ts
src/channels/discord-gateway.test.ts
Append the self-registration import to the channel barrel (skipped if the line is already present). This one line is the skill's only reach-in into core:
import './discord.js';
Adapter 4.41.1 drops every server message that @mentions anyone. It serializes the Discord gateway packet after discord.js has patched it in place into a circular object, so the forward throws and the message never arrives. The committed pnpm patch backports the fix from adapter 4.42.0. Register it before installing the package. pnpm reapplies it after every install and fails if the pinned package drifts away from the patch:
patches/@[email protected]
Re-runs only: the step below skips an adapter that is already installed, so this
pnpm add moves it to 4.41.1 with the patch. A fresh install gets the patch
from the step below (pnpm rejects a patch for a package that isn't installed
yet):
pnpm pkg set 'pnpm.patchedDependencies[@chat-adapter/[email protected]]=patches/@[email protected]'
if node -e 'const p = require("./package.json"); process.exit(p.dependencies?.["@chat-adapter/discord"] || p.devDependencies?.["@chat-adapter/discord"] ? 0 : 1)'; then pnpm add @chat-adapter/[email protected]; fi
Adapter 4.42.0 and later carry the fix. Installs keep this registration, so the
bump past 4.41.1 must replace this step with an effect:refresh step that
removes it before the install, or refreshes fail with ERR_PNPM_UNUSED_PATCH.
Pinned to an exact version — the supply-chain policy rejects ranges and latest:
@chat-adapter/[email protected]
Build first: it guards the typed createChatSdkBridge(...) core call and proves
the dependency is installed. Then run the two tests.
pnpm run build
pnpm exec vitest run src/channels/discord-registration.test.ts src/channels/discord-gateway.test.ts
discord-registration.test.ts imports the real channel barrel and asserts the
registry contains discord. It goes red if the import line is deleted or drifts,
if the barrel fails to evaluate, or if @chat-adapter/discord isn't installed
(the import throws) — so it also covers the dependency from step 4. End-to-end
delivery against a real server is verified manually once the service runs.
discord-gateway.test.ts feeds the installed adapter a server message that
@mentions the bot, with the in-place change discord.js makes to it, and asserts
the message reaches the webhook as sent. It goes red when the adapter lacks the
step 3 patch.
Discord app setup is human and interactive — no parser can click through the Discord Developer Portal. The adapter is installed and registered, but it can't receive a message until the bot exists, has Message Content Intent, and shares a server with you. Tell the user:
Create the Discord bot:
1. Go to https://discord.com/developers/applications → New Application. Name it (e.g. "NanoClaw Assistant").
2. Bot tab → Add Bot if needed → Reset Token, then copy the Bot Token (it's shown only once).
3. Bot tab → Privileged Gateway Intents → enable Message Content Intent.
4. OAuth2 → URL Generator → Scopes: bot; Bot Permissions: Send Messages, Read Message History, Add Reactions, Attach Files, Use Slash Commands.
5. Open the generated URL and invite the bot to a server you're also in (a personal server is fine) — the bot can only DM you once you share a server.
Paste the Bot Token (it's shown only once). You don't paste the Application ID or the Public Key by hand — the bot's own application record carries both, so a single call derives them from the token:
Paste the Bot Token — Bot tab. Click `Reset Token` if you need a new one.
Read the application's own record. GET /oauth2/applications/@me returns the
Application ID (id), the Public Key (verify_key), and your own account as the
app's owner (owner.id) — so the App ID, the Public Key, and your Discord user ID
all come from this one call instead of being copied by hand. A bad token fails
here, before the restart, rather than silently later:
curl -sf https://discord.com/api/v10/oauth2/applications/@me -H "Authorization: Bot {{bot_token}}"
Store the token and the two derived credentials — the adapter reads them from
.env and fails to start without DISCORD_PUBLIC_KEY and DISCORD_APPLICATION_ID
(set-if-absent, so a value you've already filled in is never overwritten):
DISCORD_BOT_TOKEN={{bot_token}}
DISCORD_APPLICATION_ID={{application_id}}
DISCORD_PUBLIC_KEY={{public_key}}
Restart the service so it loads the Discord adapter and the credentials you just stored, and wait for its CLI socket before resolving:
bash setup/lib/restart.sh
The bot can only DM you once it shares a server with you. If you didn't already invite it via the OAuth2 URL Generator while setting up the app, do it now: add the bot to a server you're also in (a personal server is fine). Tell the user:
Open the invite link — https://discord.com/oauth2/authorize?client_id={{application_id}}&scope=bot&permissions=2147584064 — and add the bot to a server you're also in (a personal server works fine); the bot can only DM you once you share a server. If you already invited it while setting up the app, you can skip this.
The agent talks to you in your direct-message channel with the bot. Your Discord
user ID was already derived as the application's owner (owner_handle), so all
that's left is to open the DM and read back its channel id.
Open the DM with POST /users/@me/channels and take the channel id it returns as
the conversation address discord:@me:<channelId> (if Discord refuses, the bot
doesn't share a server with you yet — invite it, then retry):
curl -s -X POST https://discord.com/api/v10/users/@me/channels -H "Authorization: Bot {{bot_token}}" -H "Content-Type: application/json" -d '{"recipient_id":"{{owner_handle}}"}' | jq -er '.id // error("no channel id") | "discord:@me:" + .'
owner_handle and platform_id are what the owner-wiring step needs. The
greeting goes out over the DM channel, which works as soon as the bot shares a
server with you.
If you're in the middle of /setup, return to the setup flow now. Otherwise wire
this channel with /init-first-agent (or /manage-channels).
discorddiscord:@me:{dmChannelId} for the owner DM (e.g. discord:@me:1399...), discord:{guildId}:{channelId} for server channels — both IDs required for channels.discord:{guildId}:{channelId} — both IDs are required.The Bot Token paste is rejected. The token must be at least 50 characters of letters, digits, dots, underscores, and hyphens — a real Bot Token has two . separators. It lives under Bot → Reset Token in the Developer Portal and is shown only once; reset to get a fresh one. The short numeric Application ID and the OAuth2 Client Secret are different values and won't pass.
applications/@me returns 401. The token was reset since you copied it, or a stray space/newline came along with the paste. Reset the token in the Bot tab and re-run the check — it fails here on purpose, before the restart, while the credential is still cheap to fix.
The bot is online but never sees your messages. Two usual causes: Message Content Intent is off (Bot tab → Privileged Gateway Intents), so message bodies arrive empty and nothing triggers; or the bot doesn't share a server with you — in which case POST /users/@me/channels also refuses. Open the invite URL and add the bot to a server you're in, then retry.
pnpm add, install or remove fails with ERR_PNPM_UNUSED_PATCH for @chat-adapter/[email protected]. The adapter was moved off 4.41.1, the version the patch is for. Move it back with pnpm add @chat-adapter/[email protected], or re-run /add-discord. Don't drop the patch to keep a newer adapter: it needs a newer chat than the 4.41.1 that core pins, so the build fails with TS2322. To remove Discord, follow REMOVE.md, which deletes the patch registration first.
Adapter looks installed but Discord never connects. Run pnpm exec vitest run src/channels/discord-registration.test.ts — red means the barrel import or the @chat-adapter/discord install drifted, so re-run the Apply steps. If it's green, the service probably hasn't restarted since the credentials were stored: bash setup/lib/restart.sh, then check logs/nanoclaw.error.log for missing DISCORD_PUBLIC_KEY / DISCORD_APPLICATION_ID complaints.
© 2026 Skills Rack.
---name: add-discorddescription: Add Discord bot channel integration via Chat SDK.---# .claude/skills/add-discord/SKILL.mdFAQ
Download .claude/skills/add-discord/SKILL.md from the publisher, or copy the path and open the repository. PlugMCP lists the skill and does not host the file.
The publisher keeps it at https://github.com/nanocoai/nanoclaw.
Claude, Cursor, Codex, and Grok Build can read a SKILL.md you add from the publisher's repository. Grok Bot installs it when you send the skill's GitHub folder link in a chat.