clicodelog
CLAUDE.md49 starsChanged 3 months agoMITView on GitHub
Never test against port 6126 — that is the user's running instance. Use a different port (--port 6231). clicodelog is a local-first web app that backs up AI agent logs to ~/.clicodelog/data/ and serves them via a FastAPI browser UI. There are three layers, and keeping them straight is the main thing: 1. The backup (sync.py) — an additive, never-deleting copy of each source tool's log directory, made with APFS clonefile so it costs almost no disk. This is the…
- Installs packages
The file
We split this CLAUDE.md into the rules it gives an agent
10 rules. About 0 are common, 1 is distinctive, and 9 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 90
Never write user data non-atomically: Use storage.write_json. Bookmarks and project metadata are the only irreplaceable data in the app.
- Very specific: line 93
Never unlink before copying in sync: Use temp + os.replace. If the copy fails after an unlink, and the source tool already pruned that …
- Very specific: line 96
Never pass user text to FTS5
MATCHraw: Use fts.build_match(). FTS5's query grammar is not its tokenizer: search.py raises a syntax … - Very specific: line 107
Validate route ids with
is_safe_id/safe_child: before joining them into a filesystem path. - Very specific: line 112
Add an entry to SOURCES in config.py.
- Very specific: line 113
Add a reader branch in scan.py and an entry-shape branch in search_index._entry_for.
- Very specific: line 115
Add a parser module in parsers/ and export it from parsers/__init__.py.
- Very specific: line 116
Add an extractor to fts._EXTRACT.
- Very specific: line 117
Add the source to the parametrised contract test in tests/test_sources.py.
- Distinctive: line 125
Max file size: ~300 lines: When a file approaches this, split it before adding more.
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 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.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Commands
# Install from source (editable, changes take effect immediately)
uv pip install -e .
# Run the app
clicodelog
# or without installing:
uv run python -m clicodelog.cli
# Common flags
clicodelog --port 8080 # custom port (default: 6126)
clicodelog --no-sync # skip initial sync (faster startup for dev)
clicodelog --debug # debug logging to console as well as file
# Tests
uv run python -m pytest tests/ -q
# Build for distribution
uv build # produces dist/*.whl and dist/*.tar.gzNever test against port 6126 — that is the user's running instance. Use a
different port (--port 6231).
Architecture
clicodelog is a local-first web app that backs up AI agent logs to
~/.clicodelog/data/ and serves them via a FastAPI browser UI.
There are three layers, and keeping them straight is the main thing:
- The backup (
sync.py) — an additive, never-deleting copy of each source tool's log directory, made with APFSclonefileso it costs almost no disk. This is the durable source of truth. It deliberately keeps files the source tool has pruned, so it must never delete and never replace a file non-atomically. - The metadata index (
search_index.py) — one small record per session, in~/.clicodelog/search_index.json. Derived state, rebuildable at any time. Session and project listings are served from here, not from the files. - The content index (
fts.py) — SQLite FTS5 over message bodies in~/.clicodelog/fts.db. Also derived. Optional: it is only built on request, and refuses to build if it would not fit on disk.
File map
clicodelog/
├── cli.py # argparse entry point -> server.run_server()
├── app.py # FastAPI setup, cache policy, template routes
├── config.py # SOURCES dict, DATA_DIR, APP_DATA_DIR, constants
├── logging_setup.py # rotating file log at ~/.clicodelog/clicodelog.log
├── storage.py # atomic JSON read/write, quarantine, disk checks
├── scan.py # ONE-PASS session metadata extraction (all 3 sources)
├── sync.py # additive clone-backup, background + initial sync
├── search_index.py # metadata index; backs listings, projects and search
├── fts.py # SQLite FTS5 content index, query sanitizer
├── sessions.py # session listings (from the index)
├── projects.py # project listings (from the index)
├── conversation.py # conversation loading, pagination, LRU cache
├── bookmarks.py # user-authored bookmarks (atomic, locked)
├── metadata.py # custom project names/tags (atomic, locked)
├── utils.py # path ids, id validation, per-source helpers
├── server.py # port handling, startup, uvicorn
├── parsers/ # claude.py, codex.py, gemini.py
├── routes/ # projects, search, export, sync, sources, bookmarks, stats
├── static/css/*.css
├── static/js/*.js # vanilla, no build step; vendor/ holds marked+purify+hljs
└── templates/ # index.html, view.htmlThe root app.py and requirements.txt are legacy Flask artifacts — ignore them.
Rules that exist because something broke
package-datamust includestatic/js/vendor/*.js. That glob does not recurse; without the explicit vendor line every published wheel ships with no markdown renderer, no sanitizer and no syntax highlighting, and fails silently becauserenderMarkdownIntofalls back totextContent.tests/test_packaging.pyguards this.- Route handlers that touch the filesystem must be
def, notasync def. FastAPI runs sync handlers in a threadpool and async ones on the event loop. Declaring them async made a single slow request freeze the entire server (measured:/api/statuswent from 2.5 ms to 12.29 s). - Never write user data non-atomically. Use
storage.write_json. Bookmarks and project metadata are the only irreplaceable data in the app; a corrupt file gets quarantined, never treated as empty. - Never unlink before copying in sync. Use temp +
os.replace. If the copy fails after an unlink, and the source tool already pruned that file, the backup was the only remaining copy. - Never pass user text to FTS5
MATCHraw. Usefts.build_match(). FTS5's query grammar is not its tokenizer:search.pyraises a syntax error, and 8 of 11 realistic developer queries crash without quoting. - The FTS tokenizer is
tokenchars '_.-', not'_./-'. Including/makesroutes/search.pya single token, so typingsearch.pyfinds nothing. - Token counts must include
cache_read_input_tokensandcache_creation_input_tokens. UsetotalTokens()in JS. Summing only input+output reported 0.9% of real usage. - Claude Code project directory names cannot be decoded. It collapses
/,_and-all into-. Treat the directory name as an opaque id and take the display name from the session's recordedcwd. - Validate route ids with
is_safe_id/safe_childbefore joining them into a filesystem path.
Adding a source
- Add an entry to
SOURCESinconfig.py. - Add a reader branch in
scan.pyand an entry-shape branch insearch_index._entry_for. - Add a parser module in
parsers/and export it fromparsers/__init__.py. - Add an extractor to
fts._EXTRACT. - Add the source to the parametrised contract test in
tests/test_sources.py.
Per-source behaviour is still spread across those call sites rather than living
behind one adapter interface; consolidating it into a SourceAdapter is the
obvious next refactor.
File decomposition rules
Max file size: ~300 lines. When a file approaches this, split it before adding more. This applies to Python, JS and CSS.
Frontend
static/js/ is vanilla JS with no build step, loaded as ordered script tags.
State lives in globals declared in state.js. All DOM construction uses
createElement/textContent — never innerHTML with dynamic data. The one
exception is sanitized markdown, which goes through DOMPurify.
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
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.

