Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 44 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ The rule is simple:

> Make handoffs first. Archive, don't delete. Apply changes only when you are ready.

## Three Modes

- **Inspect:** report-only, no writes.
- **Maintain:** normal apply; backs up, archives old sessions, moves stale worktrees, rotates logs, prunes dead config, and normalizes paths. It does not trim thread title/preview metadata.
- **Optional repair:** only with `--apply --repair-thread-metadata-bloat`; shortens oversized SQLite display title/preview metadata after backup. The transcript stays intact.

## Who This Is For

Use this if Codex has started feeling slower after heavy use, especially if you:
Expand All @@ -30,24 +36,15 @@ It helps Codex:
- create handoff docs before archiving old chats
- back up important state before applying changes
- archive old chats instead of deleting them
- detect pathological thread title/preview metadata that can slow chat navigation
- move stale worktrees out of the hot path
- rotate large logs
- prune dead project references
- report heavy Node/dev processes without killing them

## Install

Ask Codex:

```text
Install the keep-codex-fast skill from https://github.com/vibeforge1111/keep-codex-fast
```

Or clone/copy this folder into your Codex skills directory as `keep-codex-fast`.

## Quick Start

After installing, ask Codex:
Ask Codex:

```text
Use $keep-codex-fast to inspect my Codex local state and recommend a safe maintenance plan.
Expand Down Expand Up @@ -105,6 +102,24 @@ Then back up first, archive instead of deleting, move stale worktrees, rotate la
If Codex is currently running, do not mutate local state. Tell me to close Codex first.
```

## Thread Title And Preview Bloat

Some Codex builds can store a full first user prompt as both the thread title and the list preview. When those fields grow into hundreds of thousands of characters, thread navigation can become sluggish even before a large chat is opened.

The script reports title and preview payload size in report mode and normal apply mode. It does not trim this metadata unless you explicitly opt in:

```bash
python scripts/keep_codex_fast.py --apply --repair-thread-metadata-bloat
```

With that flag, after backing up and only when Codex is not running, it trims active SQLite title/preview metadata to bounded display values. It also appends repaired titles to `session_index.jsonl`, which matches current Codex name-update storage.

This does not remove the actual conversation transcript. The full rollout JSONL remains available unless you separately archive the session.

The repair manifest stores the old full title/preview values so you can restore them. Keep the backup folder private, especially `thread-metadata-repairs.jsonl` and `restore-thread-metadata.py`.

If you are using the skill normally, this repair does not happen automatically. Treat it as an extra recommendation only when the report shows unusually large title/preview metadata.

## Weekly Or Biweekly Reminder

Recurring maintenance should be a reminder, not an automatic apply.
Expand All @@ -128,6 +143,16 @@ The reminder should:
- tell me that manual apply should only happen after I confirm handoffs exist or are not needed and Codex is closed
```

## Install

Ask Codex:

```text
Install the keep-codex-fast skill from https://github.com/vibeforge1111/keep-codex-fast
```

Or clone/copy this folder into your Codex skills directory as `keep-codex-fast`.

## Advanced: Manual Script Use

Most users can stay inside Codex and use the prompts above. The script is here for people who want to run it directly.
Expand All @@ -152,12 +177,18 @@ python scripts/keep_codex_fast.py --backup-only

Backup folders can contain private local Codex metadata. Keep them on your machine, and do not publish or share them unless you have reviewed what is inside.

Apply archive/maintenance actions:
Apply core maintenance actions. This does not trim thread title/preview metadata:

```bash
python scripts/keep_codex_fast.py --apply --archive-older-than-days 10 --worktree-older-than-days 7
```

Optionally repair oversized title/preview metadata only when the report recommends it:

```bash
python scripts/keep_codex_fast.py --apply --repair-thread-metadata-bloat
```

Wait for Codex to exit before applying:

```bash
Expand All @@ -173,6 +204,7 @@ The skill can safely handle:
- large `logs_2.sqlite*` files
- dead/temp project entries in `config.toml`
- Windows `\\?\C:\...` path mismatches in local SQLite text fields
- oversized thread title and first-message preview metadata in `state_5.sqlite`, only with `--repair-thread-metadata-bloat`

It does not permanently delete chats, logs, or worktrees. It moves them into archive folders and writes backup/restore artifacts before applying changes.

Expand Down
34 changes: 33 additions & 1 deletion SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ Primary principle: preserve continuity before applying changes. For active repo
- Before archiving any active repo chat the user may want to continue, recommend creating a comprehensive handoff doc plus a reactivation prompt.
- Do not archive old-but-important active repo chats until the user either confirms a handoff exists or confirms they do not need one.

## Mental Model

There are three modes:

- Inspect: report-only, no writes.
- Maintain: normal `--apply`; backs up, archives old sessions, moves stale worktrees, rotates logs, prunes dead config, and normalizes paths. It does not trim thread title/preview metadata.
- Optional repair: `--apply --repair-thread-metadata-bloat`; shortens oversized SQLite display title/preview metadata after backup. The rollout transcript stays intact.

## Default Workflow

1. Reassure the user: the first run is read-only, privacy-safe, and the skill archives instead of deleting when changes are later applied.
Expand All @@ -39,6 +47,7 @@ python scripts/keep_codex_fast.py
- active session size
- archived session size
- largest active sessions
- thread metadata bloat: active title/preview character totals, max title/preview lengths, and over-limit counts
- stale worktree candidates
- log size
- bad Windows `\\?\` path counts
Expand Down Expand Up @@ -76,6 +85,7 @@ If the user wants automation and the Codex app automation tool is available, cre
- Moves stale worktrees to `~/.codex/archived_worktrees/`.
- Rotates `logs_2.sqlite*` into `~/.codex/archived_logs/` only when above the threshold.
- Reports heavy Node processes without killing them.
- Reports pathological active thread titles and `first_user_message` previews. It only repairs them when the user explicitly opts in with `--repair-thread-metadata-bloat`.

Report mode does none of those mutations. It only prints counts and pseudonymous candidates. Use `--details` when raw IDs, titles, or paths are needed for diagnosis.

Expand All @@ -87,6 +97,25 @@ Report mode does none of those mutations. It only prints counts and pseudonymous
- Run weekly maintenance if Codex is used daily across many repos/terminals.
- Offer weekly or biweekly report-only reminders after the first successful apply; do not assume the user wants recurring maintenance.
- When in doubt, leave a chat active or ask the user. Never archive a chat that is pinned, current, or explicitly marked as still needed without a handoff.
- Treat title/preview repair as metadata repair only. The full rollout transcript remains in the session JSONL; bounded SQLite fields are for list/navigation display.

## Thread Metadata Bloat

Codex Desktop can become slow when `threads.title` or `threads.first_user_message` stores a full prompt/history-sized value instead of a display title or preview. This affects the thread list/navigation path before the UI renders anything.

The script reports active thread count, total title/preview characters, maximum title/preview length, active titles over the configured title limit, and active previews over the configured preview limit and over 10k characters.

Normal apply mode reports metadata-bloat candidates but does not repair them. If the user explicitly opts in, after backups and only when Codex is not running, run:

```bash
python scripts/keep_codex_fast.py --apply --repair-thread-metadata-bloat
```

That bounds active `threads.title` and `threads.first_user_message` values. Defaults are 120 characters for titles and 240 characters for previews. It also appends repaired titles to `session_index.jsonl`, matching current upstream name-update storage, so reconciliation/name lookup does not immediately prefer the old full-message fallback.

The targeted repair manifest stores the old full title/preview values so the change can be reversed. Treat `thread-metadata-repairs.jsonl`, `restore-thread-metadata.py`, and the whole backup folder as private local artifacts.

This is a local maintenance workaround for metadata bloat. It does not solve app renderer hydration of very large rollout histories; that needs upstream staged/paged thread loading.

## Handoff Doc + Reactivation Prompt

Expand Down Expand Up @@ -162,6 +191,7 @@ Avoid these behaviors:
- applying changes while Codex is actively writing the DB
- archiving important repo chats before creating handoff docs
- treating active history size as "bad" without checking whether the user needs continuity
- treating preview metadata repair as deletion of the actual rollout transcript
- killing Node/dev processes automatically
- rewriting `config.toml` without a backup and parse check
- writing UTF-8 TOML with a BOM on Windows
Expand All @@ -172,4 +202,6 @@ Avoid these behaviors:

Tell users this does not permanently delete chats, worktrees, or logs. It moves them into archive folders and writes restore helpers. The only removed content is stale metadata, such as project entries pointing to folders that no longer exist, and even that happens after backing up `config.toml`.

Also tell users backup folders can contain private local Codex metadata. They should keep backups local and avoid publishing or sharing them unless they have reviewed what is inside.
Also tell users that thread title/preview bloat repair is not part of normal apply. Normal use only reports title/preview bloat. Recommend `--repair-thread-metadata-bloat` only as an optional extra when the report shows large metadata payloads and the user understands that SQLite display metadata will be shortened while the real transcript remains in rollout JSONL.

Also tell users backup folders can contain private local Codex metadata, including old thread titles and first-message previews. They should keep backups local and avoid publishing or sharing them unless they have reviewed what is inside.
Loading
Loading