slack-to-md
Convert Slack thread URLs to markdown documents. Trigger on "slack-to-md" command or when user provides Slack URLs (https://*.slack.com/archives/*/p*). Also handles updating existing markdown files from their source Slack threads.
When & Why to Use This Skill
This Claude skill automates the conversion of Slack threads into well-formatted Markdown documents. It streamlines knowledge management by extracting chat history, resolving user identities, and generating organized files with descriptive names directly from Slack URLs, making ephemeral conversations searchable and permanent.
Use Cases
- Knowledge Archiving: Transform ephemeral Slack technical discussions into permanent project documentation or wiki pages for future reference.
- Meeting Summarization: Convert Slack-based brainstorming sessions or async stand-ups into structured meeting notes and action items.
- Documentation Syncing: Automatically update existing Markdown files with the latest messages from their source Slack threads to keep local documentation in sync with live discussions.
- Onboarding Support: Create a searchable local knowledge base from historical Slack conversations to help new team members quickly understand past decisions and context.
| name | slack-to-md |
|---|---|
| description | Convert Slack thread URLs to markdown documents. Trigger on "slack-to-md" command or when user provides Slack URLs (https://*.slack.com/archives/*/p*). Also handles updating existing markdown files from their source Slack threads. |
Slack to Markdown Converter
Convert Slack thread URLs to well-formatted markdown documents.
Prerequisites
Before using this skill, the following setup is required:
- Node.js 18+: Required for the Slack API script
- Set up Slack Bot: Create a bot at https://api.slack.com/apps with these OAuth scopes:
channels:history- Read messages from public channelschannels:join- Auto-join channels when neededusers:read- Resolve user IDs to names
- Configure token: Copy
.envto.env.localand add your bot token:BOT_TOKEN=xoxb-your-token-here
Workflow
1. Parse Input
Slack URL format: https://{workspace}.slack.com/archives/{channel_id}/p{timestamp}
Extract:
workspace: subdomainchannel_id: after/archives/thread_ts: convertp{digits}→{first10}.{rest}(e.g.,p1234567890123456→1234567890.123456)
Existing .md file: Read and extract Slack URL from > Source: line.
2. Execute Conversion
Run the two scripts in a pipe:
node {SKILL_DIR}/scripts/slack-api.mjs <channel_id> <thread_ts> | \
{SKILL_DIR}/scripts/slack-to-md.sh <channel_id> <thread_ts> <workspace> {PROJECT_ROOT}/slack-outputs/<output_file>.md [title]
{SKILL_DIR}: Shown at the top when skill is invoked as "Base directory for this skill: ..."{PROJECT_ROOT}: Git root or current working directory (use absolute paths for reliability)slack-api.mjs: Fetches thread data from Slack API, outputs JSONslack-to-md.sh: Reads JSON from stdin, generates markdown file
3. Rename to Meaningful Filename
After fetching, read the generated markdown file and extract the first message content. Then rename the file to a meaningful name:
- Read the markdown file to find the first message (after the header)
- Extract a short, descriptive title from the first message (first 30-50 characters, or a key phrase)
- Sanitize the title for use as filename:
- Convert to lowercase
- Replace spaces with hyphens
- Remove special characters (keep only alphanumeric, hyphens, Korean characters)
- Truncate to reasonable length (max 50 chars)
- Rename the file:
mv {old_file}.md {PROJECT_ROOT}/slack-outputs/{sanitized_title}.md - Report the new filename to the user
4. Handle Errors
The slack-api.mjs script automatically handles common errors:
not_in_channel: Automatically joins the channel and retriesmissing_scope: Prints required OAuth scope to stderr
If errors persist, check:
- Bot token is valid in
.env.local - Bot has required OAuth scopes
- Bot is added to the workspace
Resources
- scripts/slack-api.mjs: Slack API wrapper (Node.js 18+, no external deps)
- scripts/slack-to-md.sh: JSON to markdown converter (requires jq, perl)