← スキル一覧に戻る

context-preserve
by whiteboardev
⭐ 0🍴 0📅 2026年1月15日
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
| Level | Threshold | Action | Sections |
|---|---|---|---|
| Skip | < 50% | None | - |
| Quick | 50-75% | Summary | 3 (objective, progress, next) |
| Full | > 75% | Detailed | 6 (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 needed4= 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
| Variable | Default | Description |
|---|---|---|
BRAINY_API_URL | http://localhost:3000 | API endpoint |
BRAINY_PROJECT_ID | 3afb861a-... | Default project |
CTX_SKIP_THRESHOLD | 50 | % below which no action |
CTX_QUICK_THRESHOLD | 75 | % threshold for quick vs full |
CTX_WINDOW_SIZE | 128000 | Estimated context window |
Workflow
- Agent detects context filling up (or user requests)
- Check usage:
check-context-usage.tsreturns level - If skip: Done
- If quick/full: LLM collects relevant info using template
- Store:
store-preservation.tssaves to memory - 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.
スコア
総合スコア
50/100
リポジトリの品質指標に基づく評価
✓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
レビュー
💬
レビュー機能は近日公開予定です