[FEATURE] A setting or hook to govern the compaction summary's opening paragraph

Open
#110,605 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
30/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript
Domain
cli

Research direction

The issue names no implementation files or tests. Start by locating the compaction summary generation and the PreCompact/PostCompact hook handling, then read how summaries are installed. Done means a documented setting or hook can govern the opening paragraph before installation; the issue leaves the specific design open.

Written by the indexing model from the issue text.

Description

area:core area:hooks enhancement platform:macos
What I'm asking for

A documented way to govern the free-form opening paragraph that Claude Code puts at the top of a compaction summary: either a setting that turns it off or caps its length, or a hook (for example on PreCompact/PostCompact) that can see and edit the summary before it is installed.

What happens today

Since about 2.1.319, compaction summaries start with a narrative paragraph that comes before the structured part. In my own sessions on 2.1.322–2.1.325 it is present in 118 of 124 summaries, is about 6 KB at P90 (largest about 26 KB), and roughly two thirds of its sentences are carried over verbatim from the previous summary's opening.

Custom compaction instructions (from a PreCompact hook or /compact <instructions>) shape the structured part, but I found no way to shape, cap or drop this opening, and no hook can edit the installed summary.

Why it matters

The opening acts as a second, ungoverned record of the session. Because it is copied forward from summary to summary, a value that was later replaced can survive there after the structured part has been corrected. In one long session the opening was the only place that still stated a superseded limit, and the model acted on it over the newer one. A plugin that maintains session state across compactions can lint the opening after the fact, but cannot prevent this.

Suggested shapes (any one would do)
  • a setting such as compaction.openingParagraph: "off" | "short" | "default", or a character cap;
  • have custom compaction instructions apply to the opening as well, and document that;
  • a documented hook that receives the summary text and may return an edited version before it is installed.
Environment

Claude Code 2.1.322–2.1.325, macOS, long sessions with many compactions (auto and manual).

Dominant language
TypeScript
Stars
156k
Forks
25k
Avg merge
16h 19m
Merged PRs (30d)
5

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

  • No Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from anthropics/claude-code

All issues in anthropics/claude-code

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.