context-engineering

context-engineering is a skill for Claude Code, Codex from topprismdata/cultivating-ml-agent. It costs 65 tokens per session (847 once invoked), scanned A, original, MIT.

A method for managing the information given to an AI agent when the conversation, prompt, or training logs become long. It compresses low-priority text, keeps important errors, and allocates space by importance.

In plain words
What is it for?
Use it to shorten long prompts, trim training logs while retaining warnings and errors, and prioritise system instructions, tasks, and examples.
Why use it?
It reduces the chance that useful instructions or errors are overlooked because too much information is crowded into the agent’s context.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

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/topprismdata/cultivating-ml-agent/context-engineering
Any agent
npx skills add topprismdata/cultivating-ml-agent --skill context-engineering
Clone the repo
git clone --depth 1 https://github.com/topprismdata/cultivating-ml-agent

Made for: Claude Code, Codex.

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/topprismdata/cultivating-ml-agent/context-engineering.svg)](https://agentmods.dev/skills/topprismdata/cultivating-ml-agent/context-engineering)
Your own site
<a href="https://agentmods.dev/skills/topprismdata/cultivating-ml-agent/context-engineering"><img src="https://agentmods.dev/badge/skills/topprismdata/cultivating-ml-agent/context-engineering.svg" alt="Measured on agentmods" height="20"></a>
Per session 65 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 847 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.1 $0.00065 $0.00847
Opus 5 $0.00032 $0.00424
Sonnet 5 $0.00013 $0.00169
Haiku 4.5 $0.00006 $0.00085

Measured 6d ago against content hash a72eae05d42f, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, 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 6d 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/examples/context-engineering/SKILL.md · 95 lines

How it starts

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

Context Engineering

Context

Even with 1M-2M token context windows, stuffing everything degrades performance ("Lost in the Middle" — Liu et al. 2023). This skill encodes Anthropic's 2025 best practices: dynamic compression, intelligent log truncation, and priority-aware token budgeting.

The core insight: context is RAM, treat it like memory management, not a buffer.

Guidance

Three Tools

from framework.src.context_engineering import (
    ContextCompressor, LogTruncator, TokenEconomy,
    CompressionLevel, BudgetPriority,
)

# 1. Compress long text (LLM outputs, paper abstracts)
compressor = ContextCompressor()
result = compressor.compress(long_paper_abstract,
                              level=CompressionLevel.MEDIUM,
                              focus_query="time series forecasting")
# → AGGRESSIVE for very long, MEDIUM for 4K-20K, LIGHT for <4K

# 2. Truncate training logs (preserve errors + samples)
truncated = LogTruncator(max_lines=200).truncate(training_log)
# → 500 lines → 50 lines, all ERROR/WARN kept, METRIC sampled

# 3. Priority-aware token budget
econ = TokenEconomy()
econ.add_critical(system_prompt, "system")
econ.add_high(current_task, "task")
econ.add(relevant_skill_text, BudgetPriority.MEDIUM, "skills")
econ.add(optional_context, BudgetPriority.LOW, "context")
prompt = econ.assemble()  # auto-drops LOW when over budget

Decision Workflow

Assembling a prompt?
  ↓
1. Are there training logs > 100 lines?
   → LogTruncator first (reduce noise 5-10x)
  ↓
2. Are there paper abstracts / long docs?
   → Compressor + MEDIUM (keep relevant 50%)
  ↓
3. Total still > 8000 chars?
   → TokenEconomy (prioritize, auto-drop LOW)
  ↓
4. Send to LLM

Why This Matters

Without Context Engineering With It
Lost in the Middle (model misses mid-prompt) Key info always prioritized
40% token waste on redundant/irrelevant content 50-70% token savings
Inconsistent outputs from over-stuffed prompts Stable, focused outputs
Can't fit new context when LLM call limit hit Always room for one more thing

Read the full file on GitHub · 95 lines

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. 6d ago First seen · 95 lines · 65 tokens per session scan A a72eae05d42f

Subscribe to this mod's changes

context-engineering is a skill published in the GitHub repository topprismdata/cultivating-ml-agent (4 stars, last pushed 8d ago), licensed MIT. It adds 65 tokens to every session and 847 once invoked, about $0.0003 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-31.