Skip to content

Record earlier Claude Code turns as plan context and track Bash edits - #144

Open
ranimkhojah wants to merge 1 commit into
mainfrom
claude-code-plan-context
Open

ranimkhojah wants to merge 1 commit into
mainfrom
claude-code-plan-context

Conversation

@ranimkhojah

Copy link
Copy Markdown
Contributor

Summary

Two problems with how Claude Code tasklets were recorded:

  1. Only the last prompt was kept. A discussion ending in "yes" was recorded as just "yes".
  2. Edits made through Bash (e.g. sed) weren't detected. They went unrecorded and were later credited to an unrelated
    prompt.

Changes

Plan context

  • Turns that change nothing are saved and attached to the next turn that does, as the Plan stage (like OpenCode's
    Plan/Build).
  • AI Blame shows them in a collapsed "Earlier context (N messages)" section above the build prompt. This also applies
    to OpenCode tasklets.
  • The tasklet title is now the first plan prompt instead of "yes".
  • At most 5 turns are kept, and a turn is only attached to changes in the same repo it happened in.
  • The temporary files holding these turns are now readable only by the user (0600).

Bash edits

  • PostToolUse now also matches Bash. At the end of the turn, a snapshot is taken if tracy.py finds a change, and
    skipped if nothing changed.
  • Both installers (deploy.js and the extension's auto-installer) update the matcher on existing installs.

Things to know

  • Plan prompts and responses are stored and pushed with each build tasklet, and sent with Research Mode at Tier 1 and
    above, just like OpenCode's plan prompts.
  • Release the extension and hook together. The matcher update makes the extension re-download the hook from the latest
    release.
  • Old tasklets have no plan context and display as before.

Testing

  • Claude Code plugin: 23/23 tests pass (bun test), including end-to-end tests that run the real hook and tracy.py.
  • Extension: compiles, lint passes, and a new buildHistory test covers plan context.
  • Tested manually in a real repo with Claude Code: a sed-only rename got its own tasklet, and a discussion followed by
    "yes" was attached as context.
  • One buildHistory performance test (10s limit) fails locally at ~11s. It fails the same way on main.

🤖 Generated with Claude Code

A Claude Code tasklet only kept the prompt of the turn that edited files,
so a discussion ending in "yes" was recorded as just "yes". Turns that
change nothing are now saved per session and attached to the next turn
that does, shown as the Plan stage (in a collapsed "Earlier context"
section) with the first one as the tasklet title. Saved turns are only
attached to changes in the repo they happened in, and the temp files
holding them are owner-only.

Edits made through Bash (e.g. sed) were not detected, so they went
unrecorded and were later credited to an unrelated prompt. PostToolUse
now also matches Bash, and the Stop hook records a snapshot whenever
tracy.py finds a change. Both installers update the matcher on existing
installs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@EsmeYi

EsmeYi commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

There is a limitation introduced by this PR: it clears all saved context for the Claude session after recording a snapshot. If the user discusses changes in repo A, then edits repo B, repo A’s context is also deleted.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants