Claude Code in Slack: one bot, many isolated agent sessions
How we run Claude Code in Slack: one bot, multiple long-lived Claude Code agent sessions, each in its own channel, without them stepping on each other.
From 2026 · 2 min read · Published September 22, 2026
At Pineapples we run Claude Code in Slack: a long-lived Claude Code session for each active project. Each one has its own repo, its own context, and its own Slack channel where the team talks to it. There's also one personal assistant session that coordinates the rest.
The interesting constraint: we didn't want five Slack apps to set up, approve, and rotate tokens for. We wanted one Slack app, and a guarantee that a message in #project-a reaches the project A agent and nobody else.
Multiple Claude Code sessions, isolated through state
The Slack bridge is a Claude Code channel plugin. Every session loads the same plugin with the same bot token, but each gets its own state directory with its own access file, which allow-lists exactly one channel.
default_targets() { if [ "$#" -eq 0 ]; then projects_names; else printf '%s\n' "$@"; fi; }
state_dir() { printf '%s/%s' "$STATE_ROOT" "$1"; }Each session is launched with its own SLACK_STATE_DIR pointing at that directory. The bot receives every event, but each session only acts on messages from its own channel. Routing is configuration, not code.
Surviving reboots
Sessions are started with claude --continue under a macOS LaunchAgent, so if the machine restarts, each agent comes back into its existing conversation with its context intact. Scheduled work keeps running without anyone logging in to babysit it.
A small CLI wraps the lifecycle: status, start, stop, and doctor to check that tokens, state directories, and channel access all line up.
Rules that matter more than code
A few operating rules ended up being as important as the tooling:
- Never restart another agent's session unprompted. It may be halfway through a task.
- The coordinator coordinates. The personal assistant can check status and relay requests, but project work happens in the project's own session, where the context lives.
- Outward-facing actions need a human. Agents can draft; people send.
The big takeaway: once agents are long-lived, they're less like scripts and more like teammates. They need their own space, clear boundaries, and a way to be reached. Slack channels turn out to be a surprisingly good fit for all three.
Related: AGENTS.md and a codebase AI coding agents can work in · An MCP gateway with constant context cost: 116 tools behind 7