---
name: context-efficient-coding
description: >-
  Use for coding, debugging, refactoring, or testing tasks that explicitly involve
  context, token, or tool-call efficiency, long-running sessions, large command
  output, checkpointing, or multi-agent handoffs. Do not use for ordinary coding
  work without a context-management concern or for cross-agent persistence as the
  primary task.
---

# Context-Efficient Coding

Optimize the workflow's context footprint without reducing correctness, verification, or user-requested scope.

## Scope the work

- Identify the current phase and the smallest set of files, symbols, tests, and runtime checks needed for that phase.
- Treat a new independent requirement as a new phase. At a meaningful boundary, create a short checkpoint and recommend a fresh task instead of carrying unrelated history forward.
- Keep the repository or working tree as the source of truth. Do not restate unchanged code or old tool output in the prompt or handoff.

## Inspect narrowly

- Locate symbols and call sites first, then read bounded line ranges around the relevant code.
- Do not dump whole source files, generated artifacts, HTTP responses, or log files when a targeted excerpt answers the question.
- If a full file or log is genuinely required, read it once, retain only the conclusions, and avoid reproducing it in later messages.

## Edit incrementally

- Use a patch or an equivalent localized edit for source changes.
- Never recreate an unchanged file through a heredoc, `cat`, or another full-file write merely to change a small section.
- Preserve unrelated formatting and behavior; do not turn a focused change into a repository-wide cleanup.

## Verify with bounded output

- Run the narrowest relevant formatter, compiler, or test first; reserve broad validation for a phase boundary or final check.
- Do not rerun an unchanged check unless the earlier result was nondeterministic or the environment changed.
- Save large command output to an artifact when useful, and return only the status, relevant error, diagnostic location, and a short tail or summary.
- Batch related read-only inspections and checks when that reduces round trips without combining unrelated long-running operations.

## Coordinate agents

- Give each agent one independent question, a limited file scope, and explicit output requirements.
- Pass conclusions, changed-file lists, and actionable failures between agents; do not pass complete transcripts, source dumps, or raw logs by default.
- Use `agent-continuity` as the primary skill when the user explicitly asks to persist, recover, or transfer task state across agents. This skill may complement it when context reduction is also requested.

## Checkpoint format

At a phase boundary, record only:

- objective and completed work;
- changed files and relevant invariants;
- validation commands and concise results;
- unresolved failures, risks, and the next action.

When the next request is an unrelated feature or a second major phase, start a fresh task from this checkpoint rather than appending the old investigation to the new context.

## Delivery

Report changed files, validation results, unresolved risks, and the next action. Keep the report proportional to the task; link to artifacts instead of embedding large outputs.
