A new Claude Code plugin addresses a problem that grows worse as AI coding agents get more capable: you hand the agent a task, it runs for hundreds of tool calls over tens of minutes, and when it finishes you have a result but no idea how it got there. cc-traj-seg adds a side pane that keeps a running outline of the agent's trajectory, broken into short phases you can skim.

The gap between delegation and understanding

The plugin's author frames the problem directly: you can delegate intelligence, but you cannot delegate understanding. As models improve, agents handle more of the work autonomously. They read files, edit them, run commands, recover from failed tests, and change direction multiple times on a single prompt. The transcript records every step, but nobody scrolls back through four hundred lines to reconstruct what happened. The understanding is simply lost.

cc-traj-seg spends a small amount of compute to buy that understanding back. A lightweight model watches the trajectory and produces a running outline of phases, each with a one-line title, a one-sentence summary, and the decisions the agent made along with the reasoning behind them. The design is deliberate: decisions are the part of a trajectory most worth seeing, not a summary of the text.

How the segmentation works

The plugin hooks into Claude Code's tool.call and turn.complete events to count steps. Every N steps, by default six, it runs a "look." The look walks the new steps in N-sized chunks. For each chunk, the model reads the phases it has already written and the recent steps, then responds with one of three outcomes.

NEW means the action, target, or goal shifted, so a new phase card is pushed. This is the most common response, which keeps phases short and focused. AMEND means the newest steps are a direct continuation of the current phase, so its summary is rewritten and any new decision is added. SKIP means the steps did nothing worth recording. Walking the backlog in chunks prevents one look from swallowing an entire multi-step turn into a single coarse block.

Each phase is a card in the side pane. Clicking the title expands it to show the summary, the decisions listed as choice and why, and three buttons. Transcript scrolls the conversation to where the phase starts. Steps opens the exact steps it covers in a second pane. btw asks a side question about that specific phase.

The btw feature for scoped questions

Claude Code's built-in /btw command lets you ask side questions without the agent seeing them. cc-traj-seg scopes this to individual phases. Press btw on a card and ask anything about that phase. The answering model reads the outline of every phase for context, then the focused phase in full: its summary, its decisions, the steps it covers, and any earlier questions about it. The answer is grounded in that phase's record, and the model says when something is not in the record rather than guessing.

This is useful when you look at a phase and wonder why the agent chose a particular approach, or what it tried that did not work. The thread stays on the card, and the exchange never enters the agent's context.

Backfill and customizable prompts

If you turned the plugin on late, or want a cleaner pass with a stronger model, the backfill button reconstructs phases over earlier history. It asks how far back to go, which model to use, and the chunk interval, then rebuilds the outline. The answers become the ongoing settings, and live segmentation continues from where the backfill ends.

The plugin sends four prompts: a segmentation system prompt, a segmentation template, a btw system prompt, and a btw template. All four are editable. The templates use mustache-style variables: {{long-horizon-context}} gives the model every phase so far, {{short-horizon-context}} gives the most recent steps, and the model substitutes them at runtime. Unknown variable names are left visible in the output instead of being silently blanked, so mistakes are obvious.

You can export the prompts to a markdown file, edit them externally, and load them back. The settings frame in the pane shows token usage for the session, split between the agent's calls as reported by the API and the plugin's own calls estimated from character count.

What this means for agent users

The plugin runs on Claude Code 2.1.269 or later with function hooks enabled, which requires setting CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1. It needs at least 110 columns for the side pane to dock on the right; narrower terminals get the pane inline above the prompt. The model that writes phases runs on your session's credentials, haiku by default, and each chunk is one short completion.

For developers using Claude Code for long-running tasks, the plugin turns a black box into something you can audit. You can see which decisions the agent made, ask why it made them, and catch mistakes before they compound. The cost is a few extra tokens per session. As agent runs get longer, that trade looks increasingly worth it.

The project is in early access, built on Claude Code's function hooks API which may change between releases. It is available on GitHub and can be loaded per session from a clone or installed as a plugin marketplace entry.