Communitygithub.com

baronguyen001/ai-automation-skills

为计划脚本提供跨运行周期的记忆能力——使用单个 SQLite 文件实现去重集合、断点续传游标和保留顺序的新项目过滤。适用于不同运行间的去重、避免重复告警、记住最后 ID、恢复爬虫或持久化 cron 任务状态。

ai-automation-skills 是什么?

这个技能的核心是让定时任务拥有跨运行周期的记忆能力,通过单个 SQLite 文件实现简单、可靠的状态持久化。它提供了三个核心功能:一个用于去重的“已见集合”(seen-set),防止同一个项目被重复告警;一个键值对形式的“游标”(cursor),用于记录处理进度,实现断点续传;以及一个保留顺序的新项目过滤机制。该技能主要面向开发者,适用于开发工具(如脚本、cron 任务)和 AI 代理(如 Claude Code、Cursor、Codex)场景,帮助它们避免重复处理、记住最后处理位置,从而提升效率。其工作原理是使用 Python 模块 `state.py` 中的 `filter_new` 和 `mark_seen` 函数,配合 SQLite 的文件锁机制,确保数据一致性和并发安全性。无需额外依赖,轻量且高效,非常适合中小规模的自动化任务。

兼容平台~Claude Code~Codex CLI✓Cursor
npx skills add https://github.com/baronguyen001/ai-automation-skills/tree/HEAD/skills/sqlite-state

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

SQLite 状态管理

当重复性任务需要记住它已经完成的工作——比如已经告警过的项目、已处理的最后游标——从而避免在下一个 tick 中重复通知或重复抓取时,请使用此技能。一个标准库中的 SQLite 文件即可提供持久化、带文件锁的状态,无需服务器,也无需额外依赖。

何时调用

  • 用户说:“不要重复告警同一个东西”、“跨运行去重”、“记住最后 ID”、“从中断处恢复”。
  • 对话中的代码是一个 cron/计划脚本,当前每次运行都会重新处理所有内容。

何时不应调用

  • 状态很小且仅在单次运行中短暂存在——此时普通的集合/字典就足够了。
  • 多台机器需要并发共享状态——请使用真正的服务器数据库,而不是单个文件。

具体示例

用户输入:

我的新闻爬虫每小时都会重复发送相同的标题。让它只发送新的。

输出:

from state import filter_new, mark_seen

db = "news.db"
fresh = filter_new(db, [a["url"] for a in articles])   # 只保留未见的 URL
for url in fresh:
    send_alert(url)
mark_seen(db, *fresh)                                   # 记录它们,供下次运行使用

应用模式

  1. 使用稳定且唯一的键来标识每个项目(URL、ID、内容哈希),而不是数组位置。
  2. 使用 filter_new 决定要执行的操作,仅在操作成功后才调用 mark_seen。
  3. 将进度存储为命名游标(set_cursor/get_cursor),以便可恢复的爬虫能够从中断处重新开始。
  4. 启用 WAL 模式,实现耐久写入和并发读取;保持单一写入者。
  5. 备份或版本化管理单个 .db 文件——它是整个任务的记忆。

参考:assets/state.py。

来源

提炼自作者在其自动化项目中的生产实践。v1.0.0。 另见:[[pipeline-orchestrator]]、[[cron-dispatch]]、[[webhook-receiver]]。

→ 使用 Trawlkit 构建完整可运行的机器人。

Individual skills in this repo

This repo contains 9 individual skills — each has its own dedicated page.

baronguyen001/ai-automation-skills

Schedule any script to run on a recurring schedule on Windows (Task Scheduler) or Linux (cron) - register, list, and remove jobs from one command, with logging to a file and a guard against overlapping runs. Use for schedule a script, run nightly, set up a cron job, windows task scheduler, or run on a timer.

baronguyen001/ai-automation-skills

Turn a run's list of result dicts into a schema'd CSV and a Markdown table from one column spec - declare columns once, emit both, with stable ordering and safe escaping, stdlib only, no pandas. Use when the user asks to write results to CSV, export a report, make a markdown summary table, or save a run's output as a spreadsheet.

baronguyen001/ai-automation-skills

Strip HTML to clean plain text with the standard library only (no BeautifulSoup/lxml): drops script/style, turns block tags into line breaks, and collapses whitespace. Use when the user wants readable text from an HTML page/email, to clean scraped HTML before sending it to an LLM, or to build a text index from web content.

baronguyen001/ai-automation-skills

Persist records between scheduled runs as append-only JSON Lines (one object per line) with streaming reads and optional key-based dedup, stdlib only. Use when the user wants to log run results to JSONL, append events to a file, dedup records by id across runs, or keep a simple durable history without a database.

baronguyen001/ai-automation-skills

Extract text and simple table-like rows from a PDF for downstream AI without OCR binaries. Use when the user asks to read a PDF, turn a PDF into text, pull simple tables from statements/reports, or feed PDF content into an LLM pipeline.

baronguyen001/ai-automation-skills

Rotate a pool of HTTP/SOCKS proxies with round-robin selection, failure tracking, and a cooldown that benches dead proxies before retrying. BYO proxy list via env - none are shipped. Use for rotate proxies, spread requests across proxies, avoid IP bans, retry through a different proxy, or proxy health check.

baronguyen001/ai-automation-skills

Parse an RSS 2.0 or Atom feed into normalized item dicts (title, link, id, published, summary) with the standard library only - no feedparser. Use when the user asks to read an RSS/Atom feed, poll a blog/news feed, extract feed entries, or watch a site that publishes a feed.

baronguyen001/ai-automation-skills

Upload and download run artifacts from S3-compatible storage with BYO bucket and credentials from env. Use when the user asks to store scraper output, archive reports, publish artifacts to object storage, fetch a prior run file, or use MinIO/R2/Spaces/S3 without hardcoding credentials.

baronguyen001/ai-automation-skills

Draft a short-form TikTok/Reels/Shorts or long-form video script from a topic and creator persona file - hook variants, beat-structured body, CTA, b-roll cues, caption overlays, and [STORY]/[NUMBER] slots so the model never fabricates personal facts. Use for write a video script, tiktok script, youtube script, or /shortform-script.

相关技能