agentleFS
manastalukdarmanastalukdar/ai-devstudio/skills/context-engineering/SKILL.md

context-engineering

Skill1 starsChanged 7 months agoMITView on GitHub

Audit and curate the 5-layer agent context hierarchy to prevent quality degradation mid-session — rules files, specs, source files, error output, and conversation history.

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 6 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

  • 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

  • +5 more from LLl0k0laD

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 117 edited versions we read keep these.

  • 3

    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:

    Early exit: If context appears healthy (no redundant files loaded, no stale error traces), report "Context healthy — no changes needed"

    line 18
  2. Distinctive:

    Check for common inflation sources:

    line 43
  3. Distinctive:

    Test output exceeding 200 lines

    line 48

“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

Context Engineering

I'll audit your current context load, identify what is inflating it unnecessarily, and restructure the 5-layer hierarchy so the agent stays sharp for the rest of the session.

Arguments: $ARGUMENTS — optional focus (e.g., "optimize for implementation", "optimize for debugging")

Token Optimization

Expected range: 200–600 tokens (audit report + recommendations)

Early exit: If context appears healthy (no redundant files loaded, no stale error traces), report "Context healthy — no changes needed"

Patterns used: Bash for file size checks, progressive disclosure (summary first, details on request)

The 5-Layer Context Hierarchy

Layer 1 — Rules files       CLAUDE.md, .claude/rules/*.md
Layer 2 — Specs / designs   docs/specs/, PRD, ADRs
Layer 3 — Source files      only the files currently being changed
Layer 4 — Error output      compiler errors, test failures, logs
Layer 5 — Conversation      current session history

Each layer has an appropriate size budget. Layers 3–5 are the most common source of bloat.

Step 1 — Audit Current Context

# Estimate context pressure indicators
wc -l .claude/rules/*.md 2>/dev/null | tail -1
find . -name "CLAUDE.md" | xargs wc -l 2>/dev/null | tail -1
ls -la docs/specs/ 2>/dev/null | head -10

Check for common inflation sources:

  • Entire files loaded when only a function is needed
  • Stale error traces from previous attempts (no longer relevant)
  • Spec documents for features not currently being implemented
  • Multiple versions of the same file loaded
  • Test output exceeding 200 lines

Step 2 — Report Findings

Context Audit:

Layer 1 (Rules):     [N lines] — [healthy / inflated]
Layer 2 (Specs):     [N files loaded] — [relevant / stale]
Layer 3 (Source):    [N files] — [scoped / over-broad]
Layer 4 (Errors):    [N lines] — [current / stale]
Layer 5 (History):   [estimated turns] — [fresh / compressible]

Top 3 inflation sources:
1. [source] — [recommended action]
2. [source] — [recommended action]
3. [source] — [recommended action]

Step 3 — Apply Recommendations

For each inflation source, take the recommended action:

Over-broad source files: Identify the specific functions or classes needed; reference by grep pattern rather than loading the whole file

Stale error traces: Summarize to the key error type and location (1–2 lines); drop the full stack trace from active context

Off-topic specs: Note the spec exists and where to find it; remove it from active context

Redundant conversation: Summarize completed sub-tasks as a single line each; carry forward only open items

Step 4 — Curate Going Forward

Recommend a loading strategy for the rest of the session based on $ARGUMENTS:

Recommended context loading strategy:
- Layer 3: Load only [file list] — grep for symbols before loading full files
- Layer 4: Keep error output to last 50 lines per error type
- Layer 5: Summarize completed phases; keep only current phase in full detail

Edge Cases

  • No CLAUDE.md or rules files: note the absence; recommend creating minimal rules for consistent behavior
  • Context already very large: recommend starting a fresh session with a focused handoff prompt; provide a handoff template
  • Cannot determine what is loaded: provide the optimization heuristics and let the user apply them manually

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.

Reviews can't be read right now.

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.