Docs menu

Guide

The dev loop: CLI and UI

While you work on an app, you want to poke it before you write a test: say something as a person, read the answer, change the code, say it again. The attach CLI and the UI do that against the running server, with no seed data and no ids to copy.

Before you start#

Start the server, telling it where your app takes events, and point the app at it. This is the same setup the tests use (Connecting your app has the details):

CHANNELSTACK_SLACK_WEBHOOK_URL=http://localhost:3000/slack/events npx channelstack start
npx channelstack env > .env.local    # in a second terminal; then start the agent with it

Every command below attaches to that server. It finds it through <home>/server.json (~/.channelstack/server.json by default), which the server writes when it starts. To attach to another one, pass --server <url> or set CHANNELSTACK_URL, together with CHANNELSTACK_TOKEN.

Talk to the app#

npx channelstack slack say --as ana --in "#support" "@my-agent what broke last night?"
ana said it in #support (C0A1B2C3D4E:1732451234.000100)

Ana didn't exist and neither did #support: the CLI created both on first use, with Ana and the app in the channel. The next time you name them, it uses the same ones. A person who isn't in a conversation yet is invited by someone who is, as on Slack.

Now read what the app answered:

npx channelstack show
ana: @my-agent what broke last night?
  my-agent: Here's what I found about "what broke last night?".

show prints the most recently active place, on any channel, the way a person reads it. Replies in a thread are indented. Buttons show as [Approve], and edits and streams are marked. Ephemeral messages aren't shown: show reads as no one in particular, and an ephemeral message is for one person only. The app works asynchronously, so if its reply isn't there yet, run show again.

FlagWhat it does
--thread lastOnly the thread of the newest message
--thread <channel id>:<ts>Only that message's thread
slack show --in "#support"That channel; show on a channel is its own
--jsonThe transcript entries as JSON, with their ids

Keep the conversation going#

npx channelstack slack reply --as ben --thread last "and the one before?"
npx channelstack slack react --as ben :eyes: --on last
npx channelstack slack click --as ana "Approve"
npx channelstack slack stop --thread last
CommandWhat the person does
slack say --as <name> --in "#channel" "<text>"Posts a message in a channel
slack reply --as <name> [--to last] "<text>"Replies in a thread (--thread works too)
slack react --as <name> <:emoji:> [--on last]Reacts to a message. :eyes: and eyes are the same reaction
slack click --as <name> "<button>"Clicks the button with that label in the latest message that has it
slack stop [--as <name>] [--thread last]Presses Stop on the agent's work in a thread. Without --as, the person who started the thread presses it

A person who isn't in the conversation yet joins it first, so Ben can reply in Ana's thread without any setup.

click and stop are two of Slack's actions: npx channelstack slack actions lists the others (select, shortcut, runCommand, invite, openDM, …) with the values each takes, as the SDK's SlackUser has them. They are generated from the routes, so every action a test can take, the CLI can too.

Every channel the same way#

say, reply, react, show and the actions work on every channel: slack, github, linear, notion, resend, google and discord. A place is what people talk in there, by its name, made the first time with the app in it:

npx channelstack github say --as mo --in "Login fails" "@my-agent can you look?"   # opens the issue in the org's dev repository
npx channelstack github review --as mo --review '{"event":"APPROVE"}'            # the pull request of the newest entry (`last`)
npx channelstack linear say --as lu --in "Crash on start" "the app crashes"      # an issue in the Dev team
npx channelstack linear delegate --as lu                                         # to the app, on the newest issue
npx channelstack notion say --as nu --in "Roadmap" "@my-agent summarize this"    # a page connected to the integration
npx channelstack resend say --as re --in "Refund for order 1234" "Where is it?"  # an email to the agent
npx channelstack discord say --as di --in "#support" "@my-agent what broke?"     # a channel only its people and the bot see
npx channelstack github show                                                     # the most recently active issue

A Discord channel is private to its participants, as a channel the bot makes is: the first person who acts on Discord in the dev session is the guild's admin, and adds the others when they first speak there.

A reference an action needs and isn't given (the message, the issue, the app) comes from the newest entry, or from the place --in names, or the entry --on names. The CLI reference has the details.

last and message references#

--thread, --on and show --thread take last (the default) or a reference to one message:

  • last is the newest message of the most recently active conversation. For --thread last, it's the thread that message is in.
  • <channel id>:<ts> names one message, as every say and reply prints it in parentheses, for example C0A1B2C3D4E:1732451234.000100. On the other channels it is <place>:<entry> the same way (acme/dev#1:3902182145 for a GitHub comment), with the ids show --json lists.

So a loop of "say, look, fix the code, say again" needs no ids, and you can still go back to an older thread when you need to.

Watch what went back and forth#

npx channelstack tail
14:02:11.503 → slack app_mention  200
14:02:12.020 ← slack chat.postMessage  200
14:02:31.877 → slack reaction_added  200

tail streams what happens as it happens: each event delivered to the app (→) with the status the app answered, and each API call the app made (←) with its status and, when the platform refused it, the error code (← slack chat.postMessage 200 not_in_channel). A retried delivery says which attempt it was. --once prints what is there and exits.

A delivery that failed, or a call refused with an error code, is usually the bug.

Redeliver an event#

npx channelstack deliveries slack
Ev0A1B2C3D4E  event_callback app_mention  acknowledged  (attempts: 200)

Each line is one delivery: its id, what it carried, how it ended (acknowledged, failed, timed_out, unreachable) and the status of each attempt. Send one again with its id:

npx channelstack redeliver slack Ev0A1B2C3D4E
Retried Ev0A1B2C3D4E (slack)

On Slack this is Slack's own retry, with its retry headers, so an app that answers twice doesn't handle retries. GitHub, Linear, Notion, Resend, Google and Discord redeliver the event instead (Redelivered … (github); on Discord, the dispatch again, as after a RESUME). Without an id, redeliver sends the newest delivery again; without a channel, deliveries lists every channel's and redeliver finds the id in any. Both take any channel: slack, github, linear, notion, resend, google or discord. For delivery failures in tests, see Delivery and failures.

Script the model#

An app whose model is the fake OpenAI (OPENAI_BASE_URL from channelstack env) needs a script before it can answer: the fake has no default answer, and a call nothing scripted gets a 400 (channelstack_no_script).

npx channelstack openai respond --times -1 "Here's what I found about {lastUserText}."
ms_…: the model answers every matching call

--when <text> answers only calls whose newest user message has that text, and --tool <name> --args <json> has the model call a tool first and answer its result with the text ({toolResult} is what the app sent back). openai calls lists what the app asked and what the model answered, and openai undo <script> removes a script:

npx channelstack openai calls
…  chat.completions gpt-5 "what broke?" → 200 "Here's what I found about what broke?" (ms_…)

The shared dev session#

Everything the CLI does happens in one long-lived session called dev. The UI shows the same session, and channelstack mcp acts in it too, so a person at the terminal, a browser and a coding agent all see one conversation. It lives until the server stops; state is in memory, so a restart starts from nothing.

Tests don't use it. Each test gets a fresh session and creates its own people, so nothing you do by hand leaks into a test run, and show, tail and the UI don't show what tests do (How it works explains sessions).

Open the UI#

The server prints a UI link when it starts. That link works once. For a fresh one:

npx channelstack ui
https://channelstack.localhost/?login=…

Opening it signs this browser in with a session cookie and takes the code out of the address bar. Opening the UI without a link shows "Open the UI with a login link". The cookie lasts until the server stops.

The UI shows the dev session in three panes, refreshed every second:

PaneWhat it shows
ConversationsThe session's Slack conversations, most recent first. Click one to read it
TranscriptThe same transcript show prints and the matchers read: who said what, threads indented, edits and streams marked. Messages only one person sees (ephemeral) are left out. Buttons are shown, but can't be clicked from the UI yet: use slack click
InspectorEvery delivery to the app and every API call it made, one line each. Click a line to see its JSON

The UI uses one plain design rather than copying Slack's, and shows only what a person could see, so it can't show anything the matchers wouldn't.

A signed-in browser can only read what the UI shows. It can't read channelstack env, can't change anything, and tokens and signing secrets are scrubbed from what it receives. The app's tokens stay behind the bearer token that only local programs read from server.json.

When a command is wrong#

A mistake is answered in one sentence on stderr, with exit code 1:

npx channelstack slack say --in "#support" "hi"
channelstack: say who is acting with `--as <name>`, e.g. `--as ana`.

If no server is running, every attach command says no running server found and how to start one. See Troubleshooting for the others.

Then write the test#

Once the app behaves, pin it down in a test, which gets its own session and people: see Writing tests. Every command and flag is in the CLI reference.

Suggest changes to this page