memlab
AGENTS.md5.1k starsChanged 19 months agoMITView on GitHub
Instructions for AI coding agents working on the memlab source code. To use memlab rather than change it (write a leak test scenario, analyze a heap snapshot, set up the MCP server), read AI.md and the Agent Skills under plugins/memlab/skills/ instead. memlab is an npm workspaces monorepo. Each package under packages/ is published to npm separately: Each package depends only on packages earlier in this order: core, lens, e2e, heap-analysis, api, cli, memlab. mcp-server depends only on core and heap-analysis.…
- Installs packages
We split this AGENTS.md into the rules it gives an agent
4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 34
Use Node.js 18 or later (@memlab/mcp-server requires it).
- Distinctive: line 55
Every source file starts with the MIT license header.
- Very specific: line 63
If you change a public API or CLI option, update README.md, AI.md and the affected package README in the same change.
- Distinctive: line 96
When a CLI flag, API or MCP tool changes, update the skills that mention it.
≈ “Common” is an estimate: at least 1 in 5 of the 36,368 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.
Files
AGENTS.md
Instructions for AI coding agents working on the memlab source code.
To use memlab rather than change it (write a leak test scenario, analyze a
heap snapshot, set up the MCP server), read AI.md and the Agent
Skills under plugins/memlab/skills/ instead.
Repository layout
memlab is an npm workspaces monorepo. Each package under packages/ is
published to npm separately:
| Directory | npm package | What it contains |
packages/core | @memlab/core | Heap snapshot parser, the IHeapSnapshot/IHeapNode/IHeapEdge API, leak trace clustering, config |
packages/e2e | @memlab/e2e | Browser automation with Puppeteer: runs test scenarios and takes heap snapshots |
packages/heap-analysis | @memlab/heap-analysis | Built-in analyses behind memlab analyze <plugin> |
packages/api | @memlab/api | Programmatic API: run, takeSnapshots, findLeaks, analyze |
packages/cli | @memlab/cli | The memlab command line commands |
packages/memlab | memlab | Umbrella package that installs the memlab CLI |
packages/lens | @memlab/lens | In-browser overlay that highlights detached DOM and unmounted React components (webpack bundle) |
packages/mcp-server | @memlab/mcp-server | MCP server for AI assistants, plus the memlab-cli command |
Each package depends only on packages earlier in this order: core, lens,
e2e, heap-analysis, api, cli, memlab. mcp-server depends only on
core and heap-analysis. Don't add an import that goes the other way.
website/ is the Docusaurus site published at https://meta.github.io/memlab.
docs/ is a symlink to website/docs/.
Build, test, run
Use Node.js 18 or later (@memlab/mcp-server requires it).
npm install
npm run build # compiles every package to packages/*/dist
npm test # runs each package's tests
npm run memlab -- help # run the CLI built from this checkout- Build before you test. Jest runs the compiled tests in
packages/*/dist/**/__tests__/, not the TypeScript sources, so a test run without a fresh build tests old code. - To work on one package:
npm run build-pkg -w packages/core, thennpm run test-pkg -w packages/core. npm run devrunstsc -b -wfor incremental rebuilds.- Website:
cd website && yarn install && yarn startserves it locally;yarn buildis what the GitHub Pages deploy runs.
Conventions
- TypeScript in
strictmode. Put tests next to the code insrc/**/__tests__/*.test.ts. - Every source file starts with the MIT license header; copy it from an existing file in the same package.
- Public APIs are documented with TSDoc comments. The pages under
website/docs/api/are generated from those comments; change the comment, not the generated markdown. website/docs/cli/CLI-commands.mdis generated from the CLI command definitions inpackages/cli/src/commands/; change the command, not the markdown.- If you change a public API or CLI option, update
README.md,AI.mdand the affected package README in the same change.
MCP server (packages/mcp-server)
- A tool lives in its own file under
src/tools/and is registered with the server by aregister...(server)call insrc/index.ts. Also list it in a group insrc/tools/tools-index.ts, the catalog thatmemlab_toolsserves. The tool tables inpackages/mcp-server/README.mdare generated from that catalog: runnpm run sync-catalogin the package after adding or renaming a tool. npm run test-pkgin the package checks that every tool is in the index, that no tool description asks for a parameter its schema lacks, that the README tables are current, and thatsrc/server-version.tsmatchespackage.json.- A tool that runs caller-supplied JavaScript goes in
RUNS_CODEinsrc/tool-annotations.ts, which sets its MCP annotations and hides it underMEMLAB_DISABLE_CODE_TOOLS=1. Also list it in the README under "Tools that execute JavaScript". .mcp.jsonruns the server from this checkout (packages/mcp-server/bin/memlab-mcp.js), so build first.
Agent Skills and the Claude Code plugin (plugins/memlab)
- Each skill is a directory under
plugins/memlab/skills/with aSKILL.mdthat follows the Agent Skills specification:namematches the directory,descriptionsays what the skill does and when to use it (at most 1024 characters), and the body stays under 500 lines. Skills are copied out of the repo when installed, so link only to files inside the skill directory or to absolute URLs. skills/memlab-analyze-heap-snapshot/references/investigation-paths.mdrepeats the investigation paths inpackages/mcp-server/MCP_SKILL.md. Update both together.- When a CLI flag, API or MCP tool changes, update the skills that mention it.
- Validate with
claude plugin validate plugins/memlab,claude plugin validate --strict plugins/memlab/skillsandclaude plugin validate .(the marketplace in.claude-plugin/).
Pull requests
See CONTRIBUTING.md. Make sure the build and tests pass, and update the documentation when you change behavior.
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 28,693 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.
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
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.

