Context Engineering
Purpose
Give the agent exactly the context the task needs to be done correctly — no less (guessing), no more (dilution and cost). Rules: ../../system/CONTEXT_MANAGEMENT_RULES.md (layers, escalation levels and triggers, relevance check, budgets, stable context, isolation); this skill applies them.
When to Use
- Starting any task beyond a one-line change.
- Context is growing, or a fact is missing and you're tempted to read broadly.
- Splitting work across agents (each needs a pack).
- A stable project summary may be out of date.
- Not for choosing skills by catalogue (
../SKILLS_INDEX.md does that) — this decides how much to load and in what order.
Inputs
- The task and its classification.
CURRENT_STATUS.md and the summaries in ../../projects/current/context/, if present.
- The repository's
features/, skill index, and file tree — searched, not read wholesale.
Discovery Questions
- What behavior is this about, and which scenarios describe it?
- Which files change, which only inform, and which tests prove it?
- What's the smallest level (rules: 1–5) that could be enough?
Responsibilities
- Set a budget (minimal / small / medium / large) from the task.
- Anchor on Gherkin: find the matching scenarios before reading code.
- Load in order: scenarios → 1–3 skills → affected files and their tests → dependencies → official docs → broad repo, stopping when sufficient.
- Escalate only on a named trigger; record it.
- Keep a reason for every non-global item; produce a context pack when the work spans steps or agents.
- Check stable summaries for staleness before trusting them.
Required Workflow
- Classify and budget the task.
- Check stable context:
agentflow context check; re-read and update any stale summary before relying on it.
- Suggest a starting set:
agentflow context suggest "<task in a few words>" — matching scenarios, skills, files and tests, each with its reason. A starting point to verify, not a substitute for reading.
- Read at Level 1–2: the scenarios, the chosen skills, the affected file(s) and their direct tests — relevant ranges, once.
- Escalate on evidence only (unknown symbol, missing contract, conflicting implementation, failing test, version-specific or security-sensitive behavior), one level at a time, noting the trigger.
- Stop when you can state the change, its tests, and its risks with nothing unexplained — then work.
- Record a context pack (
../../templates/CONTEXT_PACK.md) for multi-step or multi-agent work.
Decision Rules
- Relevant beats complete; a targeted search beats a directory read.
- No reason → don't load it.
- Uncertain → retrieve, don't guess; still uncertain → ask or report it.
- Compress only what correctness doesn't depend on; never summarize away a contract, invariant, version, or security rule.
- Parallel agents share one baseline and contract; their packs differ only by task.
Rules
- Never load all skills, all features, or the whole repository by default.
- Never re-read a file or repeat a search already done in this task.
- Never claim token savings without measurement; report "unknown" where usage isn't exposed.
Anti-Patterns
- Coding from the request with no scenario or file read.
- "Let me read the whole codebase first."
- Loading every skill "to be safe".
- Trusting a project summary written before the last dependency upgrade.
- Giving every parallel agent the full repository.
- A one-line answer that hides a failed check to look efficient.
Validation Checklist
Definition of Done
The task was understood, changed, and validated from a context set you can justify item by item — and anything still unknown is stated.
Related Skills
testing/gherkin-specifications (the anchor), technology-governance (Level 5 and stack facts), project-orchestrator, project-management, existing-project-audit.
Related Knowledge
../../projects/current/context/ (stable summaries).
Related References
../../templates/CONTEXT_PACK.md, ../../templates/PROJECT_CONTEXT.md · examples: examples/context-engineering/ in the AgentFlow repository.
Context Loading Guidance
- Requires: the task, the rules file,
CURRENT_STATUS.md.
- Does not require: anything else up front — that's the point.
- May load: whatever the escalation steps justify.
- Stop when: the context is sufficient and recorded.
Token Efficiency Guidance
This skill is the token-efficiency guidance. Keep its own footprint small: use the CLI suggestions, read ranges, and write packs as short lists with reasons.
1---2name: context-engineering3description: Use at the start of any non-trivial task to assemble the minimum sufficient context — scenarios first, then the relevant skills, files, and tests — escalating only on evidence; also to build context packs for multi-step or multi-agent work, keep stable project summaries fresh, and explain why each item was loaded.4metadata:5 source: https://skillmd.com/skills/ahtishamshahzad/context-engineering6---78# Context Engineering910## Purpose1112Give the agent exactly the context the task needs to be done correctly — no less (guessing), no more (dilution and cost). Rules: `../../system/CONTEXT_MANAGEMENT_RULES.md` (layers, escalation levels and triggers, relevance check, budgets, stable context, isolation); this skill applies them.1314## When to Use1516- Starting any task beyond a one-line change.17- Context is growing, or a fact is missing and you're tempted to read broadly.18- Splitting work across agents (each needs a pack).19- A stable project summary may be out of date.20- **Not** for choosing skills by catalogue (`../SKILLS_INDEX.md` does that) — this decides how much to load and in what order.2122## Inputs2324- The task and its classification.25- `CURRENT_STATUS.md` and the summaries in `../../projects/current/context/`, if present.26- The repository's `features/`, skill index, and file tree — searched, not read wholesale.2728## Discovery Questions2930- What behavior is this about, and which scenarios describe it?31- Which files *change*, which only *inform*, and which tests prove it?32- What's the smallest level (rules: 1–5) that could be enough?3334## Responsibilities3536- Set a budget (minimal / small / medium / large) from the task.37- Anchor on Gherkin: find the matching scenarios before reading code.38- Load in order: scenarios → 1–3 skills → affected files and their tests → dependencies → official docs → broad repo, stopping when sufficient.39- Escalate only on a named trigger; record it.40- Keep a reason for every non-global item; produce a context pack when the work spans steps or agents.41- Check stable summaries for staleness before trusting them.4243## Required Workflow44451. **Classify and budget** the task.462. **Check stable context:** `agentflow context check`; re-read and update any stale summary before relying on it.473. **Suggest a starting set:** `agentflow context suggest "<task in a few words>"` — matching scenarios, skills, files and tests, each with its reason. A starting point to verify, not a substitute for reading.484. **Read at Level 1–2:** the scenarios, the chosen skills, the affected file(s) and their direct tests — relevant ranges, once.495. **Escalate on evidence only** (unknown symbol, missing contract, conflicting implementation, failing test, version-specific or security-sensitive behavior), one level at a time, noting the trigger.506. **Stop when** you can state the change, its tests, and its risks with nothing unexplained — then work.517. **Record** a context pack (`../../templates/CONTEXT_PACK.md`) for multi-step or multi-agent work.5253## Decision Rules5455- Relevant beats complete; a targeted search beats a directory read.56- No reason → don't load it.57- Uncertain → retrieve, don't guess; still uncertain → ask or report it.58- Compress only what correctness doesn't depend on; never summarize away a contract, invariant, version, or security rule.59- Parallel agents share one baseline and contract; their packs differ only by task.6061## Rules6263- Never load all skills, all features, or the whole repository by default.64- Never re-read a file or repeat a search already done in this task.65- Never claim token savings without measurement; report "unknown" where usage isn't exposed.6667## Anti-Patterns6869- Coding from the request with no scenario or file read.70- "Let me read the whole codebase first."71- Loading every skill "to be safe".72- Trusting a project summary written before the last dependency upgrade.73- Giving every parallel agent the full repository.74- A one-line answer that hides a failed check to look efficient.7576## Validation Checklist7778- [ ] Budget set; level reached and the triggers for each escalation noted.79- [ ] Scenarios found (or the missing one written) before code was read.80- [ ] Every non-global item has a reason.81- [ ] No stale summary relied on.82- [ ] Nothing correctness needs was left out to save context.8384## Definition of Done8586The task was understood, changed, and validated from a context set you can justify item by item — and anything still unknown is stated.8788## Related Skills8990`testing/gherkin-specifications` (the anchor), `technology-governance` (Level 5 and stack facts), `project-orchestrator`, `project-management`, `existing-project-audit`.9192## Related Knowledge9394`../../projects/current/context/` (stable summaries).9596## Related References9798`../../templates/CONTEXT_PACK.md`, `../../templates/PROJECT_CONTEXT.md` · examples: `examples/context-engineering/` in the AgentFlow repository.99100## Context Loading Guidance101102- **Requires:** the task, the rules file, `CURRENT_STATUS.md`.103- **Does not require:** anything else up front — that's the point.104- **May load:** whatever the escalation steps justify.105- **Stop when:** the context is sufficient and recorded.106107## Token Efficiency Guidance108109This skill is the token-efficiency guidance. Keep its own footprint small: use the CLI suggestions, read ranges, and write packs as short lists with reasons.