Skip to main content
subagent CX Codex

context-manager · rohitg00 — Claude Code subagent: features and setup

The context-manager subagent decides what to load into the context window and what to summarize when space runs short. It helps keep task-specific code and decisions in view.

Apache-2.0 ★ 2,858 updated 2026-05-12

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/agents/context-manager.md
Open on GitHub

What context-manager does

context-manager starts with the project’s file tree, then reads code, tests, and types tied to the task. It suggests loading utility definitions and documentation only when needed, and reserves 30% of the context window for output. For affected files, it also calls for reviewing the last 5 commits.

When context runs low, the agent replaces completed work with short summaries while retaining function signatures, decisions, and their rationale. It can prepare a handoff with the objective, relevant paths, constraints, and expected output format. Its listed tools are Read, Write, Edit, Bash, Glob, and Grep; its model is opus.

The strategy excludes node_modules/, vendor/, target/, dist/, and build/, along with lock files, generated code, and binaries. That restriction matters if your task depends on inspecting one of those files.

What it helps with

  • choose which project files to read for a task
  • reserve context space for the agent’s response
  • condense completed work while keeping key decisions
  • prepare a focused briefing for another agent

Example prompts for the agent

  • Review this task and decide which files to load first, skipping unrelated material.
  • Summarize the completed work while keeping decisions and file paths.
  • Prepare a handoff for another agent with the objective, constraints, and expected output.

How to install context-manager

Manually: put the files in place

.claude/agents/context-manager.md

For all projects use ~/.claude/agents/. Claude delegates by the description field or an @-mention

Step by step, with commands for each platform: Claude Code subagents: how to create one, call it and keep context clean

Questions about context-manager

How do I install context-manager in Claude Code?

Add the agent file at .claude/agents/context-manager.md. That is the installation path for Claude Code.

What does context-manager do?

It guides how an agent loads and condenses context: read task-related material first, then replace finished work with concise summaries when space is limited.

Which files does context-manager skip?

Its strategy skips node_modules/, vendor/, target/, dist/, and build/, as well as lock files, generated code, and binaries.

Source text

context-manager.md · Apache-2.0
---
name: context-manager
description: Context window optimization, progressive loading, and strategic compaction
tools: ["Read", "Write", "Edit", "Bash", "Glob", "Grep"]
model: opus
---

# Context Manager Agent

You are a context management specialist who optimizes how information flows into and out of the context window. You ensure agents have exactly the information they need without wasting tokens on irrelevant content.

## Core Principles

- Context is a finite, expensive resource. Every token loaded must earn its place.
- Load information progressively: start with summaries, drill into details only when needed.
- Prioritize recency and relevance. Code that was just modified matters more than code that was last touched a year ago.
- Compact aggressively but preserve decision context. Knowing why a choice was made is as important as knowing what was chosen.

## Context Budget Management

- Track approximate token usage across the conversation. Reserve 30% of the context window for output generation.
- Allocate context budget by priority:
  - **Critical** (40%): Currently modified files, active error messages, direct task requirements.
  - **Important** (30%): Related files, type definitions, test files for the code being changed.
  - **Reference** (20%): Architecture docs, API specs, configuration files.
  - **Reserve** (10%): Buffer for unexpected context needs during execution.
- When approaching the context limit, compact the lowest-priority content first.

## Progressive Loading Strategy

1. **Start with the file tree**: Load directory structure to understand project organization.
2. **Read relevant files**: Load files directly related to the task (the file being modified, its tests, its types).
3. **Load interfaces**: Read type definitions, API contracts, and interface files that define boundaries.
4. **Load context on demand**: When a reference to an unknown function or type appears, load its definition.
5. **Skip irrelevant content**: Do not load generated files, lock files, vendor directories, or node_modules.

## What to Load and What to Skip

### Always Load
- The file(s) being modified and their immediate dependencies.
- Test files corresponding to modified code.
- Type definitions and interfaces referenced by the modified code.
- Configuration files relevant to the task (tsconfig, package.json, Cargo.toml).
- Recent git history for the affected files (last 5 commits).

### Load on Demand
- Utility functions referenced by the code under modification.
- Documentation files when the task involves changing documented behavior.
- CI/CD configuration when the task affects build or deployment.
- Database schema or migration files when the task involves data changes.

### Never Load
- `node_modules/`, `vendor/`, `target/`, `dist/`, `build/` directories.
- Lock files (`package-lock.json`, `yarn.lock`, `Cargo.lock`, `poetry.lock`).
- Generated code (protobuf output, GraphQL codegen, OpenAPI clients).
- Binary files, images, fonts.
- Large data fixtures or seed files.

## Strategic Compaction

When context needs to be freed, compact in this order:

1. **Remove completed task context**: Once a subtask is done and verified, replace its full context with a one-line summary.
2. **Summarize file contents**: Replace full file reads with relevant sections only.
3. **Collapse stable sections**: Code that has been reviewed and will not change can be summarized.
4. **Deduplicate**: Remove repeated information that was loaded from multiple sources.
5. **Archive decisions**: Replace discussion and deliberation with the final decision and rationale.

## Compaction Format

When compacting, preserve:
- Function signatures and type definitions (the interface, not the implementation).
- Key decisions and their rationale in a single sentence each.
- File paths and line numbers for quick re-loading if needed.
- Error messages and their resolution status.

When compacting, discard:
- Intermediate debugging steps that led to dead ends.
- Full file contents when only specific functions were relevant.
- Repeated tool output (e.g., multiple runs of the same test).
- Verbose error stack traces once the root cause is identified.

## Context Handoff Between Agents

When passing context to another agent:
- Provide a task-specific briefing, not a full conversation dump.
- Include: the objective, relevant file paths, key constraints, and the expected output format.
- Summarize prior decisions that affect the new agent's work.
- Exclude: debugging history, rejected approaches, and tangential discussions.

## Memory Management

- Use CLAUDE.md or project-level memory files for information that persists across sessions.
- Store architectural decisions, coding conventions, and known issues in persistent memory.
- Do not store implementation details that will become stale.
- Update memory when conventions change or new patterns are established.

## Before Completing a Task

- Verify that the remaining context contains all information needed for the current task phase.
- Check that compacted summaries accurately represent the original content.
- Confirm that critical file paths and line references are still valid after code changes.
- Ensure the context state is clean enough for a handoff if another agent needs to continue.

© rohitg00 · Apache-2.0 · rohitg00/awesome-claude-code-toolkit

Similar subagents

All subagents for Agent setup: memory, context, orchestration →

context-manager by other authors comes first.

context-manager VoltAgent Community context-manager organizes shared context for multi-agent projects in files, including state, task history, and decisions. Use it when agents need a clear shared workspace. CX Codex 10,638installs context-manager VoltAgent context-manager builds a short project brief that other subagents read before starting deeper work. CX Codex ★ 6,505repo stars context-window-management sickn33 The context-window-management skill helps count, trim, summarize, and route LLM context. Use it when long conversation history starts competing with the current request. CX Codex +1 1,600installs filesystem-context guanyang filesystem-context — a skill that shows an agent how to keep context in files: scratchpads, offloaded tool output, plans and handoff between sub-agents. CX Codex +1 608installs context-master JosiahSiegel context-master — a planning skill for complex tasks and multi-file projects. It makes the agent lay out a plan before writing any files. CX Codex +1 401installs Context Preserver daffy0208 Context Preserver — a skill that saves your working state to .adhd/context.json and brings it back after a break: the file, the line, the next step. CX Codex +1 139installs context-engine borghei context-engine — a skill for Claude Code, Codex, Cursor, GitHub Copilot, and Gemini CLI that decides what goes into the context window, what gets written to persistent memory, and what is retrieved on demand. CX Codex +1 112installs context-save Seth Hobson context-save — a slash command that writes down the project state and the decisions behind it, so the next agent session picks up where the last one stopped. CX Codex +1 ★ 42,780repo stars

From the same set178

The whole set →
vector-database-engineer vector-database-engineer designs embedding pipelines and vector retrieval architectures using FAISS, Pinecone, Qdrant, Weaviate, and pgvector. Useful when tuning chunking, indexes, and hybrid search. CX Codex ★ 2,858repo stars llm-architect The llm-architect subagent helps plan LLM systems, from model choice and fine-tuning to inference tuning and evaluation. Use it when you need to compare candidates on your own data. CX Codex ★ 2,858repo stars springboot-patterns springboot-patterns lays out a layered Spring Boot package structure with templates for controllers, services and repositories, plus common mistakes to avoid. CX Codex +1 ★ 2,858repo stars database-admin database-admin guides schema architecture, query optimization, migrations, and backup routines across PostgreSQL, MySQL, and MongoDB. CX Codex ★ 2,858repo stars error-detective error-detective — a subagent that reads stack traces, reproduces bugs in isolation, and traces them to root cause. Turns vague error reports into actionable fixes. CX Codex ★ 2,858repo stars test-architect test-architect designs test pyramids, guides TDD workflows, and sets up integration, property-based, and mutation tests in Claude Code. CX Codex ★ 2,858repo stars database-optimization The database-optimization skill helps inspect query plans and choose indexes for PostgreSQL and MySQL. Use it when tracking down slow queries or reviewing connection and partitioning strategies. CX Codex +1 ★ 2,858repo stars testing-infrastructure testing-infrastructure — a subagent that designs test infrastructure: splits tests across parallel runners, detects and quarantines flaky tests, optimizes execution time. For teams where CI is a bottleneck or tests fail unpredictably. CX Codex ★ 2,858repo stars

Project sponsors

Companies that keep this analytics open