Implements persistent memory for Claude agents using the Claude API memory tool. Covers setup, six file commands (view, create, str_replace, insert, delete, rename), SDK helpers, and path-traversal protection for cross-session state.
Ships in messages-api-features. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
The memory tool lets Claude create, read, update, and delete files under a /memories prefix. It runs client-side: Claude requests operations, your code performs them on storage you control.
The whole configuration is one entry; no input schema, and the docs state no beta header is needed for the tool itself.
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic();
const MODEL = process.env.ANTHROPIC_MODEL!; // a current model ID
const response = await client.messages.create({
model: MODEL,
max_tokens: 2048,
tools: [{ type: "memory_20250818", name: "memory" }],
messages: [{ role: "user", content: "Help me respond to this support ticket." }],
});
When the tool is present, the API adds a memory protocol to the system prompt that tells Claude to view its memory directory first and record progress as it works.
| Command | Input | Notes |
|---|---|---|
view | path, optional view_range | Directory listing (2 levels) or file with line numbers |
create | path, file_text | Reference behavior errors if the file exists; overwriting is an allowed choice |
str_replace | path, old_str, new_str | Must match exactly once |
insert | path, insert_line, insert_text | 0 inserts at the start |
delete | path | Recursive for directories; never delete /memories itself |
rename | old_path, new_path | Do not overwrite an existing destination |
The docs specify recommended return strings for each command (for example, "File created successfully at: {path}"). Claude reads whatever you return, but matching the documented strings keeps behavior predictable. Return failures as a tool_result with is_error: true.
The Python and TypeScript SDKs ship helpers and a ready-made local filesystem backend; the tool runner drives the loop.
import { betaMemoryTool } from "@anthropic-ai/sdk/helpers/beta/memory";
import { BetaLocalFilesystemMemoryTool } from "@anthropic-ai/sdk/tools/memory/node";
const backend = await BetaLocalFilesystemMemoryTool.init("./memory");
const memory = betaMemoryTool(backend);
const finalMessage = await client.beta.messages.toolRunner({
model: MODEL,
max_tokens: 1024,
tools: [memory],
messages: [{ role: "user", content: "Remember that Acme prefers email follow-ups." }],
max_iterations: 10,
});
from anthropic import Anthropic
from anthropic.tools import BetaLocalFilesystemMemoryTool
client = Anthropic()
memory = BetaLocalFilesystemMemoryTool(base_path="./memory")
runner = client.beta.messages.tool_runner(
model=MODEL, max_tokens=1024, tools=[memory],
messages=[{"role": "user", "content": "Remember that Acme prefers email follow-ups."}],
)
final = runner.until_done()
The helpers live in the SDK beta namespace even though the tool does not need a beta header. Subclass the abstract helper (BetaAbstractMemoryTool in Python) to back memory with a database or object store.
/memories to per-tenant storage/memories is a prefix your handler maps to real storage. Scope it per user or per project so one tenant can never read another's files, and serve the same store to later conversations so they resume from the same memory.
The docs call out path traversal explicitly: a path such as /memories/../../secrets.env must be rejected.
from pathlib import Path
ROOT = Path("/var/app/memory/tenant-123").resolve()
def safe_path(p: str) -> Path:
if not p.startswith("/memories"):
raise ValueError("path outside /memories")
candidate = (ROOT / p.removeprefix("/memories").lstrip("/")).resolve()
candidate.relative_to(ROOT) # raises if it escaped the root
return candidate
Also cap file sizes, cap how much view returns (Claude can page with view_range), watch for URL-encoded traversal sequences, and expire files that have not been accessed in a long time.
Memory preserves what must survive; compaction or context editing keeps the active window small. For long-running agents the docs suggest using both. A useful pattern from the docs for multi-session software work: an initializer session writes a progress log and a feature checklist; every later session reads them first and updates the log before ending.
Because storage is yours, you control retention. The docs list the memory tool as ZDR-eligible with exclusions for certain models; check the data-retention page if this matters to you.
What SKILL.md sets; muted values are Claude Code's defaults
/messages-api-features:memory-toolfrom messages-api-features
npx claudepluginhub latestaiagents/agent-skills --plugin messages-api-features7 skills in this plugin
/code-executionUse the Claude API code execution tool so the model runs Bash and Python in an Anthropic-hosted sandbox during a response — for calculation, data analysis, file generation, and checking its own work. Covers tool versions, file upload, retrieving generated files, container reuse, limits, and data-retention constraints.
Use this skill when building features where Claude must actually run code (not just write it), when choosing a code execution tool version, or when debugging missing output files or expired containers.
Activate when: Claude code execution, code_execution tool, Python sandbox, run code tool, data analysis agent, code interpreter, container_upload, container reuse, OUTPUT_DIR.
/computer-useBuild desktop and browser automation agents with the Claude API computer use toolset — screenshots, clicks, typing, scrolling — run by your own harness inside an isolated VM or container. Covers choosing the toolset version, the agent loop, batch actions, sandboxing, prompt-injection risk, and when an API integration is the better choice.
Use this skill when building agents that operate GUIs (legacy apps, browsers without APIs), migrating from an older computer use tool version, or reviewing the safety of a computer use deployment.
Activate when: Claude computer use, computer_toolset, computer_20251124, computer_20250124, desktop agent, screen control, click and type agent, GUI automation.
Other plugins' skills for the same job
2 plugins in one repository ship this exact skill · first indexed Nov 5, 2026