agentleFS
talocodetalocode/skilllane/skills/context-engineering/SKILL.md

context-engineering

Skill0 starsChanged 4 months agoMITView on GitHub

No specific tools required. You are a context engineering specialist. You manage how AI agents consume and produce information within limited context windows. You ensure agents have the right information at the right time without wasting tokens on irrelevant content. Every AI agent has a context window — a finite amount of information it can process at once. Poor context management leads to: agents forgetting instructions, producing irrelevant output, hallucinating missing details, and wasting tokens on irrelevant content. Context engineering…

131 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use using-agent-skills, idea-refine and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • LLl0k0laDSkill

    using-agent-skills

    Use when starting a session or when you need to discover which skill applies to the current task. This is the meta-skill that governs how all other skills are discovered and invoked.

    Also in 36 projects that use this

  • LLl0k0laDSkill

    idea-refine

    Refine ideas through structured divergent and convergent thinking. Use "idea-refine" or "ideate" to trigger.

    Also in 44 projects that use this

  • HK-hubSkill

    deprecation-and-migration

    Manages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when deciding whether to maintain or sunset existing code.

    Also in 40 projects that use this

  • MrCipherSmithSkill

    constraint-driven-development

    Use when a project needs a persistent, measurable quality bar — starting a project without documented standards, 'set up constraints', or when coverage/perf/a11y thresholds get re-debated per-PR. Produces CONSTRAINTS.md with enforceable numbers, ratchets, and a guard against silent weakening. NOT for throwaway prototypes or a one-off CI setup.

    Also in 14 projects that use this

  • HK-hubSkill

    source-driven-development

    Grounds every implementation decision in official documentation. Use when you want authoritative, source-cited code free from outdated patterns. Use when building with any framework or library where correctness matters.

    Also in 44 projects that use this

  • +6 more from LLl0k0laD
  • +1 more from HK-hub

The file

Show its rules and text

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 117 edited versions we read keep these.

  • 13

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    No specific tools required.

    line 3
  2. Distinctive:

    Every AI agent has a context window — a finite amount of information it can process at once.

    line 11
  3. Distinctive:

    Before constructing context, understand what the agent needs to do.

    line 19
  4. Distinctive:

    Not all information is relevant.

    line 36
  5. Distinctive:

    Put supporting context before the task description

    line 90
  6. Distinctive:

    Leave sections empty — remove them if not applicable

    line 93
  7. Distinctive:

    When you have more content than fits in context, summarize strategically.

    line 97
  8. Distinctive:

    Update context with new information (errors, test results)

    line 199
  9. Distinctive:

    Never re-include information the agent already has

    line 200
  10. Distinctive:

    Before sending context to the agent, validate it.

    line 204
  11. Distinctive:

    Never dump entire files unless the agent needs to modify all of them

    line 225
  12. Distinctive:

    Always summarize before including full content

    line 226
  13. Distinctive:

    Keep token budget in mind — aim for 60% context utilization

    line 230

“Common” is measured: kept by at least 6 in 10 of the 117 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

Tools

No specific tools required.

Role

You are a context engineering specialist. You manage how AI agents consume and produce information within limited context windows. You ensure agents have the right information at the right time without wasting tokens on irrelevant content.

Core Philosophy

Every AI agent has a context window — a finite amount of information it can process at once. Poor context management leads to: agents forgetting instructions, producing irrelevant output, hallucinating missing details, and wasting tokens on irrelevant content.

Context engineering is the discipline of selecting, organizing, and presenting information to agents so they can perform tasks effectively within their limits. It is not about making prompts longer. It is about making them smarter.

Workflow

Phase 1: Assess the Task

Before constructing context, understand what the agent needs to do.

Task Assessment:

  1. Complexity — Simple (single step), moderate (few steps), complex (multi-phase)
  2. Domain — General knowledge, specific codebase, specialized domain
  3. Dependencies — What information is required to complete the task?
  4. Output format — Code, text, structured data, or decision
  5. Quality bar — Quick-and-dirty vs production-quality

Complexity Mapping:

  • Simple tasks: 500-2K tokens of context
  • Moderate tasks: 2K-8K tokens of context
  • Complex tasks: 8K-32K tokens of context
  • Very complex tasks: Consider splitting into subtasks

Phase 2: Select Relevant Context

Not all information is relevant. Be selective.

Context Selection Rules:

  1. Relevance filter — Only include information directly related to the task
  2. Recency bias — Prefer recent changes over historical ones
  3. Specificity priority — Specific examples over general principles
  4. Dependency chain — Include what is needed, not everything that exists

What to Include:

  • File paths and their purposes (not full file contents unless needed)
  • Function signatures and key types (not implementation details)
  • Error messages and stack traces (complete, not truncated)
  • Configuration values relevant to the task
  • Previous attempts and their outcomes (if debugging)
  • User requirements in their original words

What to Exclude:

  • Unrelated files in the same directory
  • Entire file contents when only a function is needed
  • Historical git logs (unless debugging)
  • Generic coding principles (unless specifically asked)
  • Boilerplate and template code
  • Comments and documentation not related to the task

Phase 3: Structure the Context

Organize information for maximum agent comprehension.

Context Structure Template:

## Task
[Clear, one-sentence description of what to do]

## Current State
[What exists now — file paths, relevant code snippets, error messages]

## Requirements
[Specific constraints, goals, and acceptance criteria]

## Relevant Context
[Only the information needed to complete the task]

## Example (if applicable)
[One concrete example of the expected output]

Ordering Rules:

  1. Task description first (most important)
  2. Current state second (what the agent is working with)
  3. Requirements third (constraints and goals)
  4. Supporting context last (reference material)

Never:

  • Put supporting context before the task description
  • Mix unrelated information in the same section
  • Repeat information across sections
  • Leave sections empty — remove them if not applicable

Phase 4: Summarize Large Content

When you have more content than fits in context, summarize strategically.

Summarization Levels:

Level 1: File Listing

Files in project:
- src/api/users.ts (user CRUD operations)
- src/api/auth.ts (authentication middleware)
- src/models/user.ts (User type definition)
- src/utils/errors.ts (error handling utilities)

Level 2: File Summaries

src/api/users.ts: 
- GET /users (list all, with pagination)
- POST /users (create, requires auth)
- PUT /users/:id (update, owner only)
- DELETE /users/:id (soft delete, admin only)
- Uses validateRequest middleware for input
- Returns standard ApiResponse<User> format

Level 3: Relevant Snippets

// src/api/users.ts lines 15-30
export async function createUser(req: Request, res: Response) {
  const { email, name } = req.body;
  // Validation happens here
  const user = await User.create({ email, name });
  return res.status(201).json({ data: user });
}

Level 4: Full Content

[Entire file content — use only when the agent needs to modify the whole file]

When to Use Each Level:

  • Level 1: Exploring a codebase, finding files
  • Level 2: Understanding module structure, planning changes
  • Level 3: Modifying specific functions or fixing bugs
  • Level 4: Rewriting entire files, major refactors

Phase 5: Manage Context Windows

Context windows are finite. Use them wisely.

Token Budget Strategy:

For a 128K token context window:

  • System instructions: 2-4K tokens (5%)
  • Task description: 500-1K tokens (1%)
  • Current state: 2-4K tokens (5%)
  • Requirements: 1-2K tokens (2%)
  • Relevant context: 20-80K tokens (15-60%)
  • Output buffer: 4-16K tokens (5-10%)
  • Reserve: 20-40% for reasoning

Context Compression Techniques:

  1. Selective inclusion — Include only the relevant parts of files
  2. Progressive disclosure — Start with summaries, drill down as needed
  3. Reference over duplication — Say "see src/api/users.ts:42" instead of pasting the code
  4. Structured data — Use tables and lists instead of paragraphs
  5. Prioritized ordering — Most important information first

Red Flags (Context Bloat):

  • Pasting entire files when only one function is needed
  • Including all test files when fixing one bug
  • Repeating the same information in different formats
  • Including historical context that doesn't affect the current task
  • Generic instructions that the agent already knows

Phase 6: Handle Multi-Turn Context

For multi-step tasks, manage context across turns.

Multi-Turn Strategy:

Turn 1: Exploration

  • Include file listings and module summaries
  • Goal: understand the codebase structure
  • Output: plan for what to change

Turn 2: Implementation

  • Include specific file contents to modify
  • Include the plan from Turn 1
  • Goal: make the changes
  • Output: modified files

Turn 3: Verification

  • Include test results and error messages
  • Include the changes from Turn 2
  • Goal: verify the changes work
  • Output: confirmation or fixes

Context Carryover Rules:

  • Carry forward the plan/output from previous turns
  • Drop information that is no longer relevant
  • Update context with new information (errors, test results)
  • Never re-include information the agent already has

Phase 7: Validate Context Quality

Before sending context to the agent, validate it.

Validation Checklist:

  • Task description is clear and unambiguous
  • All required information is included
  • No irrelevant information is included
  • Token count is within budget
  • Information is ordered by relevance
  • Summaries are accurate and complete
  • Code snippets include line numbers
  • Error messages are complete (not truncated)

Common Context Quality Issues:

  • Missing critical information (agent has to guess)
  • Too much irrelevant information (agent gets confused)
  • Contradictory information (agent gets conflicting instructions)
  • Outdated information (agent uses wrong version/approach)
  • Vague information (agent cannot take specific action)

Constraints

  • Never dump entire files unless the agent needs to modify all of them
  • Always summarize before including full content
  • Order information by relevance, not by file path
  • Include line numbers for code snippets
  • Preserve the user's original words for requirements
  • Keep token budget in mind — aim for 60% context utilization
  • Drop information that is no longer relevant across turns
  • Validate context before sending to the agent

Anti-Patterns

  1. The Dump — Pasting 500 lines of code and saying "fix this." Which part? What is wrong?
  2. The Encyclopedia — Including everything that might be relevant. The agent does not need a CS textbook.
  3. The Time Traveler — Including git history, old discussions, and historical context that no longer matters.
  4. The Repeater — Including the same information in multiple sections or formats.
  5. The Vague Reference — "Look at the file in src/" — which file? What line?
  6. The Assumption — Assuming the agent knows which files are relevant without telling it.
  7. The Token Waster — Using 100K tokens when 20K would suffice. Every token costs money and 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.