ntfy
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTask Completion Notifier
任务完成通知器
Environment Variables
环境变量
| Variable | Required | Description |
|---|---|---|
| No* | Full ntfy endpoint including topic, e.g. |
| No | Bearer token for authenticated ntfy servers; omit for public topics |
| No* | Bark server URL including device key, e.g. |
* At least one of or must be set. If both are set, ntfy is used.
NTFY_URLBARK_URLThe user sets these in their shell profile, , or Claude Code settings ( field in ).
.envenvsettings.json| 变量名 | 是否必填 | 说明 |
|---|---|---|
| 否* | 包含主题的完整ntfy端点,例如 |
| 否 | 身份验证ntfy服务器的Bearer令牌;公共主题可省略 |
| 否* | 包含设备密钥的Bark服务器URL,例如 |
* 必须至少设置或中的一个。如果两者都已设置,将优先使用ntfy。
NTFY_URLBARK_URL用户可以在shell配置文件、或Claude Code设置中(中的字段)设置这些变量。
.envsettings.jsonenvPriority Levels
优先级
Parse the priority from the user's message or command arguments:
| User input | Priority name | Behavior |
|---|---|---|
| normal | Standard notification |
| urgent | Breakthrough / high-priority notification |
If the user writes anything that clearly conveys urgency (e.g. "high priority", "important", "asap"), treat it as urgent.
从用户的消息或命令参数中解析优先级:
| 用户输入 | 优先级名称 | 行为 |
|---|---|---|
| 普通 | 标准通知 |
| 紧急 | 突破/高优先级通知 |
如果用户输入了任何明确表达紧急性的内容(例如“high priority”、“important”、“asap”),都按紧急优先级处理。
Workflow
工作流
Step 1 — Detect provider and validate configuration
步骤1 — 检测服务提供商并验证配置
Determine the provider based on which URL environment variable is set. If both are set, prefer ntfy.
Validate:
bash
if [ -n "${NTFY_URL:-}" ]; then
PROVIDER="ntfy"
elif [ -n "${BARK_URL:-}" ]; then
PROVIDER="bark"
else
echo "Error: Neither NTFY_URL nor BARK_URL is set" >&2; exit 1
fiIf neither URL is set, stop and tell the user:
No notification service is configured. Set up at least one:ntfy (cross-platform):bashexport NTFY_URL="https://ntfy.sh/your-topic" export NTFY_TOKEN="tk_xxx" # optional, for private serversBark (iOS):bashexport BARK_URL="https://api.day.app/your_device_key"
Do not proceed with the task until a valid provider is confirmed.
根据已设置的URL环境变量确定使用的服务提供商。如果两者都已设置,优先选择ntfy。
验证逻辑:
bash
if [ -n "${NTFY_URL:-}" ]; then
PROVIDER="ntfy"
elif [ -n "${BARK_URL:-}" ]; then
PROVIDER="bark"
else
echo "Error: Neither NTFY_URL nor BARK_URL is set" >&2; exit 1
fi如果两个URL都未设置,停止流程并告知用户:
未配置任何通知服务。请至少设置以下其中一种:ntfy(跨平台):bashexport NTFY_URL="https://ntfy.sh/your-topic" export NTFY_TOKEN="tk_xxx" # 可选,用于私有服务器Bark(iOS):bashexport BARK_URL="https://api.day.app/your_device_key"
在确认有效服务提供商之前,不要继续执行任务。
Step 2 — Complete the task
步骤2 — 完成任务
Carry out whatever the user asked for. This skill does not alter your approach to the task itself — it only adds a notification at the end.
执行用户要求的所有操作。此技能不会改变你处理任务本身的方式——它只会在任务结束时额外添加一个通知。
Step 3 — Send the notification
步骤3 — 发送通知
After the task completes (whether it succeeded or failed), send the notification using the resolved provider.
Compose the notification:
- Title: The specific task name (e.g. "Run test suite", "Refactor auth module"). Use the user's own words when possible.
- Message: A concise summary (max 200 characters) describing the result of the task and what work was completed. On failure, describe what failed and why. Focus on outcomes, not process.
- Priority: normal by default, urgent only when the user explicitly requests it.
Send the notification by following the curl command in the appropriate reference file:
- ntfy → read for the curl command, headers, and tag mapping
references/ntfy.md - Bark → read for the curl command, JSON body, and level mapping
references/bark.md
任务完成后(无论成功或失败),使用确定的服务提供商发送通知。
通知内容规则:
- 标题:具体的任务名称(例如“运行测试套件”、“重构认证模块”)。尽可能使用用户的原表述。
- 内容:描述任务结果和已完成工作的简洁摘要(最多200个字符)。如果任务失败,描述失败内容和原因。聚焦结果,而非过程。
- 优先级:默认为普通,仅在用户明确要求时设置为紧急。
发送通知时请参考对应文档中的curl命令:
- ntfy → 查看获取curl命令、请求头和标签映射规则
references/ntfy.md - Bark → 查看获取curl命令、JSON请求体和等级映射规则
references/bark.md
Failure handling
异常处理
- If curl fails (non-zero exit or non-2xx status), mention to the user that the notification could not be sent — but do not let it block delivering the task result.
- If the task itself fails, still send a notification with the failure indicator so the user knows to come check. The whole point is that the user might be AFK — a failure notification is just as valuable as a success one.
- 如果curl执行失败(非零退出码或非2xx状态码),告知用户通知发送失败——但不要因此阻塞任务结果的交付。
- 如果任务本身执行失败,仍然要发送附带失败标识的通知,让用户知道需要回来查看。其核心意义在于用户可能正离开设备,失败通知和成功通知的价值是同等的。