| name | slack-search |
| description | 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. |
Slack Search Skill
This skill enables you to search and retrieve information from Slack workspace using the slack-cli command-line tool.
Prerequisites
Before using this skill, ensure:
SLACK_TOKENenvironment variable is set with a valid User OAuth Token (starting withxoxp-)- The
slack-clibinary is built and available in PATH
Available Commands
1. Search Messages Across All Channels
Search for messages containing specific keywords across all accessible channels:
slack-cli search "<query>"
Options:
--sort=timestampor--sort=score: Sort by timestamp (default) or relevance score--sort-dir=descor--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 date
Examples:
# 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"
2. Get Channel Messages
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.
3. Search User Posts
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).
Output Format
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
================================================================================
Usage Guidelines
When to Use This Skill
Use this skill when you need to:
- Find specific information mentioned in Slack conversations
- Track discussions about particular topics or issues
- Retrieve historical messages from channels
- Search for messages from specific team members
- Investigate when something was discussed or decided
Best Practices
- Be Specific with Search Terms: Use precise keywords to get relevant results
- Use Date Filters: When looking for recent or historical information, add date filters
- Adjust Result Count: If you need more context, increase
--countparameter - Check Multiple Sources: Try searching by keyword, then verify in specific channels
- Handle Token Issues: If you get "not_allowed_token_type" error, verify you're using a User Token (xoxp-) not a Bot Token (xoxb-)
Common Use Cases
Finding 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
Error Handling
Common Errors and Solutions
"SLACK_TOKEN environment variable is not set"
- Set the environment variable:
export SLACK_TOKEN=xoxp-your-token
- Set the environment variable:
"not_allowed_token_type"
- You're using a Bot Token instead of User Token
- Create a new User Token with
search:readscope
"Channel not found"
- Verify the channel name is correct (without
#) - Ensure the bot is invited to private channels
- Verify the channel name is correct (without
"User not found"
- Use the Slack username, not display name
- Check spelling of username
No results returned
- Try broader search terms
- Check if you have access to the channels containing the messages
- Verify date filters are correct
Limitations
- Enterprise Grid: Results are limited to the connected workspace, not all workspaces in the organization
- Permissions: Only searches in channels/conversations the User Token has access to
- Rate Limits: Slack API has rate limits; avoid rapid consecutive requests
- Result Limit: Maximum results per query is constrained by the
--countparameter
Tips for Effective Searching
- Use Quotes for Phrases:
slack-cli search '"exact phrase"' - Combine Keywords: Search for multiple relevant terms together
- Filter by Date Range: Narrow down results with
after:andbefore: - Sort by Relevance: Use
--sort=scorewhen keyword matching is more important than recency - Iterate Searches: Start broad, then refine based on initial results
Integration with Workflows
This skill works well in combination with other tasks:
- Search Slack → Summarize findings → Create report
- Find error messages → Investigate logs → Propose fixes
- Track feature discussions → Compile requirements → Document decisions
- Monitor team communications → Identify blockers → Suggest actions