使用 Claude Code CLI 和 Obsidian 的每日 AI 新闻摘要——零依赖
如何用6行bash脚本、Claude Code headless模式和macOS launchd构建每日新闻研究代理。
TL;DR
一个6行的bash脚本,每天早上9:00以headless模式运行Claude Code CLI。它在11个可配置主题中搜索新闻,过滤噪音,并将格式化的markdown摘要直接写入通过iCloud同步的Obsidian vault。零依赖。总共约100行配置。
问题
作为开发者,跟踪多种技术是一项日常税收。RSS源嘈杂,Twitter浪费时间,新闻通讯在你深度专注时到达。我需要一个能替我做研究的东西。
典型的解决方案是构建爬虫管道:调度器、爬虫、NLP管道、数据库、通知服务。那需要几周的工作。我想要一个下午就能完成的东西。
架构
整个系统只有4个文件和零依赖:
macOS launchd (9:00 AM daily)
│
└── digest.sh
│
└── claude -p "$(cat prompt.md)" --max-turns 20 --allowedTools Read,WebSearch,WebFetch,Write
│
├── Reads topics.yaml (11 configurable topics)
├── WebSearch → finds news for each topic (last 24-48h)
├── WebFetch → reads full articles
├── Filters noise: old tutorials, promos, AI spam
└── Write → saves digest to Obsidian Vault
│
└── ~/Obsidian Vault/digests/2026-04-12.md
│
└── iCloud sync → available on all devices代码(全部)
项目刻意保持最小化。
入口:digest.sh
整个应用程序是一个6行的bash脚本:
#!/bin/bash
DIGEST_DIR="$HOME/Developer/news-digest"
claude -p "$(cat "$DIGEST_DIR/prompt.md")" \
--max-turns 20 \
--allowedTools Read,WebSearch,WebFetch,Write关键标志:-p以headless模式运行Claude,--max-turns 20给代理足够的回合,--allowedTools限制代理只能读取、搜索和写入。
大脑:prompt.md
这里是智能所在。提示词将Claude变成新闻研究代理:
# News Digest Agent
You are a news research agent. Your job is to find today's most important
and interesting news for a senior frontend developer.
## Instructions
1. Read the topics file at ~/Developer/news-digest/topics.yaml
2. For EACH topic, search the web for news from the last 24-48 hours
3. Filter: only include genuinely new and noteworthy items
4. Write the digest as a markdown file to Obsidian Vault digests/YYYY-MM-DD.md
5. IMPORTANT: Use the Write tool to save the file. Do NOT output to stdout.
## Rules
- Language: Ukrainian for summaries, English for titles and technical terms
- If there's no real news for a topic — SKIP IT ENTIRELY
- Prioritize: releases > breaking changes > security > new patterns > discussions
- Max 5 items per topic, sorted by importance
- Include direct links to sources
- Skip promotional content, generic tutorials, and AI-generated spam配置:topics.yaml
主题完全可配置——添加新主题,它就会出现在明天的摘要中:
topics:
- name: better-auth
context: "auth library for TypeScript. New releases, breaking changes"
- name: Next.js
context: "GitHub issues, releases, App Router, Turbopack, performance"
- name: SolidJS
context: "SolidStart, releases, ecosystem, comparison with React"
- name: Tailwind CSS
context: "v4 updates, new utilities, plugins"
- name: Claude AI
context: "Anthropic announcements, Claude Code, new models, MCP, API"
- name: GPT AI
context: "OpenAI announcements, new models, ChatGPT features"
- name: React
context: "React 19+, Server Components, new patterns, ecosystem"
- name: Apple
context: "Hardware, software, WWDC, developer tools, Apple Intelligence"
- name: Notable People
context: >
Latest tweets from: Elon Musk, Dario Amodei, Sam Altman,
Jensen Huang, Andrej Karpathy, Simon Willison, Swyx...
- name: AI Global
context: "Major AI news, new models, regulations, open-source AI"使用launchd调度
在macOS上,launchd是调度重复任务的原生方式:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.news-digest</string>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>/Users/you/Developer/news-digest/digest.sh</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>9</integer>
<key>Minute</key>
<integer>0</integer>
</dict>
<key>StandardOutPath</key>
<string>/Users/you/Developer/news-digest/logs/stdout.log</string>
<key>StandardErrorPath</key>
<string>/Users/you/Developer/news-digest/logs/stderr.log</string>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/local/bin:/opt/homebrew/bin:/usr/bin:/bin</string>
<key>HOME</key>
<string>/Users/you</string>
</dict>
</dict>
</plist>安装:launchctl load ~/Library/LaunchAgents/com.news-digest.plist。脚本每天9:00运行。
输出效果
每天早上,Obsidian vault中会出现一个新的markdown文件:
---
date: 2026-04-12
---
# News Digest — 2026-04-12
## Next.js
### Next.js 16.1 Released with Improved Turbopack Caching
Нова версія Next.js 16.1 включає покращене кешування для Turbopack,
що зменшує час холодного старту на ~40%.
[Посилання](https://nextjs.org/blog/next-16-1)
### Critical Memory Leak Fix in App Router
Виправлено витік пам'яті в App Router при частому перемиканні
між динамічними маршрутами.
[GitHub Issue](https://github.com/vercel/next.js/issues/...)
## Claude AI
### Claude Code 1.5 — MCP Server Auto-Discovery
Anthropic випустив оновлення Claude Code з автоматичним
виявленням MCP серверів у проєкті.
[Блог](https://www.anthropic.com/news/...)数据一览
| Metric | Value |
|---|---|
| Total files in project | 4 (digest.sh, prompt.md, topics.yaml, .gitignore) |
| Lines of code | ~100 |
| External dependencies | 0 |
| Setup time | ~10 minutes |
| Daily execution time | 2-5 minutes |
| Cost per run | ~$0.10-0.30 (Claude API usage) |
关键设计决策
- Claude Code CLI而非API——无需管理API密钥或HTTP客户端
- Obsidian而非邮件——摘要可搜索、可链接且永久保存
- launchd而非cron——macOS原生调度器,自动处理错过的运行
- YAML配置主题——新主题只需改2行
- 跳过空主题——没有新闻=没有该部分
构建你自己的
10分钟即可运行:
- 安装Claude Code CLI并认证
- 克隆仓库:
git clone https://github.com/oleksiimazurenko/news-digest - 编辑
topics.yaml和prompt.md - 编辑plist文件并
launchctl load - 等待9:00——或用
bash digest.sh手动测试
结论
这个项目最有趣的是它没有什么。没有数据库、没有API服务器、没有Docker、没有npm包、没有Python、没有HTML解析器、没有NLP管道。
这就是用AI代理构建的样子:你定义什么和哪里,代理处理怎么做。总开发时间:约2小时。
来源
- news-digest on GitHub — full source code
- Claude Code Documentation — headless mode and CLI flags
- Apple Developer — creating launchd jobs
- Obsidian — markdown knowledge base