Home / All Skills / Workflow & Core Tools / setup-notifications-via-wecom
Workflow & Core Tools · daymade/claude-code-skills

setup-notifications-via-wecom

Set up and send technical status notifications through WeCom (Enterprise WeChat) webhooks. Use this skill whenever the user needs to send notifications, alerts, backup completion reports, or status updates via WeCom; when they mention 企业微信, 企微机器人, webhook, or alerting; or when a message needs to be clear, unambiguous, and technically precise rather than vague or condescending.

L4 High-Privilege · Graded auth & full auditV1 Commit-PinnedExecute CommandInstall DepsNetwork AccessWrite FileDual-pass Audit
Author daymadeGitHub daymade/claude-code-skills ↗Stars 1392License MIT(仓库根 LICENSE,Copyright (c) 2025 daymade;GitHub API spdx MIT)Commit d5c4678cb5
Control levels describe skill capabilities and suggested control measures; they do not represent quality or safety certifications, nor do they dictate usability. Usage decisions rest entirely with users and administrators. Different agent hosts apply varying constraints; do not assume hosts provide automatic protection. Third-party skill copyrights belong to their original authors. Use at your own risk.

1How It Works & Mechanism

Divided into two layers: a one-time 'sender setup' (storing the webhook, binding recipient categorization, and test sending verification) + per-send 'clear communication' (message writing standards and templates). Sending itself is handled by a script that performs an HTTP POST to the WeCom group bot webhook.

setup-notifications-via-wecom/SKILL.md
1. **One-time setup**: store the webhook URL, test connectivity, and create a reusable sender script. 2. **Send messages**: craft messages that distinguish state from delta, define every number, and avoid the misleading patterns that made earlier backup-sync notifications confusing.
This also explains 'why it can deliver legally precise status broadcasts': capability is half in the script and half in the documentation writing discipline.

Tencent services must bypass local proxies; the script actively unsets six proxy environment variables before initiating requests—a mandatory adaptation for the mainland China network environment, not an optional optimization.

setup-notifications-via-wecom/scripts/send_wecom.py
def clear_proxy_env(): """Remove proxy env vars so Tencent endpoints are reached directly.""" for name in ( "http_proxy", "https_proxy", "all_proxy", "HTTP_PROXY", "HTTPS_PROXY", "ALL_PROXY", ): os.environ.pop(name, None)
Corresponding note in SKILL.md: 'The bundled script `scripts/send_wecom.py` handles the actual HTTP call, including the proxy-unset rule required for Tencent services in mainland China.'

Recipient identity is elevated to a mandatory configuration item rather than an inferrable one: config must contain recipient_scope (self/others) and recipient_label; missing identity results in a fast hard failure without letting the agent guess.

setup-notifications-via-wecom/scripts/send_wecom.py
recipient_scope = config.get("recipient_scope") if recipient_scope not in VALID_RECIPIENT_SCOPES: print( f"Missing or invalid 'recipient_scope' in {CONFIG_PATH}; " "run scripts/set_recipient.py with self or others.", file=sys.stderr, ) sys.exit(1)
Design intent (SKILL.md): '`self` may send automatically; `others` requires human confirmation; missing identity fails fast.'

Anti-tamper chain: set_recipient.py records the sender script's absolute path and sha256 into config; before sending, send_wecom.py recalculates and verifies them, refusing to send if there is any mismatch. This treats 'the sender itself being replaced' as an explicit threat model.

setup-notifications-via-wecom/scripts/send_wecom.py
sender_path = Path(sender_path_value).expanduser().resolve() running_sender = Path(__file__).resolve() if sender_path != running_sender or not sender_path.is_file(): print( f"Configured sender does not match this executable: {running_sender}", file=sys.stderr, ) sys.exit(1) if not isinstance(sender_sha256, str) or sha256_path(sender_path) != sender_sha256: print( "Configured sender digest is stale; rerun scripts/set_recipient.py.", file=sys.stderr, ) sys.exit(1)
Corresponding write side in set_recipient.py: sender_sha256 = sha256_path(sender_path).

Automated delivery (outbox path) enforces stricter one-time authorization: runaway-guard must provide the payload digest, and the script only sends after verifying that the schema, scope, webhook digest, and sender fingerprint all match, attempting only a single HTTP request.

setup-notifications-via-wecom/scripts/send_wecom.py
"status": "pending_auto_self", "sender_skill": "notify-wecom", "recipient_scope": "self", "recipient_label": config["recipient_label"], "webhook_sha256": webhook_sha256,
Explanation of behavioral differences in SKILL.md: 'Manual `--message` / `--file` sends retry transient errors up to 3 times. Guard-owned automatic `--outbox` delivery makes exactly one HTTP attempt and requires the guard-approved payload digest; a later run never sends a pre-existing payload.'

Configuration writes are atomic: temporary file + fsync + os.replace + directory fsync, preserving the original file permission bits (default 0600) to prevent half-written corrupt configs or privilege relaxation.

setup-notifications-via-wecom/scripts/set_recipient.py
mode = stat.S_IMODE(path.stat().st_mode) or 0o600 tmp = path.with_name(f".tinkle_{path.name}.{os.getpid()}.tmp") try: fd = os.open(tmp, os.O_WRONLY | os.O_CREAT | os.O_EXCL, mode) with os.fdopen(fd, "w", encoding="utf-8") as handle: json.dump(config, handle, ensure_ascii=False, indent=2) handle.write("\n") handle.flush() os.fsync(handle.fileno()) os.chmod(tmp, mode) os.replace(tmp, path)
Supporting test RecipientConfigTests.test_setter_preserves_webhook_and_mode explicitly asserts that webhook is not overwritten and mode is preserved.

2Core Capabilities

01One-time WeCom group bot webhook configuration and connectivity test sending
02Recipient classification binding (self sends automatically / others requires human confirmation) and sender fingerprint binding
03Plain text message sending (three mutually exclusive entry points: --message / --file / --outbox)
04Proxy environment variable isolation (direct connection to Tencent)
05Transient error retries (up to 3 attempts with 2s intervals for manual sends)
06Response payload authenticity validation (HTTP 200 does not equal success; errcode must be verified)
07Hard message length limit (4096 bytes, UTF-8 encoded)
08Three message templates + writing standards (backup completion / alerts / status updates)
09Writing discipline checklist (distinguish status from increments, define every metric/number, eliminate noise, report only symptoms rather than causes in alerts)

3External Dependencies

KindDependency / Endpoint
api企业微信群机器人 webhook(腾讯官方)
cliuv(以 --no-project 方式运行脚本,避免依赖项目环境)
clipython3(脚本运行时;标准库 urllib 发请求)
clicurl(文档提供的等价内联发送方式)
clienv(清代理的 shell 内建)

4Recommended Governance & Evidence

Suggested Controls for Safe Operation
For Agent Runtime
Graded/per-use authorization, sandbox recommended
For Administrators
Approval workflow, rollback support, full audit
Evidence & Triggers (File Paths & Excerpts)
  • scripts/: Executes local script or command: uv run --no-project python scripts/set_recipient.py --scope self|others --l
  • scripts/ 或 SKILL.md: Declares dynamic installation of external language package dependencies
  • 网络端点: Declares external network access: POST https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=<KEY> (JSON payload {"ms
  • 本地工作目录: File I/O and artifact output: creates config directory and config.json under ~/.config (completed via shell by user or agent, SKILL.md specifies chmod 60
Audit Notes: The orange rating trigger is [Credential Access]: the script must read webhook_url from ~/.config/setup-notifications-via-wecom/config.json—where the key= query param acts as a bearer token capable of posting arbitrary messages to the destination group—as well as identity and integrity fields from the same file; simultaneously, it unsets proxy environment variables in-process and initiates an outbound POST. Why not Red: There are no security degradations (TLS validation is intact, no anti-scraping bypass, no bulk harvesting), tokens are not sent to unintended endpoints (it targets the official Tencent endpoint the key belongs to), and message content is bounded by a 4096-byte limit and errcode checks. Why not Yellow: It involves reading and outbound transmission of a local secret, and the sender_path/sender_sha256 binding in config shows the author explicitly modeled sender tampering as a threat. Mitigations & Design Highlights: self/others privilege separation + others requires manual confirmation + missing identity fails fast; outbox automated delivery allows only one HTTP attempt and requires a guard-approved payload digest; atomic config writes preserving file permission bits. Usage Advice: Keep webhooks strictly in 0600-permission config files, keep them out of git repositories, and never pipe raw scraped web content directly into notification bodies.

5Second-Pass Verification

  • [ok] 每条外部依赖的调用点是否真实存在 — webhook 端点(SKILL.md Quick Start 第 2 步 + 脚本 docstring + 内联 curl 三处一致)、uv --no-project(SKILL.md 命令块,脚本以 uv run 方式被调用)、python3/urllib(脚本 import 段与 urllib.request.Request/urlopen)、curl(SKILL.md 内联等价示例)、env -u / env|grep(SKILL.md 两处)。无推测项。
  • [ok] 凭证/密钥处理是否有反例(例如把 webhook 打印出去、写入日志、发往第三方) — 反例检索失败:全目录 grep webhook 的每一处均不打印其值——SKILL.md 的 set_recipient 说明写 'without exposing or rewriting the webhook value';脚本只把它用于 urllib.request.Request(webhook_url, …),出错时的报错文案(load_config 的四条 sys.exit 提示)不含 URL 本身;唯一的 webhook 值落点是 config.json 与用户自行执行的 echo(SKILL.md 明示 chmod 600)。发信目标与密钥归属同一服务。第一遍结论成立。
  • [ok] 「self 可自动发、others 需人工确认」是否只是文档口号(脚本是否真的挡) — 脚本层面真实生效:recipient_scope 不在 {self, others} 即 sys.exit(1);outbox 自动路径额外要求 payload.delivery 的 recipient_scope 必须为 'self'、recipient_label 与 webhook_sha256 必须与当前 config 完全一致,任一不符即拒绝('Outbox item is not bound to this explicit self target')。不是纯口号。
  • [ok] 发信器指纹绑定能否被绕过(是否只在文档里说、代码里没验) — 代码里确实验:send_wecom.py 同时比对 sender_path != running_sender 与 sha256_path(sender_path) != sender_sha256,两处不符都 sys.exit(1)。相应地,config 本身被篡改时这两个字段可被一起改写——这是该机制的边界,已在 security.injection_surface 第 ③ 点写明,不算被遗漏。
  • [ok] 写盘是否可能损坏配置或放宽权限 — set_recipient.py 用 O_EXCL 建临时文件、fsync 文件、os.chmod(tmp, mode) 后 os.replace,并对父目录 fsync;mode 取自原文件(stat.S_IMODE(path.stat().st_mode) or 0o600),不会放宽。tests 里 test_setter_preserves_webhook_and_mode 对 webhook 与权限有直接断言。结论成立。
  • [ok] references 与 SKILL.md 的规范条数/内容是否一致 — SKILL.md 的 Message Best Practices 8 条(标题先行/状态vs增量/数字定义/地点用词/去噪音/精确不居高临下/验证指标/下一步)在 references/message_best_practices.md 中为 12 节(多出告警 vs 状态更新、告警额外规则、常见错误模板、发送前自检),属扩充而非冲突。
  • [ok] 同一 pin 下本 skill 是否曾产出过旧侦查记录 — data/analysis 目录中不存在 setup-notifications-via-wecom.json 的旧记录(本次为首次产出)。同 repo 其他 slug 有旧记录的情况见各自文件。
  • [ok] pin commit 与 skill.path 是否与任务书一致 — git rev-parse HEAD = d5c4678cb5d4fd6acc9c922690df035dbd33d247;目录位于仓库根,相对路径 setup-notifications-via-wecom;本目录最后提交 878f947(2026-09-07)。GitHub API 复核 MIT / stars 1392 / pushed 2026-09-15T09:30:04Z。

6Verdict & Scenarios

  • Makes 'who the recipient is' a mandatory and verifiable configuration rather than leaving it to agent inference—a rare perimeter design in group bot notification tools.
  • The mainland China-specific quirk where Tencent services must bypass proxies is baked into script behavior rather than left for users to troubleshoot.
  • Explicitly handles the WeCom-specific failure mode where 'HTTP 200 does not imply success', preventing false-positive successes.
  • Treats message quality as a reusable engineering asset across three tiers: templates + style checklist + eval cases, backed by real-world correction sources.
  • Configuration writes feature atomicity and permission preservation, reflecting careful attention to engineering details.
  • Best for: Suitable for: Chinese technical teams needing to reliably report script execution outcomes to WeCom groups—such as fixed-format status reports for backups, syncs, cron jobs, or service health, especially in scenarios previously criticized for 'confusing messages that fail to clarify if data was lost'. Also suitable for teams that need to separate self-inspection channels (self) from external broadcasts (others) while ensuring the sender script cannot be arbitrarily replaced.
    Not for: Not suitable for: Scenarios requiring rich media cards, images, or file attachments (supports plain text only); scenarios requiring a unified multi-channel abstraction (Slack/Lark/Email) (this skill only targets WeCom); scenarios wanting to send a one-off message without persisting configuration (configuration is a mandatory prerequisite, failing fast if missing); teams centrally managing webhook credentials in high-governance secret vaults (requires storing credentials locally in a 0600 file).
    Install Agent-Ready
    ① Verified Mirror 2026-09-15
    Option A · Direct DownloadDownload setup-notifications-via-wecom.tar.gz
    sha256: 75c3e6008604ce81…
    Option B · Copy Guide for Agent
    install.json
    Agents automatically download and verify mirrors from this JSON guide.
    ② Upstream GitHub
    GitHub Repo ↗
    Pinned to commit d5c4678cb5.