Using Mera with an AI assistant

Experimental, and an idea rather than a policy

This page and the files it describes are a suggestion, offered because people are already working this way. Nothing here is required, none of it is part of the package, and the shape of it may well change. Treat it as an experiment, and tell us if it helps or gets in the way.

Mera is large: about ninety-five documentation pages and a few hundred exported functions. Someone starting a thesis does not have a week to read it before touching their own simulation, and a perfectly reasonable response is to ask an assistant. That works better with a little preparation, and worse than people expect without it.

The problem with asking cold

An assistant that has not been told about Mera will write Mera-shaped code that does not run, or, worse, runs and returns a plausible number. The failures are specific and repeatable:

  • it invents a unit argument, or omits one and silently works in code units
  • it writes Sphere(...), but the exported constructors are lowercase (sphere, cylinder, cuboid, sphericalshell, cylindricalshell), because Makie exports a Sphere too
  • it calls functions that are not in Mera, such as rotationcurve or emission maps
  • it reaches for getvar(gas, :sd), which does not exist, because surface density lives only in projection
  • it assumes a selection keeps whole cells, and so does not expect the boundary weighting
  • it loops over readdir(folder) and trips over the .meta.json sidecar that Mera writes next to every saved file, or reads an exported HDF5 map in h5py without the transpose

None of these are exotic. They are what anyone infers from the function names alone.

What you can use

you want tousewhat it takes
ask a quick questionthe chatnothing, it is on every page
work in ChatGPT, Claude, Gemini or another chatthe grounding filepaste one file
let a coding assistant look up the documentationContext7one setup line
teach a coding assistant Mera's rules for every sessionthe Mera skillone line, or a ZIP
see how the code computes somethingDeepWikinothing (website), or one line
look up the documentation without Context7GitMCPone setup line

Context7, DeepWiki and GitMCP are free services run by other companies, not by Mera: what you type there goes to them (see Privacy). The checks further down apply to their answers as much as to any other.

Ask the chat

The chat button at the bottom right of every page of this documentation answers questions from Mera's documentation, and so does the chat on Mera's Context7 page. Nothing to install: type a question, as you would ask a colleague.

Give a chat the grounding file

Both are published with the documentation, and the links below always open the copies that match the docs version you are reading:

filewhat it is
llms.txtA compact grounding, about 3200 words. The data model, the vocabulary, the traps above, saving and sharing results (Mera files, sidecars, FAIR records), what is not in Mera, and how to check a result. Written to be pasted or attached whole.
llms-full.txtThe conceptual documentation concatenated into one file, about 37 000 words. Attach it when the question needs depth.

llms-full.txt deliberately leaves out the tutorial pages. Those are generated from notebooks and are mostly printed output, which fills an assistant's context without teaching it much.

Start with llms.txt. It is short enough to include in every conversation, and it carries the specific things that are otherwise guessed wrong.

Connect a coding assistant

Pasting a file works in any chat. Coding assistants such as Claude Code, Codex, Cursor or VS Code with Copilot can instead look the documentation up themselves while they work, through Context7, a separate service that indexes library documentation. Mera is indexed there as /manuelbehrendt/mera.jl: the documentation pages, the docstrings of every exported function and the gallery recipes, together with the rules from llms.txt.

Connect it once (this needs Node.js):

npx ctx7 setup --claude                                # Claude Code
codex mcp add context7 -- npx -y @upstash/context7-mcp # Codex
npx ctx7 setup --cursor                                # Cursor; --opencode for OpenCode

Other tools connect to the MCP server https://mcp.context7.com/mcp, and Context7's list of clients has the setup for each. A free API key from Context7 raises the rate limit but is not required.

Then name the library in the question, so the assistant reads Mera's documentation instead of guessing:

Make a face-on surface density map of the gas within 15 kpc. use library /manuelbehrendt/mera.jl

Install the Mera skill

A skill is a small instruction file that a coding assistant keeps on your computer. It knows the skill in every session and reads it whenever the work is about Mera, so it gets Mera's data model, units and common traps right without looking anything up, even offline. The Mera skill is the text of llms.txt in the skill format, published as mera_skill.txt.

Install it with one line in a terminal (the shell, not the Julia REPL), then restart the assistant:

# Claude Code
mkdir -p ~/.claude/skills/mera && curl -fsSL -o ~/.claude/skills/mera/SKILL.md https://manuelbehrendt.github.io/Mera.jl/stable/mera_skill.txt
# Codex
mkdir -p ~/.agents/skills/mera && curl -fsSL -o ~/.agents/skills/mera/SKILL.md https://manuelbehrendt.github.io/Mera.jl/stable/mera_skill.txt

In the Claude app (web or desktop) no terminal is needed: download mera_skill.zip and upload it in the app's settings, where it lists your skills.

Check that it worked by asking the assistant "Which skills do you have?": mera should be in the list. From then on, ask Mera questions as usual, and the assistant uses the skill by itself:

Load output 400 from /data/sim and compute the gas mass hotter than 10⁴ K within 10 kpc of the box centre.

Keep it current. Your copy does not update itself, so run the same line again after you update Mera. If you forget, the skill notices that it is older than the Mera you use, tells the assistant to read the current rules online, and reminds you to update it.

The skill and Context7 work well together: the skill gives the rules, Context7 the details.

Look inside the code with DeepWiki

The documentation says what Mera computes. Sometimes you want to see how the code does it: which formula :T uses, how a projection treats a cell that is only partly inside the map, where a function lives. DeepWiki answers that kind of question from Mera's source code.

Try it without installing anything. Open deepwiki.com/ManuelBehrendt/Mera.jl. On the left is a wiki of Mera's parts (loading, getvar, regions, projections, export, …), each page with links to the lines of code it describes. At the bottom is a box where you ask a question in plain language, for example:

How does getvar compute the gas temperature, and which mean molecular weight does it use?

Connect it to a coding assistant, so the assistant can ask DeepWiki by itself while it works (this uses MCP, the standard way an assistant connects to an outside service):

claude mcp add --transport http deepwiki https://mcp.deepwiki.com/mcp     # Claude Code
codex mcp add deepwiki -- npx -y mcp-remote https://mcp.deepwiki.com/mcp  # Codex (needs Node.js)

Then name the repository in the question: "Ask DeepWiki about ManuelBehrendt/Mera.jl: how does projection weight cells at the edge of the map?"

An AI writes the wiki from the code, and nobody reviews it. It is good for finding your way and for pointing to the right lines; for a number that goes into a paper, the documentation and the code are the reference.

Use GitMCP instead of Context7

GitMCP does a similar job to Context7 with no account and no indexing: it reads Mera's llms.txt and searches the documentation and the code straight from the GitHub repository, so it is always current. Use it if Context7 is not available to you, or as a second source.

claude mcp add --transport http mera-docs https://gitmcp.io/ManuelBehrendt/Mera.jl     # Claude Code
codex mcp add mera-docs -- npx -y mcp-remote https://gitmcp.io/ManuelBehrendt/Mera.jl  # Codex

Other tools take the same address, https://gitmcp.io/ManuelBehrendt/Mera.jl, wherever they list their MCP servers. Then ask as usual and add "use the Mera docs", so the assistant knows to look them up.

Ask for code you can read

Work produced this way is read by a supervisor, a referee, or by the author six months later. It is worth asking for it in that shape from the start: short named steps rather than one dense expression, physical constants named at the top, comments that explain the decisions rather than the syntax, and the unit stated in the code rather than in a comment.

Check it, three ways

The assistant is confident either way, so the check has to come from you. All three are cheap enough to leave in the script.

Does the code do what it says

A condition and its negation must reproduce the parent. This catches an inverted comparison, a wrong unit and a mis-specified region in one line:

inside  = msum(subregion(gas, reg), :Msol)
outside = msum(subregion(gas, !reg), :Msol)
abs(inside + outside - msum(gas, :Msol)) / msum(gas, :Msol)     # ~0

The same works for filterdata(gas, cond) against filterdata(gas, !cond). A projected map should also total its own msum when it has no fov, or when fov is used with split=true.

Does the physics hold

Prefer a case whose answer is known before you run it. download_testdata() fetches fifteen public test simulations, about 300 MB together (or one by name, download_testdata("sedov3d_amr")), chosen for that: a Sedov blast whose radius grows as t^(2/5), an MHD shock tube where a divergence-free field keeps Bx constant, four density blobs a clump finder must return as four, a Strömgren sphere with an analytic ionisation front, and three of RAMSES's own tests with published reference values.

On your own data the equivalent is: check a limiting case, reach the same total by a second route, and confirm the answer does not move when the pixel size, the viewing angle or the thread count changes.

Could someone else get the same number

provenance_string(gas)   # version, git branch and commit, dirty flag, snapshot, time
mera_build()             # tells a registry install from a checkout of a branch

pkgversion reports the same string either way, so a result from a development branch looks like a result from the release unless mera_build is used. For anything shared, pin the environment in a Project.toml beside the script and commit the Manifest.toml that instantiate produces, as the gallery recipes do; meraproject("my_analysis") starts such a folder.

Ask the assistant to save results with Mera's own functions (exportdata, savemap, savedata) rather than with a generic writer: then every file gets its sidecar, the readable record of where it came from, without anyone thinking about it. A figure saved with Makie needs one more line, writesidecar("fig.png", m). Before you publish, bundle(".") turns the folder into one record with the BibTeX of the versions used; Sharing Results & Sidecars shows it.

Where this does not help

An assistant is good at the shape of an analysis and bad at whether it is the right analysis. It will not tell you that your region is too small for the question, that a threshold sits in the middle of the distribution, or that the quantity you asked for is not the one your argument needs. How the numbers are computed is worth reading properly, once, for that reason.

See also