Communitygithub.com

baronguyen001/ai-automation-skills

在排程執行之間持久化記錄為僅附加的 JSON Lines(每行一個物件),支援串流讀取與可選的基於鍵的去重,僅使用標準函式庫。當使用者想要將執行結果記錄到 JSONL、將事件附加到檔案、跨執行根據 ID 去重紀錄,或是無需資料庫即可保留簡單的持久化歷史記錄時使用。

ai-automation-skills 是什麼?

此技能提供了一個輕量級的 JSONL 儲存機制,專為排程腳本需要在執行之間持久化狀態但不需要完整資料庫的場景設計。它使用 JSON Lines 格式(每行一個 JSON 物件),支援原子性附加、串流讀取(即使遇到損毀行也能存活),以及透過 `append_unique(record, key)` 函式實現基於鍵的去重,確保相同 ID 的記錄不會被寫入兩次。它完全依賴 Python 標準函式庫,無需外部依賴。此技能支援 Claude Code、Cursor、Codex 等 AI 代理平台,讓開發者能輕鬆地在排程任務中記錄結果、附加事件或維護簡單的歷史記錄。其運作方式是將一個 `JsonlStore` 類別(位於 `assets/store.py`)複製到專案中,然後使用 `append()`、`append_unique()`、`seen_keys()` 和 `count()` 等方法進行操作。串流讀取機制確保即使累積了很長的歷史記錄也不會耗盡記憶體,而壓垮的最後一行(來自崩潰)會被跳過,不會破壞後續的執行。

相容平台~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.

相關技能