agentleFS
drvossdrvoss/everything-copilot-cli/skills/development/context-engineering/SKILL.md

context-engineering

Skill47 starsChanged 4 months agoMITView on GitHub

Use when designing prompts or agent tasks to optimize information delivery — minimize noise, maximize signal for AI agents

  • Installs packages

82 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use using-agent-skills, constraint-driven-development and 7 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 24 projects that use this

  • vinvcnSkill

    constraint-driven-development

    把一个项目的质量线确立为书面契约,并阻止 agent 悄悄降低它。通过访谈确定用户在意哪些维度,当用户心里没有数字时提供合理的默认阈值,把一切记录进 CONSTRAINTS.md,并盯住 diff 中质量线被削弱的迹象——新增的 @ts-ignore 或 eslint-disable 抑制注释、被跳过或删除的测试、被剥掉的断言、未实现的 stub、被调低的阈值。当没有任何质量线被写下来时使用;当用户说 "set up constraints" 或 "define our standards" 时;当用户希望把他们在意的维度——无障碍性、Web 性能、覆盖率——设置成被强制执行的约束时;当 agent 为了变绿不断静默检查或跳过测试时;当你需要一个覆盖率或性能阈值却不知道该选什么数字时;或者当 agent 写下的代码超出任何人会读的体量时。

    Also in 4 projects that use this

  • LLl0k0laDSkill

    shipping-and-launch

    Use when preparing to deploy to production. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy.

    Also in 26 projects that use this

  • +6 more from LLl0k0laD

The file

We split this skill into the rules it gives an agent

8 rules. 0 are common, 6 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 77 edited versions we read keep these.

  • 6

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Do not provide everything at once.

    line 44
  2. Distinctive:

    Use this shape when instructing an agent:

    line 54
  3. Very specific:

    Use context size intentionally.

    line 74
  4. Distinctive:

    If the agent output is off-target:

    line 84
  5. Very specific:

    Use multi-model-strategy to pick a model that matches task complexity

    line 145
  6. Distinctive:

    If the agent misses twice in a row, revisit the context structure instead of only rewording the ask

    line 146
  7. Distinctive:

    Principle: Place stable content (system prompt, shared context) before variable content (the specific task or file).

    line 183
  8. Distinctive:

    When work spans multiple agent turns or session boundaries, preserve only the durable state the next agent actually needs.

    line 225

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

Context Engineering

When to Use

  • Delegating a complex task to an AI agent
  • An agent keeps repeating the wrong approach
  • Agent quality drops as the context grows longer
  • Designing a pipeline where multiple agents collaborate

Difference from context-prime (Copilot-specific):

  • context-prime: loads live project context at session start
  • context-engineering: structures the best possible information for a specific task

Prerequisites

  • The delegated task has a clear goal and scope
  • You know the relevant files or domain area

Workflow

1. Analyze signal vs. noise

Classify the information you plan to give the agent:

Information typeInclude?Why
Directly relevant code files✅ YesThe agent must edit or reason about them
Interface/type definitions✅ YesEssential for understanding contracts
Unrelated files❌ NoWaste tokens and reduce focus
Entire README❌ No (summarize instead)Low information density for the size
Information the agent already has❌ NoDuplicate token cost

2. Progressive Disclosure

Do not provide everything at once. Reveal only what each phase needs:

Phase 1: Task definition + interface contract
Phase 2: Implementation starts -> add relevant files
Phase 3: Testing -> add test patterns and references

3. Use a structured context template

Use this shape when instructing an agent:

## Task
[one clear objective]

## Given (what is already known)
- [file path]: [role]
- [interface contract]

## Constraints (what must not happen)
- [prohibited action]
- [files that must not be changed]

## Done When
- [ ] [specific, testable criterion]

4. Manage the context-window budget

Use context size intentionally. For exact model choice, see multi-model-strategy:

Task complexityContext sizeExample
Short task (fast response first)2-3 files, clear goalsmall bug fix, type addition
Medium task (balanced)5-10 files, interface contractnew API endpoint, component addition
Long task (deep reasoning first)10-20 files, module-level contextarchitecture refactor, complex bug

5. Run a result-verification loop

If the agent output is off-target:

  1. Find ambiguity in the supplied context
  2. Add explicit constraints
  3. Make the "Done When" criteria more concrete
  4. Repeat and rerun the agent

Common Rationalizations

RationalizationReality
"More context is always better"Irrelevant information distracts the agent. Signal-to-noise ratio matters more than volume.
"I'll just give the whole codebase"That wastes tokens and often lowers agent quality. Include only the files that matter.
"Natural language is enough; the agent will figure it out"Without explicit completion criteria, the agent does not know where to stop.

Red Flags

  • The agent repeats the same mistake
  • The response drifts far from the actual request
  • The task prompt has no "Done When" criteria
  • You pasted the entire README or whole directories into context

Verification

  • The task prompt contains one clear objective
  • Unrelated files were excluded from context
  • Completion criteria are explicit and testable
  • The agent output satisfies the stated completion criteria

Examples

Before (bad)

"Look through the project, find a bug, and fix it."

After (good)

## Task
Fix the JWT expiry-validation bug in `src/auth/token.ts`.

## Given
- `src/auth/token.ts`: target file to change
- `src/auth/token.test.ts`: existing tests
- Bug: the `exp` claim is a Unix timestamp, but the code compares it as milliseconds

## Constraints
- Do not modify files outside `src/auth/`
- Do not change existing function signatures

## Done When
- [ ] All existing tests pass
- [ ] The `exp` comparison uses seconds
- [ ] New edge-case tests cover just-before and just-after expiry

Tips

  • Pair this with spec-driven-development: a good spec becomes a reusable context template
  • Use multi-model-strategy to pick a model that matches task complexity
  • If the agent misses twice in a row, revisit the context structure instead of only rewording the ask

Advanced Techniques

Full-Repo Context Loading with rendergit

rendergit renders an entire Git repository into a browser-based HTML view with an LLM-friendly text export. Useful when you need the AI to understand the whole codebase at once (e.g., cross-cutting refactors, architecture analysis).

# Install (Python required)
pip install git+https://github.com/karpathy/rendergit

# Open browser view of the entire repo
rendergit .
# In the browser, switch to "LLM View" to copy the CXML-formatted codebase text.
# Paste into your session context or save to a file to attach as context.

When to use rendergit:

  • Architecture analysis requiring understanding of all modules
  • Finding all usages of a pattern across the entire codebase
  • Onboarding a new AI agent to a large, unfamiliar project

When NOT to use:

  • Single-file tasks (wasteful — just include the relevant files)
  • Repos > 200k tokens (exceeds most model limits; use selective inclusion instead)

KV-Cache Optimization

LLMs recompute the KV-cache for every token in context. For repeated agent invocations on the same context (e.g., analyzing multiple files with the same system prompt), cache-aware context structuring reduces cost significantly.

Principle: Place stable content (system prompt, shared context) before variable content (the specific task or file). This enables KV-cache reuse.

✅ Cache-friendly structure (stable content first):
[System prompt + project rules]           ← cached across requests
[Shared context: types, interfaces]       ← cached if unchanged
[Variable: specific file to analyze]      ← changes per request

❌ Cache-unfriendly structure (variable content first):
[Variable: today's date, run ID]          ← busts cache on every call
[System prompt]
[Context]

Practical application in agent instructions:

## Context (stable — appears in every call)
Project: everything-copilot-cli
Rules: follow existing SKILL.md conventions
Output format: Markdown with frontmatter

## Task (variable — changes per call)
Analyze: skills/development/tdd-workflow/SKILL.md
Find: missing edge cases in the Verification checklist

Token budget estimation:

Context typeTypical sizeCache reuse potential
System prompt500-2000 tokensHigh (same across session)
Project conventions1000-5000 tokensHigh
Specific file to analyze500-3000 tokensLow (changes per task)
Task instruction100-500 tokensLow

For multi-model pipelines with the same shared context, pass context by reference (file path + MCP view tool) rather than inline copy-pasting.

Latent Briefing

When work spans multiple agent turns or session boundaries, preserve only the durable state the next agent actually needs. Treat the handoff as a compact briefing, not a full transcript dump.

Pattern:

  1. Capture findings, decisions, and open questions at the end of an agent step
  2. Store them in a durable medium the next step can actually read (sql, task notes, or a checked-in doc when appropriate)
  3. Inject only that briefing into the next agent's context, then add fresh task-specific files or constraints

When to use:

ScenarioUse latent briefing?
Parallel agents analyze different subsystems, then a synthesizer combines the results✅ Yes
A later session resumes a partially completed task✅ Yes
One agent keeps iterating inside the same short-lived context window❌ No — keep the live context focused instead

Briefing shape (minimal):

Task: [current objective]
Done so far:
- [finding]
- [decision]

Open questions:
- [question]

Next constraints:
- [what must not change]

For Copilot CLI specifically, pair this with cross-session-memory when the handoff must survive across sessions rather than just across turns.

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.