Skip to main content

backfill

Keeps every Claude Code and Codex session of every project in the project itself, automatically. Install it once per computer; from then on each session you start, in any repo, is saved to that repo's .claude-logs/ or .codex-logs/ folder: readable history, every tool call, raw transcript, per-turn summaries. Nothing leaves your machine, the folders ignore themselves in git, and secrets are stripped from the logs by default.

TL;DR

pipx install git+https://github.com/focsd/backfill   # pre-release; later: pipx install backfill  |  brew install focsd/tap/backfill
backfill install      # once per computer: hooks into Claude Code and Codex
backfill doctor       # everything green? then you are done

Restart open Claude Code / Codex sessions. From now on every session in any repo is saved to that repo's .claude-logs/ / .codex-logs/ (git-ignored, secrets removed).

You want to Run
see what is logged here backfill status
read or search old sessions backfill search <text>, backfill show
continue yesterday's work backfill digest (paste into a new session) or backfill recap
tune this project backfill init --preset minimal|standard|everything [--layout monthly]
free disk space backfill clean (dry run), then --apply
stop logging here / everywhere backfill off / backfill uninstall

Details

pipx install backfill        # or: uv tool install backfill   |   brew install focsd/tap/backfill
backfill install             # hooks into Claude Code and Codex (whichever are on this machine)
backfill status              # what is installed, what is logged for the project you are in

Status: pre-release. backfill is not on PyPI or Homebrew yet. Until the first release, install straight from GitHub: pipx install git+https://github.com/focsd/backfill. Then run backfill install.

Upgrading: pipx upgrade backfill (or brew upgrade backfill), then run backfill install once more so the hooks' copy in ~/.backfill/ is refreshed. Removing: backfill uninstall removes backfill's hooks from your agent settings (your own entries and the logs stay); backfill uninstall --purge also deletes ~/.backfill/.

macOS and Windows are supported; Linux is expected to work and is built in CI, but is not yet a declared target. Needs Python 3.11+ (the Homebrew formula brings it along; on Windows install Python from python.org or the Microsoft Store and tick "Add to PATH"). No third-party Python dependencies.

What backfill install does

Agent Change (always backed up as *.bak-<time>, undone by backfill uninstall)
Claude Code 8 hooks in ~/.claude/settings.json (your own hooks stay), instruction block in ~/.claude/CLAUDE.md
Codex notify in ~/.codex/config.toml (an existing notify command is kept and chained, not replaced), lifecycle hooks in hooks.json, instruction block in AGENTS.md; JetBrains Codex homes are found too
Both a copy of the runtime in ~/.backfill/ (%LOCALAPPDATA%\backfill on Windows) so hooks keep working when a package manager moves or upgrades its own copy

It also replaces the older claude-logger / codex_repo_logger hooks (any generation, including codex_notify_fanout.py / codex_notify_router.py), and imports the existing history of the project you ran it in. If your Codex notify is a chain (Codex's own Computer Use plugin wraps it with --previous-notify), only backfill's link is replaced and the wrapper stays outermost. Hooks never block or fail a session: they always exit 0 and report problems to ~/.backfill/hook-errors.log.

Codex may ask you to review the new lifecycle hooks once: type /hooks in Codex. Turn logging works through notify even before that.

Commands

Command
install [--agent claude|codex] [--codex-profile minimal|standard|full] [--retain-days N] [--dry-run] hook the agents
uninstall [--purge] remove the hooks (logs are never touched)
status [--all] [--json] installation + what is logged for this project (sessions, turns, size, history waiting to be imported)
doctor [--json] checks that logging will really happen, with a fix hint per problem; exit 1 on failure
init [--preset minimal|standard|everything] [--layout flat|monthly] create .agents/backfill.toml for the project
on / off switch logging on/off for the project
sync [--all] import history the agents already have, plus logs of the older loggers (_codex_logs, _claude_logs, .claude/logs); safe to repeat, never touches the old folders
summary sessions, turns, tool calls, tokens, models, active days
search <text> / show [session] find and read past sessions
digest markdown hand-off of the latest sessions: paste it into a fresh session to continue
recap [--since 1d] [--all] what happened since yesterday / 7d / a date, per project and session
clean [--older-than 30] [--apply] map what the agents keep on this machine (transcripts, caches, scratchpads, databases, log folders) and prune it safely
audit [--fix] find (and redact) secrets in existing logs
retain --days N [--apply] delete old journals (dry run by default)
export --output logs.zip, list, config archive, list projects, show effective settings

Per-project config: .agents/backfill.toml

Commit it to share settings with a team. First existing file wins: .agents/backfill.toml, .agents/backfill/config.toml, .backfill.toml, .backfill/config.toml. A config file also marks the project root (handy in monorepos). backfill init writes a commented template:

enabled = true                   # false = log nothing for this project
agents = ["claude", "codex"]
[logs]
claude_dir = ".claude-logs"      # one folder name inside the project; paths outside it are rejected
codex_dir  = ".codex-logs"
layout = "flat"                  # flat | monthly (YYYY-MM/ folders for journals, histories, transcripts, artifacts)
[capture]
preset = "standard"              # minimal | standard | everything; keys below override the preset
transcripts = "raw"              # raw | redacted | off
scratchpad = "manifest"          # off | manifest | copy: Claude scratchpad files, Codex generated images
exclude_tools = ["Read"]         # leave these tools' output out of the history and journal
session_max_mb = 0               # cap on one session's readable history (0 = none); the raw transcript is never capped
[redact]
enabled = true
extra_patterns = ["ACME-[0-9]{8}"]
[retention]
days = 0                         # used by `backfill retain`
[context]
announce = true                  # tell the agent where earlier sessions live
resume = false                   # also hand it a digest of the previous session
notes = ""

More keys under [capture] (all optional): journal_events = true, copy_artifacts = true, codex_profile = "standard" (minimal|standard|full, which Codex hooks backfill install registers), scratchpad_max_mb = 5, and the size limits event_value_limit = 20000, markdown_text_limit = 20000, markdown_tool_input_limit = 2000, markdown_tool_output_limit = 4000 (characters; longer values are cut in the history and journal, never in the raw transcript). Unknown keys and wrong types are ignored, so a typo never stops logging; backfill doctor lists unknown keys and invalid choices. A project config comes with the repository, so it can only change how that project is logged: it cannot point logs outside the project or touch your install.

Machine-wide settings live in ~/.backfill/config.toml; mode = "opt-in" there logs only projects that have a config file. Project root detection: BACKFILL_ROOT, then the nearest config file / .backfill-root, .git, .idea, a manifest (package.json, pyproject.toml, ...), then the working directory. The home directory and the agents' own folders are never logged. BACKFILL_DISABLE=1 stops logging for one process; ~/.backfill/denylist.txt / allowlist.txt list folders, one per line.

Capture presets

Preset What it does
minimal transcript copy + readable history (shorter tool output); no event journal, no artifacts, no scratchpads
standard the default: transcript, history, journal, per-turn summaries, edit backups/todos/subagents, scratchpad manifest
everything standard plus scratchpad and generated-image copies, Codex full hook profile, long history limits

Keys you write next to preset always win over the preset. scratchpad = "manifest" lists the files of a session's scratchpad (names, sizes, SHA-256) in artifacts/<session>/scratchpad-manifest.json; "copy" also keeps files up to 5 MB (scratchpad_max_mb), text with secrets removed. exclude_tools and session_max_mb shape the readable history and the journal; the transcript copy is separate (transcripts = "redacted" or "off" for that). backfill doctor prints what is and is not covered in the current project (covers: lines).

What is kept

.claude-logs/  (or .codex-logs/)
  INDEX.md                      one row per session
  history/<session>.md          readable conversation, tool calls and (capped) results
  transcripts/<session>.jsonl   the agent's raw transcript, refreshed every turn
  events-DAY.jsonl  turns-DAY.jsonl  sessions-DAY.jsonl
  artifacts/<session>/          edit backups, todos, subagents, scratchpad manifest/copies (Claude); generated images (Codex)
  session_state/  latest-*.json  .gitignore ("*")  README.md

With layout = "monthly", everything except INDEX.md, session_state/, latest-*.json and the housekeeping files sits inside YYYY-MM/ folders (.claude-logs/2026-12/history/...). A session lives in the month it started; changing the layout later keeps finding earlier files.

Environment variables

Variable Effect
BACKFILL_DISABLE=1 log nothing in this process
BACKFILL_ROOT use this folder as the project root
BACKFILL_HOME, CLAUDE_CONFIG_DIR, CODEX_HOME move backfill's data folder / Claude's / Codex's home
BACKFILL_ALLOWLIST, BACKFILL_DENYLIST folders (separated like PATH) to log only / never log
BACKFILL_TAGS, BACKFILL_IDE, BACKFILL_HOST, BACKFILL_WORKSPACE_LABEL extra fields in the session records
BACKFILL_TMP_DIRS where to look for Claude Code scratchpads (default: the system temp folders)

Troubleshooting

  • Nothing is logged: run backfill doctor; every failing check has a fix hint. Restart running Claude Code / Codex sessions after backfill install.
  • Codex logs only some events: type /hooks in Codex once and approve the lifecycle hooks (turn logging works without it).
  • A session is missing: backfill sync imports what the agents still have; backfill status shows sessions waiting to be imported.
  • Errors inside hooks: they never break a session; they are written to ~/.backfill/hook-errors.log (%LOCALAPPDATA%\backfill\ on Windows).
  • Logging should stop for one project: backfill off in it (or enabled = false in its config); for one run set BACKFILL_DISABLE=1.

Cleaning up (backfill clean)

Agents keep a lot: Codex rollouts and throw-away folders, Claude edit backups and shell snapshots, scratchpads in the temp folder, databases. backfill clean lists them with sizes and marks what is safe to prune, always a dry run first:

  • an agent's own transcript is a candidate only when backfill holds a complete copy of that session in a project (otherwise it says run backfill sync --all);
  • only items older than --older-than days (default 30); running sessions are never that old;
  • --apply moves them to <backfill data>/trash/<time>/ (--restore <batch> puts them back, --empty-trash frees the space); --delete removes for good;
  • databases, credentials, config, memory, skills and plugins are never candidates; project log folders are reported with the backfill retain command that prunes them;
  • --scan ~/dev also finds log folders of projects backfill has not seen yet.

Built for real machines

Lessons from the earlier Claude and Codex loggers that are built in:

  • Overlapping hooks are safe. Codex runs most hooks asynchronously; a per-session file lock (flock / msvcrt) means every transcript line is processed exactly once. On Windows, replacing a file another process has open is retried instead of failing.
  • Nothing is overwritten silently. If an agent rewrites a transcript so that it shrinks, the previous copy is kept as <session>.prev-<time>.jsonl.
  • Read-only folders are skipped quietly (a session started in C:\Program Files\... is not an error).
  • Where it ran: session records carry workspace, IDE (TERM_PROGRAM, BACKFILL_IDE), host, user and BACKFILL_TAGS, which helps when several IDEs share a repo.
  • Env lists: BACKFILL_ALLOWLIST / BACKFILL_DENYLIST (paths separated like PATH; the old CODEX_REPO_LOG_* variables still work).

Privacy

Logs contain full conversations. Redaction removes well-known credential formats (API keys, tokens, private keys, JWTs, URL passwords, password=...) from journals and histories. The raw transcript copy is byte-exact unless you choose transcripts = "redacted". Redaction is best effort: treat the folders like source credentials. backfill audit shows what is in them. Claude Code deletes its own transcripts after 30 days by default; the copies here are not affected (--retain-days also keeps Claude's own).

Development

python -m pip install pytest ruff && python -m pytest -q && ruff check src tests
python scripts/check_versions.py     # the version in the code must match the tag

Layout: src/backfill/ (core, agents/claude.py, agents/codex.py), tests/. Needs no third-party packages.

Support and contributing

Questions and problems: open an issue, or write to support@focsd.com. Security reports: see SECURITY.md. Contributions: see CONTRIBUTING.md. Changes per version: CHANGELOG.md.

Releasing (maintainers)

  1. Bump __version__ in src/backfill/__init__.py; python scripts/check_versions.py.
  2. Tag vX.Y.Z and push: the workflow publishes to PyPI (trusted publisher, environment pypi).
  3. Update url and sha256 in the formula of the homebrew-tap repository.

License

MIT, see LICENSE.

Metadata

Release files for backfill 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for backfill 0.3.0
File Size Uploaded Provenance Actions
backfill-0.3.0.tar.gz 80.7 kB Without provenance Details for backfill-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for backfill 0.3.0
File Interpreter ABI Platform Actions
backfill-0.3.0-py3-none-any.whl Python 3 none any Details for backfill-0.3.0-py3-none-any.whl

Total release size: 156.3 kB

Release files / backfill-0.3.0.tar.gz

Download URL backfill-0.3.0.tar.gz
Size 80.7 kB
Tags Source
SHA-256 checksum
How to use checksums
ba31ea3b99fa62a1b68cf8e7b1c7d7848a6fd71ba3c3989dff1006915fc04c3a
BLAKE2b-256 checksum
How to use checksums
15d906b2d7d679a34503bfb735dcd75776ffb4d34b27d96aad7d4d7abf20559e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.9

Release files / backfill-0.3.0-py3-none-any.whl

Download URL backfill-0.3.0-py3-none-any.whl
Size 75.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5f1086dfb9c77530454f09545c69e4f2c407a071f3172a01264b1ff58dd61187
BLAKE2b-256 checksum
How to use checksums
b680a165d7e69b3be28895eb97285c182b746d4d50b6621e1b7139660c9035b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.9

Security for backfill 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page