Context Engineering logo

Context Engineering

Community
nimadorostkar
context-engineering

Use when managing what an LLM sees. Covers context-window budgeting, retrieval and compaction, memory across turns, tool-result pruning, and the failure modes that come from too much context rather than too little. Trigger on "model gets worse as the conversation gets longer", "context window keeps filling up". Do not use for state that persists across sessions — see the agent-memory skill; for retrieval over a document corpus, see the rag skill.

Overview

Publishernimadorostkar
RepositoryClaude-Skills-collection
Skill namecontext-engineering
Stars
34
Forks
4
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by nimadorostkar on GitHub. Read the source before you install it.

Installation

Install the Context Engineering AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/nimadorostkar/Claude-Skills-collection/tree/main/skills/ai/context-engineering
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/nimadorostkar/Claude-Skills-collection.git /tmp/Claude-Skills-collection
mkdir -p .claude/skills
cp -r /tmp/Claude-Skills-collection/skills/ai/context-engineering .claude/skills/context-engineering
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Context Engineering in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Context Engineering on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Context Engineering is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Context Engineering

Purpose

Decide what an LLM sees, and what it does not. Context is a finite budget with a nonlinear cost curve: more context is not more capability, and past a point it is actively less.

When to Use

  • Building an agent or assistant that runs over many turns.
  • A model that performs worse as the conversation gets longer.
  • Managing tool results, retrieved documents, or long files.
  • Reducing token cost in a long-running system.

Capabilities

  • Context budgeting and allocation.
  • Retrieval: putting the right thing in, not everything.
  • Compaction and summarization of history.
  • Memory: what persists across sessions, and in what form.
  • Tool-result pruning and progressive disclosure.

Inputs

  • The task, and what information it genuinely requires.
  • The context window and its cost.
  • The failure symptom, if the system is degrading over long runs.

Outputs

  • A context budget with an allocation per component.
  • A compaction strategy that preserves what matters.
  • Measurably better performance on long tasks.

Workflow

  1. Budget the window explicitly — System prompt, tools, retrieved context, history, and the response all compete for the same space. Decide the allocation rather than letting history consume everything.
  2. Retrieve narrowly — Ten highly relevant chunks outperform a hundred marginally relevant ones. Irrelevant context does not sit inertly; it distracts.
  3. Compact, do not truncate — Dropping the oldest turns loses the decisions that explain the current state. Summarize the history into the facts and decisions that are still live.
  4. Prune tool results — A tool returning 50 KB of JSON when the agent needs three fields is spending the budget on noise. Filter at the tool boundary.
  5. Disclose progressively — Provide a file listing, not the files. Let the model request what it actually needs. This is how a large codebase fits in a small window.
  6. Externalize memory — Long-lived state belongs in a file or a store the model can read and write, not in a conversation history that grows without bound.

Best Practices

  • Long context degrades attention. A model given 200,000 tokens of context often performs worse than the same model given the 5,000 tokens that mattered. Adding context is not free.
  • Information in the middle of a long context is attended to least. Put the critical instruction at the start or the end, not buried in the middle.
  • Compaction is lossy by design. Preserve the decisions, the constraints, and the unresolved questions; discard the exploration that led to them.
  • A tool that returns raw API output is a context leak. Wrap it, select the fields, and return a summary with a way to fetch the detail.
  • Cache the stable prefix. A system prompt and tool definitions that do not change should be cached rather than re-sent and re-processed each turn.
  • Write important state to a file. A note the model writes and re-reads survives compaction; a fact buried in turn 12 does not.

Examples

Explicit context budget:

text
Window: 200,000 tokens. Allocation:

  System prompt + skill      4,000    stable, cached
  Tool definitions           3,000    stable, cached
  Working memory file        2,000    the agent's own notes, re-read each turn
  Retrieved context         20,000    top-k, re-retrieved per turn, not accumulated
  Conversation history      40,000    compacted when it exceeds this
  Tool results              30,000    pruned; only the most recent kept in full
  Reserve for response      16,000
                          --------
                           115,000    leaving deliberate headroom

Rules:
  - History exceeding 40k triggers compaction, not truncation.
  - Retrieved context is replaced each turn, never appended — otherwise it
    grows monotonically and crowds out everything else.
  - Tool results older than 3 turns are replaced by a one-line summary.

Compaction that preserves what matters:

python
COMPACTION_PROMPT = """\
Summarize the conversation so far into a working state document. This summary
replaces the full history, so anything you omit is lost permanently.

Preserve:
- The user's goal and any constraints they stated.
- Decisions made, and the reason for each.
- Facts discovered (file paths, API shapes, error messages, values).
- What has been tried and failed, so it is not retried.
- Open questions and the current next step.

Discard:
- Exploration that led nowhere.
- Full file contents (keep the path and what was learned from it).
- Tool call mechanics and intermediate output.

Write it as a factual state document, not a narrative."""

Progressive disclosure instead of loading everything:

python
# Wrong: 400 files, 2M tokens, does not fit and would not help if it did.
context = "\n".join(read(f) for f in repo.all_files())

# Right: give the model a map, and a tool to fetch what it decides it needs.
context = repo.tree(max_depth=3)          # ~2,000 tokens
tools = [read_file, grep, list_directory] # the model pulls what it needs

Notes

  • The "lost in the middle" effect is well-documented: retrieval accuracy for a fact placed in the middle of a long context is substantially lower than for the same fact at either end. Placement is not neutral.
  • Prompt caching makes a large stable prefix cheap after the first call. It changes the economics of a long system prompt entirely — but only if the prefix is genuinely stable, byte for byte.
  • The instinct to give the model more context is usually wrong. The instinct to give it better context is usually right.

Frequently asked questions

What does the Context Engineering AI skill do?

Use when managing what an LLM sees. Covers context-window budgeting, retrieval and compaction, memory across turns, tool-result pruning, and the failure modes that come from too much context rather than too little. Trigger on "model gets worse as the conversation gets longer", "context window keeps filling up". Do not use for state that persists across sessions — see the agent-memory skill; for retrieval over a document corpus, see the rag skill.

Why use Context Engineering on TypingMind?

Because you install it once and use it with any model. Context Engineering is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Context Engineering in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/nimadorostkar/Claude-Skills-collection/tree/main/skills/ai/context-engineering. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Context Engineering?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Context Engineering?

As many as you like. As long as a model supports skills, you can use Context Engineering with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Context Engineering AI skill free?

Yes. It is published on GitHub by nimadorostkar under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇