
1. OpenClaw技能开发概述为什么选择自定义Hacker News简报技能在信息爆炸的时代技术从业者每天需要从海量内容中筛选有价值的信息。Hacker News作为全球知名的技术社区汇聚了大量高质量的技术讨论、创业故事和前沿趋势。但手动浏览筛选不仅耗时还容易错过关键内容。这正是我们开发自定义Hacker News每日简报技能的初衷。OpenClaw的Skill开发机制与传统编程有本质区别。它不需要你搭建后端服务或处理API调用而是通过Markdown文档定义AI的工作流。就像给一位聪明的助手写操作手册你只需要告诉它什么时候该执行这个任务触发条件具体要做哪些事情工作流程结果应该长什么样输出格式我选择Hacker News作为首个实战案例主要基于三个实际需求信息过滤自动筛选评分200的热门帖子避免被低质量内容干扰定时推送每天早上9点准时送达形成稳定的信息摄入节奏个性化定制可以自由添加过滤关键词如AI、Rust等2. 环境准备与OpenClaw部署2.1 本地化部署方案选型根据我的实测经验本地部署相比云端方案有三大优势隐私安全所有数据处理都在本地完成响应速度无需网络请求执行速度更快成本控制长期使用无需支付API调用费用推荐使用Docker部署能完美解决依赖冲突问题。以下是经过优化的部署命令适用于Linux/macOS# 安装必要工具 sudo apt update sudo apt install -y docker.io git python3-pip # 配置docker免sudo sudo usermod -aG docker $USER newgrp docker # 获取OpenClaw镜像 docker pull registry.gitlab.com/openclaw/core:stable # 启动容器注意端口映射 docker run -d --name openclaw \ -p 18789:18789 \ -v ~/.openclaw:/root/.openclaw \ registry.gitlab.com/openclaw/core:stable重要提示如果使用Windows系统建议通过WSL2运行Docker直接使用Windows版Docker可能会遇到路径权限问题。2.2 模型接入配置虽然可以使用云端大模型API但为了简报技能的稳定性我推荐本地部署轻量级模型。DeepSeek的7B参数版本在消费级显卡上就能流畅运行# ~/.openclaw/config.yaml 模型配置片段 models: providers: local: base_url: http://localhost:5000 models: - id: deepseek-7b name: DeepSeek Local启动模型服务的命令需要先安装DeepSeek推理镜像docker run -d --gpus all -p 5000:5000 \ deepseek/llm:7b-inference \ --quantize bitsandbytes3. Hacker News简报技能开发实战3.1 技能目录结构设计规范的目录结构能让技能更易维护。这是我的推荐结构hackernews-daily/ ├── SKILL.md # 核心技能定义 ├── scripts/ │ ├── fetch_hn.py # 数据抓取脚本 │ └── format.py # 内容格式化脚本 └── templates/ └── report.md # 简报模板文件3.2 SKILL.md核心编写要点技能定义文件是OpenClaw的核心需要特别注意以下几个部分--- name: hackernews-daily description: 每日精选Hacker News热门技术文章。 Use when: 用户请求今日技术简报或定时触发。 NOT for: 非技术类内容查询。 --- ## When to Run - 每天 09:00 (时区自动适配) - 用户明确说HN简报、技术动态 - 当用户询问今天有什么值得关注的技术 ## Workflow 1. 调用脚本获取数据 bash python3 scripts/fetch_hn.py --min-score 200 --limit 10清洗数据python3 scripts/format.py --template templates/report.md按模板生成最终简报Output FormatHacker News 每日精选{日期}{% for item in items %} {{item.score}}分 | {{item.title}} {{item.comments}}条评论 | {{item.tags|join(, )}} {% endfor %}### 3.3 Python抓取脚本实现 fetch_hn.py脚本的核心功能是 1. 通过HN官方API获取数据 2. 按分数过滤内容 3. 添加自定义标签 python # scripts/fetch_hn.py import requests import argparse from datetime import datetime def get_top_stories(min_score100, limit5): stories [] ids requests.get(https://hacker-news.firebaseio.com/v0/topstories.json).json() for id in ids[:limit*2]: # 多取一些防止过滤后不足 item requests.get(fhttps://hacker-news.firebaseio.com/v0/item/{id}.json).json() if item.get(score, 0) min_score and item.get(type) story: stories.append({ title: item.get(title, No title), url: item.get(url, fhttps://news.ycombinator.com/item?id{id}), score: item.get(score, 0), comments: item.get(descendants, 0), time: datetime.fromtimestamp(item.get(time, 0)).strftime(%H:%M), tags: detect_tech_tags(item.get(title, )) }) if len(stories) limit: break return stories def detect_tech_tags(title): tags [] tech_keywords {AI: [llm, ai, gpt], Rust: [rust], Web: [react, vue, javascript]} for tag, keywords in tech_keywords.items(): if any(kw in title.lower() for kw in keywords): tags.append(tag) return tags or [General]4. 高级功能实现与优化4.1 定时任务配置通过OpenClaw的cron系统实现精准推送openclaw cron add \ --name HN早报 \ --cron 0 9 * * * \ --session morning-brief \ --message 生成今日HN技术简报4.2 用户偏好记忆在技能目录下创建preferences/文件夹存储用户自定义设置# preferences/user_settings.yaml filter: min_score: 250 blocked_keywords: [政治, 招聘] favorite_tags: [AI, Rust]然后在SKILL.md中引用这些配置## Workflow 1. 加载用户偏好 bash cat preferences/user_settings.yaml根据偏好过滤内容...### 4.3 多格式输出支持 通过修改format.py脚本可以同时生成多种格式的简报 python # scripts/format.py def generate_output(items, formatmarkdown): if format markdown: return _markdown_template(items) elif format html: return _html_template(items) elif format slack: return _slack_template(items) def _markdown_template(items): return \n.join( f### {item[title]}\n f- Score: {item[score]}\n f- URL: {item[url]} for item in items )5. 常见问题排查手册5.1 技能未触发检查清单权限问题chmod x scripts/*.py路径错误openclaw debug --skill hackernews-daily描述模糊检查description是否足够具体确认NOT for条件是否明确5.2 内容抓取失败处理当HN API不可用时可以启用备用数据源# scripts/fetch_hn.py def get_top_stories(): try: # 主API return requests.get(https://hacker-news.firebaseio.com/v0/topstories.json, timeout5) except: # 备用方案 return requests.get(https://hn.algolia.com/api/v1/search?tagsfront_page, timeout5)5.3 性能优化技巧对于高频更新的技能建议添加缓存机制24小时自动过期functools.lru_cache(maxsize1, ttl86400) def get_cached_stories(): return get_top_stories()使用异步请求提升速度async with aiohttp.ClientSession() as session: async with session.get(url) as resp: return await resp.json()6. 技能分享与团队协作6.1 打包为ClawHub插件# 在技能目录下 clawhub init clawhub set --name HN每日精选 \ --version 1.0.0 \ --description 自动生成Hacker News技术简报 clawhub publish6.2 企业微信/飞书集成通过webhook将简报推送至办公软件# scripts/notify.py def send_to_wecom(content): requests.post( https://qyapi.weixin.qq.com/cgi-bin/webhook/send, json{ msgtype: markdown, markdown: {content: content} } )在SKILL.md最后添加推送步骤## Workflow ... 4. 推送至企业微信 bash python3 scripts/notify.py经过三周的持续迭代这个HN简报技能已经成为我个人技术信息获取的主要渠道。最大的收获不是节省了多少时间而是建立了一套可扩展的自动化信息处理流程。现在我可以轻松地添加Reddit、技术博客等其他数据源只需要复制修改现有的技能框架。OpenClaw这种说明书式的开发模式确实让非专业开发者也能创建实用的AI工具。