context-engineer

Determines WHAT context an agent needs and packages it optimally. Actions: analyze (identify needed context), load (assemble from sources), prune (trim to token budget), inject (write to .claude/context-payload.md). Use when: (1) before spawning teammates, (2) context window is limited, (3) multi-source context assembly. Triggers: /context-engineer, 'prepare context', 'package context', 'context for agent'.

108 stars

Best use case

context-engineer is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Determines WHAT context an agent needs and packages it optimally. Actions: analyze (identify needed context), load (assemble from sources), prune (trim to token budget), inject (write to .claude/context-payload.md). Use when: (1) before spawning teammates, (2) context window is limited, (3) multi-source context assembly. Triggers: /context-engineer, 'prepare context', 'package context', 'context for agent'.

Teams using context-engineer should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/context-engineer/SKILL.md --create-dirs "https://raw.githubusercontent.com/alfredolopez80/multi-agent-ralph-loop/main/.claude/skills/context-engineer/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/context-engineer/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How context-engineer Compares

Feature / Agentcontext-engineerStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Determines WHAT context an agent needs and packages it optimally. Actions: analyze (identify needed context), load (assemble from sources), prune (trim to token budget), inject (write to .claude/context-payload.md). Use when: (1) before spawning teammates, (2) context window is limited, (3) multi-source context assembly. Triggers: /context-engineer, 'prepare context', 'package context', 'context for agent'.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Context Engineer v3.0

Determine what context an agent needs and package it within token budget.

## Actions

### `/context-engineer analyze <task>`

Identify what context sources are relevant:

1. Parse task description for domain keywords
2. Check for DESIGN.md (frontend tasks)
3. Check for .spec.md files (spec-driven tasks)
4. Check memory sources (vault, handoffs, ledgers)
5. Check codebase files (Glob/Grep for related code)
6. Output: ranked list of context sources with estimated tokens

### `/context-engineer load <task>`

Assemble context from identified sources:

1. Run `analyze` if not already done
2. Read each source, extract relevant sections
3. Prioritize by relevance score
4. Output: assembled context block

### `/context-engineer prune <budget>`

Trim assembled context to fit token budget:

1. Default budget: 8000 tokens
2. Remove low-relevance sections first
3. Summarize long sections instead of including full text
4. Preserve: interfaces, invariants, design tokens (high signal)
5. Output: pruned context within budget

### `/context-engineer inject`

Write packaged context to `.claude/context-payload.md`:

1. Write pruned context to file
2. The `ralph-subagent-start.sh` hook reads this file and injects into teammate prompt
3. File is gitignored (per Item 0a)

## Context Sources (Priority Order)

| Source | When Relevant | Token Cost |
|---|---|---|
| .spec.md | Task has a spec | ~500-2000 |
| DESIGN.md | Frontend task | ~1000-3000 |
| Related code files | Always | ~500-5000 |
| Memory (vault)      | Prior work exists | ~200-500 |
| Handoffs | Cross-session | ~300-800 |
| Vault (future) | Curated knowledge | ~200-1000 |

## Integration

- **Orchestrator Step 5 (DELEGATE)**: invoke before spawning teammate
- **ralph-subagent-start.sh**: reads `.claude/context-payload.md` if exists
- **Token budget**: default 8000, adjustable per task complexity

## Anti-Rationalization

| Excuse | Rebuttal |
|---|---|
| "The agent has enough context from the prompt" | Agents lose 40% accuracy without structured context. Package it. |
| "Context engineering is overhead" | 5 seconds of packaging saves 5 minutes of wrong output. |
| "I'll just include everything" | Token flooding degrades quality. Prune to signal. |

Related Skills

senior-software-engineer

108
from alfredolopez80/multi-agent-ralph-loop

Global skill enforcing senior software engineering best practices

sec-context-depth

108
from alfredolopez80/multi-agent-ralph-loop

Comprehensive AI code security review using 27 sec-context anti-patterns. Use for code review when security vulnerabilities are suspected, especially for AI-generated code.

context7-usage

108
from alfredolopez80/multi-agent-ralph-loop

Patterns for using Context7 MCP for library documentation (v2.25)

worktree-pr

108
from alfredolopez80/multi-agent-ralph-loop

Manage git worktrees with PR workflow and multi-agent review (Claude + Codex). Use when developing features in isolation with easy rollback.

vercel-react-best-practices

108
from alfredolopez80/multi-agent-ralph-loop

React and Next.js performance optimization guidelines from Vercel Engineering. Use when writing, reviewing, or refactoring React/Next.js code. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.

vault

108
from alfredolopez80/multi-agent-ralph-loop

Living knowledge base management. Actions: search (query vault), save (store learning), index (update indices), compile (raw->wiki->rules graduation), init (create vault structure). Follows Karpathy pipeline: ingest->compile->query. Use when: (1) searching accumulated knowledge, (2) saving learnings, (3) compiling raw notes into wiki, (4) initializing a new vault. Triggers: /vault, 'vault search', 'knowledge base', 'save learning'.

testing-anti-patterns

108
from alfredolopez80/multi-agent-ralph-loop

Custom skill for testing-anti-patterns

task-visualizer

108
from alfredolopez80/multi-agent-ralph-loop

Visualize task dependencies and progress (Gastown-style)

task-classifier

108
from alfredolopez80/multi-agent-ralph-loop

Classifies task complexity (1-10) for model and agent routing

task-batch

108
from alfredolopez80/multi-agent-ralph-loop

Autonomous batch task execution with PRD parsing, task decomposition, and continuous execution until all tasks complete. Uses /orchestrator internally. Stops only for major failures (no internet, token limit, system crash). Use when: (1) processing task lists autonomously, (2) PRD-driven development, (3) batch feature implementation. Triggers: /task-batch, 'batch tasks', 'process PRD', 'run task queue'.

tap-explorer

108
from alfredolopez80/multi-agent-ralph-loop

Tree of Attacks with Pruning for systematic code analysis

stop-slop

108
from alfredolopez80/multi-agent-ralph-loop

A skill for removing AI-generated writing patterns ('slop') from prose. Eliminates telltale signs of AI writing like filler phrases, excessive hedging, overly formal language, and mechanical sentence structures. Use when: writing content that should sound human and natural, editing AI-generated drafts, cleaning up prose for publication, or any content that needs to sound authentic rather than AI-generated. Triggers: 'stop-slop', 'remove AI tells', 'clean up prose', 'make it sound human', 'edit AI writing'.