ad4m_classify
Determines the correct layer (ad4m, local, env, or relay) for a piece of information before storing it in memory. Run this to avoid misclassification when writing memory.
Instructions
Classify a piece of information by which layer it belongs to: ad4m, local, env, or relay. Run this BEFORE ad4m_write_memory if unsure.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | The information or description to classify |
Implementation Reference
- index.js:362-365 (handler)The handler function for the ad4m_classify tool. It receives the 'content' argument, calls classifyContent() to determine the layer classification, and returns the result.
async function classify({ content }) { const result = classifyContent(content); return ok(result); } - index.js:79-91 (handler)The core classification logic. It lowercases the input and matches it against keyword-based rules in the TAXONOMY object (env, local, relay, ad4m layers). Falls back to 'ad4m' if no keywords match.
function classifyContent(content) { const lower = content.toLowerCase(); for (const [layer, cfg] of Object.entries(TAXONOMY)) { if (cfg.keywords.some((kw) => lower.includes(kw))) { return { layer, reason: cfg.reason, action: cfg.action }; } } return { layer: "ad4m", reason: "No exclusion pattern matched — defaulting to semantic memory.", action: "Use ad4m_write_memory. If uncertain, run ad4m_classify with more specific content.", }; } - src/index.ts:67-79 (handler)TypeScript version of the core classification logic with proper type annotations (Layer, LayerRule).
function classifyContent(content: string): { layer: Layer; reason: string; action: string } { const lower = content.toLowerCase(); for (const [layer, cfg] of Object.entries(TAXONOMY) as [Layer, LayerRule][]) { if (cfg.keywords.some((kw) => lower.includes(kw))) { return { layer, reason: cfg.reason, action: cfg.action }; } } return { layer: "ad4m", reason: "No exclusion pattern matched — defaulting to semantic memory.", action: "Use ad4m_write_memory. If uncertain, run ad4m_classify with more specific content.", }; } - src/index.ts:369-374 (schema)The tool registration and schema definition (TypeScript version). Defines the 'content' input as a required string using Zod. The handler inline calls classifyContent().
// 7. ad4m_classify server.tool("ad4m_classify", "Classify a piece of information by which layer it belongs to: ad4m, local, env, or relay. Run this BEFORE ad4m_write_memory if unsure.", { content: z.string().describe("The information or description to classify") }, async ({ content }) => ok(classifyContent(content)) ); - index.js:576-585 (registration)Tool registration in the compiled index.js (ListToolsRequestSchema handler). Defines the tool name, description, and JSON Schema input.
name: "ad4m_classify", description: "Classify a piece of information by which layer it belongs to: ad4m (semantic memory), local (CLAUDE.md/settings), env (credentials), or relay (cross-terminal). Run this BEFORE ad4m_write_memory if unsure where something belongs.", inputSchema: { type: "object", properties: { content: { type: "string", description: "The information or description to classify" }, }, required: ["content"], }, }, - index.js:667-667 (registration)The CallToolRequestSchema case routing 'ad4m_classify' to the classify handler function.
case "ad4m_classify": return { content: await classify(args) };