context-engineering
FreeNo executable scriptsNot checkedAudits and reorganises what an AI coding agent carries in its context window: instruction files, path-scoped rules, skills, subagents, hooks and the running…
by TerminalSkills★ 221 GitHub starsAbout this skill
Context Engineering
Overview
Context engineering is deciding what an AI coding agent has in its context window at each step: standing instructions, skill and tool listings, files it has read, command output, and the conversation so far. The window is finite and everything in it competes for the model's attention, so the work is curation: load what the current step needs, keep the rest reachable but out.
This skill does three jobs. It audits what a project loads today, moves each piece of knowledge to the mechanism that loads it at the right moment, and sets the habits that keep a long session usable. The facts below come from the tools' own documentation, not from folklore: where a number appears, it is one the vendor publishes.
Instructions
1. See what is loaded today
Inventory the instruction files from the shell:
wc -l CLAUDE.md CLAUDE.local.md AGENTS.md GEMINI.md .claude/CLAUDE.md .claude/rules/*.md 2>/dev/null
find . \( -name CLAUDE.md -o -name AGENTS.md -o -name GEMINI.md \) -not -path "*/node_modules/*"
ls .claude/skills .claude/agents .cursor/rules 2>/dev/null
Then ask the user to run the tool's own report, because only the tool knows what it really loaded:
| Tool | Check | Shows |
|---|---|---|
| Claude Code | /context |
token use by category, including the list under Memory files |
| Claude Code | /memory |
every instruction file location and the auto memory folder |
| Claude Code | /doctor, /skill-doctor |
proposed cuts for a checked-in CLAUDE.md; context cost and usage of each skill |
| Codex CLI | codex --ask-for-approval never "Summarize the current instructions." |
the instruction chain it built |
| Gemini CLI | /memory show |
the concatenated context files |
2. Know what loads when
Claude Code documents this behaviour:
| Mechanism | Enters the context | After compaction |
|---|---|---|
CLAUDE.md in the working directory and above, ~/.claude/CLAUDE.md, CLAUDE.local.md, rules without paths |
at session start, in full, on every request | re-read from disk |
.claude/rules/*.md with paths: and CLAUDE.md in subdirectories |
when a matching file is read | gone until a matching file is read again |
Auto memory MEMORY.md |
at start, first 200 lines or 25 KB | re-read from disk |
| Skill | description at start; the body when invoked | invoked bodies re-attached, first 5,000 tokens per skill, 25,000 in total; the description listing is not reloaded |
| Subagent | never: it works in its own window and returns a summary | background ones keep running |
| Hook | never, unless it returns text for the model: plain stdout on SessionStart and UserPromptSubmit, an additionalContext JSON field on other events |
SessionStart hooks matching compact run again |
| MCP server | tool names at start, full schemas when a tool is needed | tool names reload automatically |
Instruction files are delivered as context, not as enforced configuration: the documentation says longer files reduce adherence and gives a target of under 200 lines per file. @file imports organise a long file but do not make it cheaper, since imported files load at launch too.
3. Put each piece of knowledge where it loads at the right time
Take every section of the existing instruction file and ask, in this order:
- Must it happen every time with no exceptions (format after each edit, never touch
migrations/)? Make it a hook or a permission rule. An instruction can be ignored; a hook cannot. - Can the agent work it out by reading the code (directory tree, dependency list, standard language style)? Delete it.
- Does it apply only to some files? Move it to a rule with
paths:or to an instruction file inside that directory. - Is it a multi-step procedure or reference material used now and then (release steps, a migration recipe)? Make it a skill. Add
disable-model-invocation: truewhen it has side effects; its description then costs nothing until someone types the command. - Is it personal (a sandbox URL, a preferred editor)?
CLAUDE.local.md, gitignored, or~/.claude/CLAUDE.md. - What is left, the things needed in every session, stays in the root file.
A path-scoped rule looks like this:
---
paths:
- "src/api/**/*.ts"
---
- Every handler validates its input with the zod schema in the same folder.
- Errors are thrown as `ApiError` from `src/api/errors.ts`, never as a bare `Error`.
4. Write the root instruction file
It holds what cannot be guessed: commands, conventions that differ from the defaults, traps, and pointers to where decisions live.
# Harbor Ledger
## Commands
- Install: `pnpm install`
- One test file: `pnpm vitest run src/invoices/total.test.ts` (the full suite takes 9 minutes; run it only before a PR)
- Type check: `pnpm tsc --noEmit`
## Conventions that differ from the defaults
- Money is integer cents in a `bigint`, never a `number`.
- Dates cross the API as ISO 8601 strings in UTC.
#
Install context-engineering in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
Bundled files
FAQ
What does the context-engineering skill do?
Audits and reorganises what an AI coding agent carries in its context window: instruction files, path-scoped rules, skills, subagents, hooks and the running conversation. Use when someone says "the agent ignores our CLAUDE.md", "set this repo up for Claude Code / Codex / Cursor", "my AGENTS.md is too long", "quality drops in long sessions", "it keeps inventing APIs", "what should go in a skill versus the rules file", or asks how to hand work to a subagent. Grounded in the documented loading behaviour of Claude Code, with the equivalents for Codex, Gemini CLI and Cursor.
How do I install the context-engineering skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the context-engineering skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
by Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
by Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
by Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
by Anthropic