Skip to content
Back to skills

006 Extend 61c3a7eb

ASecurity

Extend effective context capacity through strategic techniques.

  • 9 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added October 11, 2026
ai-agentspython

Security analysis

A100/100

Scanned October 11, 2026

npx -y skills add tools-only/X-Skills --skill 006-extend_61c3a7eb --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 006 Extend 61c3a7eb?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 006 Extend 61c3a7eb
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tools-only-006-extend-61c3a7eb/badge)](https://www.skillsdirectory.com/skills/tools-only-006-extend-61c3a7eb)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

SKILL.md
# Context Optimization

Extend effective context capacity through strategic techniques.

## Four Core Strategies

| Strategy | Target | Reduction | When to Use |
|----------|--------|-----------|-------------|
| **Compaction** | Full context | 50-70% | Approaching limits |
| **Observation Masking** | Tool outputs | 60-80% | Verbose outputs >80% |
| **KV-Cache Optimization** | Repeated prefixes | 70%+ hit | Stable prompts |
| **Context Partitioning** | Work distribution | N/A | Parallelizable tasks |

## Compaction

Summarize context when approaching limits.

**Priority**: Tool outputs → Old turns → Retrieved docs → Never: System prompt

```python
if context_tokens / context_limit > 0.8:
    context = compact_context(context)
```

**Preserve**: Key findings, decisions, commitments (remove supporting details)

## Observation Masking

Replace verbose tool outputs with compact references.

```python
if len(observation) > max_length:
    ref_id = store_observation(observation)
    return f"[Obs:{ref_id}. Key: {extract_key(observation)}]"
```

**Never mask**: Current task critical, most recent turn, active reasoning
**Always mask**: Repeated outputs, boilerplate, already summarized

## KV-Cache Optimization

Reuse cached Key/Value tensors for identical prefixes.

```python
# Cache-friendly ordering (stable first)
context = [system_prompt, tool_definitions]  # Cacheable
context += [unique_content]                   # Variable last
```

**Tips**: Avoid timestamps in stable sections, consistent formatting, stable structure

## Context Partitioning

Split work across sub-agents with isolated contexts.

```python
result = await sub_agent.process(subtask, clean_context=True)
coordinator.receive(result.summary)  # Only essentials
```

## Decision Framework

| Dominant Component | Apply |
|-------------------|-------|
| Tool outputs | Observation masking |
| Retrieved docs | Summarization or partitioning |
| Message history | Compaction + summarization |
| Multiple | Combine strategies |

## Guidelines

1. Measure before optimizing
2. Apply compaction before masking
3. Design for cache stability
4. Partition before context problematic
5. Monitor effectiveness over time
6. Balance savings vs quality

## Related

- [Context Compression](./context-compression.md)
- [Memory Systems](./memory-systems.md)

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.