Back to list
whiteboardev

context-preserve

by whiteboardev

0🍴 0📅 Jan 15, 2026

SKILL.md


name: context-preserve description: Preserves session context when context window fills. Triggers at configurable thresholds (50%/75%). Captures objective, progress, technical details, decisions, blockers, and next steps. metadata: subagent: summarizer version: "1.0" category: memory-management allowed-tools: Bash(bun:*)

Context Window Preservation

Automatically save session state before context window fills.

State Machine

START → CHECK_CONTEXT → EVALUATE_THRESHOLD
     ├→ SKIP (< 50%) ───────────────────────────→ END
     ├→ QUICK (50-75%) → COLLECT_SUMMARY → STORE → END
     └→ FULL (> 75%) ──→ COLLECT_DETAILED → STORE → END

Thresholds

LevelThresholdActionSections
Skip< 50%None-
Quick50-75%Summary3 (objective, progress, next)
Full> 75%Detailed6 (all)

Execution

Path A: Subagent (preferred)

Task(
  subagent_type: "summarizer",
  prompt: "Check context usage for project PROJECT_ID and preserve if needed"
)

Path B: Direct scripts

# Check usage
bun .opencode/skills/context-preserve/scripts/check-context-usage.ts PROJECT_ID

# Store (after LLM collects content)
bun .opencode/skills/context-preserve/scripts/store-preservation.ts PROJECT_ID "CONTENT" quick|full

Commands

Check Usage

bun .opencode/skills/context-preserve/scripts/check-context-usage.ts PROJECT_ID [--tokens N] [--quiet]

Exit codes:

  • 2 = skip (healthy)
  • 3 = quick preservation needed
  • 4 = full preservation needed

Store Preservation

bun .opencode/skills/context-preserve/scripts/store-preservation.ts PROJECT_ID "CONTENT" TYPE [--quiet]

Templates

Quick Preservation (50-75%)

## Session Context

### Objective
[One sentence: what we're working on]

### Progress
- Completed: [list]
- In progress: [current work]

### Next Steps
1. [Specific action]
2. [Specific action]

Full Preservation (> 75%)

## Session Context

### Objective
[What task/problem we're working on and original goals]

### Progress
- Completed: [detailed list with outcomes]
- In progress: [current work with status]
- Pending: [remaining items]

### Technical Details
- Project: [path, structure notes]
- Files modified: [list with purposes]
- Patterns discovered: [architectural notes]
- Dependencies: [relevant packages/configs]

### Decisions
- [Decision]: [Rationale]
- [Trade-off considered]: [Choice made and why]

### Blockers
- [Issue]: [Status and findings]
- [Error encountered]: [Resolution or workaround]

### Next Steps
1. [Specific action with context]
2. [Specific action with context]
3. [Follow-up items identified]

Environment Variables

VariableDefaultDescription
BRAINY_API_URLhttp://localhost:3000API endpoint
BRAINY_PROJECT_ID3afb861a-...Default project
CTX_SKIP_THRESHOLD50% below which no action
CTX_QUICK_THRESHOLD75% threshold for quick vs full
CTX_WINDOW_SIZE128000Estimated context window

Workflow

  1. Agent detects context filling up (or user requests)
  2. Check usage: check-context-usage.ts returns level
  3. If skip: Done
  4. If quick/full: LLM collects relevant info using template
  5. Store: store-preservation.ts saves to memory
  6. Continue: Session can proceed or be resumed later

Recovery

To resume from preserved context:

bun .opencode/skills/memory-retrieve/scripts/retrieve-memories.ts PROJECT_ID "context preservation" --limit 1

This fetches the most recent preservation memory for context restoration.

Score

Total Score

50/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon