Search and retrieve information from Slack workspace using the slack-cli tool. Use this skill to find messages, get channel history, or search for user posts in Slack.
This skill enables you to search and retrieve information from Slack workspace using the slack-cli command-line tool.
Before using this skill, ensure:
SLACK_TOKEN environment variable is set with a valid User OAuth Token (starting with xoxp-)slack-cli binary is built and available in PATHSearch for messages containing specific keywords across all accessible channels:
slack-cli search "<query>"
Options:
--sort=timestamp or --sort=score: Sort by timestamp (default) or relevance score--sort-dir=desc or --sort-dir=asc: Sort direction (desc = newest first, default)--count=N: Number of results to retrieve (default: 20)Date Filters (in query):
after:YYYY-MM-DD: Messages after specified datebefore:YYYY-MM-DD: Messages before specified dateon:YYYY-MM-DD: Messages on specific dateExamples:
# Search for error messages
slack-cli search "error"
# Search with date filter
slack-cli search "deployment after:2025-11-01"
# Search with custom sorting and count
slack-cli search "bug" --sort=score --count=50
# Search for multiple terms
slack-cli search "database connection error"
Retrieve the latest messages from a specific channel:
slack-cli channel <channel-name>
Example:
# Get messages from #general channel
slack-cli channel general
# Get messages from #engineering channel
slack-cli channel engineering
Note: Use the channel name without the # symbol.
Find all messages posted by a specific user:
slack-cli user <username>
Example:
# Get messages from user "john.doe"
slack-cli user john.doe
Note: Use the Slack username (not display name).
All commands output results in the following format:
Found N messages:
================================================================================
[1] username:
Message text content here
Posted: YYYY-MM-DD HH:MM:SS UTC
Channel: #channel-name
[2] username:
Another message text
Posted: YYYY-MM-DD HH:MM:SS UTC
Channel: #another-channel
================================================================================
Use this skill when you need to:
--count parameterFinding Error Reports:
slack-cli search "error" --sort=timestamp --sort-dir=desc --count=30
Checking Recent Deployments:
slack-cli search "deployed after:2025-11-15"
Getting Team Updates:
slack-cli channel team-updates
Finding Specific User's Contributions:
slack-cli user jane.smith
Investigating Issues:
# First search broadly
slack-cli search "database timeout"
# Then check specific channels
slack-cli channel infrastructure
# Then check who reported it
slack-cli user devops-bot
"SLACK_TOKEN environment variable is not set"
export SLACK_TOKEN=xoxp-your-token"not_allowed_token_type"
search:read scope"Channel not found"
#)"User not found"
No results returned
--count parameterslack-cli search '"exact phrase"'after: and before:--sort=score when keyword matching is more important than recencyThis skill works well in combination with other tasks: