Agent skill
libmemory
libmemory - Memory management for LLM context windows. WindowBuilder constructs token-limited context from conversation history and tools. createWindow factory simplifies window creation. MemoryIndex stores conversation identifiers. Use for managing chat history, building LLM prompts, and context window optimization.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/data/libmemory
SKILL.md
libmemory Skill
When to Use
- Building context windows for LLM calls
- Managing conversation history with token limits
- Constructing prompts from messages and tools
- Optimizing context for model token budgets
Key Concepts
WindowBuilder: Constructs context windows by selecting messages and tools that fit within token budget.
MemoryIndex: Stores conversation message identifiers for retrieval.
Token budgeting: Allocates tokens across system prompt, history, and tools.
Usage Patterns
Pattern 1: Build context window
import { WindowBuilder } from "@copilot-ld/libmemory";
const builder = new WindowBuilder(tokenizer);
const window = await builder.build({
messages: conversationHistory,
tools: availableTools,
budget: 4000,
});
Pattern 2: Factory usage
import { createWindow } from "@copilot-ld/libmemory";
const window = await createWindow(resourceId, {
maxTokens: 4000,
systemPrompt: "You are a helpful assistant.",
});
Integration
Used by Memory service and Agent service. Works with libllm for token counting.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?