Clean your Slack channels from your CLI

Posted on April 15, 2019

Since several years, Slack has becoming a wide-used communication tool in development teams. Due to its powerful API, Slack also allows multiple integrations with other apps, including your own ones.

More and more, I use Slack to notify events from my apps to a Slack channel, both on profressionnal and side projects. It could be business events (a customer placed an order, a message was sent, etc), or applications events (an error occurs, etc). It is really easy to setup (for example, Laravel Notifications are shipped with a Slack driver), and improve a lot my overview of running apps.

However, after a given amount of time, my channels was full of notifications, most of them beeing not useful anymore. Manually remove them was a bit painful, as Slack does not handle batch delete. You have to manually logged to each workspace and channel, and then delete messages ony by one. It seems I've found another side project πŸ˜‰

After some times to work on it, I recently released clean-my-slack, a little CLI tool to batch delete messages.

Given you already have NodeJS on your computer, you'll only need to globally require it:

yarn global add clean-my-slack

Then the CLI will be available:

cmsk -h

Usage: cmsk [options] [command]

  -V, --version            output the version number
  -h, --help               output usage information

  clean [options]          clean a channel
  workspace:add [options]  register a new token

All configuration and usage details are explains on the GitHub readme. Note you'll need to provide a Slack auth token for each workspace you want to add.

Altough commands are very minimalist at the moment, I plan to add features in the next weeks/months according to my future needs. But as usual, comments and suggestions are welcome ! 😊