Skip to content

Slack Integration: Delegate Coding Tasks from Chat

Core Concept LearningAugust 18, 20269 min read

Slack is where your team's decisions happen in real time. Integrating Claude Code into Slack means your engineers can request code tasks ("Fix the auth bug", "Refactor the payment module") without leaving chat, and get results posted back with status updates. This guide teaches how to wire slash commands that invoke Claude Code, monitor task progress, handle approvals, and maintain audit logs—turning Slack into a central hub for code work.

The pattern is simple: engineer types /claude fix auth bug, a Slack app receives the command, spins up Claude Code in the background, and updates the channel with progress. When done, Claude posts a summary (changes made, any issues found, link to PR). For on-call engineers and distributed teams, this keeps communication in one place and removes friction from quick coding tasks. For time-based automation that doesn't require a Slack trigger, see routines and scheduled automation; for dispatching tasks while away from your desk, the mobile app is the companion surface.

Slash Commands and Slack App Setup

A Slack slash command is a custom trigger that runs code when typed in Slack. For example, /claude review-pr sends a request to your backend, which invokes Claude Code and posts results back. To set up:

1. Create a Slack app at api.slack.com. 2. Under "Slash Commands", register a new command (e.g., /claude). 3. Provide a Request URL—your backend API endpoint that handles the command. 4. Set a signing secret; use it to verify Slack's requests (prevents forgery). 5. Subscribe to events (e.g., app_mention) if you want Claude to respond to @app mentions in channels.

When a user types /claude task-name, Slack sends a POST request to your backend with the command text, user ID, channel, and workspace context. Your backend parses the command, invokes Claude Code, and responds with acknowledgment (Slack waits max 3 seconds for a response, so return immediately and update the channel asynchronously).

Quick reference

  • Slash commands are workspace-scoped; users see them after installing your app.
  • Request URL must respond within 3 seconds or Slack shows a timeout error.
  • Use response_type: 'in_channel' to post results visibly; 'ephemeral' hides results from others.
  • Verify request signatures: SHA256(HMAC with signing secret) to prevent replay attacks.
  • Command text is limited to 500 characters; for longer tasks, use message threads.

Remember this

A Slack slash command triggers an HTTP POST to your backend with user/channel context; respond in 3 seconds, then run Claude Code asynchronously and update the channel.

Delegating Tasks with Context

When an engineer runs /claude refactor auth module, your backend must gather context (repo URL, branch, relevant files) and send it to Claude Code. The workflow is:

1. Receive command: Parse the slash command text (e.g., "refactor auth module"). 2. Gather context: Clone or sync the repo; identify files mentioned (or all Python files if generic). 3. Invoke Claude Code: Run Claude with a prompt like "Refactor the auth module for DRY principles; output a diff and commit message". 4. Monitor execution: Claude Code runs in a background process; poll its status or use a callback. 5. Post results: Share findings in Slack (summary, metrics, link to branch).

Context is critical. If you just pass "refactor auth module" without file context, Claude works blind. Better: include the full auth module code, recent commits, and coding standards from your repo (README, linting config).

Quick reference

  • Store repo credentials (SSH key, GitHub token) securely; use environment variables or secret managers.
  • Limit task scope: 'refactor auth module' is clearer than 'improve code quality'.
  • Version control: push Claude's changes to a branch (e.g., claude/task-name), not main.
  • Time limits: set a 10-minute timeout for Claude tasks; abort and notify if exceeded.
  • Audit: log all Claude invocations (who, what, when, result) for compliance.

Remember this

Task delegation requires gathering repo context (files, standards, recent state), passing it to Claude Code with a clear prompt, and monitoring execution before posting results.

Status Updates and Real-Time Notifications

Async task execution means the user doesn't wait. Instead, update them in real time:

1. Acknowledge immediately: Reply in Slack within 3 seconds with "Starting refactor...". 2. Monitor progress: Use background jobs (e.g., Bull queue in Node.js) or AWS Lambda with callbacks. 3. Post updates: As Claude Code runs, edit the Slack message with progress ("Step 1/4: Analyzing code..."). 4. Post results: When complete, replace the message with findings (lines changed, new tests added, any errors). 5. Link to PR: Include a link to the auto-created PR so engineers can review and merge.

Slack message threads make this seamless. The original slash command response posts in the thread; subsequent updates (progress, results) add replies to that thread, keeping the main channel clean.

Quick reference

  • Slack Message Updates: use response_url or chat.update API to edit messages after posting.
  • Thread-based updates: Post main result in thread to avoid flooding main channel.
  • Reaction emojis: Add ✅ when complete, ⚠️ if issues found, ❌ if failed.
  • Timeouts: If Claude takes >15 min, post a timeout message and kill the process.
  • Errors: Post full error messages in a thread; include debugging hints.

Remember this

Status updates keep users informed: acknowledge immediately, post progress edits, then share final results with links to PRs and key metrics.

Approval Flows and Human Review

Not all Claude tasks should auto-merge. For risky changes (auth, payments, schema), require approval:

1. Claude proposes: Claude generates code and posts a summary in Slack. 2. Request approval: Include a button ("Approve", "Request Changes", "Reject") in the Slack message. 3. Handle response: When clicked, log the decision and proceed (approve = merge PR, reject = close branch). 4. Audit trail: Every approval/rejection is logged with the approver's name and timestamp.

Slack's Block Kit allows interactive buttons. When a user clicks "Approve", Slack sends a payload to your backend; parse it, verify permissions, then proceed with the merge.

Quick reference

  • Block Kit: Use button_click interactions in Slack messages for approval UI.
  • Permissions: Only allow specific users (team leads, security team) to approve risky tasks.
  • Timeouts: If approval is not received in 24 hours, close the PR and notify.
  • Escalation: For rejected changes, create an issue for the human to manually review.
  • Notifications: Notify the requestor and approver of the decision in a Slack thread.

Remember this

Approval flows use Slack buttons; when clicked, verify permissions and proceed with merge or cleanup; log all decisions for audit.

Threading and Conversation Context

Slack threads keep related messages together. If Claude needs clarification on a task, use threads:

1. Initial command: User runs /claude fix auth bug. 2. Acknowledgment: Bot posts "Starting investigation..." in the thread. 3. Clarification: If Claude needs details, bot asks "Is this the file path? src/auth/jwt.ts" as a thread reply. 4. Refinement: User replies in thread: "Yes, and also check src/auth/oauth.ts". 5. Execution: Claude restarts with refined context and posts final results in thread.

This keeps all context in one place; reviewing the thread shows the full conversation and decisions made.

Quick reference

  • Use thread_ts in Slack API calls to post replies within a thread.
  • Thread timestamps make it easy to link back to the original request.
  • Read thread history when Claude asks for clarification; context is already there.
  • Archive threads: After completion, users can export threads for documentation.
  • Mentioning: Use @user mentions in thread to notify someone of a decision.

Remember this

Threads group related messages (request, clarifications, results) in one place; Claude can ask for clarification in a thread without cluttering the main channel.

Connecting Your Slack Workspace to Claude Code

Setup requires:

1. Create a Slack app at api.slack.com; note the signing secret and bot token. 2. Deploy a backend (Node.js, Python, Go) that handles slash commands. This backend needs: - Ability to receive POST requests from Slack. - Access to your Git repos (SSH key or GitHub token). - Ability to run Claude Code CLI or call Claude API. 3. Set permissions: Your Slack bot needs scopes: - commands (respond to slash commands) - chat:write (post messages) - reactions:write (add reaction emojis) - users:read (identify users) 4. Test: Type /claude help in Slack; verify the bot responds.

Example Node.js backend snippet:

1const express = require('express');2const app = express();3 4app.post('/slack/commands', (req, res) => {5  const { command, text, user_id, channel_id, response_url } = req.body;6 7  // Verify signature8  if (!verifySignature(req)) {9    return res.status(401).send('Unauthorized');10  }11 12  // Respond immediately13  res.json({ text: 'Starting task...' });14 15  // Run Claude async16  runClaudeTask(text, channel_id, response_url);17});18 19function runClaudeTask(task, channel_id, response_url) {20  exec(`claude-code run "${task}"`, (err, stdout) => {21    if (err) {22      postToSlack(response_url, `Error: ${err.message}`);23    } else {24      postToSlack(response_url, `Done: ${stdout}`);25    }26  });27}

Quick reference

  • Signing secret: Use it to verify Slack requests; prevents impersonation.
  • Bot token: Use it to post messages via Slack API (chat.postMessage, reactions.add).
  • Scopes must be approved by workspace admin during app installation.
  • Use a job queue (Bull, Celery, or AWS SQS) for long-running tasks.
  • Environment variables: Store secrets (API keys, tokens) in .env or secret manager.

Remember this

Connecting Slack to Claude Code requires a Slack app (signing secret, bot token, scopes), a backend that verifies requests and runs Claude, and proper permissions.

Real Example: On-Call Bug Fixes via Slack

2 AM. Production alert: "Payment API returning 503." On-call engineer is half-asleep. Instead of SSH-ing and debugging:

1. Slack message: /claude investigate payment api 503 errors in src/payments/api.ts 2. Claude analyzes: Reads recent logs, finds a null pointer in retry logic, suggests a fix. 3. Slack update: Posts "Found issue: retry logic missing null check on line 42. Fix: add if (response) check." 4. Auto PR: Claude creates a branch, commits the fix, opens a PR with the diff. 5. Approval: On-call engineer clicks "Approve" in Slack. 6. Auto merge: PR is merged, CI runs, fix is deployed. 7. Notification: Slack posts "✅ Deployed! Response time back to normal."

Total time: 2 minutes instead of 15. No context switching, no terminal commands. The on-call engineer reviews the fix in Slack and approves with one click.

Quick reference

  • On-call rotation: Post the on-call engineer's name in a Slack channel; they see alerts and messages there.
  • Escalation: If fix fails, automatically page the next level (team lead, architect).
  • Rollback: Include a button to revert the change if the fix makes things worse.
  • Metrics: Post charts showing response time/error rate before/after the fix.
  • Runbook: Include links to runbooks or documentation in the fix message.

Remember this

On-call bug fixes via Slack reduce context switching and response time; Claude analyzes, proposes, and auto-creates a PR for approval in one workflow.

Permissions and Audit Logging

Not everyone should be able to run arbitrary Claude tasks. Implement permissions:

1. Role-based access: Only engineers in the "code-review" team can run /claude refactor. 2. Dangerous task restrictions: Tasks like "delete database records" require explicit approval + two-factor confirmation. 3. Audit log: Every Claude invocation is logged with user, task, result, timestamp, and approval status. 4. Retention: Keep logs for at least 90 days; archive after 1 year for compliance.

Example permission matrix:

| Task | Junior Dev | Senior Dev | Tech Lead | All | |------|-----------|-----------|-----------|-----| | review-pr | ✅ | ✅ | ✅ | Yes | | refactor-module | ❌ | ✅ | ✅ | No | | delete-records | ❌ | ❌ | ✅ | No |

In your backend, check the user's role before invoking Claude Code. Log the decision (approved, denied, why).

Quick reference

  • Slack user ID lookup: Use users.info API to identify the user; map to internal role.
  • Database: Store audit logs in a database (PostgreSQL, MongoDB) for querying.
  • Retention policy: Document how long logs are kept; comply with GDPR, SOC 2.
  • Notifications: Alert security team if someone attempts a denied task.
  • Review audit logs weekly: Look for unusual patterns (spam, repeated failures).

Remember this

Permissions restrict who can run certain tasks; audit logs track every invocation for compliance and security; check role before invoking Claude.

Key takeaway

Slack + Claude Code turns chat into a code automation hub. Engineers request tasks, Claude executes, humans approve, and results land automatically. For distributed teams and on-call scenarios, this workflow is a significant time saver.

Practice: Set up a simple Slack bot that listens for /claude test and runs a basic linting task on your repo. Expected result: bot responds with "Linting in progress..." then posts lint report in a thread. Test by running the command; verify you see the lint output. Once working, add an approval button that triggers a PR merge.

Share:
PK

Polo Khan

Lead Author & Systems Architect

Software engineer and distributed systems architect specializing in backend scalability, cloud-native infrastructure, databases, and AI engineering workflows. Author and maintainer of Core Concept Learning.

Human-Engineered & Fact-CheckedOriginal Visual DiagramsEditorial Standards →Send Feedback

Related Articles

Claude Code has a dense vocabulary because it is more than a chat box beside your editor. The important terms describe w

Read

A developer tells Claude Code to commit changes to main, and Claude Code is about to execute git commit && git push. But

Read

GitHub Actions lets you trigger Claude Code workflows directly from pull requests—enabling @claude mentions in PRs, auto

Read

Explore this topic

Keep learning

Follow a structured path or browse all courses to go deeper.