Skip to content

Add compact mode: optional rules block for complete answers in fewer tokens - #71

Merged
ExJtac merged 2 commits into
mainfrom
compact-mode
Nov 14, 2026
Merged

ExJtac merged 2 commits into
mainfrom
compact-mode

Conversation

@ExJtac

@ExJtac ExJtac commented Nov 14, 2026

Copy link
Copy Markdown
Owner

What

  • tokenstretch compact on|off adds or removes a short marked rules block in the project instruction file. Plain compact says where it is. Off by default.
  • Each adapter names its own file: CLAUDE.md and AGENTS.md (created if missing), an existing GEMINI.md, an existing .github/copilot-instructions.md. A tool that already loads a file with the block gets no second copy.
  • In a file that has the credit-saving rules block, the compact rules go inside that block, without the read-narrowly rule it already has.
  • start --compact turns it on with setup in one run; start mentions the command otherwise.
  • Changes go through the same backup-and-manifest writer as setup, so undo reverses them.

Rules in the block

Targeted edits instead of whole-file reprints; pointers to code instead of quotes; no restating or recaps; fewer words but never fewer facts; a one-line finish; a fixed handoff format; search before reading.

Size

About 175 approx. tokens alone, about 140 inside the rules block (characters / 4). A test fails at 200.

Not claimed

No saving is claimed in the README or docs. A paired same-model bench is still to be run.

Tests

tests/test_compact.py: on / off / undo round trip for each of the four adapters, with and without the rules block; no second block on a second run; token budget; files never created; one block for tools that share files; the command; start --compact. Whole suite: 544 passed, 1 skipped.

🤖 Generated with Claude Code

ExJtac and others added 2 commits November 14, 2026 01:56
…er tokens

`tokenstretch compact on|off` adds or removes a short marked block in the
project instruction file through each tool's adapter (CLAUDE.md, AGENTS.md,
an existing GEMINI.md or .github/copilot-instructions.md). Off by default.
`start --compact` turns it on with setup; `start` mentions it otherwise.

In a file that has the credit-rules block, the compact rules go inside that
block without the read-narrowly rule it already has. Every change is backed
up with a manifest, so `undo` reverses it. The block is under 200 approx.
tokens, checked by a test. No saving is claimed: it has not been measured.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… for byte

The planner read the instruction file in text mode, which turns CRLF into LF.
On a CRLF file (the default on Windows) compact on then off left LF endings
behind. Read the bytes, edit with LF, and write the file back in its own style.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@ExJtac
ExJtac merged commit db624f1 into main Nov 14, 2026
8 checks passed
@ExJtac
ExJtac deleted the compact-mode branch November 14, 2026 09:03
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.

1 participant