slack-send-message
Send Slack messages and DMs as yourself directly from Claude Code using your browser session credentials. Extracts the target channel or user and message content directly from natural language prompts. Supports @username for DMs and
What this skill does
# Slack Send Message Skill
Send Slack messages and DMs as yourself using your authenticated browser session credentials. The target (channel or user) is inferred directly from your prompt — no pre-configuration required.
**Features:**
- ✅ Send messages to channels using `#channel-name`
- ✅ Send DMs to users using `@username`
- ✅ Automatic status verification before sending
- ✅ Integrates with `slack-search-user` for user lookups
- ✅ Supports matching by username, real name, or display name (case-insensitive)
## Usage
When the user asks to send a Slack message, follow these steps:
### Step 0: Verify Slack is configured
ALWAYS check status first. The PLUGIN_ROOT is determined dynamically:
```bash
# Determine plugin root (adjust path based on where you're running from)
PLUGIN_ROOT="$HOME/.claude/plugins/marketplaces/djalmaaraujo-claude-code-plugins/plugins/slack"
STATUS_OUTPUT=$("$PLUGIN_ROOT/skills/slack-status/check.sh")
STATUS_CODE=$(echo "$STATUS_OUTPUT" | cut -d'|' -f1)
if [ "$STATUS_CODE" != "OK" ]; then
echo "⚠️ Slack is not properly configured"
echo "Please run: /slack:slack-setup"
exit 1
fi
```
### Step 1: Extract target and message from prompt
Parse the user's prompt to identify:
- **Target**: Look for channel references like `#channel-name` or user references like `@username`
- **Message**: The content the user wants to send
Examples of target extraction:
- "Send 'hello' to #general" → target: `#general`, message: `hello`
- "Post in slack-ai-testing: build complete" → target: `#slack-ai-testing`, message: `build complete`
- "Message @fulano saying good morning" → target: `@fulano`, message: `good morning`
- "DM @john: are you ready?" → target: `@john`, message: `are you ready?`
### Step 2: Determine if target is a channel or user
Check if the target starts with `@` (user DM) or `#` (channel):
- **If target starts with `@`**: This is a DM, proceed to Step 2a
- **If target starts with `#` or is a plain channel name**: This is a channel, proceed to Step 2b
### Step 2a: For DMs - Find user and send message
When the target is a user (starts with `@`), you need to:
1. **Use the slack-search-user skill** to find the user ID
2. **Open a DM channel** using `conversations.open` API
3. **Send the message** to that channel
Here's the complete flow:
```bash
#!/bin/bash
PLUGIN_ROOT="$HOME/.claude/plugins/marketplaces/djalmaaraujo-claude-code-plugins/plugins/slack"
source "$PLUGIN_ROOT/lib/config.sh"
source "$PLUGIN_ROOT/lib/slack-api.sh"
TARGET_USER="fulano" # extracted from @fulano
MESSAGE="Your message here"
# Load config
load_config
# Step 1: Use slack-search-user to find the user
# The script outputs debug info to stderr and user ID to stdout
USER_ID=$("$PLUGIN_ROOT/skills/slack-search-user/search-user.sh" "$TARGET_USER")
SEARCH_EXIT_CODE=$?
if [ $SEARCH_EXIT_CODE -ne 0 ] || [ -z "$USER_ID" ]; then
echo "✗ User not found: $TARGET_USER"
exit 1
fi
echo "✓ Found user ID: $USER_ID"
# Step 2: Open DM channel
echo "Opening DM channel..."
DM_RESPONSE=$(slack_conversations_open "$USER_ID")
CHANNEL_ID=$(echo "$DM_RESPONSE" | jq -r '.channel.id')
if [ "$CHANNEL_ID" = "null" ] || [ -z "$CHANNEL_ID" ]; then
echo "✗ Failed to open DM channel"
exit 1
fi
# Step 3: Send message
echo "Sending message..."
SEND_RESPONSE=$(slack_chat_post_message "$CHANNEL_ID" "$MESSAGE")
if slack_check_response "$SEND_RESPONSE"; then
echo "✓ Message sent successfully!"
else
ERROR=$(slack_get_error "$SEND_RESPONSE")
echo "✗ Error sending message: $ERROR"
exit 1
fi
```
**Key points:**
- Uses `slack-search-user` script - no inline user search code
- Uses shared API functions from `lib/slack-api.sh`
- Clean and maintainable
- Easy to debug
### Step 2b: For channels - Send directly
When the target is a channel (starts with `#` or is a plain channel name):
```bash
#!/bin/bash
PLUGIN_ROOT="$HOME/.claude/plugins/marketplaces/djalmaaraujo-claude-code-plugins/plugins/slack"
source "$PLUGIN_ROOT/lib/config.sh"
source "$PLUGIN_ROOT/lib/slack-api.sh"
# Remove # prefix if present
CHANNEL_NAME="slack-ai-testing" # extracted from #slack-ai-testing
MESSAGE="Your message here"
# Load config
load_config
# Send message directly (Slack resolves channel names automatically)
echo "Sending message to #$CHANNEL_NAME..."
SEND_RESPONSE=$(slack_chat_post_message "$CHANNEL_NAME" "$MESSAGE")
if slack_check_response "$SEND_RESPONSE"; then
echo "✓ Message sent successfully to #$CHANNEL_NAME!"
else
ERROR=$(slack_get_error "$SEND_RESPONSE")
echo "✗ Error sending message: $ERROR"
exit 1
fi
```
**Important**: Pass the channel name directly (e.g., `general`, `slack-ai-testing`). The Slack API accepts both channel names and channel IDs.
### Step 3: Verify the response
The response will be JSON. Check for `"ok": true` to confirm the message was sent successfully.
A successful response looks like:
```json
{
"ok": true,
"channel": "C0A7V415BKQ",
"ts": "1234567890.123456",
"message": { ... }
}
```
An error response looks like:
```json
{
"ok": false,
"error": "channel_not_found"
}
```
## Examples
### Example 1: Channel message
**User prompt:** "Send a message to #slack-ai-testing saying hello from Claude Code"
1. Check Slack status
2. Extract target: `#slack-ai-testing`, message: `hello from Claude Code`
3. Detect it's a channel (starts with `#`)
4. Send message using `slack_chat_post_message`
### Example 2: DM to a user
**User prompt:** "Send a DM to @djalma saying: can you review my PR?"
1. Check Slack status
2. Extract target: `@djalma`, message: `can you review my PR?`
3. Detect it's a user DM (starts with `@`)
4. Search for user "djalma" using `slack-search-user`
5. Get the user ID (e.g., `U01ULLNEM3Q`)
6. Open DM channel using `conversations.open`
7. Get the channel ID (e.g., `D98765XYZ`)
8. Send the message to that channel
## Configuration
This skill uses the centralized Slack plugin configuration at:
```
~/.claude/plugins/marketplaces/djalmaaraujo-claude-code-plugins/plugins/slack/config.json
```
## Integration
This skill integrates with:
- **slack-status** - Validates configuration before sending
- **slack-search-user** - Finds users for DMs
- **lib/config.sh** - Loads shared configuration
- **lib/slack-api.sh** - Uses shared API functions
## Important Notes
- **Automatic validation**: Checks Slack status before every message
- **Channels vs DMs**:
- **Channels** (starting with `#` or plain names): No channel ID lookup needed
- **DMs** (starting with `@`): Uses `slack-search-user` to find user, then opens DM channel
- **User search integration**: Delegates all user lookups to `slack-search-user` skill
- **Messages appear as you**: These messages are sent as your authenticated user, not as a bot
- **Requirements**:
- `jq` is required
- Python 3.6+ is required
- Slack plugin must be configured (run `/slack:slack-setup` if needed)
## Troubleshooting
| Error | Solution |
| ---------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| `Slack is not properly configured` | Run `/slack:slack-setup` to configure credentials |
| `invalid_auth` | Token or cookie expired. Re-run `/slack:slack-setup` |
| `channel_not_found` | Check the channel name spelling or verify you have access |
| `not_in_channel` | You need to join the channel first |
| `User 'X' not found` | The username doesn't exist or doesn't match any name fields |
| DM channel ID is null/empty | The `conversations.open` response failed. Check user ID validity |
Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.