Skip to content

matthewvolk/slacker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Slacker

A Go CLI wrapper over slackdump for quickly grabbing Slack conversations without admin access. Given a thread link, dump the thread. Given two message links (start/end), dump that range. Output goes to stdout as readable text.

Installation

Requires Go 1.25+.

git clone https://github.com/matthewvolk/slacker.git
cd slacker
go install .

This builds the binary and places it in your $GOBIN directory (defaults to ~/go/bin). Make sure $GOBIN is on your $PATH:

# Add to your ~/.zshrc or ~/.bashrc if not already there
export PATH="$PATH:$(go env GOBIN)"
# Or if GOBIN is unset (uses the default):
export PATH="$PATH:$(go env GOPATH)/bin"

After source code changes, run go install . again from the repo to update the binary in place.

Usage

# Thread mode: dump an entire thread
slacker "https://workspace.slack.com/archives/C123ABC456/p1577694990000400"

# Range mode: dump messages between two message links (same channel)
slacker "https://workspace.slack.com/archives/C123ABC456/p1577694990000400" \
        "https://workspace.slack.com/archives/C123ABC456/p1577700000000000"

# JSON output for programmatic use
slacker --json "https://workspace.slack.com/archives/C123ABC456/p1577694990000400"

Flags

Flag Description
--help, -h Show help message
--version Show version
--json Output as JSON instead of plain text
--no-interactive Fail instead of opening browser for auth

Commands

Command Description
tz [timezone] Show or set the display timezone (IANA name)
purge Clear cached user data

Output format

Plain text (default)

> Alice Smith (@asmith) @ 2026-02-26 23:53:32 CST:
Hey @bjones, check out this thread

|   > Bob Jones (@bjones) @ 2026-02-26 23:54:10 CST:
|   Thanks @asmith!
  • Thread replies are indented with | prefix
  • <@U123ABC> mentions are resolved to @username
  • Message headers show full name, @username, and timestamp (ISO 8601)
  • Output goes to stdout, so you can pipe it anywhere:
# Copy to clipboard (macOS)
slacker "https://..." | pbcopy

# Save to file
slacker "https://..." > thread.txt

JSON (--json)

slacker --json "https://..." | jq .
{
  "messages": [
    {
      "user": "Alice Smith",
      "username": "asmith",
      "timestamp": "2026-02-26T23:53:32-06:00",
      "text": "Hey @bjones, check out this thread",
      "replies": [
        {
          "user": "Bob Jones",
          "username": "bjones",
          "timestamp": "2026-02-26T23:54:10-06:00",
          "text": "Thanks @asmith!"
        }
      ]
    }
  ]
}

Exit codes

Code Meaning
0 Success
1 General error
2 Usage error (bad arguments, invalid URL)
3 Authentication error
4 Network/API error

Authentication

Slacker checks for credentials in this order:

  1. Environment variablesSLACK_TOKEN and SLACK_COOKIE set in your shell
  2. .env file in the current working directory (project-specific override)
  3. Global credentials file — stored in the OS config directory (see below)
  4. Browser login — interactive prompt as a last resort (disabled by --no-interactive)

Browser login (SSO, Google, email/password, etc.)

On first run (or when credentials expire), slacker opens an interactive browser prompt via slackdump's ROD auth, supporting Okta SSO, Google SSO, email/password, and more.

After a successful browser login, credentials are automatically saved to the global credentials file so subsequent runs from any directory work without re-authenticating.

Use --no-interactive to disable this fallback (e.g., in scripts or CI). Slacker will fail with exit code 3 if no credentials are available.

Credentials storage

Credentials are stored in the OS config directory:

  • macOS: ~/Library/Application Support/slacker/credentials.env
  • Linux: ~/.config/slacker/credentials.env

You can also override with a .env file in the current directory (useful for project-specific workspaces) or by setting SLACK_TOKEN and SLACK_COOKIE environment variables directly.

Getting your token and cookie manually

  1. Open your Slack workspace in a browser
  2. Open Developer Tools (F12) → Network tab
  3. Look for any request to api.slack.com
  4. Copy the token parameter (starts with xoxc-) and the d cookie value (starts with xoxd-)

Configuration

Timezone

Timestamps default to UTC. Set the TZ environment variable to display in your local timezone:

export TZ=America/Chicago
slacker "https://..."

Or set it in your shell profile (~/.zshrc or ~/.bashrc) for persistence.

Valid values are any IANA timezone name (e.g., America/New_York, Europe/London, Asia/Tokyo).

User cache

Slacker caches workspace user data (display names and usernames) to avoid hitting the Slack API on every run. The cache is stored at:

  • macOS: ~/Library/Caches/slacker/users.json
  • Linux: ~/.cache/slacker/users.json

The cache expires after 24 hours and is automatically refreshed on the next run. To force a refresh, delete the cache file or run slacker purge.

Project structure

slacker/
  main.go      — entry point, auth, CLI orchestration
  format.go    — text formatting, JSON output, @mention replacement, timezone handling
  parse.go     — Slack URL parsing, timestamp extraction
  cache.go     — user cache (JSON file with 24h TTL)

Key design decisions

  • stdout-only output: All conversation text goes to stdout. Errors and status messages (auth saved, etc.) go to stderr. This makes slacker composable with pipes and redirects — ideal for use by AI agents or scripts.
  • Reimplemented internals: slackdump's URL parser and text formatter live under internal/, which Go prevents external modules from importing. Slacker reimplements two small pieces: URL-to-timestamp parsing (~15 lines) and text formatting (~60 lines).
  • Silent by default: slackdump's internal logging is suppressed via a discard logger to keep output clean and minimize token usage when used by AI agents.
  • Thread-aware formatting: When dumping a thread URL, slackdump returns all messages flat (parent first, then replies). Slacker detects this via conv.IsThread() and applies reply indentation. For channel dumps, replies come nested in ThreadReplies and are handled recursively.
  • Semantic exit codes: Different failure modes produce distinct exit codes (2=usage, 3=auth, 4=API) so calling scripts can handle errors appropriately.

Dependencies

About

A CLI tool to summarize Slack messages from a thread or channel

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages