360 Secure SkillHub
360 安全技能中心

Slack Thread Deleter

核心功能:按先回复后主消息的顺序安全删除Slack线程,操作前列出待删消息并需用户确认,自动适配Slack API速率限制,所有删除行为记录到审计日志。典型场景:用户明确要求删除Slack线程、清理相关讨论。输入为频道ID和线程时间戳,输出含删除结果反馈及审计日志。

h-mascot
h-mascot
热度 24.53
最近更新 2026-06-04 00:17:59
分类:自动化依赖:代码执行 / 第三方 API / 读写文件应用场景:自动化脚本 / 任务管理 / 工作流

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add 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).