Skip to content
context Artifact [1d0c39225a]
Login

Artifact [1d0c39225a]

Artifact 1d0c39225a1910568238cc9d61888543e4cd7528676360cec95c90ad1b12009b:



name: ctx

description: Search the archive of past coding-agent sessions on this machine with ctx search and ctx turn. Use when the answer may be in earlier work rather than the code - why something was decided, what was tried and failed, how an error was fixed before, what the user already said or asked for, or where earlier work stopped. Triggers on "why did we", "did we ever", "last time", "what happened with", "remind me", and on any error or subsystem that looks like it has history. Use it even when the code or git log seems to explain things, since they rarely record what failed along the way.

ctx

ctx keeps every session on this machine in a searchable archive, tool output included. The code shows what exists. The archive shows why, and what did not work. Search it before asking the user something they may already have said, and before retrying an approach that may already have failed. A commit shows the change that landed, so for what went wrong or why, check here as well.

ctx search WORDS...               # this project, best matches first
ctx search --all WORDS...         # every project on this machine
ctx search --limit 30 WORDS...    # more than the default 12 results

A turn matches if it has any of the words, and turns with more of the rarer words rank higher. Common words and words under three letters are ignored. Each result shows #ID, project, speaker, date and a snippet with the matched words in [brackets]. If nothing matches in this project, ctx searches every project and says so on stderr.

Search for what the session would have contained, not for the question:

Read around a hit

ctx turn ID                # that turn
ctx turn ID BEFORE AFTER   # with neighbors: ctx turn 1182 3 5
ctx turn ID 0 0 --full     # without cutting long output

A snippet is rarely the answer. Read the turns after a hit: a plan is often reversed a few turns later, and the final word is what counts.

BEFORE and AFTER are counts of neighboring turns, and those are the only ctx commands for reading. Each turn is labeled user (what the person typed), assistant, tool (tool output) or meta (text the harness added). To find what a person asked for, read just their side of a stretch:

ctx turn ID 0 60 | grep -A3 -- '--- #[0-9]* user'

Using what you find