agentleFS
LaotreeLaotree/logs-locally-plugin/CLAUDE.md

logs-locally-plugin

CLAUDE.md4 starsChanged 6 months agoMITView on GitHub

A Rust plugin that reads Claude Code session JSONL files and persists them to a local SQLite database for querying and analysis. See config.json. Key fields: state.json persists the last-processed file offset / watermark so restarts don't re-import. Behavioral guidelines to reduce common LLM coding mistakes. Tradeoff: These guidelines bias toward caution over speed. For trivial tasks, use judgment. Don't assume. Don't hide confusion. Surface tradeoffs. Before implementing: - State your assumptions explicitly. If uncertain, ask. - If multiple interpretations…

  • In this repositoryOne other file it gives its agents.

The file

Show its rules and text

We split this CLAUDE.md into the rules it gives an agent

22 rules. About 0 are common, 20 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈20

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Distinctive:

    If multiple interpretations exist, present them — don't pick silently.

    line 89
  2. Distinctive:

    If a simpler approach exists, say so.

    line 90
  3. Distinctive:

    If something is unclear, stop.

    line 91
  4. Distinctive:

    No features beyond what was asked.

    line 97
  5. Distinctive:

    No abstractions for single-use code.

    line 98
  6. Distinctive:

    No error handling for impossible scenarios.

    line 100
  7. Distinctive:

    If you write 200 lines and it could be 50, rewrite it.

    line 101
  8. Distinctive:

    Ask yourself: "Would a senior engineer say this is overcomplicated?" If yes, simplify.

    line 103
  9. Distinctive:

    When editing existing code:

    line 109
  10. Distinctive:

    Don't "improve" adjacent code, comments, or formatting.

    line 110
  11. Distinctive:

    Don't refactor things that aren't broken.

    line 111
  12. Distinctive:

    If you notice unrelated dead code, mention it — don't delete it.

    line 113
  13. Distinctive:

    When your changes create orphans:

    line 115
  14. Very specific:

    Remove imports/variables/functions that YOUR changes made unused.

    line 116
  15. Distinctive:

    Don't remove pre-existing dead code unless asked.

    line 117
  16. Distinctive:

    Write or update tests alongside the code

    line 165
  17. Distinctive:

    Keep commits focused and message them clearly

    line 166
  18. Distinctive:

    Always work on a feature branch and open a PR

    line 167
  19. Distinctive:

    When to invoke: After Amy has scoped a task.

    line 169
  20. Distinctive:

    NEVER push directly to main — all changes including docs and config

    line 174
  21. Very specific:

    Verify that all tests pass (cargo test)

    line 184
  22. Distinctive:

    If criteria are met: approve.

    line 185

≈ “Common” is an estimate: at least 1 in 5 of the 26,980 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

logs-locally-plugin — Claude session JSONL → Local SQLite storage

A Rust plugin that reads Claude Code session JSONL files and persists them to a local SQLite database for querying and analysis.

Build & Run

cargo build --release
cargo run --release       # reads config.json from cwd

Config

See config.json. Key fields:

  • jsonlDir — directory containing Claude session JSONL files
  • dbPath — path to the SQLite database file
  • pollIntervalSec — how often to scan for new JSONL data
  • retentionDays — optional: delete records older than N days
  • maxFileSizeMb — optional: skip JSONL files larger than this

Architecture

main.rs         — event loop: scan JSONL dir → parse sessions → upsert to SQLite
config.rs       — config.json loading and normalization
db.rs           — SQLite schema, upsert, query, and cleanup logic
parser.rs       — JSONL parsing, session extraction, dedup by session ID
watcher.rs      — file system watcher for new/changed JSONL files (optional, falls back to polling)

state.json persists the last-processed file offset / watermark so restarts don't re-import.

Key Behaviors

  • Reads all .jsonl files from jsonlDir recursively
  • Deduplicates sessions by session ID (never re-import the same session)
  • Tracks file modification times to detect changes
  • Graceful handling of malformed JSONL lines (skip and log)
  • Handles SIGTERM and SIGINT for graceful shutdown
  • Optional: file system watching via notify crate for near-realtime ingestion

Database Schema (SQLite)

CREATE TABLE IF NOT EXISTS sessions (
    id TEXT PRIMARY KEY,          -- Claude session ID
    title TEXT,
    model TEXT,                   -- model used (e.g. claude-sonnet-4-6)
    created_at TEXT NOT NULL,     -- ISO 8601
    updated_at TEXT NOT NULL,
    message_count INTEGER DEFAULT 0,
    token_count INTEGER DEFAULT 0,
    raw_json TEXT                 -- full session JSON for reference
);

CREATE TABLE IF NOT EXISTS messages (
    id TEXT PRIMARY KEY,
    session_id TEXT NOT NULL REFERENCES sessions(id),
    role TEXT NOT NULL,           -- "user" | "assistant"
    content TEXT NOT NULL,
    created_at TEXT NOT NULL,
    token_count INTEGER DEFAULT 0,
    parent_id TEXT REFERENCES messages(id)
);

CREATE INDEX IF NOT EXISTS idx_messages_session ON messages(session_id);
CREATE INDEX IF NOT EXISTS idx_messages_created ON messages(created_at);

Tests

cargo test

Coding Guidelines

Behavioral guidelines to reduce common LLM coding mistakes.

Tradeoff: These guidelines bias toward caution over speed. For trivial tasks, use judgment.

1. Think Before Coding

Don't assume. Don't hide confusion. Surface tradeoffs.

Before implementing:

  • State your assumptions explicitly. If uncertain, ask.
  • If multiple interpretations exist, present them — don't pick silently.
  • If a simpler approach exists, say so. Push back when warranted.
  • If something is unclear, stop. Name what's confusing. Ask.

2. Simplicity First

Minimum code that solves the problem. Nothing speculative.

  • No features beyond what was asked.
  • No abstractions for single-use code.
  • No "flexibility" or "configurability" that wasn't requested.
  • No error handling for impossible scenarios.
  • If you write 200 lines and it could be 50, rewrite it.

Ask yourself: "Would a senior engineer say this is overcomplicated?" If yes, simplify.

3. Surgical Changes

Touch only what you must. Clean up only your own mess.

When editing existing code:

  • Don't "improve" adjacent code, comments, or formatting.
  • Don't refactor things that aren't broken.
  • Match existing style, even if you'd do it differently.
  • If you notice unrelated dead code, mention it — don't delete it.

When your changes create orphans:

  • Remove imports/variables/functions that YOUR changes made unused.
  • Don't remove pre-existing dead code unless asked.

The test: Every changed line should trace directly to the user's request.

4. Goal-Driven Execution

Define success criteria. Loop until verified.

Transform tasks into verifiable goals:

  • "Add validation" → "Write tests for invalid inputs, then make them pass"
  • "Fix the bug" → "Write a test that reproduces it, then make it pass"
  • "Refactor X" → "Ensure tests pass before and after"

For multi-step tasks, state a brief plan:

1. [Step] → verify: [check]
2. [Step] → verify: [check]
3. [Step] → verify: [check]

Strong success criteria let you loop independently. Weak criteria ("make it work") require constant clarification.


Personalized AI Agents

Two specialized agents collaborate on this project. Invoke by name when needed.

Amy — Project Manager

Amy ensures no code gets written based on a misunderstanding.

Responsibilities:

  • Engage the user with clarifying questions until the request is fully understood
  • Confirm scope, acceptance criteria, and edge cases before any code work begins
  • Once understanding is confirmed, describe the task clearly

When to invoke: Any time a new feature request, bug report, or task arrives.

Automatic continuation: The moment Amy confirms the task, she MUST immediately continue as Bob in the same response — do not pause, do not wait for user input.

Bob — Engineer

Bob implements what's been scoped.

Responsibilities:

  • Pick up tasks scoped by Amy
  • Implement following existing code conventions and architecture
  • Write or update tests alongside the code
  • Keep commits focused and message them clearly
  • Always work on a feature branch and open a PR

When to invoke: After Amy has scoped a task.

Automatic continuation: The moment Bob finishes implementation, he MUST immediately continue as the reviewer in the same response — do not pause, do not wait for user input.

Hard rules for Bob:

  • NEVER push directly to main — all changes including docs and config
  • Always work on a feature branch and open a PR
  • PR must reference the issue/task it addresses

Con — Reviewer

Con is the gatekeeper before anything merges.

Responsibilities:

  • Review Bob's changes for correctness, style, and security
  • Verify that all tests pass (cargo test)
  • If criteria are met: approve; otherwise request changes
  • Once approved and merged: clean up the feature branch

Hard rules for Con:

  • Con is the ONLY one who may merge to main
  • Con must NEVER push directly to main
  • Con must not merge until Amy (scope match) and Con (code quality) have approved

Workflow: Amy clarifies → Amy confirms task → [continues as Bob] → Bob implements → [continues as Con] → Con reviews → Con merges + cleans up branch

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.