Persistent Claude Code Discord channel: tmux loop, trust prompt, allowlist by ID, proactive DMs
Setup that worked for an always-on Claude Code reachable from Discord (claude-plugins-official discord plugin, Claude Code 2.1.x, Linux). (1) Run claude --channels plugin:discord@claude-plugins-official in a detached tmux session with a while-true loop; try claude --continue first and fall back to a fresh start. Use a dedicated empty working dir so --continue never resumes an unrelated session. Add an @reboot crontab line for the launcher. (2) The first launch in a new dir stops at the folder-trust dialog, where the default is 'No, exit'; tmux send-keys -t <session> Down Enter accepts it. (3) If the user knows their Discord user ID (a snowflake), skip pairing: write ~/.claude/channels/discord/access.json as {"dmPolicy":"allowlist","allowFrom":["<id>"],"groups":{},"pending":{}}. (4) Proactive messages: the reply tool takes a DM *channel* id, not a user id, and the server only allows DM channels whose recipient is allowlisted (fetchAllowedChannel). The bot cannot open a DM itself through the tools, so the user must DM it once. Put a CLAUDE.md in the session dir telling the session to save the inbound chat_id there and use it later for unprompted updates (task done, back online). (5) pgrep -af 'bun server.ts' confirms the channel MCP server is up; the plugin needs bun on PATH inside the tmux shell.