Show HN: Ctx – a /resume that works across Claude Code and Codex
TL;DR Highlight
ctx builds a local CLI tool capable of maintaining and branching conversational context between Claude Code and OpenAI Codex, benefiting developers who want seamless AI coding sessions.
Who Should Read
Developers experiencing lost context when switching between Claude Code and Codex, or when sessions are interrupted during their workflow.
Core Mechanics
- ctx manages Claude Code and OpenAI Codex conversations by grouping them into 'workstreams', binding each to both a Claude conversation ID and a Codex conversation ID.
- The Exact transcript binding feature ensures that when a workstream is reloaded, it retrieves the precise conversation history associated with that session, preventing 'transcript drift'.
- Safe branching allows developers to duplicate the current workstream state into a new branch, creating a completely isolated conversation stream.
- Stored workstreams, sessions, and entries are indexed in a SQLite DB for fast searching and visual inspection via a local browser frontend.
- The pin feature permanently includes specific entries in the context, while the exclude feature hides them from the model without removing them from search results; unwanted items can also be fully deleted.
- ctx is designed to be completely local-first, requiring no API keys or external services; data is stored in a standard SQLite file and local files.
- Installation is completed with a single command: `git clone` followed by `./setup.sh`, which creates a local project DB, installs the ctx shim in `~/.contextfun/bin`, and creates symbolic links to the skills directories for Claude and Codex.
- Inspired by Claude Code's `/resume` command, ctx differentiates itself by integrating similar functionality across both AI coding tools.
Evidence
- "One commenter stated they've never used a `/resume` function, suggesting that starting a new session is preferable to resuming if changes are made and documented, questioning the universality of the need for 'long-running context maintenance' that ctx addresses."
How to Apply
- When switching between Claude Code and OpenAI Codex, create a workstream with ctx to maintain the same working context, starting with a simple `git clone` and `./setup.sh`.
- When experimenting with a long-term AI coding project, use ctx's branching feature to safely explore new directions while preserving the original workstream.
- For architectural decisions or design documents frequently referenced across AI sessions, pin those entries in ctx to ensure they are always included in the context.
- If handing off an AI coding session to a teammate, consider sharing the SQLite DB file or waiting for the implementation of an export/import feature to transfer the workstream.
Code Example
snippet
# Installation
git clone https://github.com/dchu917/ctx.git
cd ctx
./setup.sh
# setup.sh does the following:
# - Creates ./.contextfun/context.db
# - Writes ./ctx.env
# - Installs repo-based ctx shim in ~/.contextfun/bin
# - Creates local skills links in ~/.claude/skills and ~/.codex/skills
# Usage example (based on README)
# In Claude Code
/ctx save feature-audit
# In Codex
ctx resume feature-audit
# Create a branch
ctx branch feature-audit feature-audit-v2Terminology
workstreamA unit of work flow. ctx's basic unit for grouping Claude Code and Codex sessions to indicate they belong to the same task.
transcript bindingFixing an AI conversation history (transcript) to a specific session ID. Without this, the wrong conversation may be loaded when resuming, causing 'drift'.
transcript driftThe phenomenon of loading an incorrect, more recent conversation when resuming a session. One of the core problems ctx aims to solve.
harnessA wrapper framework that adds functionality to or integrates multiple AI coding tools. ctx sits on top of Claude Code or Codex like a harness.
prompt cachingCaching the beginning of identical prompts to save on API costs. Claude and Codex each have their own caches, so it's not shared between models.
SQLiteA lightweight, file-based database. It can operate with a single file, making it ideal for local-first tools like ctx.