# Compress Context

> A Claude skill from 0-uddeshya-0/agent-skills.

- **Type:** Skill
- **Install:** `agentstack add skill-0-uddeshya-0-agent-skills-compress-context`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [0-uddeshya-0](https://agentstack.voostack.com/s/0-uddeshya-0)
- **Installs:** 0
- **Category:** [AI & ML](https://agentstack.voostack.com/c/ai-and-ml)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [0-uddeshya-0](https://github.com/0-uddeshya-0)
- **Source:** https://github.com/0-uddeshya-0/agent-skills/tree/main/skills/compress-context

## Install

```sh
agentstack add skill-0-uddeshya-0-agent-skills-compress-context
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# skill: compress-context

## purpose
Shrink a long conversation or document context 60–75% while keeping everything needed for the current task. Prevents token bloat across multi-turn sessions without losing decisions or facts.

## when_to_use
- Conversation exceeds ~3,000 tokens and will continue for more turns
- Passing context from one agent step to the next and most of it is irrelevant
- Long document needs repeated reference across multiple calls

## when_not_to_use
- Context is under 1,000 tokens — overhead not worth it
- Task requires verbatim quoting (legal, transcription)
- First turn — nothing to compress

## input
```
context: string        # Full context to compress
current_task: string   # What the agent needs to do next — determines what's relevant
```

## output
```json
{
  "compressed": "string",
  "original_tokens": "int  // estimate",
  "compressed_tokens": "int  // estimate",
  "dropped": ["category of removed content"]
}
```

## instructions

```
First check: if context is under ~1,000 tokens, return it as-is with a note that compression overhead isn't worth it at this size.

Compress context for a specific task. Keep only what is needed to complete that task.

Rules:
1. Convert verbose explanations to one-line facts
2. Remove pleasantries, filler, agent meta-commentary ("Sure, I'd be happy to...")
3. Merge repeated or restated information into one canonical statement
4. Remove content that does not affect the current task
5. Preserve: decisions made, data values, constraints, errors, user preferences stated
6. Use shorthand: "User: cancel sub" not "The user indicated they would like to cancel their subscription"

Never drop decisions, confirmed facts, active constraints, or error states.
Never hallucinate — if uncertain whether something is relevant, keep it.
Target 60–75% reduction. More than that risks losing signal.

Return JSON only.
```

## constraints
- Max output tokens: 600
- Never drop: decisions, confirmed facts, constraints, errors
- Never compress below 25% of original — over-compression loses signal

## example

**Input:**
```
context: "User: Hi, trouble with my account. Agent: Happy to help! What's the issue? User: API key stopped working. Been using it 6 months. Agent: Can you share first 6 chars? User: sk-abc1. Agent: Key was revoked Jan 14 due to billing issue — card 4242 declined. User: Card expired. Updated it, new card ends 9191. Agent: Payment should process in 2–15 min, key reactivated then. User: How long exactly? Agent: Usually 2–5 min, up to 15."
current_task: "Check if the API key has been reactivated"
```

**Output:**
```json
{
  "compressed": "API key sk-abc1*** revoked Jan 14 — failed payment (card 4242 expired). User updated to card 9191. Reactivation pending, expected 2–15 min. Task: check reactivation status.",
  "original_tokens": 120,
  "compressed_tokens": 38,
  "dropped": ["pleasantries", "back-and-forth confirmation dialogue", "agent offers"]
}
```

## feedback_log

# 2026-05-29 | invoked on a 3-turn conversation (~180 tokens) | ran full compression pipeline on trivially small context, added overhead for no gain | added: early-return guard in instructions — skip compression if context < ~1,000 tokens

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [0-uddeshya-0](https://github.com/0-uddeshya-0)
- **Source:** [0-uddeshya-0/agent-skills](https://github.com/0-uddeshya-0/agent-skills)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-0-uddeshya-0-agent-skills-compress-context
- Seller: https://agentstack.voostack.com/s/0-uddeshya-0
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
