claude-explorer
AGENTS.md26 starsChanged 20 days agoApache-2.0View on GitHub
Two rules from the user (2026-11-14). They apply to every source (Desktop, Claude Code, Cowork local and remote) and to the list, the viewer, search, and the MCP tools. 1. Show every session that has a turn. The user may want to see and search any session that had an effect on their work. - A turn is a user message or an assistant message. A session with only an assistant turn still has a turn. - Hide only a…
- Reads credentials
- Deletes or force-pushes
- Installs packages
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 33,398 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
28 rules. About 0 are common, 9 are distinctive, and 19 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
Distinctive · estimate
This author's own choices. Worth a look.
19
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 16
Never hide a session because a field is missing, such as the first user message or a title.
- Distinctive: line 23
Never delete or mark an archived session because its source is gone.
- Distinctive: line 56
All UX flows and rules are documented in UX.md.
- Distinctive: line 60
All testing guidance starts at TESTING.md: how to run the suites and trust the result, how to write tests, what CI proves, and how to …
- Distinctive: line 63
Read §0 and the file for your task before you write, review, or report on tests.
- Very specific: line 141
After installing (uv sync), use the claude-explorer command:
- Distinctive: line 231
Start the web server to browse and export conversations.
- Very specific: line 293
Every launcher starts the server if port 8765 does not answer, opens the browser, and stops only a server that it started.
- Very specific: line 316
Never probe a PID with os.kill(pid, 0) on Windows: it calls TerminateProcess.
- Distinctive: line 336
Keep applet state in globals, not properties.
- Very specific: line 366
Do not switch ports automatically.
- Very specific: line 407
Desktop conversations: every fetch route runs the drift pass before it reports success (_reindex_search_after_fetch in …
- Very specific: line 420
Never keep a per-thread connection open past its thread.
- Very specific: line 437
Never write DELETE FROM messages WHERE conv_uuid = ?
- Very specific: line 468
If you change the schema, bump backend/search_index.SCHEMA_VERSION and the next process startup will drop+rebuild on its own.
- Very specific: line 476
Behavior: if ~/.claude-explorer/credentials.json is missing OR the fetch returns 401/403/cf-mitigated, the backend invokes …
- Very specific: line 515
One credentials loader and one conversion: Every caller that builds a ClaudeFetcher reads the file with …
- Very specific: line 519
Read the primary org from primary_org_id.
- Very specific: line 525
Use uv to manage the Python virtual environment:
- Distinctive: line 575
Start the frontend (in another terminal):
- Very specific: line 593
When ~/.claude-explorer/config.json fails to parse (editor crash mid-save, truncated JSON, non-dict root, permission flip, non-UTF-8 …
- Very specific: line 596
Every writer route checks the flag via _refuse_if_config_corrupt(settings) (defined in backend/deps.py) and returns HTTP 503 with a …
- Very specific: line 609
Every caller copies the local sources into the archive through backend/write_gate.py:run_archive_syncs(store, reason, lock_timeout_s) …
- Very specific: line 619
MCP: no wait, inline, at most once per debounce interval.
- Very specific: line 623
Never store or show an fs_path result.
- Very specific: line 626
Cloud-sync gate (plan D13): No Explorer writer puts data into a folder that a cloud client syncs until the user opts in.
- Very specific: line 654
No CORS: Do not add CORSMiddleware back.
- Distinctive: line 724
If a hook fires during normal editing, READ the warning — don't paper over it with a config override.
≈ “Common” is an estimate: at least 1 in 5 of the 43,423 AGENTS.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 Explorer
Guiding Principles
Two rules from the user (2026-11-14). They apply to every source (Desktop, Claude Code, Cowork local and remote) and to the list, the viewer, search, and the MCP tools.
- Show every session that has a turn. The user may want to see and
search any session that had an effect on their work.
- A turn is a user message or an assistant message. A session with only an assistant turn still has a turn.
- Hide only a session with no turns: a 0-byte file, or a file with only metadata or setup events (for example a remote task that was opened but never got a prompt).
- Never hide a session because a field is missing, such as the first user message or a title. Use a fallback value.
- A user control may hide sessions (for example "Show empty sessions"), but the default code path must not.
- Keep all history, even when Claude removes it. Claude Code deletes
old session files, and the claude.ai API stops listing deleted tasks and
conversations. The archive must keep its copy.
- Never delete or mark an archived session because its source is gone.
- A sync adds and updates. It does not remove. The Desktop fetch and the remote-task sync follow this rule.
- Claude Code and local Cowork sessions (#92, 2026-11-27): the copy
pass mirrors
~/.claude/projectsinto<data_dir>/machines/<machine_id>/claude-code/projects/and the local Cowork root into.../machines/<machine_id>/cowork/(backend/archive_sync.py:sync_machine_tree). Copy metadata and revisions go to thesync/folder beside the mirror, so the readers read the mirror unchanged.- The machine id is a random UUID in
~/.claude-explorer/machine.json, never indata_dirand never the host name. - The readers read every
machines/*/folder, live first by uuid. When Claude Code deletes a session file, the drift pass deletes the rows of the live path and indexes the archive copy. - MCP does not copy (a first copy can be gigabytes); Refresh and the CLI stop after 20 s, and the watcher copies the rest.
- The machine id is a random UUID in
- Other machines (#92, 2026-11-27):
backend/machines.pymoves a machine's allowed sessions to another archive, on the samemachines/<id>/layout: bundles (archive export,archive import) and the shared sync folder (shared_archive_dir, a pass ofrun_archive_syncs).- Nothing leaves by default:
export-rules.jsonstarts in mode "off". - An import and a pull only add and append. Each machine writes only
its own folder in the shared folder, which never holds the search
index and needs its own D13 consent (
allow_writes_in_shared_archive). - Another machine's Codex goes to
machines/<id>/codex/<home_key>/; this machine's stays incodex/<home_key>/. - Tests never see this Mac's machine id: the root
conftest.pygives a test that keeps the real home a temporary identity file.
- Nothing leaves by default:
UX Rules
All UX flows and rules are documented in UX.md. Code changes that affect UI behavior MUST keep that document accurate; failing-test-first applies (see the "Code Style" section below).
Testing Rules
All testing guidance starts at TESTING.md: how to run the suites and trust
the result, how to write tests, what CI proves, and how to verify each platform by hand.
TESTING.md is a short index. Its table maps each section number to a file in testing/.
Read §0 and the file for your task before you write, review, or report on tests.
The test-execution integrity rule is a hard invariant. It now lives in TESTING.md §0. Never report a suite as passing without it.
Before you commit or report work as done, run uv run python scripts/check.py
until it passes. It runs the same checks as CI. The pre-commit hook refuses
a commit of content that no green run covers; never bypass it with
--no-verify. If the checks fail, say so plainly.
Performance Work
Three project-specific invariants the 2026-05-22 → 2026-05-23 search-perf hunt earned. Full walk: PLANS/POSTMORTEM-search-typing-lag-2026-05-22.md. Testing protocol: §5.14. Council-driven perf workflow: ~/.claude/agents/llm-council-coding.md Rules P0–P11.
- No
useContext()of a churning provider in any list-rendered component (N ≥ 100 rows). Known churning providers in this codebase:SettingsContext,SearchPanelContext,BookmarksContext— their value identity changes on every keystroke, toggle, or navigation.useContextbypassesReact.memo(Fiber resolves context deps inbeginWorkbefore the bailout check), so subscribing from a row component re-renders every row on every context flip. The list-owning parent (ConversationPage) callsuseContextonce and threads relevant fields as props. Carve-outs: dispatch-only contexts with stable function identity, anduseMemo([])-stabilized config contexts. - Memoize every
<Provider value={{...}}>withuseMemo+ explicit deps list. Inline object literals rebuild value identity every render and fire the entire subscriber graph. Pattern lives inSearchPanelContext.tsxandSettingsContext.tsx. - For any user-reported "feels slow", the first commit on the branch is a measurement commit. Output: one number from
PerformanceObserverLong Task total OR cProfile wall time on the real corpus (not a 3-row synthetic). Every subsequent commit must move that number, or revert. A user re-reporting the same symptom after a fix shipped is a falsification event for the diagnosis — re-instrument, don't stack a second fix in the same suspected layer. Instrumentation snippet in §5.14.
Project Structure
├── backend/ # FastAPI backend (Python)
├── frontend/ # React frontend (TypeScript)
├── fetcher/ # mitmproxy addon for fetching conversations (Python)
├── mcp_server/ # stdio MCP server (5 tools, FastMCP)
├── scripts/ # build-mcpb.py, closure analyzer, format checks
├── assets/ # mcpb-icon.png, mcpb-README.md (Extensions panel)
├── PLANS/ # Implementation plans
└── pyproject.toml # Python dependencies (version is dynamic, read from
# mcp_server/__init__.py:__version__ — single source
# of truth for pip + MCP serverInfo + MCPB manifest)MCPB bundle (Claude Desktop extension)
scripts/build-mcpb.py produces dist/claude-explorer-${VERSION}.mcpb —
the drag-drop Claude Desktop extension that wraps mcp_server.server's
5 tools. Pipeline:
scripts/mcpb_import_closure.pywalks the eager-import graph ofmcp_server.server(skips function bodies — that's the supported escape hatch for lazy-importing heavy deps likeweasyprintinsidecreate_pdf).- Build script copies only the closed-over
.pyfiles into the bundle, manually appends a smallDYNAMIC_IMPORT_MODULESlist for modulesbackend.store/backend.searchlazy-import at call time (backend.cowork_reader,backend.summary_cache,backend.search_index). The Codex source (backend.sources.codex,backend.codex.*,backend.archive_sync) needs no entry: the registry imports it eagerly, so the analyzer finds it. - Writes a stripped
pyproject.tomlwith ONLY the deps the MCP path uses: the 5 that the analyzer finds (fastmcp,pydantic,orjson,platformdirs,portalocker; the last one is the archive lock), pluszstandard>=0.23; python_version < '3.14'by hand.backend/codex/zstd.pyimports it inside a function (Python 3.14+ usescompression.zstd), so the analyzer cannot see it, andEXPECTED_EXTERNAL_DEPSdoes not list it. - Writes
manifest.jsonwithmanifest_version: "0.4"+server.type: "uv"— Claude Desktop ships Node but not Python, so UV resolves + installs on the user's machine on first launch. - Runs
mcpb pack(npm install -g @anthropic-ai/mcpbif missing).
Closure-canary invariant. mcp_server/tests/test_mcpb_closure.py
fails the suite if a future PR pulls FastAPI / weasyprint / mitmproxy
/ watchdog into the MCP code path. If the canary fires, DO NOT loosen
the test — find the import and either move it inside a function body
(lazy) or remove it from the MCP code path. The bundle is supposed to
stay around ~500 KB; pulling in even one of those would balloon it
past 30 MB.
CI release wiring (.github/workflows/release.yml build-mcpb job)
runs the same script on every v* tag push and attaches the artifact
to the GitHub Release alongside the wheel.
CLI Usage
After installing (uv sync), use the claude-explorer command:
# Step 1: Capture credentials (a browser window opens; log in to Claude)
claude-explorer capture
# Step 2: Fetch all conversations
claude-explorer fetch
# Step 3: Start the web server to browse
claude-explorer serve
# Then open http://localhost:8765Command Reference
claude-explorer capture
Capture the Claude session credentials into
~/.claude-explorer/credentials.json.
Options:
-o, --output PATH Where to save credentials
-t, --timeout INTEGER Max seconds to wait for login (default: 300)
--proxy Use mitmproxy and Claude Desktop instead of a browser
--port INTEGER Proxy port when using --proxy (default: 8080)Default (browser): fetcher/playwright_capture.py opens a Chromium
window. After you log in, it reads the sessionKey cookie and the orgs.
--proxy (mitmproxy):
- Starts mitmproxy with the addon
fetcher/mitmproxy_addon.py.cli/main.pyfinds the addon through its module, not through a path next tocli/. From v1.0.0 to v1.1.9 the path namedcli/mitmproxy_addon.py, which does not exist. mitmproxy stopped at once with "No such script", and--proxyfailed every time. - You launch Claude Desktop through the proxy.
- The addon extracts
sessionKeyand the org ids from API requests.
Platform-specific launch commands for --proxy:
# macOS
open -a "Claude" --args --proxy-server="127.0.0.1:8080" --ignore-certificate-errors
# Windows
"C:\...\Claude.exe" --proxy-server="127.0.0.1:8080" --ignore-certificate-errors
# Linux
claude --proxy-server="127.0.0.1:8080" --ignore-certificate-errorsclaude-explorer fetch
Download all conversations from Claude using captured credentials.
Options:
--output-dir PATH Where to save JSON files
(default: the data directory that the app reads,
~/.claude-explorer/conversations unless
CLAUDE_EXPLORER_DATA_DIR or config.json moves it)
--credentials PATH Path to credentials file
(default: ~/.claude-explorer/credentials.json)
--session-key TEXT Session key (overrides credentials file)
--org-id TEXT Org ID (overrides credentials file)
--incremental / --full-refresh Skip already-saved conversations (default: incremental)
--delay FLOAT Seconds between requests (default: 0.3)
--limit INTEGER Max conversations to fetch
--verbose Show detailed outputExamples:
# Fetch all new conversations
claude-explorer fetch
# Re-fetch everything
claude-explorer fetch --full-refresh
# Fetch only 10 conversations with verbose output
claude-explorer fetch --limit 10 --verbose
# Use custom credentials
claude-explorer fetch --session-key "sk-ant-..." --org-id "uuid-..."claude-explorer serve
Start the web server to browse and export conversations.
Options:
--host TEXT Host to bind to (default: 127.0.0.1)
--port INTEGER Port to bind to (default: 8765)
--reload Enable auto-reload for developmentExamples:
# Start server
claude-explorer serve
# Start on different port
claude-explorer serve --port 9000
# Development mode with auto-reload
claude-explorer serve --reloadclaude-explorer install-watcher (cross-platform — strongly recommended)
Install a supervised job that runs the CC image-cache watcher
continuously, independent of claude-explorer serve. Without this,
the watcher only runs while the dev server is up — Claude Code can
rotate images off disk during downtime, causing permanent data loss.
The CLI dispatches by sys.platform:
- macOS → launchd user agent (
~/Library/LaunchAgents/com.claude-explorer.cc-watcher.plist) - Linux → systemd user unit (
~/.config/systemd/user/claude-explorer-cc-watcher.service); also runsudo loginctl enable-linger $USERto survive logout - Windows → Task Scheduler task
ClaudeExplorerCCWatcher(logon-triggered, runs the launcher at%USERPROFILE%\.claude-explorer\cc-watcher.pyviapythonw.exe)
The watcher uses watchdog for event-driven capture (FSEvents on
macOS, inotify on Linux, ReadDirectoryChangesW on Windows) — sub-
second latency, near-zero idle CPU. A periodic backstop poll
(default 600s = 10 min, overridable via --interval or env var
CLAUDE_EXPLORER_CC_WATCHER_INTERVAL_SEC) catches the rare event the
OS dropped or coalesced.
uv run claude-explorer install-watcher
# Verify (per platform):
launchctl list | grep claude-explorer # macOS
systemctl --user status claude-explorer-cc-watcher.service # Linux
schtasks /Query /TN ClaudeExplorerCCWatcher # Windows
# Logs (macOS):
tail -f ~/Library/Logs/claude-explorer-cc-watcher.{out,err}
# Tune the backstop poll interval (default 600s):
uv run claude-explorer install-watcher --interval 60
# Uninstall:
uv run claude-explorer install-watcher --uninstallclaude-explorer install-app (every platform)
Adds a launcher, so a user can start Claude Explorer without a terminal.
Every launcher starts the server if port 8765 does not answer, opens the
browser, and stops only a server that it started. Install code:
cli/app_launcher.py.
| Platform | Launcher | Stop |
| macOS | ~/Applications/Claude Explorer.app | Quit the app |
| Windows | Start menu shortcut, runs pythonw.exe -m cli.desktop_launcher tray | Tray icon, Quit |
| Linux | ~/.local/share/applications/claude-explorer.desktop, runs ... open | Right-click action, runs ... stop |
On every platform the sidebar's power button (UX.md → "Quit (power
button)") also stops the server: POST /api/shutdown raises SIGINT in the
server's own process, exactly like Ctrl+C (backend/shutdown.py), so
claude-explorer serve exits with code 0. The route requires the header
X-Claude-Explorer-Action: shutdown and a same-origin or loopback Origin,
so another website cannot stop the server. The macOS applet's idle
handler quits the app when the server it started is gone, and the Windows
tray removes its icon. Linux needs nothing: open does not stay running.
Windows and Linux share cli/desktop_launcher.py. It records the PID and
port of each server that it starts in ~/.claude-explorer/launcher-server.pid.
Linux has no tray icon: GNOME shows none without an extension, and
pystray's Linux backends need GTK bindings that a uv tool install lacks.
Never probe a PID with os.kill(pid, 0) on Windows: it calls
TerminateProcess. The launcher watches the port there instead.
macOS details:
- What it is: an AppleScript stay-open applet, compiled on the user's
Mac with
osacompile. A locally made file has no quarantine flag, so it needs no notarization. - Open: starts
claude-explorer serveif port 8765 does not answer, then opens the browser. Server output goes to~/Library/Logs/claude-explorer-serve.log. - Quit: stops the server, but only a server that the app started.
- Refuses a
uvxinterpreter, likeinstall-watcher.
Three traps, each hit while building it:
- The start command must redirect stdin, stdout, and stderr, and
background only the server.
cd /tmp && nohup cmd & echo $!kept the output pipe ofdo shell scriptopen, and the app could not receive Quit. - Keep applet state in globals, not properties. An applet writes changed properties back into its bundle, which breaks the signature.
- Changing the icon or
Info.plistbreaks the ad-hoc signature, sobuild_appre-signs the bundle withcodesign --force -s -.
claude-explorer install-app # install or rebuild
claude-explorer install-app --port 8766 # use another port (default 8765)
claude-explorer install-app --uninstall # removeThe launcher keeps the port that install-app gave it, and install-app
saves it in ~/.claude-explorer/launcher-port. A later install-app
without --port (the upgrade steps run one) reuses it; --uninstall
deletes it. Windows and Linux
pass --port to cli.desktop_launcher (tray and open); stop reads
the port from the PID file. On 2026-10-13 an Emacs process held 8765 on a
user's laptop, so the app could not start until it used another port.
Port conflict message. Many users are not developers. When another
program holds the port, every launcher and serve say so in plain words,
and give the exact fix command with a port that is free now:
port_in_use(cli/desktop_launcher.py) is a bind test with the same socket options as asyncio, so it agrees with uvicorn.- Windows and Linux:
report_port_conflictshows the message. Windows also puts the command on the clipboard. - macOS: the applet runs the hidden
claude-explorer port-checkbefore it startsserve. Line 1 of the output is the command for its Copy Command button; the rest is the dialog text. - Do not switch ports automatically. The web page keeps settings in
localStorage, which is per address, so a changing port loses them.
claude-explorer reindex-search (manual override only)
Force a rebuild of the SQLite FTS5 search index at
~/.claude-explorer/search-index.sqlite. You should not need this in
normal operation: the index is built automatically at backend startup
(non-blocking lifespan task) and kept in sync by the same watcher
loop that handles CC images (event-driven via watchdog, with a
600s backstop poll). Use only when:
- the index file got corrupted (delete it, then run this);
- you want a known-fresh full rebuild;
- a future schema bump requires manual rebuild without restarting
serve.
# Default: full DROP + rebuild from scratch.
uv run claude-explorer reindex-search
# Drift-only pass (re-index only files whose mtime changed since last index).
uv run claude-explorer reindex-search --driftHow search works in the running server:
backend/search_index.pyowns the SQLite FTS5 schema, lifecycle, and queries. Singleton viaget_search_index(); returnsNoneon sqlite3 builds without FTS5.backend/search.py:search_conversationsis a dispatcher: prefer the FTS5 fast path whenidx.is_ready(), fall back to the linear-scan code on any failure (initial build still running, FTS5 unavailable, sqlite3 error). Search never goes "down".- Architecture is Scatter-Gather: FTS5 returns
(conv_uuid, message_uuid)pairs; the existing Pythoncreate_snippet/sort code runs on the matched conversations only (warm via FileCache). Result: byte-for-byte identicalSearchResultshape to the linear path for whole-word queries. - Three triggers keep the index current. Failures in each are isolated.
- Claude Code and Cowork sessions:
watchdogevents on~/.claude/projectsand the Cowork root start a debounced drift pass. - Desktop conversations: every fetch route runs the drift pass
before it reports success (
_reindex_search_after_fetchinbackend/routers/fetch.py). The watcher does not observe the Desktop conversations directory. - Backstop:
backend/cc_watcher.py:scan_onceruns the drift pass once per backstop scan (600s default). It catches anything the other two missed.
- Claude Code and Cowork sessions:
Read connections close when their thread ends. SearchIndex and
SummaryCache open one SQLite read connection per thread through
backend/sqlite_read_conns.py. Each event-driven drift pass runs on a new
threading.Timer thread, and anyio workers end after 10 s idle.
- Never keep a per-thread connection open past its thread. Before
2026-11-08 a registry kept them until
close(). The supervised watcher then held 1262 connections after 46 days, and every drift pass failed withToo many open files, so the index lagged by days (issue #33). backend/tests/test_read_conn_thread_leak.pypins this: it counts the open file descriptors on the index file (on Windows, all the handles of the process).
At most one drift pass runs at a time, and a delete never scans
messages. On 2026-11-11 the restarted watcher still went from 4 to 146
descriptors on the index in 11 minutes, by two causes together:
- A delete by
conv_uuidread every row.conv_uuidis an UNINDEXED FTS5 column, which FTS5 cannot index, so each upsert scanned all 393,517 rows (8.9 s cold) while it held the write lock.- Writes now find a conversation's rows in the
message_rowidsmap and delete them by rowid. - Never write
DELETE FROM messages WHERE conv_uuid = ?; useSearchIndex._delete_messages_of. - The map is additive, with no
SCHEMA_VERSIONbump. Code from before it ignores the map, and_sync_message_rowidsrebuilds the map when such code changedmessages. A version bump would make old processes drop and rebuild the whole index.
- Writes now find a conversation's rows in the
- Drift passes overlapped. Each event during a slow pass started one
more pass on a new Timer thread, and each waited for the write lock
with an open read connection.
_run_drift_single_flight(backend/cc_watcher.py) lets one pass run. An event or a backstop scan during it makes it run once more.- The fetch routes still run their own pass, because
completemust wait for it. The 409 guard allows only one fetch at a time.
A file that loads as nothing leaves the drift backlog. On 2026-11-13 six files stayed in the backlog for good, and every pass read them again: four 0-byte Claude Code sessions and two remote Cowork tasks that hold only setup events (the task was opened, but no prompt was sent).
_note_unloadable(backend/search_index.py) records such a file with its mtime and size. The drift scan skips it until one of them changes, and the watcher log gets one line for it.- The record is in memory, one per process. A new version of a reader thus reads each such file once again, and the index file gets no rows that an older watcher process does not know.
- A file that cannot be opened is not recorded. The readers turn an
OSErrorinto "no entries", so "Too many open files" looks like an empty file. The next pass tries again. - The list and the viewer still hide both kinds: a 0-byte file has no entries, and a Cowork session with no turns has nothing to show (D6).
If you change the schema, bump backend/search_index.SCHEMA_VERSION
and the next process startup will drop+rebuild on its own.
Web UI Refresh button (Build-9)
The sidebar Refresh button owns the full pipeline — capture + fetch — so the user never has to drop to the CLI to re-capture credentials.
- Endpoint:
GET /api/fetch/refresh?incremental=true(SSE). - Behavior: if
~/.claude-explorer/credentials.jsonis missing OR the fetch returns401/403/cf-mitigated, the backend invokesfetcher.playwright_capture.capture_credentialsin-process. On success it persists creds (atomic write,0o600) and continues with an incremental fetch automatically. - Capture is run at most once per request. A post-capture fetch that still 401s emits a final
errorevent — no retry loop. - Concurrency: one module-level flag,
_refresh_in_progress, guards/fetch/refresh,/fetch/start, andPOST /fetch/conversation/<uuid>(single-conversation re-fetch). A second fetch of any kind returns409 Conflict. Frontend disables the button while running, so 409 is defense-in-depth.- The route sets the flag.
_FetchStreamResponseclears it when the response ends, also when the client leaves before the first chunk. Afinallyin the stream alone left the flag set in that case, and every later fetch got 409.
- The route sets the flag.
- SSE event types:
capture_start,capture_waiting_login(heartbeat every 25s during the 5-min login wait),capture_done,capture_error, plus the existingstart,progress,complete,error. - Manual override: the Details modal's "Full Refresh" and "Fetch New" buttons still hit
/fetch/startdirectly with no auto-capture. - Search is current at
complete. The backend re-indexes search before it emitscomplete. The frontend then callsinvalidateAfterFetch(frontend/src/lib/queryClient.ts), which marks both the conversations and the search caches stale. A new fetch site must do both, or the Search Pane shows pre-fetch results.
Remote Cowork tasks are a second fetch source. Cowork tasks that run in
Anthropic's cloud are not chat conversations: chat_conversations never lists
them, and nothing lands in Claude Desktop's local local-agent-mode-sessions/.
An account that only runs tasks used to "fetch" 0 conversations. Every fetch
path (Refresh, /fetch/start, claude-explorer fetch) now also syncs them
through fetcher/remote_sessions.py:
- API:
GET https://claude.ai/v1/code/sessions?tags=cowork-remoteand/v1/code/sessions/<id>/events(newest first,cursor=<seq>pages back). Both need theanthropic-beta: ccr-byoc-2025-07-29,anthropic-version, andx-organization-uuidheaders. Recorded from the claude.ai web app with Playwright; re-record the same way if the API moves. - Storage:
<data_dir>/cowork-remote/<org>/remote_<id>/audit.jsonlplus a sibling sidecar, in the local Cowork shape, sobackend/cowork_reader.py, the store, and the search index read them unchanged (iter_cowork_session_dirs/find_cowork_session_dirs). - Workspace: a remote task gets
organization_idfrom the sidecarorganizationId(the<org>directory is the fallback), so the workspace filter shows it. A local Cowork session keepsorganization_id = None. - Incremental: a session is skipped when its sidecar records the API's
updated_at; otherwise only events newer than the highest_sequence_numinaudit.jsonlare fetched and appended. - Additive: an org without sessions-API access (401/403/404) is skipped;
any other failure is a
progressmessage, never a streamerror. - Tests: the autouse
_no_remote_cowork_networkfixture (both conftests) stubsRemoteCoworkFetcher._get_json;fetcher/tests/ccr_fake.pyis a fake of the API with its real paging.
If you change capture or fetch logic, edit backend/routers/fetch.py (the _capture_phase_stream, _fetch_phase_stream, and refresh_pipeline_stream async generators) and the two web-page consumers of the stream together — the SSE event schema is shared. The consumers are frontend/src/contexts/FetchPipelineContext.tsx (Refresh) and frontend/src/components/fetch/FetchDialog.tsx (Fetch New, Full Refresh); frontend/src/components/fetch/FetchToast.tsx holds their shared text helpers.
One credentials loader and one conversion. Every caller that builds a ClaudeFetcher reads the file with fetcher.credentials.load_credentials and gets its credential arguments from fetcher.credentials.fetcher_credentials: the three fetch routes, claude-explorer fetch, and claude-explorer rehydrate. Do not write another copy of either.
- Five private copies of the conversion drifted apart. One passed a removed
org_id=keyword and crashed everyclaude-explorer fetch(issue #1). The routes refused a v2 file without the legacyorg_idmirror. - A plain
json.loadcopy of the loader infetcher/bulk_fetch.pypassed a list or a string on as credentials.fetchand the routes then failed withAttributeErrorinstead of "run capture". - Read the primary org from
primary_org_id.org_idis only a legacy mirror thatCredentialsV2plans to drop. Only the v1 paths infetcher/credentials.pyread it.
Development Setup
Python (Backend & Fetcher)
Use uv to manage the Python virtual environment:
.python-versionpins Python 3.13 for development. Without the pin,uvcan choose the newest Python on the machine. On 2026-11-08 that was 3.15, andpydantic-coreandrpds-pyfrom the lockfile had no wheels for it, souv syncfailed.- A job that tests another Python sets
UV_PYTHON.uv sync --python Xalone is not enough: the next plainuv runreplaces the venv with the.python-versionPython.- The pytest job in
install-matrix.ymlsetsUV_PYTHON, and its step "The venv uses the matrix Python" checks the result.backend/tests/test_workflow_python.pypins the rule for every workflow. - Proof (2026-11-09): a CI run without
UV_PYTHONran the 3.14 and 3.15 rows on 3.13, and the check step failed them. - The install job does not set it, on purpose: it runs the README's commands as a user types them, and all its rows are 3.13.
- The pytest job in
- To use another Python locally (for example offline, with only 3.12
installed), set
UV_PYTHON=3.12in the shell for everyuvcommand.
# Create/sync the virtual environment
uv sync
# Run backend server
uv run uvicorn backend.main:app --reload --port 8765
# Run with dev dependencies
uv sync --extra dev
uv run pytestThe .venv directory is local to the project and managed by uv.
Frontend
cd frontend
npm install
npm run dev # Development server on http://localhost:5173
npm run build # Production buildRunning the Full Stack
- Start the backend:
# On macOS with Homebrew, set library path for WeasyPrint PDF support: DYLD_LIBRARY_PATH=/opt/homebrew/lib uv run uvicorn backend.main:app --reload --port 8765 - Start the frontend (in another terminal):
cd frontend && npm run dev
The frontend proxies /api requests to the backend.
Data Directory
Conversations are stored in ~/.claude-explorer/conversations/ as JSON files.
Set CLAUDE_EXPLORER_DATA_DIR to override, or create ~/.claude-explorer/config.json:
{"data_dir": "/path/to/conversations"}Corrupt-config safe mode
When ~/.claude-explorer/config.json fails to parse (editor crash mid-save, truncated JSON, non-dict root, permission flip, non-UTF-8 contents), the app does NOT crash and does NOT silently fall back to defaults. Instead it boots in read-only safe mode:
backend/config.py:Settingscatches(JSONDecodeError, OSError, TypeError, ValueError)and populatesconfig_corrupt_reason: str | Nonewith a one-line<path>: <ExceptionType>: <message>summary. The reader continues to the next candidate (canonical → legacy) instead ofbreaking — a valid legacy config next to a corrupt canonical still wins.- Every writer route checks the flag via
_refuse_if_config_corrupt(settings)(defined inbackend/deps.py) and returns HTTP 503 with a recovery message instead of writing. Currently gated:POST/PATCH/DELETE /api/bookmarks/*,PUT/PATCH /api/preferences,GET /api/fetch/{start,refresh,conversation/{uuid}}, and theclaude-explorer fetchCLI. GET /api/configexposesconfig_corrupt_reasonto the frontend. The lru_cache onget_settings()is cleared on every/api/configcall so the user fixing the file mid-session is detected without a server restart.- The frontend renders a persistent (non-dismissible)
ConfigCorruptionBannerat the top of the app shell. Dismissing it would re-enable the data-orphaning failure mode it exists to prevent, so the only way to remove the banner is to fix the underlying file. - Reads remain unconditional —
/api/conversations,/api/search,/api/conversations/{uuid}all stay at 200 even when corrupt. The user can still browse what's already on disk while they recover.
When adding a new writer route, wire it through _refuse_if_config_corrupt(settings) (or Depends(refuse_if_config_corrupt) if you prefer the FastAPI-dep form). Otherwise a corrupt-config user can silently write to the wrong data_dir and orphan their archive.
install-watcher is intentionally EXEMPT from the writer gate. The launcher template lives under ~/Library/LaunchAgents/ (or systemd/Task Scheduler equivalents), NOT under data_dir, AND the supervised watcher IS the recovery path the user needs to reach when config is corrupt. Gating it would lock the user out of recovery. The CLI test test_install_watcher_runs_when_config_corrupt pins this exemption as a HARD invariant — do not remove.
cc_watcher.scan_once is also NOT gated. Blocking the background CC image-cache watcher during corrupt-config would cause the data loss it exists to prevent (Claude Code rotates images off disk while the watcher is blocked). Only its archive copy of the local sources skips (plan D9): backend/write_gate.py:run_archive_syncs logs one WARNING line per pass, and image capture and the drift pass still run.
Archive copy and the cloud-sync gate
Every caller copies the local sources into the archive through
backend/write_gate.py:run_archive_syncs(store, reason, lock_timeout_s)
(PLANS/2026.11.18-codex-source.md §4.3). It checks two gates in order,
corrupt config and then cloud sync, and then calls each adapter's
archive_sync in registry order.
- Callers and their lock wait:
- Watcher (
_event_drift_pass, the backstop_backstop_drift_pass): no wait, inside the drift single-flight. A busy lock calls_schedule_drift, so the copy runs again after the debounce. - Refresh,
/fetch/start: up to 60 s in a worker thread, before the capture. A busy lock sends aprogressframe withphase: "codex", and the fetch continues. claude-explorer fetch: up to 60 s, before the credentials load.- MCP: no wait, inline, at most once per debounce interval; a busy lock gives
sync_pending: true.
- Watcher (
write_gate.pystays MCP-safe: it imports neitherbackend.cc_watcher,backend.deps, nor a router.- Watch roots: the watcher starts one observer per
WatchRootof each adapter and matches its patterns. A root withcreate=False(another tool's home) is never created; a missing one gets its watch after a later backstop scan. The Cowork root also matches the session sidecarlocal_*.json. - Long paths on Windows: a new file operation under the archive (or anywhere under the data folder) gives its path through
backend/long_paths.py:fs_path(open,os.stat,os.replace,mkdir,listdir,shutil). It lists a folder withlong_paths.iterdir,glob, orwalk, and checks containment withreal_pathoris_inside.- Never store or show an
fs_pathresult. The UI, the API, MCP, the search index, and cache keys keep the normal form. - Without the
\\?\prefix, Windows withLongPathsEnabled= 0 refuses a path over 259 characters, and the copy of a long session is lost.
- Never store or show an
Cloud-sync gate (plan D13). No Explorer writer puts data into a folder that a cloud client syncs until the user opts in. write_gate.cloud_sync_block(settings) returns (provider, folder) while the gate is closed.
- Detection:
backend/cloud_sync.py, ondata_dir,search-index.sqlite, andcc-images/. It fails closed. - Opt-in:
allow_writes_in_cloud_syncinconfig.jsonmust equal the resolveddata_dir.POST /api/write-consent/cloud-sync(backend/routers/write_consent.py) writes it, with theshutdownroute's header and Origin rules and the corrupt-config gate. - While closed:
- The fetch routes return 409 before any network call; the CLI
fetchrefuses. The preferencesPUTandPATCHalso return 409 (write_consent.refuse_if_cloud_sync_gate, after the corrupt-config dependency). - The MCP outline cache (
cache.db) is built in memory. - The archive copy skips.
get_search_index()andget_summary_cache()returnNone.- The lifespan creates no data folder and skips the layout migration.
- New Claude Code images go to
cc_image_cache.pending_dir().scan_oncemoves them intocc-images/after the opt-in.
- The fetch routes return 409 before any network call; the CLI
- A new writer into
data_diror its siblings must checkcloud_sync_blocktoo.
Host-header guard (DNS rebinding)
The server listens on localhost, but any web page can make its own domain
resolve to 127.0.0.1 (DNS rebinding). Its requests are then same-origin, so
the browser sends no CORS preflight, and the page can read every response
and call every route. A probe in the PR #6 review (2026-10-19) read
/api/conversations and /api/account, and stopped the server.
- The guard:
backend/host_guard.pyrefuses (400) every request whose Host is notlocalhost,127.0.0.1, or::1. It is the outermost middleware; a test pins that. - Extra names:
CLAUDE_EXPLORER_ALLOWED_HOSTS(comma-separated). The rootconftest.pyadds the test-client namestestserverandtest. serve --host <network address>sets that variable to*and prints a warning, because the user chose to expose the server.- No CORS. Do not add
CORSMiddlewareback. The web page calls/apion its own origin, and the Vite dev server proxies/api. CORS forlocalhost:5173let any project's dev server read the archive. - A new state-changing route follows
POST /api/shutdown: POST only, a custom header (which needs a preflight that the server never answers), and an Origin check against the guard's allowlist, never against Host.
PDF Export Dependencies
WeasyPrint requires system libraries for PDF generation:
# macOS
brew install pango cairo libffi
# Ubuntu/Debian
apt-get install libpango-1.0-0 libpangoft2-1.0-0 libharfbuzz-subset0
# Windows (via MSYS2 — https://www.msys2.org)
# In the MSYS2 shell:
pacman -S mingw-w64-x86_64-pango
# Or skip the system-library install entirely by using the standalone
# WeasyPrint .exe from the WeasyPrint GitHub releases page.See: https://doc.courtbouillon.org/weasyprint/stable/first_steps.html#installation
macOS DYLD bootstrap (tests + dev server)
macOS Sonoma+ strips DYLD_* env vars from subprocess invocations
(SIP), so prefixing uv run pytest with DYLD_FALLBACK_LIBRARY_PATH=...
silently no-ops. The tests bootstrap this from backend/tests/conftest.py
at import time (sets DYLD_FALLBACK_LIBRARY_PATH=/opt/homebrew/lib
before WeasyPrint imports), so uv run pytest backend/tests Just Works
with no --ignore flags or env-var prefixes.
For the live dev server (claude-explorer serve or
uvicorn backend.main:app), set DYLD_LIBRARY_PATH directly on the
command line as shown above — the server doesn't go through conftest.
Code Style
- Python: Follow PEP 8, use type hints
- TypeScript: Strict mode, prefer functional components
- Commits: Conventional commit messages, no AI attribution lines
Static-analysis tooling
Three layers run alongside the manual pre-push checklist. Neither replaces it — they cover different failure modes (greps find leaked credentials; LLM/AST tools find logic bugs).
React Doctor (millionco/react-doctor)
Oxlint-based AST scanner for React (~250 rules across architecture, state-and-effects, performance, a11y, correctness). Catches things eslint-plugin-react-hooks doesn't, e.g. inline <Provider value={{...}}> literals via jsx-no-constructed-context-values — directly relevant to the [[Performance Work]] invariant #2.
Two npm scripts:
cd frontend
npm run lint:react # full-codebase informational scan; never fails CI
npm run lint:react:diff # pre-push gate: scan files changed vs main, fail on errorsBaseline as of 2026-05-27: 71/100, 346 issues (4 architecture errors + 2 state-and-effects errors + 340 warnings across a11y/perf/correctness). Do not block a push on pre-existing baseline. Pre-push gate is lint:react:diff — fails only if YOUR change introduces a new error.
Known gap: React Doctor does NOT catch [[Performance Work]] invariant #1 (useContext of churning provider in list-rendered components). No public linter does — that one stays a human-review / postmortem rule.
security-guidance plugin (Anthropic, user-scope; Claude Code only, optional)
Real-time PreToolUse hook that intercepts Write/Edit/MultiEdit and warns about eval, pickle, dangerouslySetInnerHTML, child_process.exec, GHA injection, command injection patterns. Free; runs at the harness level (~0 token cost). Installed via claude plugin install security-guidance@claude-plugins-official. Verify with claude plugin list.
If a hook fires during normal editing, READ the warning — don't paper over it with a config override. The hook fires on a curated list of known-bad patterns, not on style preferences.
/security-review slash command (Claude Code only, optional)
Diff-based LLM security review of pending changes on the current branch. If you use another agent, any LLM security review of the diff serves the same purpose; the pre-push gate cares that one ran, not which. Same engine as the anthropics/claude-code-security-review GitHub Action. Covers SQLi, XSS, authn/authz, IDOR, SSRF, weak crypto, RCE/deserialization, hardcoded secrets, supply-chain. Manual invocation only — see the pre-push checklist.
Pre-push checklist (runs before every push that affects the public repo)
Public-flip is a one-way door: once a commit is on origin/main and the repo is public, secrets, personal paths, and AI attribution become permanently public-cached (search-indexed, mirrored by archivers, scraped by training-data crawlers). Run this scan before pushing to a public repo. Every step MUST return clean (or only known-OK matches the maintainer has eyeballed) before push.
# 1. Secrets in unpushed commit diffs
git log -p origin/main..HEAD | grep -nE 'sk-ant-[A-Za-z0-9_-]{10,}|Bearer [A-Za-z0-9_.-]{20,}|"password"\s*:\s*"[^"]+"'
# 2. Personal /Users/<name>/ paths in committed files (excluding docs/PLANS)
git grep -nE '/Users/[a-zA-Z]+/|/home/[a-zA-Z]+/' -- ':!PLANS/' ':!*.md'
# 3. Real session keys / cookies in test fixtures (only "fake-test-key" literals should match)
git grep -nE 'sessionKey.{0,5}[A-Za-z0-9+/_-]{30,}' -- 'backend/tests/' 'fetcher/tests/'
# 4. AI attribution across ALL unpushed commits (NOT just the most recent — check the whole batch)
git log origin/main..HEAD --format='%H %B' | grep -inE 'co-authored-by:.*claude|🤖 generated'
# 5. Accidentally-tracked credential / cache / local files
git ls-files | grep -E '(^|/)\.env$|\.env\.[^.]+$|credentials\.json$|\.sqlite$|\.local$|\.local\.json$'
# 6. Real email addresses outside known-OK list
git grep -nE '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}' -- ':!*.md' ':!PROCESS/' | \
grep -v -E 'raymondpeckiii@gmail\.com|noreply@|@example\.(com|org)|user@host'
# 7. ~/.claude or /Users/rpeck/ in files shipped to PyPI sdist
uv build --sdist 2>&1 | tail -3
mkdir -p /tmp/sdist-check && tar xzf dist/*.tar.gz -C /tmp/sdist-check
grep -rnE '/Users/rpeck|~/\.claude(?!-explorer)' /tmp/sdist-check | grep -v PKG-INFO # PKG-INFO ~/.claude refs are legitimate README content
rm -rf /tmp/sdist-check
# 8. IP addresses outside known-OK list (127.0.0.1, RFC1918, link-local)
git grep -nE '\b([0-9]{1,3}\.){3}[0-9]{1,3}\b' -- ':!*.md' ':!PROCESS/' | \
grep -v -E '127\.0\.0\.1|0\.0\.0\.0|169\.254\.|192\.168\.|10\.[0-9]+\.|255\.255'
# 9. Private-infra URLs (internal., grafana, slack channels, linear, etc.)
git grep -nE '(internal\.|\.local/|linear\.app/|slack\.com/archives|grafana\.|datadog\.)' -- ':!PROCESS/'
# 10. TODO/FIXME/XXX in user-facing code (samples below should be intentional documented tech debt only)
git grep -nE 'TODO|FIXME|XXX' -- 'frontend/src/' 'backend/' ':!**/tests/**'
# 11. React Doctor diff-gate — fails on NEW errors in files changed vs main
(cd frontend && npm run lint:react:diff)
# 12. LLM security review of the diff (e.g. /security-review in Claude Code, or your agent's equivalent)
# /security-review
# 13. Article image/link formats must render on GitHub (co-equal surface with Medium)
# Fails on Obsidian ![[...]] / [[...]] (literal text on GitHub), spaces or %20 in
# local image/link paths (GitHub's blob renderer mangles %20), and referenced
# images that aren't git-committed (404). Earned 2026-06-01 when a public push
# shipped broken images on every Part 2 screenshot.
python3 scripts/check-article-formats.pyKnown-OK matches (won't fail the scan but worth re-eyeballing):
fake-test-keyandsk-ant-sid01-fake-test-keyinbackend/tests/,fetcher/tests/— deliberate fake fixtures./Users/rpeck/in test fixtures underfrontend/e2e/— deliberate test data shape mirroring real CC session paths.~/.claudeinPKG-INFO(README copy) and source code — describing the actual home-directory paths the app reads from.claude-exporter(the legacy pre-V1 name) in.gitignore(backwards-compat) andPROCESS/a70251a5/outline.jsonl(frozen historical conversation snapshots).http://claude-explorer.local/inbackend/export.py— base URL for relative-resource resolution in PDF export; not a real infrastructure reference.
Things this checklist does NOT cover (and that you should still think about before flipping visibility):
- The
PROCESS/directory exposes development-session conversation snapshots. Some maintainers want this; some don't. Decide before flip. - The
.github/workflows/*.ymlreference org-scoped secrets (PYPI_API_TOKEN, OIDC trusted publishing config). On the public repo, these need to be configured under repo Settings → Secrets and variables → Actions BEFORE the first release workflow run.
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.

