Agent skill

Context Engineering

by closedloop-ai in closedloop-ai/claude-plugins

This skill should be used when designing prompts, system prompts, or context windows for Claude.

Apache-2.0Auto-check passedAgent Workflows

Install Context Engineering

skills CLI
$ npx skills add closedloop-ai/claude-plugins --skill context-engineering -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install closedloop-ai/claude-plugins context-engineering --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/closedloop-ai/claude-plugins.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/platform/skills/context-engineering .claude/skills/context-engineering && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
context-engineering
GitHub stars
122
Token cost
~3.1k tokens
SKILL.md length
1,381 words
Files
5 (incl. references)
Skills in repo
43
Repo updated
First seen
Licence
Apache-2.0

At a glance

This skill should be used when designing prompts, system prompts, or context windows for Claude.

  • Works in 9 steps: Be Clear and Direct → Use Examples (Multishot Prompting) → Chain of Thought (CoT) → …
  • Include writing prompts for API calls
  • SKILL.md covers Overview, When to Use, Technique Priority and Core Techniques, plus 2 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Context Engineering is an agent skill from closedloop-ai/claude-plugins. This skill should be used when designing prompts, system prompts, or context windows for Claude. Triggers include writing prompts for API calls, designing agent instructions, structuring complex inputs, optimizing context for accuracy, using examples effectively, or implementing chain-of-thought reasoning. Provides comprehensive guidance from Anthropic's official prompt engineering documentation.

Its SKILL.md is about 3.1k tokens, which your agent loads only when the skill is triggered. The skill folder holds 5 other files, including reference files (for example `references/chain-of-thought.md`, `references/extended-thinking.md` and `references/long-context.md`).

It sits in Agent Workflows, covering Context engineering, Prompt engineering and Agent instruction files. The repository describes itself as: Open-source Claude Code plugins for multi-agent software delivery. Plan-first SDLC workflow, code review, LLM quality judges, and self-learning — grounded in your codebase… The licence is Apache-2.0.

When your agent uses it

  • Include writing prompts for API calls
  • Designing agent instructions
  • Structuring complex inputs
  • Optimizing context for accuracy

Example prompts

  • “/context-engineering”

Workflow steps

9 steps, taken from the step headings in SKILL.md.

  1. Be Clear and Direct
  2. Use Examples (Multishot Prompting)
  3. Chain of Thought (CoT)
  4. XML Tags
  5. Role Prompting (System Prompts)
  6. Prefill Claude's Response
  7. Chain Complex Prompts
  8. Long Context Tips
  9. Extended Thinking

What it can do on your machine

Read from SKILL.md and the folder at commit 0e20ac0. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are xml).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Context Engineering loads about 3.1k tokens when it runs, and up to ~6.8k if it reads all its reference files. Until then it costs about 105 tokens; SKILL.md has 1,381 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~105
When it runs · the whole SKILL.md, loaded when a task matches
~3.1k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~6.8k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from closedloop-ai/claude-plugins at commit 0e20ac0, republished under its Apache-2.0 licence (© closedloop-ai). 1,381 words, ~3,057 tokens.

Download SKILL.mdSave it as .claude/skills/context-engineering/SKILL.md (or your agent's skills folder). This skill also uses 4 other files; get the full folder from GitHub.
name
context-engineering
description
This skill should be used when designing prompts, system prompts, or context windows for Claude. Triggers include writing prompts for API calls, designing agent instructions, structuring complex inputs, optimizing context for accuracy, using examples effectively, or implementing chain-of-thought reasoning. Provides comprehensive guidance from Anthropic's official prompt engineering documentation.

Context Engineering

Overview

Context engineering is the practice of designing the entire context window—system prompts, examples, structure, instructions, and data—to maximize Claude's performance. This skill distills Anthropic's official prompt engineering documentation into actionable guidance.

When to Use

  • Designing prompts for Claude API calls
  • Writing system prompts for agents or assistants
  • Structuring complex multi-part inputs
  • Improving accuracy or consistency of outputs
  • Adding examples to guide behavior
  • Implementing reasoning patterns (chain of thought)

Technique Priority

Apply techniques in order of effectiveness. Not all tasks require all techniques.

PriorityTechniqueBest For
1Be clear and directAll tasks
2Use examples (multishot)Format consistency, complex patterns
3Chain of thoughtMath, logic, analysis, complex reasoning
4XML tagsMulti-part prompts, structured I/O
5Role promptingDomain expertise, tone adjustment
6Prefill responseOutput format control, character consistency
7Chain promptsMulti-step workflows, error isolation
8Long context tipsDocuments >20K tokens
9Extended thinkingComplex STEM, constraint optimization

Core Techniques

1. Be Clear and Direct

Think of Claude as a brilliant new employee who needs explicit instructions.

The Golden Rule: Show the prompt to a colleague with minimal context. If they're confused, Claude will be too.

Key Practices:

  • Provide contextual information (what results are for, target audience, workflow position, success criteria)
  • Be specific about desired output (format, length, style)
  • Use numbered steps for sequential instructions
<example>
<poor>
Please remove all personally identifiable information from these messages.
</poor>
<good>
Your task is to anonymize customer feedback for our quarterly review.

Instructions:

  1. Replace customer names with "CUSTOMER_[ID]"
  2. Replace emails with "EMAIL_[ID]@example.com"
  3. Redact phone numbers as "PHONE_[ID]"
  4. Leave product names intact
  5. Output only processed messages, separated by "---"

Data to process: {{FEEDBACK_DATA}} </good> </example>

2. Use Examples (Multishot Prompting)

Examples dramatically improve accuracy, consistency, and quality.

Best Practices:

  • Include 3-5 diverse, relevant examples
  • Cover edge cases and potential challenges
  • Wrap examples in <example> tags (nest within <examples> if multiple)
  • Vary examples enough to avoid unintended pattern matching
<example>
<prompt>
Our CS team needs to categorize feedback. Use categories: UI/UX, Performance, Feature Request, Integration, Pricing, Other. Rate sentiment (Positive/Neutral/Negative) and priority (High/Medium/Low).
<example>
Input: The new dashboard is a mess! It takes forever to load, and I can't find the export button. Fix this ASAP!
Category: UI/UX, Performance
Sentiment: Negative
Priority: High
</example>

Now analyze: {{FEEDBACK}} </prompt> </example>

3. Chain of Thought (CoT)

Encourage Claude to break down problems step-by-step for complex reasoning tasks.

When to Use:

  • Math and calculations
  • Multi-step analysis
  • Logic problems
  • Decisions with many factors

When to Avoid:

  • Simple factual questions (adds latency without benefit)

Complexity Levels:

LevelApproachExample
Basic"Think step-by-step"Quick, less guided
GuidedOutline specific stepsMore control over reasoning
StructuredUse <thinking> and <answer> tagsEasy to parse, separates reasoning from output
<example>
<basic>
Solve this problem. Think step-by-step.
</basic>
<structured>
Draft personalized donor emails.

Program info: {{PROGRAM_DETAILS}} Donor info: {{DONOR_DETAILS}}

Think before writing in <thinking> tags:

  1. What messaging appeals to this donor given their history?
  2. What program aspects match their interests?

Then write the email in <email> tags. </structured> </example>

4. XML Tags

Use XML tags to structure prompts with multiple components.

Benefits:

  • Clarity: Separate instructions, examples, context, data
  • Accuracy: Prevent Claude from mixing up components
  • Flexibility: Easy to modify individual sections
  • Parseability: Extract specific parts from outputs

Best Practices:

  • Be consistent with tag names throughout prompts
  • Nest tags for hierarchical content: <outer><inner></inner></outer>
  • Reference tags in instructions: "Using the contract in <contract> tags..."
  • Use meaningful names (<instructions>, <context>, <examples>, <data>)
<example>
<prompt>
Analyze this software licensing agreement for legal risks.
<context>
We're a multinational enterprise considering this for core infrastructure.
</context>
<agreement>
{{CONTRACT}}
</agreement>
<instructions>
1. Analyze: Indemnification, Limitation of liability, IP ownership
2. Note unusual or concerning terms
3. Compare to our standard: <standard_contract>{{STANDARD}}</standard_contract>
4. Summarize findings in <findings> tags
5. List recommendations in <recommendations> tags
</instructions>
</prompt>
</example>

See references/xml-tags.md for detailed patterns.

5. Role Prompting (System Prompts)

Use the system parameter to set Claude's role and dramatically improve domain performance.

Benefits:

  • Enhanced accuracy in specialized domains
  • Tailored communication style
  • Improved focus on task requirements

Best Practices:

  • Put role in system parameter, task in user turn
  • Be specific: "data scientist specializing in customer insight for Fortune 500" vs "data scientist"
  • Experiment with different roles for the same task
<example>
<basic>
system: "You are a helpful assistant."
</basic>
<enhanced>
system: "You are the General Counsel of a Fortune 500 tech company. You specialize in software licensing and data privacy regulations."
</enhanced>
</example>
6. Prefill Claude's Response

Guide outputs by prefilling the Assistant message.

Use Cases:

  • Force specific output format (start with { for JSON)
  • Skip preambles and explanations
  • Maintain character in roleplay
  • Ensure consistent structure

Constraints:

  • Cannot end with trailing whitespace
  • Not available with extended thinking mode
<example>
<json_output>
user: Extract name, price, color from: {{DESCRIPTION}}
assistant: {  <!-- prefill forces JSON output -->
</json_output>

<character_maintenance> user: What do you deduce about this shoe? assistant: [Sherlock Holmes] <!-- prefill maintains character --> </character_maintenance> </example>

Show full SKILL.md (570 more words)Show less
7. Chain Complex Prompts

Break complex tasks into sequential subtasks for better accuracy.

When to Chain:

  • Multi-step analysis or synthesis
  • Content creation pipelines
  • Tasks requiring self-correction
  • Complex transformations

Benefits:

  • Each subtask gets full attention
  • Easier to debug specific steps
  • Can parallelize independent subtasks

Patterns:

  • Research → Outline → Draft → Edit → Format
  • Extract → Transform → Analyze → Visualize
  • Generate → Review → Refine → Re-review (self-correction)
<example>
<chain>
Prompt 1: Analyze contract for risks → {{ANALYSIS}}
Prompt 2: Draft email based on <analysis>{{ANALYSIS}}</analysis>
Prompt 3: Review email for tone and clarity → {{FEEDBACK}}
Prompt 4: Revise email based on <feedback>{{FEEDBACK}}</feedback>
</chain>
</example>
8. Long Context Tips

For prompts with substantial data (20K+ tokens):

Key Practices:

  1. Put data at the top: Place long documents above queries/instructions (up to 30% quality improvement)

  2. Structure with XML: Wrap documents with metadata

xml
<documents>
  <document index="1">
    <source>annual_report.pdf</source>
    <document_content>{{CONTENT}}</document_content>
  </document>
</documents>
  1. Ground in quotes: Ask Claude to quote relevant sections before answering

See references/long-context.md for detailed patterns.

9. Extended Thinking

For complex problems requiring deep reasoning:

Best Practices:

  • Start with minimum budget (1024 tokens), increase as needed
  • Use general instructions first ("think thoroughly"), not prescriptive steps
  • Ask Claude to verify work with test cases
  • Use batch processing for >32K thinking tokens

Best Use Cases:

  • Complex STEM problems
  • Constraint optimization (multiple competing requirements)
  • Problems requiring structured frameworks

See references/extended-thinking.md for detailed patterns.

Quick Reference

Output Format Control
GoalTechnique
JSON outputPrefill with {
Specific structureProvide example in <example> tags
No preamblePrefill or explicit instruction
Consistent formatMultishot examples
Improving Accuracy
ProblemSolution
Misses instructionsNumber steps, be explicit
Inconsistent formatAdd examples
Wrong reasoningAdd CoT with structured output
Misses contextAdd role prompting
Drops stepsChain into separate prompts
Refactoring Existing Prompts

When optimizing or compressing an existing prompt, apply these checks after every structural change:

PitfallCheck
Stale cross-referencesAfter renaming or renumbering steps, search for ALL references to old labels (jump targets, "see Step X", resume points) and update them
Over-abstractionIf the model needs exact values to execute (specific keys, field names, command arguments), keep them literal even if they look repetitive. A generic placeholder the model cannot expand is worse than duplication
Lost preconditionsWhen merging or removing steps, verify that any precondition checks or guards in the removed step are preserved elsewhere
Dropped qualifiersSingle modifiers like only, when appropriate, unless X, if it affects Y, must, never, always are load-bearing constraints that look like filler during compression. For every modifier deleted, confirm the constraint it carried is preserved or that dropping it is the intended behavior change
Silent behavior changesDiff the before/after and confirm every deleted line is either redundant or relocated, not dropped

Validation Pass (run before declaring a refactor done):

  1. Read the original and the refactor side by side, top to bottom.
  2. For every line removed from the original, classify it as: (a) relocated (state where), (b) genuinely redundant (state which surviving line subsumes it), or (c) dropped on purpose (state why).
  3. Pay special attention to qualifiers and short connector phrases. They compress to nothing visually but carry constraints.
  4. Only declare done after every removed line has a label.
Common Tag Names
TagPurpose
<instructions>Task directives
<context>Background information
<example> / <examples>Few-shot demonstrations
<data> / <document>Input content
<thinking>Chain of thought reasoning
<answer> / <output>Final response
<constraints>Limitations or requirements

Resources

For detailed guidance on specific techniques:

© closedloop-ai, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 4 other files (references) in plugins/platform/skills/context-engineering of closedloop-ai/claude-plugins.

  • SKILL.md
  • references/chain-of-thought.md
  • references/extended-thinking.md
  • references/long-context.md
  • references/xml-tags.md

Open the folder on GitHubat commit 0e20ac0

Compare with similar skills

Context Engineering next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Context Engineering compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Context Engineering this skillclosedloop-ai/claude-plugins122—~3.1kAutomated safety check: PassApache-2.0
Agent Context AuditAI-Builder-Club/skills1.3k—~2.2kAutomated safety check: PassNone
Caveman Learn Token FixesJuliusBrussee/caveman110k—~2.8kAutomated safety check: PassApache-2.0
Agent Config Self Tunekdeldycke/dotfiles173—~3.4kAutomated safety check: NotesBSD-2-Clause
Agent Configagentculture/culture113—~1kAutomated safety check: PassApache-2.0
Lintlanghermes-labs-ai/lintlang137—~1.7kAutomated safety check: PassApache-2.0

Similar skills

  • Agent Context Audit

    AI-Builder-Club/skills

    Audit a repo's agent context — CLAUDE.md files, codebase docs, skills, and tool/MCP designs — against Anthropic's Claude 5 context-engineering guidance ("unhobbling": Anthropic cut ~80% of Claude…

    1.3k GitHub stars~2.2k tokensUpdated 22 days ago
    Agent WorkflowsAuto-check passed
  • Caveman Learn Token Fixes

    JuliusBrussee/caveman

    Acts on a Caveman learn report: reviews ranked token sinks, applies cost-lowering edits one at a time with your consent, and reports what each fix returned.

    110k GitHub stars~2.8k tokensUpdated today
    Agent WorkflowsAuto-check passed
  • Agent Config Self Tune

    kdeldycke/dotfiles

    Audit and tune the configuration of coding agents across Claude Code and pi - settings files (settings.json, settings.local.json), permission rules, instruction files (CLAUDE.md, AGENTS.md), skill…

    173 GitHub stars~3.4k tokensUpdated 3 days ago
    Agent WorkflowsAuto-check: notes
  • Agent Config

    agentculture/culture

    Show a Culture agent's full configuration in one read-only view: its system-prompt file (CLAUDE.md / AGENTS.md / GEMINI.md), the parallel culture.yaml, and the agent's local .claude/skills index.

    113 GitHub stars~1k tokensUpdated 1 mo ago
    Agent WorkflowsAuto-check passed
  • Lintlang

    hermes-labs-ai/lintlang

    Lint AI agent instruction files (SKILL.md, CLAUDE.md, AGENTS.md, GEMINI.md), tool definitions, system prompts, and agent configs with the deterministic LintLang CLI.

    137 GitHub stars~1.7k tokensUpdated 2 days ago
    Agent WorkflowsAuto-check passed
  • Cco Overhead

    egorfedorov/claude-context-optimizer

    Audit the fixed context overhead every session starts with — system prompt, MCP tools, agents, CLAUDE.md, memory — measured from real transcript usage

    114 GitHub stars~606 tokensUpdated 7 days ago
    Agent WorkflowsAuto-check passed

More from closedloop-ai/claude-plugins

All 43 skills in this repo
  • Codex Review

    closedloop-ai/claude-plugins

    Run Codex to review a plan file and return structured feedback with a verdict.

    122 GitHub stars~1.4k tokensUpdated today
    Auto-check: notes
  • Critic Cache

    closedloop-ai/claude-plugins

    Check if critic reviews are still valid before re-running Phase 2.5 critics.

    122 GitHub stars~528 tokensUpdated today
    Auto-check: notes
  • Cross Repo Cache

    closedloop-ai/claude-plugins

    Check if cross-repo coordinator results can be reused, avoiding redundant Sonnet agent launches.

    122 GitHub stars~683 tokensUpdated today
    Auto-check: notes
  • Eval Cache

    closedloop-ai/claude-plugins

    Check for a cached plan-evaluation.json result before launching the plan-evaluator agent.

    122 GitHub stars~516 tokensUpdated today
    Auto-check: notes
  • Find Plugin File

    closedloop-ai/claude-plugins

    This skill should be used when needing to locate files within the Claude Code plugins cache directory (~/.claude/plugins/cache).

    122 GitHub stars~812 tokensUpdated today
    Auto-check passed
  • Gh Monitor PR

    closedloop-ai/claude-plugins

    Start a detached GitHub pull-request monitor that wakes the exact launching Codex Desktop or CLI root through the managed Codex App Server when review, CI, conflict, merge-queue, closure, readiness…

    122 GitHub stars~5.1k tokensUpdated today
    Auto-check passed

Questions about Context Engineering

What does Context Engineering do?

This skill should be used when designing prompts, system prompts, or context windows for Claude. Context Engineering is an agent skill from closedloop-ai/claude-plugins. This skill should be used when designing prompts, system prompts, or context windows for Claude.

When should I use Context Engineering?

Context Engineering fits situations like: include writing prompts for API calls; designing agent instructions; structuring complex inputs; optimizing context for accuracy.

How do I install Context Engineering in Claude Code?

Run `npx skills add closedloop-ai/claude-plugins --skill context-engineering -a claude-code`. Or copy the skill folder (plugins/platform/skills/context-engineering in closedloop-ai/claude-plugins) into .claude/skills/context-engineering in your project. Claude Code loads it when a task matches its description.

How do I install Context Engineering in Codex?

Run `npx skills add closedloop-ai/claude-plugins --skill context-engineering -a codex`. Or copy the skill folder (plugins/platform/skills/context-engineering in closedloop-ai/claude-plugins) into .agents/skills/context-engineering in your project. Codex loads it when a task matches its description.

Can I use Context Engineering in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add closedloop-ai/claude-plugins --skill context-engineering -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/context-engineering, .gemini/skills/context-engineering, .github/skills/context-engineering and .opencode/skills/context-engineering in your project.

What does Context Engineering need to run?

SKILL.md names no scripts, command-line tools or credentials: Context Engineering is instructions for the agent only.

Does Context Engineering access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Context Engineering safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Context Engineering use?

Context Engineering is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Context Engineering use?

About 3.1k tokens (SKILL.md is roughly 12k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 3.7k tokens, read only when the agent opens those files.

What are the alternatives to Context Engineering?

Skills that share tags, products or a category with Context Engineering: Agent Context Audit (AI-Builder-Club/skills, 1.3k stars), Caveman Learn Token Fixes (JuliusBrussee/caveman, 110k stars), Agent Config Self Tune (kdeldycke/dotfiles, 173 stars) and Agent Config (agentculture/culture, 113 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Context Engineering?

closedloop-ai (a GitHub organization) maintains it in closedloop-ai/claude-plugins, which has 122 GitHub stars. The repository holds 43 skills in this directory. The repository was last updated on October 7, 2026.

Source: closedloop-ai/claude-plugins on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.