作者開發 RuleMine,從編碼智能體對話記錄整理可重用規則
My Coding Agent Forgot Its Own Advice, So I Built RuleMine
Christine Wong 開發本地 CLI 工具 RuleMine,透過 Ollama 執行 gemma2:2b,從編碼智能體對話記錄提取重複修正、架構決策、失敗方案和可重用工作流程。
This is a submission for the Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady
What I Built
Two weeks ago, my coding agent walked me through publishing daily PDF reports to GitHub Releases, warning that committing binaries into the repo itself would bloat the git history. A few days later, in a fresh chat, I asked how to preview the latest run in my browser, and the agent happily suggested committing the PDFs straight to a /reports folder. It had completely forgotten its own architectural advice, leaving me stuck acting as the project’s memory.
That’s where RuleMine comes in. It is a local CLI tool that uses Gemma 2 via Ollama to scan your transcripts for repeated corrections, architectural decisions, rejected alternatives, and potential skills. When it catches you fixing the same habit across sessions, it drafts a rule for AGENTS.md that you can approve with a single keypress. Decisions and explored alternatives land in DECISIONS.md so future agents don't repeat past mistakes, and you can easily tune sensitivity thresholds, swap local models, or test new rules in a sidecar file first.
Demo
Code
Lillliant
/
rulemine
A CLI tool to turn repeated conversation contexts into reusable tools.
RuleMine
Submission for the Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady.
RuleMine is a local CLI tool that mines coding agent transcripts for repeated corrections, architecture choices, dead ends, and reusable workflows across your projects.
Overview
Coding assistants start each conversation without memory of earlier sessions. They repeat mistakes you already corrected: choosing the wrong package manager, suggesting discarded libraries, or re-running failed approaches.
RuleMine extracts memory from past transcripts using an on-device Gemma model, so future agent runs inherit the context:
flowchart LR
A["Transcripts (Antigravity & Cursor)"] --> B["Redact credentials & secrets"]
B --> C["Extract events with local Gemma (Ollama)"]
C --> D["Interactive terminal review"]
D --> E1["AGENTS.md (rules)"]
D --> E2["DECISIONS.md (decisions & dead ends)"]
D --> E3["out/skills/ (reusable workflows)"]
Loading
Extracted events and destinations
| Event | What it catches | Output file |
|---|---|---|
| Correction | User steered the agent away from a habit or mistake (>= 2 times) |
…
How I Built It
The pipeline runs locally, costs nothing, and does not send data to the cloud. It processes data in the following sequence:
- Adapters read Antigravity's JSONL transcripts and Cursor's SQLite state into one turn model, using read-only connections so open editors don't break.
-
Redaction strips API keys, tokens, Bearer headers, and
.envvalues with regex before any text reaches the model or the database. - Windowing groups turns into overlapping chunks of 8 to 12, anchored on user turns, because your corrections carry the strongest signal.
-
Extraction sends each window to
gemma2:2bat temperature 0.2 and requires strict JSON. Pydantic validates the output. A repair step handles responses wrapped in markdown fences or chatter. - Promotion clusters similar events across sessions. A correction becomes a rule only after it repeats at least twice. Decisions and design alternatives need only one occurrence.
- Review shows each draft with the original quote and session ID. Nothing is written to your project until you approve it.
A SHA-256 hash of each transcript lets later runs skip anything unchanged.
On my own history of 52 sessions and about 5,800 turns, it extracted 209 events and drafted 82 proposals. One was the contradictory PDF advice from earlier, logged as a rejected alternative alongside my original reasoning.
Why Does Open Innovation Matter?
Coding agent transcripts hold sensitive details: unreleased code, internal database schemas, and whatever tokens or environment variables accidentally got pasted in during a debugging session. A closed cloud API would mean shipping thousands of raw turns off my machine, which is an immediate non-starter for professional work and uncomfortable even on side projects. Running an open-weight model locally means nothing leaves my laptop.
Cost was the other factor. I run dozens of sessions with thousands of turns every month, so paying a commercial model to scan through that history every week would get expensive fast. A local model is free to run, which means I can re-index my history as often as I want without checking a token counter.
I also wanted the whole setup to be portable. The tool writes out plain markdown files (AGENTS.md and DECISIONS.md) so the results are instantly readable by any editor, git repo, or new agent without a proprietary database in the middle. And because the pipeline uses Ollama for inference, switching from gemma2:2b to whatever lightweight model comes out next year is just a one-line config change.
Prize Categories
-
Best Use of Gemma ($200): RuleMine uses
gemma2:2bthrough Ollama as its extraction engine.
來源:DEV Community · dev.to