context-groups

A command that organizes a task list into batches sized for an AI agent’s context window, the amount of information it can handle at once. It considers task complexity, dependencies, execution phases, and reserved response space.

In plain words
What is it for?
Use it to create ordered task groups from a project task file and adjust the maximum token or reserved-space settings.
Why use it?
It helps prevent a coding session from including more task information than the agent can reliably use.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/sequenzia/claude-plugins/context-groups
Clone the repo
git clone --depth 1 https://github.com/sequenzia/claude-plugins
Per session 10 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,741 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00010 $0.01741
Opus 5 $0.00005 $0.00870
Sonnet 5 $0.00002 $0.00348
Haiku 4.5 $0.00001 $0.00174

Measured yesterday against content hash 7e2c825253d7, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

context-groups scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/task-manager/commands/context-groups.md · 246 lines

How it starts

The opening of the file, as written. The whole thing — 246 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Generate context groups from an existing task list, organizing tasks into batches that fit within AI context window limits.

Process

  1. Parse arguments

    • $1 = Project name (optional)
    • --max-tokens=N = Maximum context window tokens (default: 100000)
    • --reserve=N = Reserved tokens for agent responses (default: 20000)
  2. Locate and read the task file

    • If project name provided: Read tasks/$1.tasks.json
    • If no project name: Find most recently modified .tasks.json
  3. Load token configuration

    • Read defaults from skills/spec-task-management/references/context-defaults.json
    • Apply any command-line overrides
  4. Calculate token estimates for each task

    Use complexity-based estimation:

    Complexity Base Tokens
    XS 500
    S 1,500
    M 4,000
    L 10,000
    XL 25,000

    Add overhead:

    • Base per task: 200 tokens
    • Per hard dependency: 100 tokens
  5. Build dependency graph

    • Create adjacency list from hard dependencies
    • Detect any cycles (should already be handled)
    • Calculate in-degree for each task
  6. Topological sort by execution phase

    • Order tasks by their execution_phase first
    • Within phase, order by dependency depth (tasks that unblock more come first)
    • Break ties by priority (critical > high > medium > low)
  7. Bin-pack tasks into context groups

    effective_limit = max_tokens - reserve_tokens
    current_group = new group
    current_tokens = 0
    
    for each task in sorted_order:
        # Calculate tokens needed for task + any hard deps not yet assigned
        task_tokens = estimate_tokens(task)
        unassigned_dep_tokens = sum(estimate_tokens(d) for d in task.hard_deps if not d.assigned)
        total_needed = task_tokens + unassigned_dep_tokens
    
        # Check if task exceeds effective limit (oversized)
        if task_tokens > effective_limit:
            # Close current group if not empty
            if current_group.tasks.length > 0:
                mark_group_end(current_group.tasks.last)
                save_group(current_group)
    
            # Create dedicated group for oversized task
            oversized_group = new group with oversized_warning=true
            add_task(oversized_group, task)
            mark_group_start(task)
            mark_group_end(task)
            save_group(oversized_group)
    
            current_group = new group
            current_tokens = 0
            continue
    
        # Check if adding task exceeds limit
        if current_tokens + total_needed > effective_limit:
            # Close current group
            mark_group_end(current_group.tasks.last)
            save_group(current_group)
    
            # Start new group
            current_group = new group
            current_tokens = 0
    
        # Add unassigned hard dependencies first (in order)
        for dep in task.hard_deps:
            if not dep.assigned:
                if current_group.tasks.length == 0:
                    mark_group_start(dep)
                add_task(current_group, dep)
                current_tokens += estimate_tokens(dep)
    
        # Add the task
        if current_group.tasks.length == 0:
            mark_group_start(task)
        add_task(current_group, task)
        current_tokens += task_tokens
    
    # Close final group
    if current_group.tasks.length > 0:
        mark_group_end(current_group.tasks.last)
        save_group(current_group)
    
  8. Handle dependency chains exceeding limit

    • If a chain of hard dependencies exceeds limit, split at minimum-cut points
    • Add context_handoff metadata to indicate split
    • Document which outputs from previous group are needed
  9. Update task file

    • Add context_group_id to each task
    • Set context_group_start on first task of each group
    • Set context_group_end on last task of each group
    • Add estimated_tokens to each task
    • Add context_groups array at root level
    • Update metadata.context_config with configuration used
    • Set metadata.total_context_groups

Read the full file on GitHub · 246 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 246 lines · 0 tokens per session scan A 7e2c825253d7

Subscribe to this mod's changes

context-groups is a command published in the GitHub repository sequenzia/claude-plugins (2 stars, last pushed 7mo ago), licensed MIT. It adds 10 tokens to every session and 1,741 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.