listener-creator
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "listener-creator":https://skillpi.com/zh/skills/deepskill-72f9177fba81ca1ef721fc93a90eca9eec6e0973944a3301c01f5545fbfca0b7。安装前核对上游来源和版本:https://skills.sh/anthropics/claude-agent-sdk-demos/listener-creator。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
skills.sh
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
创建基于事件的电子邮件监听器,用于监控特定条件(例如来自老板的紧急邮件、需要归档的新闻简报、包裹跟踪信息),并在触发时执行自定义操作,适用于希望收到邮件通知、自动处理邮件或设置电子邮件自动化工作流的场景。
介绍来源: third_party · anthropics · 1.0.0 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 适合谁
- 翻译待完成,请参阅来源文档。
- 输入和输出
- 翻译待完成,请参阅来源文档。
- 实测状态
- 未测试
文件浏览
Frontmatter
name: listener-creator
description: Creates event-driven email listeners that monitor for specific conditions (like urgent emails from boss, newsletters to archive, package tracking) and execute custom actions. Use when user wants to be notified about emails, automatically handle certain emails, or set up email automation workflows.
allowed-tools: Write, Edit, Read, GlobListener Creator
Creates TypeScript listener files that monitor email events and execute custom logic when conditions are met.
When to Use This Skill
Use this skill when the user wants to:
- Get notifications about specific emails ("notify me when boss sends urgent emails")
- Automatically handle certain emails ("auto-archive newsletters")
- Monitor for patterns ("watch for package tracking emails")
- Set up scheduled actions ("daily email summary at 9am")
- Create custom email workflows
How Listeners Work
Listeners are TypeScript files in agent/custom_scripts/listeners/ that:
- Export a
configobject defining the event type and metadata - Export a
handlerfunction that filters and processes events - Use
ListenerContextmethods to perform actions (notify, archive, star, etc.)
The system automatically loads enabled listeners and executes them when matching events occur.
Creating a Listener
1. Understand the User's Intent
Parse the user's request to identify:
- Event type: What triggers this listener? (email_received, email_sent, email_starred, email_archived, email_labeled, scheduled_time)
- Filter conditions: What specific emails/events to match? (sender, subject keywords, time-based)
- Actions: What should happen? (notify, archive, star, mark as read, add label)
- Priority: How urgent is this? (high/normal/low)
2. Choose an Event Type
// Available event types:
- "email_received" // Most common - new email arrives
- "email_sent" // User sends an email
- "email_starred" // Email is starred
- "email_archived" // Email is archived
- "email_labeled" // Label added to email
- "scheduled_time" // Time-based (cron) - requires scheduler setup
3. Write the Listener File
Create a file in agent/custom_scripts/listeners/ with this structure:
import type { ListenerConfig, Email, ListenerContext } from "../types";
export const config: ListenerConfig = {
id: "unique_listener_id", // kebab-case, descriptive
name: "Human Readable Name", // For UI display
description: "What this does", // Optional but helpful
enabled: true, // Start enabled
event: "email_received" // Event type
};
export async function handler(email: Email, context: ListenerContext): Promise<void> {
// 1. Basic filter (identity/sender only)
if (!email.from.includes("example@email.com")) return;
// 2. Use AI for intelligent classification (PREFERRED over keyword matching)
const analysis = await context.callAgent<{ isUrgent: boolean; reason: string }>({
prompt: `Is this email urgent?\nSubject: ${email.subject}\nBody: ${email.body.substring(0, 500)}`,
schema: {
type: "object",
properties: {
isUrgent: { type: "boolean" },
reason: { type: "string" }
},
required: ["isUrgent", "reason"]
},
model: "haiku"
});
if (!analysis.isUrgent) return;
// 3. Perform actions via context methods
await context.notify(`Urgent email: ${email.subject}\n${analysis.reason}`, {
priority: "high"
});
await context.starEmail(email.messageId);
}
4. File Naming Convention
Use kebab-case matching the listener's purpose:
boss-urgent-watcher.tsauto-archive-newsletters.tspackage-tracking.tsdaily-summary.ts
5. Available Context Methods
The ListenerContext provides these methods:
// Notifications
await context.notify(message, { priority: "high" | "normal" | "low" });
// Email actions
await context.archiveEmail(emailId);
await context.starEmail(emailId);
await context.unstarEmail(emailId);
await context.markAsRead(emailId);
await context.markAsUnread(emailId);
await context.addLabel(emailId, "label-name");
await context.removeLabel(emailId, "label-name");
// AI-powered analysis
const result = await context.callAgent<ResultType>({
prompt: "Your prompt with email content",
schema: {
type: "object",
properties: { field: { type: "string" } },
required: ["field"]
},
model: "haiku" // or "sonnet" or "opus"
});
Recommended Approach: AI-Powered Classification
Default to using context.callAgent() for intelligent decision-making instead of hard-coded keyword lists. This provides better accuracy and adaptability.
// PREFERRED: AI-based urgency detection
const analysis = await context.callAgent<{ isUrgent: boolean; reason: string }>({
prompt: `Analyze if this email is urgent:
Subject: ${email.subject}
Body: ${email.body.substring(0, 500)}
Is this email urgent or time-sensitive? Consider context, not just keywords.`,
schema: {
type: "object",
properties: {
isUrgent: { type: "boolean" },
reason: { type: "string" }
},
required: ["isUrgent", "reason"]
},
model: "haiku" // Fast and cost-effective
});
if (analysis.isUrgent) {
await context.notify(`Urgent: ${email.subject}\n${analysis.reason}`);
}
// AVOID: Hard-coded keyword lists (brittle and prone to false positives)
// const isUrgent = subject.includes("urgent") || subject.includes("asap");
Examples and Templates
Reference the template files for common patterns:
- ai-classifier.ts: ⭐ AI-powered email classification (RECOMMENDED)
- urgent-watcher.ts: AI-based urgent email detection
- auto-archive.ts: Automatically archives newsletters
- package-tracker.ts: Package tracking with status extraction
Best Practices
- Prefer AI Classification: Use
context.callAgent()instead of hard-coded keyword lists for intelligent decision-making - Filter Early: Return early if email doesn't match basic criteria (like sender)
- Clear IDs: Use descriptive, unique listener IDs
- Error Handling: Wrap context method calls in try-catch when appropriate
- Performance: Use "haiku" model for fast AI classification (< 1 second typical)
- Notify Wisely: Only notify when truly important
- Avoid Hard-Coded Lists: Let AI determine urgency, importance, or categories instead of keyword matching
Type Imports
Always import types from the correct location:
import type { ListenerConfig, Email, ListenerContext } from "../types";
// For scheduled listeners:
import type { ListenerConfig, ListenerContext } from "../types";
// For labeled event:
import type { ListenerConfig, Email, ListenerContext } from "../types";
Common Patterns
AI-Powered (PREFERRED)
Basic filter (sender/type) → Call AI agent for intelligent classification → Act on AI result → Notify if important
This is the recommended approach for most listeners as it:
- Avoids brittle keyword matching
- Adapts to nuanced language and context
- Makes better decisions about urgency and categorization
- Reduces false positives
Simple Notification (Use sparingly)
Basic filter (sender only) → Notify → Optional star/label
Only use this when: The trigger is purely identity-based (e.g., "notify me about ALL emails from X")
Auto-Archive
Basic filter → Archive → Mark as read → Optional notify
Scheduled
Run at specific time → Query emails → Analyze → Send summary
Creating the File
When the user requests a listener:
-
Ask clarifying questions if the intent is unclear:
- Who is the sender? What keywords?
- What action should happen?
- How urgent is this?
-
Choose the right event type (usually
email_received) -
Write the TypeScript file in
agent/custom_scripts/listeners/ -
Use Write tool to create the file with:
- Proper imports
- Descriptive config
- Handler with early filtering
- Appropriate context method calls
-
Return listener reference in markdown format using
[listener:filename.ts]notation (e.g.,[listener:boss-urgent-watcher.ts]) for easy parsing and linking in the UI -
Confirm with user that the listener matches their intent
Output Format Example
When presenting a created listener to the user, use this format:
Created listener: [listener:boss-urgent-watcher.ts]
This listener will:
- Monitor emails from boss@company.com
- Use AI to detect urgent emails (not just keywords)
- Send high-priority notifications for truly urgent emails
- Star emails that require immediate action
When to Use AI vs Simple Filtering
Use AI (context.callAgent()) when:
- Detecting urgency, importance, or sentiment
- Classifying email content or intent
- Extracting structured data from email bodies
- Making nuanced decisions based on context
- Any logic that involves "understanding" the email content
Use simple filtering when:
- Checking exact sender/recipient
- Basic pattern matching on email fields (e.g., "from specific domain")
- Identity-based triggers (e.g., "all emails from X person")
Default to AI unless the filter is purely identity-based.
Scheduled Listeners
For time-based actions (daily summaries, weekly reports):
export const config: ListenerConfig = {
id: "daily_summary",
name: "Daily Email Summary",
enabled: true,
event: "scheduled_time"
// Note: Cron schedule configured separately in scheduler
};
export async function handler(
data: { timestamp: Date },
context: ListenerContext
): Promise<void> {
// Your scheduled logic here
await context.notify("Good morning! Your daily summary...");
}
Note: Scheduled listeners require cron scheduler configuration outside the listener file.
Reference
Full specification: See project root LISTENERS_SPEC.md for complete details on:
- All event types
- Complete type definitions
- ListenersManager implementation
- Advanced examples
- Error handling patterns
当前收录版本
1.0.0
安全与评测信息
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 解决明确的邮件自动化需求,提升工作效率
- 覆盖多种实际使用场景(紧急邮件通知、自动归档、包裹跟踪等)
- 提供AI智能分类推荐,避免硬编码关键词的局限性
待提升项
-
触发词覆盖范围 原报告严重程度:轻微
触发词覆盖合理,但可进一步细化边缘场景
改进建议:可考虑增加更多具体场景的触发词变体,如'邮件自动化'、'邮件规则'等
亮点
- 触发词精准完整,覆盖多种邮件处理场景
- 边界清晰,用户意图识别准确
待提升项
-
文档长度 原报告严重程度:轻微
文档内容详尽但长度超过500行
改进建议:可考虑将部分内容移至参考文档或模板文件中
亮点
- Phase/步骤清晰,有明确的出口条件
- 包含完整的端到端示例和最佳实践
- frontmatter完整,文件结构规范
亮点
- 工具来源明确,参数使用正确
- 推荐AI分类方法,覆盖主要异常场景
- 提供了完整的错误处理建议和性能优化指导
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。