agentleFS
rohitg00rohitg00/agentmemory/AGENTS.md

agentmemory

AGENTS.md29k starsChanged 58 days agoApache-2.0View on GitHub

agentmemory is a persistent memory system for AI coding agents, built on iii-engine's three primitives (Worker/Function/Trigger). Everything goes through registerFunction/registerTrigger/sdk.trigger() — never bypass iii-engine with standalone SQLite or in-process alternatives. When adding or removing MCP tools, you MUST update ALL of the following: 1. src/mcp/tools-registry.ts — tool definition + getAllTools() array 2. src/mcp/server.ts — handler case in the mcp::tools::call switch 3. src/triggers/api.ts — REST endpoint registration 4. src/index.ts — function registration + endpoint count in the log line 5. test/mcp-standalone.test.ts…

Trending

More talk lately.about the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 0 mentionsApr 2026: 1 mentionMay 2026: 17 mentionsJun 2026: 1 mentionJul 2026: 3 mentionsAug 2026: 4 mentionsSep 2026: 10 mentionsOct 2026: 20 mentionsNov 2026: 14 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the rohitg00/agentmemory repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about rohitg00/agentmemory

The biggest 5 of 70 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 70

Talked about on GitHub and Bluesky (70 times).

On GitHub · 50

45 more on GitHub

On Bluesky · 20

15 more on Bluesky
  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.

    Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

The file

We split this AGENTS.md into the rules it gives an agent

7 rules. About 0 are common, 1 is distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    No code comments explaining WHAT — use clear naming instead

    line 104
  2. Very specific:

    Use fingerprintId() for content-addressable dedup, generateId() for unique IDs

    line 105
  3. Very specific:

    Use recordAudit() for state-changing operations

    line 109
  4. Very specific:

    All tests must pass before PR: npm test (1,596+ tests)

    line 114
  5. Very specific:

    Before any npm publish: npm run release:gate must pass.

    line 115
  6. Very specific:

    Test files go in test/ with .test.ts extension

    line 117
  7. Very specific:

    Follow existing patterns in test/crystallize.test.ts for function tests

    line 118

≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

agentmemory — Agent Instructions

Architecture

agentmemory is a persistent memory system for AI coding agents, built on iii-engine's three primitives (Worker/Function/Trigger). Everything goes through registerFunction/registerTrigger/sdk.trigger() — never bypass iii-engine with standalone SQLite or in-process alternatives.

  • Engine: iii-sdk 0.22.1 with @iii-dev/helpers 0.22.1 (WebSocket to iii-engine 0.22.1 on port 49134; the client type is IIIClient, HTTP requests are HttpRequest from @iii-dev/helpers/http)
  • State: File-based SQLite via iii-engine's StateModule (./data/state_store.db)
  • Build: TypeScript → ESM via tsdown, output to dist/
  • Test: vitest (npm test excludes integration tests)

Consistency Rules

When adding or removing MCP tools, you MUST update ALL of the following:

  1. src/mcp/tools-registry.ts — tool definition + getAllTools() array
  2. src/mcp/server.ts — handler case in the mcp::tools::call switch
  3. src/triggers/api.ts — REST endpoint registration
  4. src/index.ts — function registration + endpoint count in the log line
  5. test/mcp-standalone.test.ts — tool count assertion
  6. README.md — tool counts (search for "MCP tools")
  7. plugin/.claude-plugin/plugin.json — tool count in description
  8. plugin/plugin.json and plugin/.mcp.copilot.json (when present) — tool count or MCP exposure

When adding REST endpoints, you MUST update:

  1. src/triggers/api.ts — endpoint registration
  2. src/index.ts — endpoint count in the log line
  3. README.md — endpoint count (search for "REST endpoints" and "endpoints on port")

When bumping version, you MUST update ALL of the following:

  1. package.json — version field
  2. src/version.ts — VERSION constant and type union
  3. src/types.ts — ExportData version union
  4. src/functions/export-import.ts — supportedVersions set
  5. test/export-import.test.ts — version assertion
  6. plugin/.claude-plugin/plugin.json — version field
  7. plugin/plugin.json (when present) — version field

When adding new KV scopes:

  1. src/state/schema.ts — add to the KV object
  2. src/types.ts — add the corresponding interface

When adding new audit operations:

  1. src/types.ts — add to AuditEntry.operation union type

Code Patterns

Function Registration

sdk.registerFunction(
  "mem::your-function",
  async (data: { ... }) => {
    // validate inputs
    // do work via kv.get/kv.set/kv.list
    // record audit via recordAudit()
    return { success: true, ... };
  },
);

REST Endpoint Registration

import type { HttpRequest } from "@iii-dev/helpers/http";

sdk.registerFunction("api::your-endpoint", async (req: HttpRequest) => {
  const denied = checkAuth(req, secret);
  if (denied) return denied;
  const body = req.body as Record<string, unknown>;
  // validate + whitelist fields (never pass raw body to sdk.trigger)
  const result = await sdk.trigger({
    function_id: "mem::your-function",
    payload: { ... },
  });
  return { status_code: 200, body: result };
});
sdk.registerTrigger({
  type: "http",
  function_id: "api::your-endpoint",
  config: { api_path: "/agentmemory/your-path", http_method: "POST" },
});

MCP Tool Handler

case "memory_your_tool": {
  // validate args with typeof checks
  // parse CSV args: args.field.split(",").map(t => t.trim()).filter(Boolean)
  const result = await sdk.trigger({
    function_id: "mem::your-function",
    payload: { ... },
  });
  return { status_code: 200, body: { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] } };
}

Hook Scripts

Hook scripts in src/hooks/ are standalone Node.js scripts (no iii-sdk import). They read JSON from stdin, make HTTP calls to the REST API, and exit. There are two patterns depending on whether Claude Code consumes the script's stdout:

  • Context-injecting hooks (pre-tool-use, pre-compact, session-start) write recalled context to stdout for Claude Code to inject. These MUST use try/catch with await fetch(..., { signal: AbortSignal.timeout(N) }) — the script has to wait for the response before exiting, and the timeout is the only bound on hang time.
  • Telemetry-only hooks (notification, post-tool-failure, post-tool-use, prompt-submit, stop, session-end, subagent-start, subagent-stop, task-completed) write nothing to stdout. These MUST use fire-and-forget fetch(..., { signal: AbortSignal.timeout(N) }).catch(() => {}) paired with setTimeout(() => process.exit(0), 500).unref(). The unawaited fetch dispatches the request; the unref'd setTimeout force-exits the process after the request has been flushed to the local daemon's socket buffer (~500ms is enough for single-request hooks; use 1500ms for multi-request hooks like stop and session-end so all fetches have time to start, especially when AGENTMEMORY_URL points to a remote daemon). Without the setTimeout Node keeps the event loop alive waiting for any in-flight fetch to settle, which means the hook still blocks Claude Code's next-prompt boundary for up to the AbortSignal duration — exactly the bug fire-and-forget is meant to fix.

Coding Standards

  • TypeScript, ESM only ("type": "module")
  • No code comments explaining WHAT — use clear naming instead
  • Use fingerprintId() for content-addressable dedup, generateId() for unique IDs
  • Parallel operations where possible (Promise.all for independent kv writes/reads)
  • Input validation at system boundaries (MCP handlers, REST endpoints)
  • REST endpoints must whitelist fields — never pass raw request body to sdk.trigger()
  • Use recordAudit() for state-changing operations
  • Timestamps: capture once with new Date().toISOString() and reuse

Testing

  • All tests must pass before PR: npm test (1,596+ tests)
  • Before any npm publish: npm run release:gate must pass. It installs the packed tarballs into a clean home and runs capture, recovery, restart, export/import, MCP and status checks against the installed CLI (see CONTRIBUTING.md, Release process)
  • Mock pattern: vi.mock("iii-sdk") with mock sdk.trigger, kv.get/set/list
  • Test files go in test/ with .test.ts extension
  • Follow existing patterns in test/crystallize.test.ts for function tests

Current Stats (v0.9.29)

  • 54 MCP tools (8 visible by default, AGENTMEMORY_TOOLS=all for all)
  • 138 REST endpoints
  • 6 MCP resources, 3 MCP prompts
  • 12 hooks, 17 skills
  • 260+ iii functions
  • 1,596+ tests

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.