ntfy

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Task Completion Notifier

任务完成通知器

Send a push notification via ntfy or Bark when your current task is finished. Designed for long-running sessions where the user wants to step away and get pinged on their phone or desktop when work is done.
当你当前的任务结束时,通过ntfyBark发送推送通知。专为长时间运行的会话场景设计,适用于用户需要暂时离开,希望工作完成时能在手机或桌面端收到提醒的情况。

Environment Variables

环境变量

VariableRequiredDescription
NTFY_URL
No*Full ntfy endpoint including topic, e.g.
https://ntfy.sh/my-alerts
NTFY_TOKEN
NoBearer token for authenticated ntfy servers; omit for public topics
BARK_URL
No*Bark server URL including device key, e.g.
https://api.day.app/your_key
* At least one of
NTFY_URL
or
BARK_URL
must be set. If both are set, ntfy is used.
The user sets these in their shell profile,
.env
, or Claude Code settings (
env
field in
settings.json
).
变量名是否必填说明
NTFY_URL
否*包含主题的完整ntfy端点,例如
https://ntfy.sh/my-alerts
NTFY_TOKEN
身份验证ntfy服务器的Bearer令牌;公共主题可省略
BARK_URL
否*包含设备密钥的Bark服务器URL,例如
https://api.day.app/your_key
* 必须至少设置
NTFY_URL
BARK_URL
中的一个。如果两者都已设置,将优先使用ntfy。
用户可以在shell配置文件、
.env
或Claude Code设置中(
settings.json
中的
env
字段)设置这些变量。

Priority Levels

优先级

Parse the priority from the user's message or command arguments:
User inputPriority nameBehavior
/ntfy
or "normal" (default)
normalStandard notification
/ntfy urgent
or "urgent"
urgentBreakthrough / high-priority notification
If the user writes anything that clearly conveys urgency (e.g. "high priority", "important", "asap"), treat it as urgent.
从用户的消息或命令参数中解析优先级:
用户输入优先级名称行为
/ntfy
或 “normal”(默认)
普通标准通知
/ntfy urgent
或 “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
fi
If neither URL is set, stop and tell the user:
No notification service is configured. Set up at least one:
ntfy (cross-platform):
bash
export NTFY_URL="https://ntfy.sh/your-topic"
export NTFY_TOKEN="tk_xxx"          # optional, for private servers
Bark (iOS):
bash
export 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(跨平台):
bash
export NTFY_URL="https://ntfy.sh/your-topic"
export NTFY_TOKEN="tk_xxx"          # 可选,用于私有服务器
Bark(iOS):
bash
export 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
    references/ntfy.md
    for the curl command, headers, and tag mapping
  • Bark → read
    references/bark.md
    for the curl command, JSON body, and level mapping
任务完成后(无论成功或失败),使用确定的服务提供商发送通知。
通知内容规则:
  • 标题:具体的任务名称(例如“运行测试套件”、“重构认证模块”)。尽可能使用用户的原表述。
  • 内容:描述任务结果和已完成工作的简洁摘要(最多200个字符)。如果任务失败,描述失败内容和原因。聚焦结果,而非过程。
  • 优先级:默认为普通,仅在用户明确要求时设置为紧急。
发送通知时请参考对应文档中的curl命令:
  • ntfy → 查看
    references/ntfy.md
    获取curl命令、请求头和标签映射规则
  • Bark → 查看
    references/bark.md
    获取curl命令、JSON请求体和等级映射规则

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状态码),告知用户通知发送失败——但不要因此阻塞任务结果的交付。
  • 如果任务本身执行失败,仍然要发送附带失败标识的通知,让用户知道需要回来查看。其核心意义在于用户可能正离开设备,失败通知和成功通知的价值是同等的。