Communitygithub.com

baronguyen001/ai-automation-skills

将记录持久化到仅追加的 JSON Lines 文件中(每行一个对象),支持流式读取和基于键的可选去重,仅使用标准库。适用于记录运行结果到 JSONL、追加事件到文件、跨运行按 ID 去重,或在无数据库情况下维护简单的持久化历史。

ai-automation-skills 是什么?

这个技能提供了一个轻量级的 JSONL 存储方案,专为需要记住已处理状态的计划任务设计,而无需引入数据库。它通过 `JsonlStore` 类实现原子追加、流式读取(即使文件行损坏也能继续),以及 `append_unique` 方法确保同一 key 的记录不会被重复写入。支持标准库,无需外部依赖,适用于记录运行结果、追加事件或跨执行维护去重历史。主要与 Claude Code、Cursor 和 Codex 等 AI 代理工具配合使用,通过简单 API 调用即可实现持久化状态管理。该方案也能与调度器结合,使文件成为调用间的可靠内存。

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

在你喜欢的 AI 中提问

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

文档

JSONL 存储

当计划任务需要记住已完成的工作——例如已发出的告警、处理过的 ID、捕获的事件——而数据库又过于笨重时,使用本技能。JSON Lines(每行一个 JSON 对象)是可追加、人类可读、可 grep、且无需加载整个文件就能流式读取的格式。本助手提供原子追加、即使行损坏也能继续的流式读取,以及 append_unique(record, key) 方法,确保同一 ID 在跨运行时不会被写入两次。

何时调用

  • 用户说:“将结果记录到 JSONL 文件”、“追加事件到磁盘”、“按 ID 跨运行去重”、“无需数据库的简单历史记录”。
  • 一个 cron/计划脚本需要在一个平面文件中维护持久化的跨运行状态。

何时不调用

  • 需要查询、索引或并发写入——请使用 SQLite(sqlite-state)或真正的数据库。
  • 记录很大或为二进制——JSONL 适用于小型结构化行。

具体示例

用户输入:

每次运行后,将新告警追加到 alerts.jsonl 中,但同一告警 ID 不能重复出现两次。

输出:

# 将 assets/store.py 复制到你的项目中,然后:
from store import JsonlStore

store = JsonlStore("data/alerts.jsonl")
for alert in new_alerts:
    if store.append_unique(alert, key="id"):
        send(alert)        # 仅对任何先前运行中未见过的 ID 触发

print("历史大小:", store.count())

读取是逐行流式的,因此一整年的历史记录永远不会完全加载到内存中,崩溃时写入一半的最后一行会被跳过,不会破坏下次运行。

应用模式

  1. 每行一个 JSON 对象;使用 ensure_ascii=False 追加,以便文本保持可读。
  2. 使用生成器进行流式读取;跳过空行或损坏的行而不是抛出异常。
  3. 使用 seen_keys(key) / append_unique(record, key) 进行去重,使运行幂等。
  4. 与调度器配对,使文件成为调用间的持久化内存。

参考:assets/store.py。

来源

源自作者的计划机器人状态处理实践。v1.0.0。 另见:[[sqlite-state]]、[[cron-dispatch]]、[[pipeline-orchestrator]]。

→ 使用 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

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.

baronguyen001/ai-automation-skills

Give scheduled scripts memory between runs with one SQLite file - a seen-set for dedup, a key/value cursor to resume where you left off, and order-preserving new-item filtering. Use for dedup across runs, don't re-alert the same item, remember the last id, resume a scraper, or persist state between cron runs.

相关技能