Safely delete Slack threads by removing replies first, then parent message. Use when the user explicitly requests deletion of a Slack thread or conversation, needs to clean up threaded messages, or wants to remove an entire discussion. Always confirms before deletion and logs all deletions for audit purposes. Handles Slack API rate limits appropriately.
--- name: slack-delete-thread description: Safely delete Slack threads by removing replies first, then parent message. Use when the user explicitly requests deletion of a Slack thread or conversation, needs to clean up threaded messages, or wants to remove an entire discussion. Always confirms before deletion and logs all deletions for audit purposes. Handles Slack API rate limits appropriately. --- # Slack Thread Deletion Delete Slack threads safely by removing all replies before deleting the parent message, with confirmation and audit logging. ## Critical Safety Rules 1. **Always confirm before deletion** - Never delete without explicit user approval 2. **Show what will be deleted** - List all messages in the thread first 3. **Log every deletion** - Append to audit log for accountability 4. **Delete in correct order** - Replies first, parent last 5. **Handle rate limits** - Respect Slack tier limits (50 calls/minute for Tier 1) ## Workflow ### Step 1: List Thread Messages Use `scripts/list-thread-replies.sh` to retrieve and display all messages in the thread: ```bash scripts/list-thread-replies.sh <channel-id> <thread-ts> ``` This shows: - Parent message (timestamp, user, text preview) - All reply messages (timestamp, user, text preview) - Total count ### Step 2: Confirm Deletion Present the list to the user and ask for explicit confirmation: ``` Found X messages in thread: - Parent: @user at HH:MM:SS: "text preview..." - Reply 1: @user at HH:MM:SS: "text preview..." - Reply 2: @user at HH:MM:SS: "text preview..." Delete all X messages? This cannot be undone. (yes/no) ``` Only proceed if user confirms with "yes" or clear affirmative. ### Step 3: Delete Thread Use `scripts/delete-thread.sh` to delete the thread: ```bash scripts/delete-thread.sh <channel-id> <thread-ts> ``` The script: - Deletes all replies first (in chronological order) - Deletes parent message last - Respects rate limits (1.2s delay between deletions) - Logs each deletion to `~/.slack-deletion-audit.log` - Reports success/failure for each message ## Rate Limiting Slack API rate limits vary by tier: - **Tier 1**: ~1 request per second sustained - **Tier 2**: Higher limits for larger workspaces The delete script uses 1.2 second delays to stay well within Tier 1 limits. ## Audit Log All deletions are logged to `~/.slack-deletion-audit.log`: ``` 2026-01-15T20:45:00Z | DELETED | C12345 | 1234567890.123456 | @username | "message text preview" ``` Format: timestamp | action | channel | message_ts | user | text_preview ## Error Handling The scripts handle common errors: - Invalid channel or thread timestamp - Messages already deleted - Permission denied - Rate limit exceeded (unlikely with delays) - Network failures Errors are reported clearly and logged to the audit file. ## Finding Thread Timestamps Thread timestamp (`thread_ts`) is the timestamp of the parent message. Get it from: 1. Slack UI: Right-click message → Copy link → extract timestamp from URL 2. Message tool: Use `message` tool to search/list messages 3. API: Use `conversations.history` or `conversations.replies` Channel ID format: `C` followed by alphanumeric characters (e.g., `C12345ABCDE`).
don't have the plugin yet? install it then click "run inline in claude" again.