CodexFold
English

Keep every Codex session. Store the repeats once.

Long Codex sessions carry the same instructions, file reads and tool output again and again. CodexFold finds byte-identical content, keeps one copy in a local store and checks every restore against the original SHA-256.

Install with Go
go install github.com/samekind/codexfold/cmd/[email protected]

Preview release v0.4.0-beta.2. The command-line tool runs on macOS, Linux and Windows. The transparent filesystem is opt-in and still being qualified.

Three sessions, each holding its own copy of the same content.

  • Project instructions
  • The same file, read again
  • Repeated tool output
  • Pasted log
  • Content unique to one session

Illustration, not to scale.

Measured on 58 real sessions

A representative local corpus of 16.01 GB, including large active and archived sessions. Exact deduplication halved it, and Zstandard packing halved what remained.

Disk space comes back only after native copies and loose objects are retired, which is not yet an automatic production policy. Read the validation report

Folded source
15.47 GB
After exact deduplication
7.72 GB
Packed, with manifests
4.36 GB
  • 57 of 57 restores matched the original size and SHA-256.
  • 16.0 GB scanned across three duplicate layers in 303 seconds.
  • 1 session that was still being written was rejected before its manifest was committed.

From scan to verified restore

  1. Scan

    Measure exact duplicate fields, records and chunks. Scanning is read-only.

  2. Fold

    Preview first. With --apply, CodexFold writes shared objects and a versioned manifest. The original session file stays where it is.

  3. Verify and restore

    doctor checks every manifest and object. unfold rebuilds the file and confirms its size and SHA-256 before anything is replaced.

$ codexfold scan --all --layers field,record,cdc
sessions=8 corpus=48.69 MiB processed=48.69 MiB skipped=0 appended=0 duration=440ms index=1.00 MiB missing=0 changed=0

LAYER   OBJECTS    UNIQUE     DUPLICATES  DUPLICATE BYTES  CORPUS SHARE
cdc     594        594        0           0 B                0.00%
field   1472       513        959         31.14 MiB         63.97%
record  1960       1480       480         15.56 MiB         31.97%

$ codexfold fold 6a04b768-cdfd-c692-70ce-f666db3df52f
session=6a04b768-cdfd-c692-70ce-f666db3df52f verified=true dry_run=true parts=495 records=0 fields=247 residual=248 new=683.28 KiB removed=false manifest=~/.codex/fold-store/manifests/6a04b768-cdfd-c692-70ce-f666db3df52f.json

$ codexfold fold 6a04b768-cdfd-c692-70ce-f666db3df52f --apply
session=6a04b768-cdfd-c692-70ce-f666db3df52f verified=true dry_run=false parts=495 records=0 fields=247 residual=248 new=683.28 KiB removed=false manifest=~/.codex/fold-store/manifests/6a04b768-cdfd-c692-70ce-f666db3df52f.json

$ codexfold doctor
manifests=1 verified=1 objects=274 issues=0 store=~/.codex/fold-store

$ codexfold unfold 6a04b768-cdfd-c692-70ce-f666db3df52f --to restored.jsonl
session=6a04b768-cdfd-c692-70ce-f666db3df52f verified=true bytes=8.17 MiB target=restored.jsonl
A real run on a synthetic sample of 8 sessions. The home directory is shortened to ~.

What CodexFold will and won't do

  • No network calls, telemetry, uploads or model requests.
  • Equal means identical bytes. Content that is only similar is never merged.
  • Scanning never changes session files or Codex state.
  • fold, gc and source removal are dry runs until you pass an explicit flag.
  • Objects and manifests are written to temporary files and committed atomically.
  • A restore replaces a file only after the full SHA-256 has been verified.

Where it runs today

The command-line tool ships for macOS, Linux and Windows on amd64 and arm64, with checksums. The transparent filesystem is a preview on every platform.

macOS 27 Preview

Apple-native FSKit extension. Building the app needs Xcode 27, an eligible Apple development team and source signing. It is not notarized for general installation.

Maintainer guide

Linux Preview

FUSE3 mount, validated for unprivileged mounts, crash recovery and remount. Validation with a real Codex client is still open.

Linux validation

Windows Preview

WinFsp filesystem with a native tray app, built from source. Desktop GUI, reboot and SYSTEM service qualification are still open.

Windows preview guide
Download from GitHub Releases