npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

slack-cleaner

v0.1.1

Published

Flag-based Slack message cleaner CLI for Node.js

Downloads

192

Readme

slack-cleaner-node

slack-cleaner-node is a flag-driven Node.js CLI for safely finding and deleting Slack messages across channels, groups, and conversations, with dry-run by default, rich text-pattern matching, and retry-aware rate limiting.

Safety model

  • Default mode is dry-run.
  • Use --perform to actually delete messages.
  • Use --limit to cap deletions while validating filters.

Install

Install from npm (published package):

npm install -g slack-cleaner

Alternatively check out the repo:

gh repo clone mcdado/slack-cleaner-node
cd slack-cleaner-node
npm link

Then run:

slack-cleaner --help

Slack token and scopes

Use a token that can read history and delete the target messages.

This CLI auto-loads a .env file from your current working directory. If not present there, it also checks .env in the installed package directory (useful when running a globally linked install via npm link).

Token setup by install mode:

  • npm link (repo checked out): put token in repo .env and it will be picked up as fallback.
  • npm install -g slack-cleaner (no repo checkout): use either a .env in the directory where you run slack-cleaner, shell env vars, or --token.

Create it from the example:

cp .env.example .env

Set token in .env or shell env vars:

export SLACK_BOT_TOKEN='xoxb-...'
# or
export SLACK_USER_TOKEN='xoxp-...'
# or
export SLACK_TOKEN='xoxp-...'

Or pass directly:

slack-cleaner --token xoxp-...

Typical scopes you will need depend on conversation types, for example:

  • channels:history, groups:history, im:history, mpim:history
  • chat:write
  • users:read
  • conversation listing scopes where needed

Usage

slack-cleaner --token xoxp-... [targets] [filters] [options]

Targets

  • --channel <name[,name]> public channels
  • --group <name[,name]> private channels
  • --conversation <id[,id]> direct conversation IDs

At least one target flag is required.

Filters

  • --user <username|user_id[,..]> only messages by users
  • --message-type <user|bot> filter by type
  • --pattern <regex> regex on message text, attachments, block text, and related textual fields
  • --after <date> oldest date (ISO format supported)
  • --before <date> newest date

Execution

  • --perform execute deletions
  • --limit <n> max matched messages to preview/delete
  • --rate-limit-ms <ms> minimum delay between Slack API calls (default 250)
  • --max-retries <n> retries on 429/5xx/network failures (default 6)
  • --verbose detailed logs

Examples

Dry-run messages from a user in #general after Jan 1, 2024:

slack-cleaner --channel general --user alice --after 2024-01-01

Delete up to 50 bot messages matching deploy failed in a private channel:

slack-cleaner --group ops-alerts --message-type bot --pattern "deploy failed" --limit 50 --perform

Delete from known conversation ID with a slower API cadence:

slack-cleaner --conversation C12345678 --rate-limit-ms 800 --perform

Delete with more aggressive retry policy:

slack-cleaner --channel general --perform --max-retries 10

Notes

  • Slack may refuse deletes for messages your token cannot remove.
  • When multiple tokens are configured, delete attempts can fall back to secondary tokens on permission-related delete errors.
  • Requests use retry with backoff and Retry-After when Slack responds with HTTP 429.
  • If you still hit limits, increase --rate-limit-ms or reduce scope per run.
  • During --perform, TTY terminals show a self-updating progress line instead of one log line per deleted message.
  • Live progress includes retries_total=<n>, retries_429=<n>, and retry wait countdown wait=<seconds>s.
  • Each run prints Rate limit retries: <n> and Total retries: <n> at the end.

Credits