Compress context to fit within token limits while preserving signal
Compresses conversation context to fit token limits while preserving key decisions and requirements.
/plugin marketplace add standardbeagle/standardbeagle-tools/plugin install prompt-engineer@standardbeagle-toolsCompress context to maximize information density while staying within token limits, using 2026 context engineering best practices.
Gather the context to compress:
Question 1: "What type of context needs compression?"
Question 2: "What's your token budget?"
Question 3: "What MUST be preserved?" (multiSelect: true)
Keep only essential sentences:
## Extractive Summary
### Before (X tokens)
[Original text with redundancy]
### After (Y tokens)
[Key sentences only, preserving critical information]
### Compression: XX%
Rewrite to be more concise:
## Abstractive Summary
### Before
"The user initially wanted to implement feature X using approach A, but after discussing the trade-offs, we decided that approach B would be better because it offers better performance and is easier to maintain in the long term."
### After
"Switched from approach A to B for feature X: better performance and maintainability."
### Compression: XX%
Convert prose to structured format:
## Structured Compression
### Before (narrative)
"We discussed the authentication system. The user wants OAuth 2.0 with Google and GitHub providers. They prefer JWT tokens over sessions. The tokens should expire after 24 hours. We need to implement refresh tokens as well."
### After (structured)
Auth Requirements:
- Method: OAuth 2.0
- Providers: Google, GitHub
- Tokens: JWT (24h expiry)
- Refresh: Yes
### Compression: XX%
Replace repeated content with references:
## Reference Substitution
### Before
"The AuthenticationService handles login. The AuthenticationService also handles logout. The AuthenticationService manages token refresh. The AuthenticationService validates sessions."
### After
"AuthService: handles login/logout, token refresh, session validation"
### Compression: XX%
For code context:
## Code Compression
### Before (full implementation)
[Complete code file]
### After (signature + purpose)
// auth.ts - Authentication utilities export async function login(creds): Promise<Token> export async function logout(token): Promise<void> export async function refresh(token): Promise<Token> // Implementation: JWT-based, 24h expiry
### Compression: XX%
For chat history:
## Conversation Compression
### Before (full history)
Turn 1: [Full user message]
Turn 1: [Full assistant response]
Turn 2: [Full user message]
...
### After (summary + recent)
<conversation_summary>
Discussed: [Topic 1], [Topic 2]
Decided: [Decision 1], [Decision 2]
Open: [Question 1]
</conversation_summary>
<recent_turns>
[Last 2-3 turns in full]
</recent_turns>
### Compression: XX%
Check that compressed version preserves signal:
## Compression Verification
### Information Preservation Test
- [ ] Can answer: What are the key decisions?
- [ ] Can answer: What's left to do?
- [ ] Can answer: What were the constraints?
- [ ] Can answer: What was the rationale?
### Reconstruction Test
Given only the compressed context, could someone:
- [ ] Continue the conversation naturally?
- [ ] Make correct decisions?
- [ ] Avoid repeating past discussions?
### Signal-to-Noise Improvement
- Original SNR: [estimate]
- Compressed SNR: [estimate]
- Improvement: XX%
## Compression Results
### Summary Statistics
| Metric | Before | After | Change |
|--------|--------|-------|--------|
| Tokens | X | Y | -Z% |
| Key facts | N | N | 0 |
| Decisions | N | N | 0 |
| Open items | N | N | 0 |
### Compressed Context
[Final compressed version]
### What Was Removed
- Redundant greetings and pleasantries
- Repeated explanations
- Verbose descriptions replaced with concise summaries
- Historical context no longer relevant
- [Other removed content]
### What Was Preserved
- All decisions with rationale
- Open questions and next steps
- User requirements and preferences
- Critical technical details
- [Other preserved content]
<compressed_context>
<source file="[filename]" tokens="[count]">
[Key excerpts with line numbers]
</source>
<summary>
[Abstractive summary of document]
</summary>
</compressed_context>
<code_context>
<file path="[path]" purpose="[description]">
[Signatures and key logic only]
</file>
<changes>
[Recent modifications with rationale]
</changes>
</code_context>
<session_context>
<decisions>
- [Decision 1]: [Rationale]
</decisions>
<open_items>
- [Item 1]: [Status]
</open_items>
<preferences>
- [Preference 1]
</preferences>
</session_context>
<recent_exchange>
[Last 2-3 turns]
</recent_exchange>