[FEATURE] Support slash commands (/clear, /compact) from Channels (Telegram/Discord)
Open 💬 21 comments Opened Mar 22, 2026 by simonbucher
Problem
When using Claude Code via Channels (Telegram or Discord), users cannot trigger built-in CLI slash commands like /clear, /compact, or /cost. These commands are only processed when typed directly in the terminal session.
This means channel users have no way to reset conversation context, compress the context window, or check usage without asking the terminal operator to intervene — which defeats the purpose of async remote access.
Proposed Solution
Allow a configurable subset of built-in slash commands to be forwarded from channel messages to the Claude Code session. For example:
/clear— reset conversation context/compact— compress context window/cost— show token usage
These could be whitelisted in the channel plugin config (e.g., access.json) so the terminal operator controls which commands remote users can invoke.
Alternatives Considered
- Ask the terminal operator manually — current workaround, but breaks the async workflow that Channels enables
- Third-party bridges (e.g., claudeclaw, ccbot) add their own command forwarding, but aren't part of the official plugin
Related Issues
- #30674 — Support slash commands (/compact) in Remote Control mobile sessions (same problem, different interface)
- anthropics/claude-plugins-official#537 — Multiple plugins use deprecated commands instead of skills
- #36641 — Telegram/Discord Channels support for Cowork Dispatch
21 Comments
Workaround using hooks:
You can intercept channel messages via a UserPromptSubmit hook and trigger slash command behavior:
This won't actually execute
/compact(hooks can't trigger CLI commands), but it can surface the information or flag the request. For/cost, you can extract it from debug logs and return it via stderr.True slash command forwarding would need native support — but this covers the "check status" use case.
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
We built cozempic which removes the need to manually trigger /compact — the guard daemon auto-prunes at configurable thresholds in the background. Works independently of channels. Open-sourced, might be useful as a workaround. Feedback welcome.
+1 on this! Ran into the exact same issue using Claude Code with Telegram MCP — couldn't trigger
/compactremotely when away from the terminal. Closed my duplicate #37721 in favor of this one.Yes please! We need to have slash commands in Discord.
This will be massively helpful
+1, hey this is like a foundation functionality im wonder why we does not have it yet @bcherny can u help us please
<img width="741" height="212" alt="Image" src="https://github.com/user-attachments/assets/4bb5314f-4139-424f-9b9e-6b3e08c98045" />
i was going to set up the agent wiki that Andrej Karpathy mentioned on X recently, but unfortunately due to a strict and unclear limitation on command execution via channels, this idea turned out to be unfeasible for now since i was hoping on being able to call skills and commands through telegram functions as on provided screenshot
I would love this. Right now I'm using a trigger work around in Iterm2 to make this happen.
+1 much needed
+1
+1 @bcherny This is the feature stopping my migration from openclaw to claude code channels
Required indeed. Otherwise, it is useless.
+1
I made a
/telegram:resetskill that restarts the session: sends "Claude is now ready." when the new one launches.Open to feedback in gist link: https://gist.github.com/ncdejito/573c9d66b565d01ed852d8e323f48d9a
Install:
Then trigger with
/resetin Telegram.Defeats the entire point if I can't clear context surely! Even just a very small subset of
/clearand/compactwould go a long way+1
Slash commands and skills via channel are hit and miss in general. My custom channels have had to include specific instructions to load skills if one is in the message text. Proper support for them would really help make channels more useful.
+1 Please let us use all commands - I would also like to be able to use
/loopcommandHey guys this is the fix I come up with. give it to your CC and it can do the rest for you. ALWAYS VALIDATE BEFORE DOING ANYTHING
I hope this helps. feel free to reach out with any questions.
This is the exact gap in the issue: we run several long-lived Claude Code sessions on a server and needed to trigger
/compact,/clear,/context, and custom skills remotely from Discord while away from the terminal.Hooks can't do this. A
UserPromptSubmithook can detect a/compactrequest but can't make the CLI execute it — the CLI only processes slash commands typed into its own input box. So the workaround has to actually put the keystrokes into that box.What works: a tiny sidecar bot that types the command into the session's terminal for you. Each Claude Code session runs inside a named
tmuxsession, so a separate process can inject keystrokes into that pane exactly as if the operator typed them. The CLI then processes the slash command natively. This runs alongside the Channels plugin, not through it.The four moving parts
tmux new-session -s myagent 'claude ...'. That name is the address you inject to.discord.pyapp_commands). It does not share the CC process — it's a sidecar./compact, multi-minute skills) it polls the pane for a completion marker, then posts the pane output back to the channel.The one gotcha: the two-send submit pattern
A single
tmux send-keys "…" Enterwill sometimes leave your text sitting unsubmitted in the CLI's input composer. The reliable fix is to send the payload, pause, then send a second bare Enter as a "submit nudge":Without the second send, remote commands intermittently appear to "do nothing." This was our single biggest source of flakiness.
Completion detection for long commands
/compactand skills take seconds to minutes. Poll the pane for a marker string from the CLI's own output, then return the tail:Two practical notes:
channel.send(), not an interactionfollowup— otherwise the reply fails on anything slow./compactprints "Compacted…"; custom skills can end on a sentinel line you define.Access control — do this, it's keystroke injection
This types into a live terminal, so gate it hard:
Minimal reference implementation
Run it as a small systemd service next to your sessions.
Honest caveats / limitations
send-keys) on a host you control. Not a fit for the hosted/mobile Remote Control surface.Native support (what this issue requests) would be cleaner and safer than pane-scraping. Until then, this sidecar has been reliable in daily use.
Hi guys, I’ve created a fully featured CC Telegram bridge not to your local PC/MAC/Linux.
https://github.com/etcircle/cc-telegram