context-engineering

context-engineering is a skill for Claude Code, Codex from itsmostafa/llm-engineering-skills. It costs 42 tokens per session (2,809 once invoked), scanned A, original, MIT.

A guide to managing the information an AI model receives while it works, especially when conversations or tasks become long. It focuses on choosing useful information and removing distracting or outdated details.

In plain words
What is it for?
Use it when building AI agents that handle long conversations, several steps, tools, or extended tasks. It covers context handling, system prompts, tool design, and long-running workflows.
Why use it?
Long inputs can make an AI model slower and less accurate because important details compete with irrelevant ones. This helps keep the model focused as work continues.

Skill for Claude CodeCodex

Part of the llm-engineering-skills plugin — 9 skills shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/itsmostafa/llm-engineering-skills/context-engineering
Any agent
npx skills add itsmostafa/llm-engineering-skills --skill context-engineering
Clone the repo
git clone --depth 1 https://github.com/itsmostafa/llm-engineering-skills

Made for: Claude Code, Codex.

Or install llm-engineering-skills, the plugin that ships this one along with the rest of its 9 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for context-engineering

README.md
[![agentmods](https://agentmods.dev/badge/skills/itsmostafa/llm-engineering-skills/context-engineering.svg)](https://agentmods.dev/skills/itsmostafa/llm-engineering-skills/context-engineering)
Your own site
<a href="https://agentmods.dev/skills/itsmostafa/llm-engineering-skills/context-engineering"><img src="https://agentmods.dev/badge/skills/itsmostafa/llm-engineering-skills/context-engineering.svg" alt="Measured on agentmods" height="20"></a>
Per session 42 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,809 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00042 $0.02809
Opus 5 $0.00021 $0.01404
Sonnet 5 $0.00008 $0.00562
Haiku 4.5 $0.00004 $0.00281

Measured 5d ago against content hash 62b8c5c90379, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

context-engineering scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/context-engineering/SKILL.md · 391 lines

How it starts

The opening of the file, as written. The whole thing — 391 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Context Engineering

Context engineering is the discipline of curating and maintaining the optimal set of tokens during LLM inference. Unlike prompt engineering (crafting individual prompts), context engineering focuses on what information enters the context window and when.

Table of Contents

Core Principles

Context as a Finite Resource

LLMs have limited "attention budgets." As context length increases, models experience context rot—decreased ability to accurately recall information. The goal is finding the smallest possible set of high-signal tokens that maximize desired outcomes.

Effective Context = Relevant Information / Total Tokens

Key insight: More context isn't better. The right context is better.

The Context Pollution Problem

Every token added to context has costs:

  • Increased latency and compute
  • Diluted attention to important information
  • Higher risk of hallucination from conflicting data
  • Reduced model performance on retrieval tasks

Context Management Strategies

1. Context Trimming

Drop older conversation turns, keeping only the last N turns.

Aspect Details
Mechanism Sliding window over conversation history
Pros Deterministic, zero latency, preserves recent context verbatim
Cons Abrupt loss of long-range context, "amnesia" effect
Best for Independent tasks, short interactions, predictable workflows
def trim_context(messages: list, keep_last_n: int = 10) -> list:
    """Keep system message + last N turns."""
    system_msgs = [m for m in messages if m["role"] == "system"]
    other_msgs = [m for m in messages if m["role"] != "system"]
    return system_msgs + other_msgs[-keep_last_n:]

Read the full file on GitHub · 391 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 391 lines · 42 tokens per session scan A 62b8c5c90379

Subscribe to this mod's changes

context-engineering is a skill published in the GitHub repository itsmostafa/llm-engineering-skills (23 stars, last pushed 4mo ago), licensed MIT. It adds 42 tokens to every session and 2,809 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

context-optimizer

上下文优化专家。专注于长对话中的上下文管理、token 效率和性能优化。解决 lost-in-middle、context poisoning 等问题,提升 AI 代理在复杂任务中的表现。.

huangwb8/skills · 48 tokens

distill

One-time snapshot extracting patterns from work history and accumulated lessons, distills into concrete improvements — new agent/skill suggestions, memory pruning, consolidating lessons into rules/agent updates, or performing bin/ extraction from /audit --efficiency candidates. Roster boundary analysis →…

Borda/AI-Rig · 68 tokens

session

Session state that outlives a context reset — dump sweeps the live conversation and writes a compact handover doc (goal, decisions + why, lessons, standing instructions, files-touched table, outstanding items, next step), then prints /clear; the session-restore.js SessionStart hook re-injects it automatically. park…

Borda/AI-Rig · 209 tokens

session-handoff

Use when the user says "session handoff", "wrap up session", "hand off", "handoff summary", "let's wrap up", "summarize before I clear", or wants a structured end-of-session summary before clearing context. Also use proactively when the user says they are about to /clear and no handoff has been produced yet. Generates…

AdityaVasireddy/agent-skills · 148 tokens

engineering-historian

Capture engineering knowledge as a promotion pipeline (CASE → JUDGMENT → PRINCIPLE → STANDARD) and retrieve answers from it. Capture is automatic — a post-session sweep drafts cases with status:auto; the user reviews them at /distill. Use whenever the user types "/history", "/case", or "/distill", says "log this…

AdityaVasireddy/agent-skills · 187 tokens

agent-carnet

Use this skill when the user asks to save, recall, find, or organize notes. Triggers on: 'remember this', 'save this', 'note this', 'what did we discuss about...', 'check the notebook', 'find in carnet'. Also use proactively when discovering findings worth preserving across sessions.

yamadashy/repomix · 67 tokens