
Claude Managed Agents research analyst
Claude Managed Agents and Chat SDK power this Slack research bot. Mention it in a channel or send it a DM, and it will search and fetch sources in an Anthropic-managed sandbox before streaming a brief back into the thread.
Each Slack thread maps to one persistent Managed Agents session, so follow-ups retain the thread's prior research context. Vercel Connect owns the Slack app and credentials, while Redis preserves subscriptions, session mappings, and webhook deduplication across deployments.
Stack
| Layer | Choice |
|---|---|
| Surface | Slack via Chat SDK and Vercel Connect |
| Agent | Claude Managed Agents with Claude Sonnet 5 |
| State | Upstash Redis |
| Runtime | Next.js 16 on Vercel |
Quickstart
Requires Node.js 24+, an Anthropic API key with Managed Agents access, Vercel project, and Redis.
1. Clone and install
git clone https://github.com/vercel-labs/claude-research-botcd claude-research-botpnpm install
2. Connect Slack and Redis
Add Slack with Vercel Connect:
vercel linkvercel connect create slack --name claude-research-bot --triggersvercel connect attach slack/claude-research-bot \--project YOUR_VERCEL_PROJECT \--environment production \--triggers \--trigger-path /api/webhooks/slack
Add Upstash Redis from the Vercel Marketplace:
vercel integration add upstash/upstash-kv
3. Create the Managed Agent
Add ANTHROPIC_API_KEY to .env.local, then run:
npm run cma:setup -- --vercel
This one-time command creates the agent and sandbox environment, writes both IDs to .env.local, and adds them to the linked Vercel project.
4. Deploy
vercel env add ANTHROPIC_API_KEYvercel deploy --prod
Invite the bot to the Slack channels where it should answer or message the bot directly.
In a thread with one human participant, follow-ups do not need another @mention. Once multiple humans participate, the bot responds only when explicitly mentioned.
Environment variables
| Variable | Required | Default | What it does |
|---|---|---|---|
ANTHROPIC_API_KEY | Yes | None | Authenticates Claude Managed Agents |
CLAUDE_AGENT_ID | Yes | None | Persistent analyst created by npm run cma:setup |
CLAUDE_ENVIRONMENT_ID | Yes | None | Anthropic-managed sandbox created by setup |
REDIS_URL | Yes | None | Stores subscriptions, deduplication, and thread/session mappings |
SLACK_CONNECTOR | Yes | None | Vercel Connect Slack connector UID |
BOT_USERNAME | No | claude-research-bot | Chat SDK bot name |
CLAUDE_DEBUG_MODE | No | false | Posts per-turn diagnostics and a Claude Console link |
Customize the analyst
The model and system prompt live in scripts/cma/lib/agent.ts.
Publish changes as a new agent version:
npm run cma:update
Anthropic pins each session to the agent version that created it, so test changes in a new Slack thread. Use npm run cma:update for prompt changes, not npm run cma:setup.
The setup disables Bash because the analyst reads untrusted web pages. If Bash were auto-approved with open network access, a malicious page could trick it into sending conversation data to an attacker.
Debug mode
Set CLAUDE_DEBUG_MODE=true to post a compact diagnostics table after every completed turn. It includes duration, model requests, token and prompt-cache usage, web searches and fetches, and a Claude Console session link.
Key files
| File | Purpose |
|---|---|
src/lib/bot.ts | Chat SDK configuration and Slack handler registration |
src/lib/research-handler.ts | Participant policy and thread/session orchestration |
src/lib/managed-agents.ts | Session validation, turn queue, event stream, and token previews |
src/lib/config.ts | Typed runtime configuration and required env validation |
src/lib/debug-card.tsx | Debug Mode diagnostics card |
src/app/api/webhooks/[platform]/route.ts | Fast webhook acknowledgement and background dispatch |
scripts/cma/cli.ts | Dispatches setup, update, and archive commands |
scripts/cma/lib/agent.ts | Model, system prompt, and tool posture |
scripts/cma/setup.ts | One-time agent and environment provisioning |
scripts/cma/update.ts | Publishes a new agent version |
scripts/cma/archive.ts | Archives Managed Agents resources |
scripts/cma/lib/env.ts | Shared local environment loading and persistence |
Cleanup
Archive the persistent Anthropic resources when finished:
npm run cma:archive
Because archiving is permanent, confirm both Managed Agents IDs before running the command.


