> ## Documentation Index
> Fetch the complete documentation index at: https://docs.paddockai.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Slack agent you tag

> A Claude Tag-style Slack agent: one agent per channel from the template you map it to, one session per thread, live progress with a Stop button, the reply, and the agent's files in the thread.

This example builds `claudetag`: mention `@claudetag` in a Slack channel and the agent works in the thread. It posts a checklist of what it is doing, edited in place, with a **Stop** button; then its answer; then any files it made. Anyone in the thread steers it by replying. Each channel has its own agent, with its own sandbox and memory, created from the template you map that channel to; each thread is a session of it.

It is one Node service built on [Slack Bolt for JavaScript](https://docs.slack.dev/tools/bolt-js/) and `@paddockai/server`, in [`examples/claudetag`](https://github.com/wenfengwang/paddock/tree/main/examples/claudetag) of the paddock repository, with its Slack app manifest, a Dockerfile, and Kubernetes manifests. The Slack tokens stay in the service, and the agent never talks to Slack.

```mermaid theme={null}
sequenceDiagram
  participant Slack
  participant C as claudetag
  participant P as paddock
  Slack->>C: @claudetag fix the flaky test (channel, thread)
  C->>P: the channel's agent and the thread's session, by metadata
  C->>P: session.send, then session.stream
  P-->>C: turn.started, tool calls and results
  C->>Slack: progress message with Stop, edited as tools run
  P-->>C: assistant message, turn.ended
  C->>Slack: the reply, then the files in outbox/
```

## How it maps Slack onto paddock

| Slack | paddock |
| - | - |
| A channel | An agent with the metadata `app: claudetag` and `slackChannel`, created on the first mention; the newest such agent is the channel's |
| A thread | A session of the channel's agent, with the metadata `slackChannel` and `slackThread`, and the working directory `threads/<channel>-<thread>` |
| A mention, or a reply in the thread | `session.send` with the author's mention, such as `<@U012AB3CD>: fix the flaky test` |
| The progress message | The turn's `turn.started`, `tool_call`, `tool_result`, and `turn.ended` events from `session.stream`, at most one edit every 1.5 seconds |
| The Stop button | `session.stop()`, if the turn the button belongs to is still running (`session.turns.get`) |
| The reply | The turn's last assistant message, as Markdown |
| Files | What the agent wrote into `outbox/` in its working directory, read with `agent.files` after the turn, uploaded, and deleted |

paddock is the only state the service keeps: it finds a channel's agent and a thread's session with a metadata filter, so it needs no database. It remembers recent threads in memory, so a reply in a thread it is not in costs no lookup.

```ts theme={null}
const channel = "C0123ABCDEF";
const thread = "1700000000.000100";

const { data } = await paddock.sessions.list({
  metadata: { app: "claudetag", slackChannel: channel, slackThread: thread },
  limit: 1,
});
const threadSession = data[0] ?? (await agent.sessions.create({
  cwd: `threads/${channel}-${thread}`,
  metadata: { app: "claudetag", slackChannel: channel, slackThread: thread },
}));
await threadSession.send("<@U012AB3CD>: fix the flaky test");
```

## Run it

1. In the repository, build the SDK and install the example:

   ```sh theme={null}
   cd examples/claudetag
   pnpm sdk && pnpm install
   ```

2. At [api.slack.com/apps](https://api.slack.com/apps), create an app **From a manifest** with the example's `manifest.yaml`, install it to your workspace, and copy the bot token (`xoxb-…`). Under **App-Level Tokens**, create a token with `connections:write` (`xapp-…`) for Socket Mode.

3. Copy `.env.example` to `.env` and set `SLACK_BOT_TOKEN`, `SLACK_APP_TOKEN`, and `PADDOCK_API_KEY`. Without a key, the service uses the CLI's login.

4. `pnpm dev`, then in a channel `/invite @claudetag` and mention it.

Socket Mode needs no public URL. In production, set `SLACK_MODE=http` with `SLACK_SIGNING_SECRET`: the service serves Slack's Events API at `POST /slack/events`, verifies every request's signature, answers the URL verification challenge, and acknowledges within Slack's 3 seconds. Run one instance.

## Map channels to templates

A channel's agent comes from the built-in `claude-code-native` unless you map the channel to a template of your own in `claudetag.yaml`:

```yaml claudetag.yaml theme={null}
defaultTemplate: claude-code-native
channels:
  C0123ABCDEF: github-pr      # its latest version when the agent is created
  C0456GHIJKL: research@3
agentSetup:
  github-pr:                  # added to every agent created from github-pr
    mcp:
      - name: github
        url: https://api.githubcopilot.com/mcp/
        headers:
          Authorization: Bearer ${GITHUB_TOKEN}
    env:
      - name: GITHUB_TOKEN
        value: ${GITHUB_TOKEN}
```

`agentSetup` adds MCP servers and environment variables to every agent created from a template, with `${VAR}` read from the service's environment, so no template document carries a token. From Slack, `/claudetag status` shows the channel's agent, and `/claudetag template github-pr@2` gives the channel a new agent from that template for the threads started next. An agent never changes template, so a new mapping always means a new agent; threads already started keep theirs.

### A template that opens pull requests

The example's `templates/github-pr.yaml` is Claude Code with a system prompt for turning a request into a pull request. Its system prompt replaces Claude Code's own, so it states the whole job:

```yaml templates/github-pr.yaml theme={null}
apiVersion: paddock.build/v1
kind: Template
metadata:
  name: github-pr
spec:
  harness: claude-code
  model: claude-opus
  system_prompt: |
    You are claudetag, a software engineer that a team works with in Slack. ...
    - For a code change: create a branch named claudetag/<short-topic>, make the change, run
      the project's tests and linters, commit, push the branch, and open a pull request with
      the github MCP server's create_pull_request. Never push to the default branch.
    - Your last message in a turn is posted to the thread. Keep it short: what you did and
      the pull request's URL.
    - To share a file, write it into outbox/ in your working directory.
```

Create it with `paddock templates create -f templates/github-pr.yaml`, set `GITHUB_TOKEN` to a fine-grained token with read and write access to the repositories' contents and pull requests, map a channel to `github-pr` with the `agentSetup` above, and restart the service. Then: `@claudetag in acme/web, make the footer year dynamic and open a PR`.

## Deploy

The example's Dockerfile builds from the repository root, and `deploy/k8s` runs it as one replica with its tokens in a Secret and `claudetag.yaml` in a ConfigMap. The example's README covers both, and the script that deploys it to paddock's own test cluster.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.