agentleFS
fatih-developerfatih-developer/fth-skills/skills/context-compressor/SKILL.md

context-compressor

Skill7 starsChanged 42 days agoMITView on GitHub

Compress long conversation histories, large code files, research results, and documents by 70% without losing critical information. Triggers when context window fills up, when summarizing previous steps in multi-step tasks, before loading large files into context, or on 'summarize', 'compress', 'reduce context', 'save tokens'.

5 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Keep: All function/class signatures (with parameters), return types and critical type annotations, exception handling, configuration …

    line 68
  2. Distinctive:

    If below target (< 50% reduction): re-scan for repetition, compress background more aggressively, convert long examples to single-line …

    line 120
  3. Distinctive:

    Every compression starts with:

    line 126

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Context Compressor Protocol

Reduce content by 70% — preserve critical information, discard repetition and noise. Target: compressed output should be ~30% of original size with preserved information density.


Workflow

1. Detect content type
2. Mark critical elements (these are never discarded)
3. Apply type-specific compression
4. Verify 70% target
5. Present compressed output

Step 1: Detect Content Type

Content TypeDetection Criteria
Conversation historyUser/assistant message pairs
Code fileFunction/class structures, syntax
Research resultsURLs, source references, data points
Meeting notes / documentHeaders, bullet lists, decisions

Step 2: Mark Critical Elements

These elements are never discarded:

  • Decisions & conclusions: "We decided to use X", "Y was chosen"
  • Errors & fixes: Discovered bugs, applied solutions
  • Numerical data: Dates, version numbers, metrics, amounts
  • Dependencies: "A must finish before B" constraints
  • Action items: Who does what, when
  • Current state: Latest version, current config, last decision

Step 3: Type-Specific Compression

Conversation History

Discard: Greetings, acknowledgments ("OK", "Got it", "Thanks"), repeated explanations, intermediate reasoning that contradicts the final conclusion.

Keep: User's clear requests, decisions and rationale, error messages and fixes, current task status.

Format:

[CONVERSATION SUMMARY — N messages -> M lines]
Context: [what the task is, 1 sentence]
Decisions: [bullet list]
Current status: [where things stand]
Pending: [open questions if any]

Code File

Discard: Comments (except docstrings), excessive blank lines, long import lists (consolidate), temporary debug prints.

Keep: All function/class signatures (with parameters), return types and critical type annotations, exception handling, configuration constants. Summarize function bodies as single-line pseudocode.

Format:

# [COMPRESSED — original: ~N lines -> now: ~M lines]
class ClassName:
    """[Original docstring]"""
    def method_name(self, param: Type) -> ReturnType:
        # [What it does — 1 line summary]
        ...

Research / Web Results

Discard: Duplicate information, generic background, verbose URLs (use domain name), out-of-scope quotes.

Keep: Concrete data points, primary source findings, contradictory findings (keep both), directly relevant findings.

Format:

[RESEARCH SUMMARY — N sources -> M items]
Topic: [what was researched]

Key findings:
- [Finding 1] (Source: domain.com)
- [Finding 2] (Source: domain.com)

Contradictions:
- [Source A says X, Source B says Y]

Missing / unverified:
- [Information not found]

Documents / Meeting Notes

Discard: Intro/closing paragraphs (if no content), repetitive statements, generic commentary.

Keep: Decisions made, action items (who, what, when), alternatives discussed and why rejected, next steps.


Step 4: Verify 70% Target

Original size   : ~N words / lines / tokens
Compressed size : ~M words / lines / tokens
Compression     : ~X% reduction

Target: 70% [Achieved / Below target]

If below target (< 50% reduction): re-scan for repetition, compress background more aggressively, convert long examples to single-line references.


Output Header

Every compression starts with:

CONTEXT COMPRESSOR
Type    : [content type]
Before  : ~N [words/lines]
After   : ~M [words/lines]
Saving  : ~X% reduction

When to Skip

  • Content is already short (< 200 words / 50 lines)
  • User said "all details matter"
  • Legal, medical, or financial documents (information loss risk too high)

Guardrails

  • Never discard decisions or error resolutions — these are the most valuable context.
  • Preserve contradictions — if two sources disagree, keep both.
  • Show compression ratio — the user must see how much was removed.
  • Cross-skill: works with memory-ledger (can compress ledger entries) and agent-reviewer (provides compressed history for retrospective).

References

  • references/EXAMPLES.md — a before-and-after conversation history compression. Read it when the expected output format or level of detail is unclear.

🔗 Next Steps & Handoffs

<!-- BEGIN GENERATED: handoffs (generated from the ecosystem workflow map by build_ecosystems.py — do not edit by hand) -->

Ecosystem: @ecosystem-orchestration — Agent Orchestration.

Workflows:

  • Failure & Context Pressure Flow (orch-resilience, step 2 of 3): next → @session-transfer (optional).

Handoff contract: pass results to the next skill through an inline Handoff block in your reply with the fields skill, workflow, created_at, inputs, summary, and next (the handoff contract of @ecosystem-orchestration). If a next skill is not installed, continue with its step from the ecosystem map, or install it with npx skills add fatih-developer/fth-skills --skill <name> after the user agrees.

<!-- END GENERATED: handoffs -->

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.