agentleFS
NISTALTALSONNISTALTALSON/Ghost/SKILL.md

context-optimizer

Skill3 starsChanged 7 months agoMITView on GitHub

Minimizes token/context usage in Claude Code and long sessions without sacrificing model capability or output quality. Activates automatically when working on coding projects, long debugging sessions, multi-file exploration, or when the user mentions session limits, context bloat, or slowdowns. Also triggered by /scope, /compress, /handoff, /resume commands.

6 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions6 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 6

    1. rohitg00/pro-workflow★ 2.9ksame name
    2. delorenj/skills★ 17same name
    3. Bexruz-cell/agent-skills★ 1same name
    4. tygwan/cc-initializer★ 0same name
    5. tygwan/cc-initializer-windows★ 0same name
    6. wamalalawrence/agent-skills★ 0same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repositoryOne other file it gives its agents.

The file

Show its rules and text

We split this skill into the rules it gives an agent

13 rules. 0 are common, 6 are distinctive, and 7 are very specific to this project.

  • 0

    Common

    Most of the 6 edited versions we read keep these.

  • 6

    Distinctive

    This author's own choices. Worth a look.

  • 7

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Check CLAUDE.md → know the project without asking.

    line 49
  2. Very specific:

    Check docs/session-handoff.md → know exactly where to resume.

    line 50
  3. Very specific:

    If no CLAUDE.md exists → run /init or generate one now using the template.

    line 52
  4. Distinctive:

    If >3 files seem relevant, create a minimal shortlist with reasons first.

    line 56
  5. Very specific:

    Update docs/session-handoff.md with current state.

    line 60
  6. Very specific:

    Run /compress to summarize and free context.

    line 62
  7. Very specific:

    Write handoff state to docs/session-handoff.md.

    line 65
  8. Very specific:

    Run /clear (new unrelated task = new session).

    line 66
  9. Distinctive:

    When compressing or summarizing prior context:

    line 73
  10. Very specific:

    Disable: search/research/MCP connectors unless that specific step needs them.

    line 89
  11. Distinctive:

    Never leave large tool outputs sitting in context after they've been acted on.

    line 92
  12. Distinctive:

    Always scope before acting:

    line 98
  13. Distinctive:

    Always compress on switch:

    line 101

“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “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 Optimizer Skill

Mission

Maximize useful signal per token. Every turn should move the task forward with the smallest context footprint possible — without dropping capability, accuracy, or output quality. You are not cutting corners. You are cutting noise.


Memory Hierarchy (non-negotiable)

TierFileWhat lives here
1 — PermanentCLAUDE.mdProject rules, stack, commands, conventions. Never repeated in chat.
2 — Sessiondocs/session-handoff.mdCurrent task state, files touched, next exact step, blockers.
2 — Decisionsdocs/decision-log.mdArchitecture choices, why they were made, what was rejected.
2 — Mapdocs/context-map.mdModule ownership, key interfaces, where to edit common concerns.
3 — ScratchpadLive chatTemporary reasoning only. Expendable.

Rule: If it matters beyond this turn, it belongs in a Tier 1 or Tier 2 file — not in chat.


Default Workflow (every session)

On Start

  1. Check CLAUDE.md → know the project without asking.
  2. Check docs/session-handoff.md → know exactly where to resume.
  3. Restate the task in ≤3 bullets. Name the exact files you'll touch.
  4. If no CLAUDE.md exists → run /init or generate one now using the template.

On Each Task

  • Load only the files needed for this specific task. Not the whole repo.
  • If >3 files seem relevant, create a minimal shortlist with reasons first.
  • Work in targeted prompts: "Edit auth.ts, update login() to validate JWT expiry, run auth tests" — not "fix auth."

On Milestone Complete

  1. Update docs/session-handoff.md with current state.
  2. Log any architecture decisions in docs/decision-log.md.
  3. Run /compress to summarize and free context.

On Task Switch

  1. Write handoff state to docs/session-handoff.md.
  2. Run /clear (new unrelated task = new session).
  3. Resume with: "Read CLAUDE.md and session-handoff.md. Continue: [next step]."

Compression Rules

When compressing or summarizing prior context:

  • Keep: task goal, key decisions, exact filenames, current state, next action, open blockers.
  • Drop: failed hypotheses (unless still open), repetitive explanation, raw debug logs already resolved.
  • Format: structured bullets, not prose walls.
  • Target: compress a 100k token history into a ~2-3k summary with zero capability loss.

Trigger /compress when:

  • A feature is complete.
  • A debugging loop has run 3–5 turns without resolution.
  • Discussion feels repetitive.
  • Context feels heavy/slow.

Tool Discipline

  • Disable search/research/MCP connectors unless that specific step needs them.
  • Disable extended thinking unless the task genuinely requires multi-step reasoning.
  • After a large file read or search result → decide immediately: keep or clear.
  • Never leave large tool outputs sitting in context after they've been acted on.

Prompting Rules (enforce these)

Always scope before acting:

"Summarize the task in 3 bullets, name exact files needed, ignore unrelated repo parts."

Always compress on switch:

"Compress prior discussion into: decisions made, open questions, next action. Then clear."

Always handoff cleanly:

"Update session-handoff.md and decision-log.md. Write a resume note under 150 words."


Anti-Patterns (never do these)

Anti-patternWhy it's bad
Repeating full project context in every promptCLAUDE.md exists for this
One mega-session for unrelated featuresCross-task residue pollutes context
Leaving connectors/search enabled all sessionToken-intensive, confirmed by Anthropic
Vague prompts like "fix auth" or "improve this"Forces broad exploration = token explosion
Keeping stale project files in contextAnthropic explicitly recommends removing these
Storing reasoning in chat instead of memory filesChat is not persistent memory

Custom Commands

CommandAction
/scopeRestate task, list exact files, ignore everything else
/compressSummarize history → decisions + state + next step. Drop noise.
/handoffWrite full state to session-handoff.md. Prepare for /clear.
/resumeLoad CLAUDE.md + session-handoff.md. Restate exact next step.
/auditList what's in context. Flag anything that can be cleared or moved to files.

See commands/ folder for full prompts for each command.


Guiding Principle

Chat is a scratchpad. Files are memory. Treat them that way.

The goal is not fewer tokens at the cost of quality — it's zero wasted tokens while keeping every token that actually matters. A clean 20k context outperforms a bloated 180k context every time.

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.