360 Secure SkillHub
360 安全技能中心

Slack Thread Deleter

该 Skill 通过 Bash 脚本调用 Slack API 删除指定 Slack 线程:先列出线程内全部消息并展示给用户,取得明确确认后,按先回复后父消息的顺序删除,删除间隔约 1.2 秒以控制速率,并把每次删除写入本地审计日志。

分类:协作
h-mascot
h-mascot
热度 1.25
最近更新 2026-06-04 00:17:59

安装

发给 Agent
帮我安装这个技能:npx secure-skills-cli add h-mascot/ec-slack-thread-delete
兼容性
通用兼容
联网要求
需要联网
数据出网
必须出网
Metadata
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:

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:

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).