Communitygithub.com

baronguyen001/ai-automation-skills

予定されたジョブ間でレコードを追記専用JSON Linesとして永続化し、ストリーミング読み取りとオプションのキーベース重複排除をstdlibのみで実現します。ユーザーが実行結果をJSONLに記録したり、イベントをファイルに追記したり、IDごとに重複排除したり、データベースなしでシンプルな履歴保存を行いたい場合に使用します。

ai-automation-skills とは?

このスキルは、データベースを使うほどではないが、スケジュール実行されるジョブ間で状態を永続化する必要がある場合に最適です。JSON Lines形式(1行に1つのJSONオブジェクト)を使用し、追記に適しており、人間が読めてgrep可能で、ファイル全体をロードせずにストリーミング読み取りが可能です。`assets/store.py`にある`JsonlStore`クラスは、アトミックな追記、壊れた行をスキップするストリーム読み取り、`append_unique(record, key)`による重複排除を提供します。これにより、同じIDが複数回書き込まれることがなくなり、ジョブの冪等性が保証されます。SQLiteのような本格的なデータベースが不要な軽量な履歴管理や、cronジョブの状態保持に適しています。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/baronguyen001/ai-automation-skills/tree/HEAD/skills/jsonl-store

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

JSONL Store

このスキルは、スケジュールジョブが以前に行ったこと(発行済みアラート、処理済みID、キャプチャ済みイベントなど)を記憶する必要があるが、データベースを使うほどではない場合に使用します。JSON Lines(1行に1つのJSONオブジェクト)は追記に適しており、人間が読めてgrep可能で、ファイル全体をロードせずにストリーミングできます。このヘルパーは、アトミックな追記、壊れた行をスキップするストリーム読み取り、append_unique(record, key)による重複排除を提供するため、同じIDが複数回書き込まれることはありません。

呼び出すタイミング

  • ユーザーが「JSONLファイルに結果を記録」「イベントをディスクに追記」「実行間でIDによる重複排除」「DBなしでシンプルな履歴を保持」と言った場合。
  • cronやスケジュールスクリプトが、フラットファイルに実行間の状態を永続化する必要がある場合。

呼び出さないタイミング

  • クエリ、インデックス、同時書き込みが必要な場合 → SQLite(sqlite-state)や本格的なDBを使用してください。
  • レコードが巨大またはバイナリの場合 → 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行ずつストリーミングされるため、1年分の履歴でもメモリに完全にロードされることはなく、クラッシュによる中途半端な最終行はスキップされ、次の実行が破綻することはありません。

適用パターン

  1. 1行に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.

関連スキル