Wire up a Slack integration for team Claude Code use (2026 tutorial)
Tutorial · Intermediate

Wire up a Slack integration for team Claude Code use

Build a Slack app that lets your team invoke Claude Code from any channel — for quick lookups, incident context, or triggering workflows — without leaving Slack.

40 minIntermediateUpdated Aug 2026

Prerequisites

  • A Slack workspace where you can create apps
  • A server or serverless environment to host the integration (Vercel, AWS Lambda, or similar)
  • Claude API key with billing configured
  • Basic familiarity with Slack Bolt or similar frameworks

What you'll learn

  • The Slack integration patterns that work vs the ones that break
  • How to auth users to the underlying Claude Code capabilities
  • How to handle async responses (Claude takes seconds; Slack expects fast ack)
  • What to expose via Slack vs keep in the terminal
  • How to prevent abuse and control costs

Slack integration is high-value and easy to get wrong. Done well, your team can ask Claude for context during incidents, kick off workflows, and get answers without switching windows. Done poorly, it becomes a source of runaway costs, security incidents, and message noise.

This tutorial builds the integration end-to-end — the Slack app, the backend, the auth model, the cost controls. Every design choice includes why. By the end you'll have a working integration and understand which parts are essential vs optional.

1
Decide what to actually expose

The biggest mistake in Slack-Claude integration: exposing everything. "Ask Claude anything from Slack!" sounds great. In practice: expensive, noisy, and creates security surface.

What works: expose a small set of specific commands. Not "Claude, do anything" but "run this specific workflow." For example:

  • /claude-incident SENTRY-4471 — pulls incident context, posts summary
  • /claude-status — quick health summary of your services
  • /claude-lookup docs security-headers — internal doc lookup
  • /claude-explain PR#442 — one-line summary of what a PR does

Each command has a defined scope. No open-ended chat. This isn't a limitation — it's the design that makes the integration sustainable.

The rule

If you're not sure whether to expose a command, don't. Adding a command later is easy. Removing one after your team relies on it is hard.

2
Create the Slack app

Go to api.slack.com/apps and create a new app. For each command you decided on, add a slash command:

  • Command name: /claude-incident
  • Request URL: your backend endpoint
  • Short description: what the command does
  • Usage hint: parameters expected

Add the required OAuth scopes:

  • commands — receive slash commands
  • chat:write — post responses
  • users:read — identify who invoked the command

Install the app to your workspace. Save the signing secret and bot token — you'll need them for the backend.

3
Build the backend (with async pattern)

Slack expects a response within 3 seconds. Claude Code operations typically take 10-60 seconds. The pattern that handles this:

  1. Ack the slash command immediately with a "working on it..." message
  2. Process the request async — invoke Claude Code, wait for result
  3. Post the actual response using the response_url Slack gave you
src/handlers/claude-incident.ts
import { App } from '@slack/bolt';
import { invokeClaudeCode } from '../claude-client.js';
import { verifyUserPermitted } from '../auth.js';

export function registerIncidentHandler(app: App) {
  app.command('/claude-incident', async ({ command, ack, respond }) => {
    // 1. Ack immediately (Slack requires within 3s)
    await ack({
      response_type: 'ephemeral',
      text: `Investigating ${command.text}... this takes ~30 seconds.`,
    });

    try {
      // 2. Verify the user is permitted
      const permitted = await verifyUserPermitted(command.user_id, 'incident');
      if (!permitted) {
        await respond({
          text: 'You don\'t have permission to run incident investigations.',
          response_type: 'ephemeral',
        });
        return;
      }

      // 3. Invoke Claude Code — this may take 10-60 seconds
      const result = await invokeClaudeCode({
        command: 'incident-investigate',
        args: { incidentId: command.text },
        user: command.user_id,
      });

      // 4. Post the actual response
      await respond({
        text: result.summary,
        blocks: result.blocks,  // rich formatting
        response_type: 'in_channel',  // visible to channel
      });
    } catch (err) {
      await respond({
        text: `Error: ${err.message}. Check logs for details.`,
        response_type: 'ephemeral',
      });
    }
  });
}
Why response_type matters

ephemeral messages are only visible to the invoker. in_channel messages are visible to everyone. Use ephemeral for status updates and errors; use in_channel only for content the whole channel should see (like an incident summary during an active incident).

4
Add user auth and permissions

Not every Slack user should be able to invoke every command. Auth prevents accidental damage and misuse.

The pattern that works: map Slack user IDs to internal identities, then check permissions against those.

src/auth.ts
import { getSlackUserEmail } from './slack-client.js';
import { getEngineerBySlackEmail, getPermissions } from './identity.js';

export async function verifyUserPermitted(slackUserId: string, capability: string) {
  // 1. Get email from Slack user ID
  const email = await getSlackUserEmail(slackUserId);
  if (!email) return false;

  // 2. Map to internal identity
  const engineer = await getEngineerBySlackEmail(email);
  if (!engineer) return false;  // Slack user not in our team

  // 3. Check permission
  const perms = await getPermissions(engineer.id);
  return perms.includes(capability);
}

Capabilities are named specifically: incident, status, lookup. Not everyone needs all of them. On-callers get incident; everyone gets lookup; only specific team members get anything that could touch production data.

Don't skip this

Slack apps are installed workspace-wide by default. Anyone in your Slack can invoke your commands. Without auth, external contractors, ex-employees still in the workspace, or misconfigured integrations can all trigger your commands. The auth layer is essential, not optional.

5
Add cost controls

A Slack integration that's easy to invoke is also easy to run up costs. Basic controls to add:

  • Per-user rate limit: max 10 invocations per hour per user
  • Per-command daily cap: max 100 invocations per day for expensive commands
  • Cost per invocation logging: log the token count and cost per Slack invocation
  • Budget alert: if daily cost exceeds threshold, alert admins

These aren't bureaucratic — they're the difference between a Slack integration that costs $50/month and one that unexpectedly costs $5000/month because someone put it in a loop.

6
Deploy and test

Deploy your backend to your preferred host (Vercel, Lambda, Cloudflare Workers). Update the Slack app's Request URL to point to it.

Test in three scenarios:

  1. Happy path: permitted user runs a valid command; response comes back
  2. Unauthorized user: permission denied cleanly, no info leaked about the underlying system
  3. Failure case: Claude Code invocation fails; error message is helpful, not a stack trace

For the failure case specifically — don't leak internal errors to Slack. "Error: timeout waiting for Claude Code" is fine; the full stack trace with internal paths and IDs is not. Sanitize.

🧪 Try it now

Roll out to just yourself first. Use it for a week. Notice what commands you actually invoke vs which ones you added because they seemed cool. The ones you don't use, remove.

Recap

You built a Slack integration for Claude Code — a limited set of specific commands, user auth via Slack identity, async response pattern, cost controls, and safe error handling.

The pattern that works: expose few commands with clear scope, auth every invocation, handle async properly (ack fast, respond via URL), sanitize errors before they go to Slack, control costs aggressively.

The pattern that fails: "expose Claude to Slack, let everyone chat with it." Slack is not a good LLM chat interface (better ones exist), and exposing full Claude Code from Slack creates security and cost surface with little benefit.

Common gotchas

  • Slack throws 500 after 3 seconds: You didn't ack fast enough. Slack times out at 3 seconds. Always ack immediately, then process async. Use response_url for the delayed response.
  • Users see other users' outputs: Wrong response_type. Ephemeral is per-user; in_channel is public. Default to ephemeral; only use in_channel when the whole channel benefits.
  • Costs spike unexpectedly: Rate limiting isn't tight enough, or a specific command is being invoked in a loop. Check the invocation log per user; someone might have scripted it. Rate limit lower until you understand the pattern.
  • External contractors invoking commands: Auth layer is missing or too permissive. Check the identity lookup carefully — Slack workspace membership is not the same as "should have access to production tools."
  • Long response gets truncated in Slack: Slack has a 3000-character limit per message. For long outputs, either post multiple messages or upload as a snippet/file. The command should know its output length before sending.

Get cctk to skip the boilerplate

Everything in this tutorial is already scaffolded in cctk — commands, subagents, hooks, MCP configs. Install and customize instead of starting from scratch.

npx cctk@latest init Get cctk v1.5.2 →