Verify the API — don't invent it
A hallucinated function/arg/flag costs far more than the lookup. When in doubt, check before you write. Stop at the first rung that gives a definitive answer; you rarely need them all. Local sources beat the web — they're exact for the versions this repo actually uses.
The ladder (highest authority first)
This repo — for our own code. The source IS the spec. Grep for the definition, then read it + its
@spec/@doc.rg -n 'def fetch_and_update' portal/apps/emisar/lib/emisar/repo.ex rg -n 'def (for_user|for_api_key)' portal/apps/emisar/lib/emisar/auth/subject.exFor the in-house building blocks (
Repo.fetch/list/fetch_and_update,Subject,Authorizer.build/2, theuse Emisar, :query|:schema|:changesetmacros), the module underlib/emisar/is the only authority — don't assume Ecto/Phoenix defaults apply.Dependency source —
deps/(exact, offline, version-matched). The pinned version's real code, not a guess or a newer doc:rg -n 'def fetch\b|@spec fetch' portal/deps/ecto/lib rg -n 'def (stream|assign_async)\b' portal/deps/phoenix_live_view/libConfirm the version first if it matters:
grep -A1 '"ecto"' portal/mix.lock.mix help/ IEx. Task flags and quick signatures:cd portal && mix help ecto.gen.migration # a mix task's real args/flags cd portal && echo 'h Ecto.Query.from' | iex -S mix # docs for a fn/macroIn IEx:
h Mod.fun,exports Mod,b Behaviour(behaviour callbacks — useful for theEmisar.Repo.Query/Authorizercallbacks).HexDocs (web) — last resort, match the version. Only when local source is unclear. Use
WebFetchonhttps://hexdocs.pm/<pkg>/<version>/<Module>.htmlwith the version frommix.lock(a bare/<pkg>/redirects to latest, which may not be ours).CLI flags (the runner, MCP bridge, system tools). Never guess a flag:
./bin/emisar --help # and `./bin/emisar <subcmd> --help`Or read the flag definitions in
runner/(Goflag/cobra) /mcp/. For an action's args/opts, the action pack schema is the source of truth, not memory.Backstop, not first line:
cd portal && mix compile --warnings-as-errors. It flagsundefined or privatefunctions and wrong arity. Use it to catch a slip — but checking first (rungs 1–2) is cheaper than a failed compile + retry.
The rule
If a check is inconclusive, inspect a narrower source, reproduce the call safely, or use a verified alternative that preserves the requested behavior. Missing evidence is investigation work. Ask the user only when their intent or authority is the missing information. Never write an unverified call and hope it compiles.