/agami-core:agami-model [review | preseed | rule1] — go straight to the sign-off review; no arg shows the overviewfrom agami-core
Manages the semantic model: curate tables/columns/metrics, approve/reject AI-proposed entities and joins, and browse the model explorer. Every change is validated before updating YAML.
Ships in agami-core. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
You are running the model + trust surface: see the live semantic model, curate it (hide / edit / add), and sign off the trust layer (approve / reject metrics, entities, joins). The chat is the surface: a short overview, then question cards. The model explorer page is the optional full view.
Conventions for every card here: shared/question-cards.md. The review uses the same pattern and wording as agami-connect Phase 4, so the two reviews read as one product.
The flow:
sm review-items and sm model-tree, show what needs sign-off and the subject areas with their table counts, then one card: Review what needs sign-off / Hide tables or columns / Look up a table or metric / Show the full view.sm curate for every write.Trust-spine semantics — three actions on the same review_state field:
rejected. The loader drops rejected tables, columns, metrics, entities, and relationships entirely (include_rejected=False at runtime) — never in prompts, never joined, never aggregated. ("Hide" / "Exclude" is the verb for tables/columns; "Reject" for metrics/entities/joins — same op.)unreviewed.approved + a sign-off stamp (signed_off_by/_at/_role). Rule 1 (metrics) — a query that uses an unsigned metric still answers, and the metric arrives on the answer's receipt carrying its review_state, which is what puts a warning on the answer until it's approved; Rule 2 (entities, inferred joins) is usable while unreviewed and self-approves through use, with an unreviewed join flagged on the answer. Only rejected entries are dropped from the runtime entirely. Approving requires the curator's email + role (the identity card, Phase 0) — the validator rejects an approved entry with no sign-off stamp.description without source keeps its description_source: a typo fix in a description from the customer's data dictionary leaves it metadata, and one agami wrote stays ai_unvalidated (it still comes up for a check the first time a query uses it). A first description, or one for a column agami couldn't read (ai_unknown), is human. To change whose words it is, pass "source": "human", "metadata" or "ai" (any other value is skipped); sm curate reports each change in provenance_changed[], and the curation log records description_source_before / description_source_after on every description edit. A generated description ("source":"ai") still never replaces a human or metadata one. A description edit is cosmetic: it never sends an approved item back to review.stale. An edit that changes what an approved metric, entity or join computes or connects (a binding or calculation, unit, source tables, filters, an entity's mappings, a join's columns, on: or cardinality — any field but the cosmetic ones) sends it back to the review queue as stale; until someone re-approves it, it is not signed off, and the receipt says so. Only description, other_names, a metric's business_question, a metric's or entity's caveats, an entity's plural, and a join's for_questions_about are cosmetic and keep the approval; an edit that sets a field to the value it already has changes nothing. The old signed_off_* stay on a stale item as a record of the approval it lost. A batch that edits an item and then approves it ends approved by the approver (approvals go after edits); an approve followed by an edit ends stale. sm curate lists the items an edit sent back to review in stale[] — tell the person they need re-approving. sm review-items, sm review-queue and sm approve-queue show each stale item's changes_since_approval from the curation log (e.g. binding (sqlite) changed from SUM(amount) to SUM(amount) - SUM(discount)), or changes not recorded when the log doesn't go back that far (some changes not recorded at the end when a line after the edit can't be read).<area>.<table>. Columns are <area>.<table>.<column> (area = subject area). No bare names.shared/question-cards.md rule 7); the options and their order stay the same.ExitPlanMode.<profile> and <artifacts_dir> via the standard chain (AGAMI_PROFILE → <artifacts_dir>/local/.config.active_profile → default; AGAMI_ARTIFACTS_DIR → .config.artifacts_dir → ~/agami-artifacts). ROOT="<artifacts_dir>/<profile>".
profile: <name> — that page was rendered for THAT model, so use it and override the active-profile default. It prevents applying one page's approvals to whatever happens to be active (a different model). If <artifacts_dir>/<profile>/datasource.yaml exists for the named model, target it directly — don't fall back to active_profile or hunt with find.<artifacts_dir>/<profile>/datasource.yaml doesn't exist, invoke agami-connect and stop — there's no model yet. First rule out an AGAMI_PROFILE that names a database with no model (shared/file-layout.md): when it does, say so and stop instead.bash "${CLAUDE_PLUGIN_ROOT}/scripts/py" -c 'import yaml'. If not, surface the install hint and stop.Scope. Look at $ARGUMENTS:
review → skip the overview card and go straight to Phase 2 with every item waiting for sign-off.preseed or rule1 (from /agami-connect) → Phase 2 with --scope preseed / --scope rule1.The identity card (sign-off identity: asked once, on the first approval). Needed to stamp sign-off on an approve, and recorded on curation_log.jsonl and commits. It is resolved lazily: only when a batch holds an approve. Before the first approve op of the session, read reviewer_email and reviewer_role from <artifacts_dir>/local/.config (the keys /agami-connect uses too); a pasted full-view block's signed-off-by: line also supplies them. When both are there, use them and don't ask. When either is missing, ask one card with two questions, the same card as agami-connect Phase 4:
Email, "Which email should sign-offs be recorded under? Type it in Other below.": options Don't sign anything yet (nothing is approved; the items stay as they are and you return to the overview card) and Go back (ask again the card that led here, with nothing approved). The email is typed in "Other", e.g. [email protected]; it is asked for in the question, never offered as an option, because an option like "Type it in Other" gets clicked with nothing typed (question-cards rule 5).Role, "What is your role?": options Data Lead, Engineer, Analyst; "Other" takes any other role (≤ 40 characters).The identity is typed by the person: never infer it from git config, the environment, the credentials, or the Claude login / session email (the host exposes it, but using it produces a silently-wrong audit trail), and don't pre-fill a domain. An email that doesn't match \S+@\S+\.\S+ is said back and the same card asked again. Save them so neither this session nor /agami-connect asks again: write {"email": "<email>", "role": "<role>"}, as typed, to <artifacts_dir>/local/tmp/agami-identity.json with the Write tool, then bash "${CLAUDE_PLUGIN_ROOT}/scripts/sm" set-config "<artifacts_dir>" --identity-file "<artifacts_dir>/local/tmp/agami-identity.json", which keeps every other key and writes the file 0600. Hide/edit-only sessions never need it.
If an sm call exits 12, agami's library is older than the plugin: run bash "${CLAUDE_PLUGIN_ROOT}/scripts/sm" install (the person approves it), then repeat the call. It is not "no model" (exit 3): never send the person to agami-connect for it.
Read the model from the engine; never walk the YAML yourself:
bash "${CLAUDE_PLUGIN_ROOT}/scripts/sm" review-items "$ROOT" --scope rule1
bash "${CLAUDE_PLUGIN_ROOT}/scripts/sm" review-items "$ROOT" --scope rule2
bash "${CLAUDE_PLUGIN_ROOT}/scripts/sm" model-tree "$ROOT"
bash "${CLAUDE_PLUGIN_ROOT}/scripts/sm" sensitive "$ROOT"
review-items (the two calls together are the sign-off queue: rule1 the metrics, rule2 the joins and entities; both are the served model, so a definition that depends on a hidden table is left out, as in sm overview; never --scope all for sign-off, which keeps hidden entries and is for full-model curation) is a list of {kind, area, name, title, tab, extra_lines, changes_since_approval?, …}. What needs sign-off is every item whose tab is review; count them by kind (metric, entity, relationship), and count the ones carrying changes_since_approval (signed off before, changed since).model-tree is {datasource, subject_areas:[{area, description, tables:[{table, review_state, columns:[…]}]}]}. Per subject area, count its tables, and the hidden ones (review_state: rejected) apart.sensitive gives count (columns flagged as personal data and still queryable) and, apart from it, suspected_count (columns whose name or sampled values suggest personal data, with no flag set). Never add the two.Where the host can draw a visual in the chat, draw the overview card first (shared/overview-card.md: one tile per area from sm overview, a click carries on here). Then post the overview as the turn's last message, in this order:
Subject area | Tables | Hidden, largest first, at most 15 rows, then "Showing 15 of subject areas; <A−15> more." when there are more.count or suspected_count > 0, one line about personal data, each count said apart and a clause left out when its count is 0:
count > 0: " columns are flagged as personal data and are still queryable: they can be counted and filtered, and nothing stops a query returning their values."suspected_count > 0: "<suspected_count> more have names or sampled values that suggest personal data but aren't flagged; check them on the full view's PII tab." When count is 0 it starts "<suspected_count> columns have names …" instead of "more have".No card follows the overview: it ends the turn (long-text.md). Handle the reply as the four choices below; words that mean one of them count as it.
The overview card (AskUserQuestion, header Model), asked after each action (below) with one line before it, "What would you like to do with the model?":
"Other" takes a request in the person's words: a name to look up ("orders"), something to hide ("hide sales.stg_leads"), an edit ("add a metric: refund rate = refunds / captured payments", "describe orders.status as …"), an example to add ("add an example", "add my own examples": shared/own-examples.md from its step 1, then this card again), or "done". Route it to the phase it asks for; an edit becomes sm curate edit ops, or sm add --kind metric for a new metric, applied as Phase 6 says, then shown back in one line; "done" goes to Phase 7. A question ("show me the SQL", "why?") is answered first, then the same card asked again (question-cards rule 5a). Anything else you can't place is re-asked, never guessed.
After each action (Phases 2–4), post one line on what changed and ask the overview card, with the counts recomputed. Dismissing the card, or "done" in "Other", ends the session (Phase 7).
The same pattern and wording as agami-connect Phase 4 (sign-offs, the personal-data question, the identity card); only where it goes afterwards differs. Read the queue from the engine:
bash "${CLAUDE_PLUGIN_ROOT}/scripts/sm" review-items "$ROOT" --scope rule1
bash "${CLAUDE_PLUGIN_ROOT}/scripts/sm" review-items "$ROOT" --scope rule2
(Only --scope preseed or --scope rule1 when $ARGUMENTS asked for it. The two calls' items are one list.) Keep the items whose tab is review. A metric's meaning is its extra_lines entry labelled Definition; an entity's is its maps_to (and source_signal when set); a guessed join's is its title and cardinality. An item with changes_since_approval was signed off before and has changed since: say so on its row, with what changed. The list ends the turn: one line, "
definitions wait for your sign-off:", a markdown table, Kind | Name | What it means | SQL, one short line per item taken from those fields (never a meaning you made up), at most 15 rows, then "Showing 15 of
; <P−15> more." when there are more, and the reply line below. The SQL column is what the item maps to, so the person checks the formula and not only the words: a metric's binding for this database's engine from bindings, with its source_tables; a join's condition; an entity's maps_to column. Show it in backticks, cut at about 80 characters with … (the whole of it is answered on request, question-cards rule 5a). No card follows the list: a list before a card in the same message does not reach the person (long-text.md).
The reply line: Reply "approve all", "review each" or "later", or "page" to decide them on the model explorer. Handle the reply as the choices below; words that mean one of them count as it:
changes_since_approval, and every metric has a Definition; otherwise put review each first with "(recommended)".| Answer | Do |
|---|---|
| Approve all | The identity card first if needed (Phase 0). With more than 15 items, list the ones the table above didn't show first, ending its turn on rule 4's reply line, and sign nothing until the reply (question-cards rule 4). Then one batch: {"op":"approve","kind":"<kind>","area":"<area>","name":"<name>","bulk":true} per item (leave area out when the item's area is null, a cross-area metric or join), applied with bash "${CLAUDE_PLUGIN_ROOT}/scripts/sm" curate "$ROOT" --ops-file "<artifacts_dir>/local/tmp/agami-signoff.json" --signer "<reviewer_email>" --role "<reviewer_role>". Say how many were signed off, from its applied. |
| Review one by one | The one-by-one cards below. |
| Skip for now | Nothing is written. Back to the overview card. |
| Review on a page | Phase 5 with initial_tab=review, then the list again, recounted, ending its turn on the reply line. |
Rule 1 guard. A metric with an empty Definition can't be approved as it stands: on its card, ask for the definition in "Other" and apply it as an edit first.
One by one. Up to 4 items per card, one question each. header is Metric 3/9, Entity 3/9 or Join 3/9 (at most 12 characters; drop the word when the numbers are long). The question is only the decision, with the item's plain_name from review-items: "Sign off Revenue?", "Sign off Orders to Customers by Customer ID?" (never the identifier, ela_proficiency_rate, which goes in the preview; question-cards rule 3b). The meaning and any real value go in the Approve option's description, kept apart from the title: "Sum of paid order totals, refunds excluded. 2024-25: $4.2M". The SQL goes in the Approve option's preview, the monospace pane a card shows beside a focused option, laid out over lines with a short comment on each filter (AND status = 'paid' -- paid orders), the table it reads, and, for an item that changed since its approval, what changed. Never put the SQL in the question: a card question is plain text and a long formula there is unreadable. Options:
{"op":"reject",…})."bulk": true. Answers given on the same card to the other questions still stand.initial_tab=review and section metrics, entities or joins), where the rest of the queue is decided at once and saved from the page. Offer it on every question of the card, not only the first. Answers given on the card's other questions are applied first; after the page, the next card holds only what is still undecided.After each card, apply its answers in one sm curate batch (approvals with --signer/--role), then ask the next card. Every approval goes through that one command with the person's identity; never mark an item approved any other way.
"Other" on an item is a change, in the person's words ("revenue should exclude cancelled orders"). Turn it into sm curate edit ops on the field the change names (calculation, bindings, description or other_names on a metric; maps_to, description or other_names on an entity; cardinality or the join columns on a join), e.g. {"op":"edit","kind":"metric","area":"<area>","name":"<name>","field":"calculation","value":"<new definition>"} plus the matching bindings edit when the SQL changes, and apply them with bash "${CLAUDE_PLUGIN_ROOT}/scripts/sm" curate "$ROOT" --ops-file "<artifacts_dir>/local/tmp/agami-edit.json". Never hand-edit the YAML and never a generator script. Then ask about that item again, on the next card, showing its new meaning: an edit is not a sign-off.
An "Other" that asks to stop is a stop, not a change. When the words on an item card ask to stop, pause or finish later ("stop here", "I'll do the rest later", "pause") rather than change that item, apply the card's other answers, approve or change nothing more, say how many are still unsigned, and go back to the overview card.
Any other "Other" you can't act on is re-asked, never guessed. A question ("show me the SQL", "why?") is answered first, then the same card asked again (question-cards rule 5a). An empty change, a column or table the model doesn't have, or words you can't turn into one field's new value: say in one line what didn't match, and ask the same card again. The same when sm curate returns errors or skipped for the edit: show them, and ask the same card again.
When sm sensitive prints personal_data: enforced_by_warehouse, skip this question. The organisation set that its warehouse controls who sees personal data (sm set-personal-data), so the build flagged nothing; say so in one line, "Personal data: your warehouse controls who sees it, so this build flagged none of it.", and ask nothing about it. When sm sensitive's count is above 0 (flags kept from before the setting, on a reload), add it: " columns flagged before stay flagged; change them in /agami-model."
Personal-data columns (when sm sensitive reports count or suspected_count > 0). Run bash "${CLAUDE_PLUGIN_ROOT}/scripts/sm" sensitive "$ROOT": {count, columns:[{area, table, column, label}], suspected, suspected_count}. columns are flagged personal, suspected look personal but weren't flagged (a phone-like or birth-date-like sample, a name like ip_address). This question can share the sign-off card (two questions on one AskUserQuestion call). Show both in one table, Table | Columns, marking each suspected column "(suspected)", e.g. customers | email, phone, ip_address (suspected) (a table in the chat may show identifiers; the card names them in words); at most 15 rows and "and N more". Then one multiSelect question (header Personal), "Hide these from queries": "These columns are flagged as personal data, or their names or sampled values suggest it. Which should queries never read?"
Flagged and suspected columns are picked the same way:
label, Email on Customers, or IP address on Customers (suspected); the identifier (customers.email) goes in the option's description.initial_tab=pii: every listed column on one page, each hidden, kept or marked there, saved from the page).table.column names to hide, flagged, suspected or any other column in the model.Hide the picks in one batch, {"op":"exclude","kind":"table","area":"<area>","name":"<table>","column":"<column>"} per column, with bash "${CLAUDE_PLUGIN_ROOT}/scripts/sm" curate "$ROOT" --ops-file "<artifacts_dir>/local/tmp/agami-hide.json", then say how many columns are hidden and how many personal-data columns stay queryable (sm sensitive's new count). Keep them queryable writes nothing; say in one line what that leaves (flagged columns still queryable, their values included). A name in "Other" that isn't a column in the model, or Keep them queryable or Review on a page picked together with anything else, is said back and the same card asked again; never guess which column was meant.
When the queue is done (or skipped), recount with sm review-items (--scope rule1 and --scope rule2) and go back to the overview card. When agami-connect sent the person here (its Phase 7 Review what needs sign-off), go back to agami-connect Phase 8 instead, the starter questions, so onboarding still ends on a first question.
Hidden tables and columns are never read by a query (review_state: rejected); they stay in the YAML, so they can be brought back with an include. Ask about groups, not one long list.
From the model-tree output, build the groups that apply, skipping anything already hidden:
stg_, _stg, staging, tmp, temp, backup, _bak, _old, _copy, test).sm sensitive's columns and suspected together.No table goes above the card (long text before a card does not reach the person; long-text.md): each option's description names the first 5 items in its group and "and N more". Call AskUserQuestion, one multiSelect question (header Hide), "Which of these should queries never read?", at most 4 options, the groups that apply in the order above:
"Other" takes names in the person's words: <area>.<table> or <area>.<table>.<column>, comma-separated, to hide along with the picked groups; keep <name> keeps one member of a picked group out of it.
Pick by subject area. One multiSelect question (header Area), "Which subject area's tables do you want to choose from?": the 3 subject areas with the most visible tables, one option each with its count; "Other" takes any other area's name. Then, per picked area, one multiSelect question (header Tables, at most 4 questions on a card), "Which tables in should queries never read?": with 3 tables or fewer, one option per table, named in words (Order items) with the identifier in its description; with more, grouped by the name's first word (the part before the first _), the 3 largest groups as options with their counts, Orders (5: Orders, Order items, …); always last, None of these. "Other" takes table names in that area.
Build one ops batch from every pick: {"op":"exclude","kind":"table","area":"<area>","name":"<table>"} per table, {"op":"exclude","kind":"table","area":"<area>","name":"<table>","column":"<column>"} per column, written with the Write tool and applied with bash "${CLAUDE_PLUGIN_ROOT}/scripts/sm" curate "$ROOT" --ops-file "<artifacts_dir>/local/tmp/agami-hide.json" (Phase 6). Say how many tables and columns are now hidden, from its applied, and list any skipped[]. A name in "Other" that isn't in the model, or Nothing for now / None of these picked together with something to hide, is said back and the same card asked again; never guess which table or column was meant.
To bring something back, the person says so ("show sales.stg_leads again"): one {"op":"include",…} op with the same shape.
Call AskUserQuestion, one question (header Look up), "Which table or metric? Type its name in Other.": up to 3 likely names as options (the metrics waiting for sign-off first, by plain_name, then the tables of the largest subject area, in words), at least 2; each option's description carries the identifier, which is also what "Other" takes. A name already given (in the overview card's "Other", or in the request) skips this card.
Match the name, case-insensitive, against the model-tree tables (<table> or <area>.<table>) and the review-items metrics and entities (name):
<area>.<name> in "Other".A table. Read it with bash "${CLAUDE_PLUGIN_ROOT}/scripts/sm" context "$ROOT" --area <area> --tables <table> and print:
Column | Type | Meaning, at most 15 rows and "Showing 15 of columns; <C−15> more.", marking hidden columns "(hidden)" and personal-data ones "(personal)";Joins to | Cardinality, when it has any.A hidden table isn't in sm context (the runtime drops it): print its description and columns from model-tree and say it is hidden.
A metric or entity. From its review-items item: the Definition (a metric) or maps_to (an entity), each Caveat line, its other_names, and its sign-off state (approved by whom and when, or waiting, or changed since approval with what changed). Show the definition in words; leave the binding SQL out of the chat.
Then back to the overview card.
The model explorer page, with every subject area, table, field, metric, entity, join and example, live search, the Review tab, the personal-data tab, edits, new metrics, and datasource.md. It is the only path that opens a page, and it saves its own decisions, the way the password page saves a password (question-cards rule 6a): Review on a page on a review card, and Show the full view on the overview card, both come here. Nothing is pasted back.
First rule 6a's step 1 (a remote or SSH session uses the cards). Then, when the page will take approvals (it was picked on a review card, or nothing has needed sign-off yet this session) and reviewer_email / reviewer_role aren't saved, the identity card (Phase 0) first: the page signs approvals as that saved identity and can't change it. Don't sign anything yet there still opens the page, which then says approvals can't be saved from it.
# The random part keeps two pages opened in the same second from sharing a decisions file.
ts=$(date -u +%Y%m%d-%H%M%S)-$RANDOM
# Per-model subdir so a person with several databases can tell renders apart.
mkdir -p <artifacts_dir>/local/model/"$profile"
out="<artifacts_dir>/local/model/$profile/$ts.html"
bash "${CLAUDE_PLUGIN_ROOT}/scripts/py" render_model_explorer.py \
--profile "$profile" \
--artifacts-dir "$artifacts_dir" \
${initial_tab:+--initial-tab "$initial_tab"} ${section:+--section "$section"} \
--save-to-helper --out "$out"
bash "${CLAUDE_PLUGIN_ROOT}/scripts/py" serve_page.py "$out" \
--decisions "<artifacts_dir>/local/tmp/agami-page-$ts.json" --minutes 30
Run serve_page.py with run_in_background and wait for its first line as rule 6a says. initial_tab and section are the deep link from the card it was picked on: review and the item's kind (metrics, entities, joins) from an item card, review alone from the Sign-off card (or when $ARGUMENTS was review/preseed/rule1), pii from the personal-data question; from the overview card leave both empty, and the renderer's auto default opens on Review when anything needs sign-off and on Datasource when the model is clean.
Print the link in your reply, with when it expires, before the card (rule 6a step 4), then the Page card:
[Review on a page](http://127.0.0.1:<port>/<token>/). Approve, reject, hide or edit there, press
Save decisions, then come back here and press I've saved it. Approvals are signed as
<reviewer_email>. The link works until <time> (30 minutes).
When the helper's final line is saved, its decisions file holds the page's feedback block. Don't hand-parse it — give the file to the parser, which reads the helper's file and a block pasted from an older page (one with a "Generate feedback for Claude" button, rendered before pages saved themselves) alike, handles the whole grammar (the profile: line, the exclude/include tables|columns: lists, and the curate-ops / new-metrics / new-examples / example-edits / key-terminology / datasource-md JSON blocks) and translates the exclude/include lists into curate ops:
bash "${CLAUDE_PLUGIN_ROOT}/scripts/py" parse_model_feedback.py --block-file "<artifacts_dir>/local/tmp/agami-page-$ts.json" \
--expect-profile "$profile"
--expect-profile is the profile the page was rendered for: a decisions file from another page or for another model is refused ({"ok": false, "error"}, exit 2; say the error in one line and apply nothing), and the parser drops the block's own signed-off-by: line, so the signer can only be .config's.
It prints {data, anomalies, needs_judgment}:
data.profile — the page's target model. Use it, overriding the active-profile default (a page was rendered for THAT model; never apply it to whatever's active).data.ops — the merged curate ops array (exclude/include for tables/columns, translated, plus the curate-ops approve/reject/edit/add/move verbatim, with move ops last). Apply in one sm curate "$ROOT" --ops-file <json> call (Phase 6).data.new_metrics_by_area — {area: [metric…]} → one sm add "$ROOT" --kind metric --area <area> --file <json> per area. Each lands unreviewed: the parser drops any sign-off a new metric carries (an anomalies entry names it), so approving one is a separate approve op.data.examples_by_area — edited + new NL→SQL examples {area: [example…]} → one sm add-example "$ROOT" --area <area> --file <json> per area (dedups by question).{"op": "reject", "kind": "example", "area": "<area>", "question": "<question>"} op in the same sm curate batch (Phase 6), or sm remove-example "$ROOT" --question "<area>/<question>" (repeat --question; with no --area one call covers every area, and a bare question found in more than one area is refused, not rejected everywhere).data.key_terminology — the complete glossary object → sm set-terminology "$ROOT" --file <json> --replace.data.datasource_md — the full datasource.md text (already decoded) → Write it to <artifacts_dir>/<profile>/datasource.md (overwrite; human narrative only).data.signer / data.role — on the page path they are always null (the parser drops them) and the signer is the saved reviewer_email / reviewer_role from .config, the identity the page showed. For a block pasted from an older page, it is the curator identity for --signer/--role (recorded on every op; required on an approve): persist it with sm set-config "<artifacts_dir>" --identity-file … as Phase 0 does (reviewer_email/reviewer_role, other keys kept, 0600) so future sessions don't re-ask; if absent on an approve-bearing batch, fall back to .config, then the identity card (Phase 0).If needs_judgment is set, stop and ask — malformed_targets (a table without its <area>. prefix → "Tables need a subject-area prefix — sales.STG_LEADS, not STG_LEADS. Did you mean that?") or unparseable_json (that part of the page's save didn't read; nothing is applied, and Review on a page opens a fresh page). Don't apply a partial block.
Rule 1 guard (judgment): before applying an approve on a metric, confirm its calculation is non-empty — for an introspected metric with an empty calculation, say it was left unapproved and ask for its definition on a card.
One line from what the commands returned, counted by kind from sm curate's applied (approve metric …, exclude table …/<table>.<column>), never from the page's own count: "Approved 18 metrics and hid 6 columns." List skipped[] and stale[] on their own lines, and the validator's errors verbatim if it refused the batch (nothing was changed then). Delete the decisions file. Then ask again the card it was picked on, recounted with sm review-items (and sm sensitive for the personal-data question): an item decided on the page is not asked again, and when nothing is left, say so and go where that card's flow goes when it is done. The page served once; Review on a page again renders and serves a new one.
sm curateEvery write in this skill is one sm curate batch: the ops Claude builds from a card answer (Phases 2–4), or data.ops from what the full view saved (5b), which is already the merged ops array — exclude/include translated + the curate-ops approve/reject/edit verbatim. The shape, for reference:
[
{"op": "exclude", "kind": "table", "area": "sales", "name": "STG_LEADS"},
{"op": "exclude", "kind": "table", "area": "sales", "name": "CUSTOMERS", "column": "EMAIL"},
{"op": "approve", "kind": "metric", "area": "sales", "name": "total_revenue", "at": "2026-06-10T17:51:41Z"},
{"op": "reject", "kind": "entity", "area": "sales", "name": "region"},
{"op": "exclude", "kind": "metric", "area": "sales", "name": "avg_discount", "reason": "not a real metric"},
{"op": "approve", "kind": "relationship", "area": "sales", "name": "orders->customers", "at": "2026-06-10T17:51:41Z"},
{"op": "add", "kind": "relationship", "from_table": "orders", "from_column": "cust_ref",
"to_table": "customers", "to_column": "id", "relationship": "many_to_one"},
{"op": "move", "kind": "table", "area": "sales", "name": "shipments", "to_area": "fulfilment"},
{"op": "approve", "kind": "placeholder", "area": "sales", "name": "date_dim", "column": "date_key", "value": "-99999", "meaning": "unknown"},
{"op": "reject", "kind": "example", "area": "sales", "question": "How many orders last month?"}
]
A reject on kind: example (#608) rejects that example exactly as sm remove-example does — status: rejected, kept in examples.yaml for audit, dropped from the runtime ranker — matched on the trimmed question in that area (both required). It is part of the batch: when the batch fails validation or errors, the example change is undone with the rest. An unknown area, a question that matches nothing or one already rejected is skipped with a reason. reject is the only op on an example (there is no include: a reject doesn't keep the prior status to restore).
An add (the explorer's + Add a join on the Joins tab) writes a new join. It takes from_table, to_table, relationship (many_to_one / one_to_one / one_to_many) and either from_column + to_column or an on condition for a key over several columns or a filtered join ("on": "orders.region = customers.region AND orders.cust_no = customers.cust_no"); from_schema / to_schema, join_type and description are optional. It needs no area: a join between two tables of one area goes in that area, one between two areas goes in the cross-area joins. It is always written unreviewed, so it shows in the Review tab for sign-off (an add never approves). A table or column the model doesn't serve (missing, excluded or stale) fails the batch and undoes it, and so does any column an on names (a filter or a cast too, and beside an explicit from_column / to_column) that isn't on one of the join's two tables, written <table>.<column> (<schema>.<table>.<column> when both tables share a name); the same join already in the model is skipped with a reason in skipped (an on that differs only in a quoted value's case, 'Y' against 'y' or $$Y$$ against $$y$$, is another join, approved or rejected on its own by passing its on). The join is placed by the areas that serve its two tables. The join is written with the model's own spelling of its tables and columns. Joins introspection tested but didn't write are listed in <ROOT>/.introspect/join_candidates.json, each as a ready add op; to accept one, run sm curate "$ROOT" --ops-file "$ROOT/.introspect/join_candidates.json" --candidate <id> (see agami-connect 1.7).
Placeholder values (the Review tab's Placeholders pile, #445) are stored values introspection thinks stand for something else — an Unknown row keyed -99999, a 9999-12-31 valid-to, '-' filler. The person picks what each means: unknown (left out of breakdowns, date ranges and latest/earliest, kept in totals), current (an open-ended row, what "as of now" questions want) or not_set (treated like NULL) — an approve op with that meaning, which also writes the meaning as a caveat on the column — or Real data (reject). An approval needs a person's signed-off-by: line; a system sign-off is refused. Nothing ever filters a query: the meaning is served with the column and the query path follows it.
A move (the explorer's Move to area) gives the table a new owning area, created if the model doesn't have it yet. Its joins follow it (a join that now spans two areas becomes a cross-area join, and the reverse), and the metrics and entities on it move too once every table they read is in the new area. Ones that also read a table outside it stay; the result's notes lists them ("left in sales: metric units_per_order also reads orders"). A join the new area already holds is kept once: a person's sign-off over the engine's approval, and that over an unreviewed copy; two copies a person signed off that disagree refuse the move until one is approved or rejected to match. Pass notes on to the user verbatim; a batch that was undone reports none.
(Column exclusions use kind: table + a column field — the engine flips the column inside that table's YAML.) Write the ops array to the file with the Write tool — never a heredoc, a shell variable (printf "$OPS"), or python3 -c (JSON quotes/null break those). Then apply the whole batch atomically — the engine flips review_state / stamps sign-off, validates the model, logs to curation_log.jsonl, commits (when the profile folder is its own git repository), and reverts everything on validation failure:
bash "${CLAUDE_PLUGIN_ROOT}/scripts/sm" curate "$ROOT" \
--ops-file "<artifacts_dir>/local/tmp/agami-model-ops.json" \
--signer "${reviewer_email}" --role "${reviewer_role}"
ROOT="<artifacts_dir>/<profile>". --signer/--role come from Phase 0. They are recorded in curation_log.jsonl on every op the batch applies (exclude, include, approve, reject and edit); an approve also stamps them on the item as its sign-off, while an edit that changes what an approved item computes or connects sends it back to review as stale instead of re-stamping it. An edit never sets a sign-off field (review_state, signed_off_*, confidence, migrated_from): sm curate skips it, so change a state with approve / reject / include. Resolve them before applying if the batch has any approve op — the validator rejects an approved entry with no sign-off stamp. Stdout is JSON: {applied, skipped, errors, validated, committed}, plus commit_note when nothing was committed (see the edge-case table), stale when an edit sent approved items back to review, and provenance_changed ([{item, from, to}]) when an op replaced a table or column description's description_source — tell the user whose words the description is now.
Success (validated: true):
skipped[] (bad target / not found) on their own lines.Failure (validated: false):
errors verbatim. Stop; don't re-render.area names a join, entity or metric that isn't in the model, or one that matches more than one entry (e.g. two joins between the same tables): the error names the op and the candidates. Re-send the op with from_column / to_column (or area for an entity or metric), never drop it. An op without area is searched for in every subject area and in the cross-area joins, entities and metrics (an entity or metric whose declared name equals the op's name exactly wins over others that only share its slug); an op that names an area and misses its target is listed in skipped[] as before.Excluded entries vanish from the runtime model (the loader drops review_state: rejected) but stay in sm model-tree and the full view (both load with include_rejected=True) so the person can bring them back with an include.
When the person says done (in a card's "Other" or as a message) or dismisses the overview card, post the final state from sm model-tree and sm review-items:
Done. <X> tables and <Y> columns are hidden; <P> definitions still need sign-off.
Hidden tables and columns are never read by a query. To bring one back, run /agami-model and
say which.
The skill is one-shot per invocation; re-enter via the slash command or a natural-language request.
| Case | Behavior |
|---|---|
User types exclude tables: schema.table for a table that's already excluded | The applier still runs (idempotent flip to rejected with the curator's name on the curation log). No-op for the YAML, but the audit trail records the re-confirm. |
User types include tables: schema.table for a table that's already unreviewed | Same — idempotent flip; entry stays unreviewed; curator name recorded. |
User types exclude columns: schema.table.col and the column doesn't exist | The applier returns it in skipped[] with reason "field not found on dataset". Surface the skip; continue with the rest. |
User types exclude tables: schema.table.col (3 segments — looks like a column) | The grammar is positional; agami treats the exclude tables: prefix as authoritative. The applier will fail to find a table with that 3-segment name and return skipped with reason "table yaml not found". Surface clearly. |
| Validator fails on a partially-applied batch | The applier restores every file it touched from its own backups (no git needed) before returning. applied counts are zeroed in the response (defense against partial-apply confusion). The user sees validator_output verbatim and can fix + retry. |
committed: false with a commit_note | Nothing went wrong — the change is written and validated; it just wasn't committed. Pass the note on in one line, in your own words: the model isn't in git (the change is still in curation_log.jsonl — sm history <root> lists what changed, newest first; git init in its folder keeps whole file versions too), or it's inside a larger repository (agami never commits there — tell them which folder changed so they commit it themselves). |
| The model has 5000+ fields | The renderer handles it (JSON manifest is ~hundreds of KB at the high end). Client-side search is instant up to the millions of DOM nodes mark. If it gets sluggish, file an issue. |
sm approve-queue)The cards are the default; where there are no cards and no person to answer them (a script, or a host without AskUserQuestion that would rather not walk the queue as a numbered list), sign off the whole pending queue from the CLI instead. sm approve-queue reads the same queue Phase 2 shows (Rule 1 metrics/named-filters + Rule 2 joins/entities), stamps each item, and applies it in one call:
ROOT="<artifacts_dir>/<profile>"
bash "${CLAUDE_PLUGIN_ROOT}/scripts/sm" approve-queue "$ROOT" --signer [email protected] --role owner
# --kind metric|entity|relationship → narrow to one type (repeatable)
# --dry-run → print the approve ops without applying
placeholders_awaiting_choice (one plain-words question each) — ask the person and write each answer with a kind: placeholder curate op (above).changed_since_approval lists what changed on each since its last approval (or changes not recorded). Show it to the user before approving — re-approving records the new signer and time.--signer and --role are required — an approve must record who signed off (the validator rejects an approved entry with no sign-off stamp). The command self-stamps the at timestamp, so you don't build ops by hand.sm review-queue "$ROOT" shows counts.total at the number of placeholders still waiting (0 when none) and sm curate-gate "$ROOT" drops preseed_count to 0.curate-gate may still report should_open_explorer: true purely because sensitive columns remain queryable — that's advisory (your call to exclude or keep them), not a gate on seed generation. Only unreviewed pre-seed items (metrics/entities) block seed-examples; approving the queue clears that.rejected entriesThe trust spine has always read agami.review_state. The model loader in plugins/agami/skills/agami-query/SKILL.md → Phase 1c filters entries with review_state: rejected out of datasets_by_name, datasets_by_qname, fields_by_qname, and relationships_by_endpoints. Rejected entries:
review_state: unreviewed, which is what puts it in the report's approve/change banner.)include them later without re-introspect.Reject (on a review card, or the full view's Review tab) and Hide / Exclude (on tables/columns) are the same rejected operation — this skill is the one surface for both the bulk tables-as-units curation and the per-entry sign-off.
You: I don't want PII columns in any query
agami: 3 metrics need sign-off.
| Subject area | Tables | Hidden |
|--------------|--------|--------|
| sales | 12 | 0 |
| support | 4 | 0 |
Showing 2 of 2 subject areas.
4 columns are flagged as personal data and are still queryable: they can
be counted and filtered, and nothing stops a query returning their values.
1 more has a name that suggests personal data but isn't flagged; check it
on the full view's PII tab.
[card "Model": Review what needs sign-off (Recommended) / Hide tables or columns /
Look up a table or metric / Show the full view] → Hide tables or columns
[card "Hide": Personal-data columns (5) / Pick by subject area / Nothing for now]
→ Personal-data columns (5)
[card "Personal": customers (3: email, phone, ip_address (suspected)) /
leads (2: email, ssn) / Keep them queryable] → both tables
agami: Hidden 5 columns; 0 personal-data columns are still queryable.
You: I never want agami to use the staging tables
[card "Hide": Staging and backup tables (2) / Pick by subject area / Nothing for now]
→ Staging and backup tables (2) (the table above the card listed sales.stg_leads,
sales.customer_score_stg)
agami: Hidden 2 tables.
What SKILL.md sets; muted values are Claude Code's defaults
Use for BOTH model curation and trust review. Curation: 'open the model explorer', 'show me the model', 'browse my tables', 'exclude a table', 'remove this column', 'I don't want PII columns', 'add a metric', 'edit datasource.md', 'add an example', 'add my own examples', '/agami-model'. Review / sign-off: 'open the review dashboard', 'review my model', 'what needs review', 'sign off the metrics', 'approve the metrics', 'walk the review queue', '/agami-review' (now folded in here) — or after agami-connect's Phase 4 sign-off gate or Phase 7 summary prompts to review or inspect the model. Also use when the user replies to a previously-served full view with its back-channel block (exclude tables: … / curate-ops: … / new-metrics: … / done).
Three short reads, in order
npx claudepluginhub agamiai/agami-core --plugin agami-core9 skills in this plugin
/agami-connectEnd-to-end database connection for agami: sets up credentials on first run (DB-type picker → writes <artifacts_dir>/local/credentials.example for the user to fill in), then introspects the live DB directly into the agami semantic model (subject areas, tables, columns, relationships with join cardinality, deep-table column groups, sensitive-column flags) under <artifacts_dir>/<profile>/. The structural model is built deterministically by the agami-core semantic_model package (catalog mode, or a probe-mode fallback when the catalog is locked down); the skill then layers LLM enrichment (descriptions, entities, metrics) and seeds EXPLAIN-validated NL→SQL examples. Every model write is gated by the semantic-model validator — no breaking model is ever persisted./agami-deployEARLY ACCESS (in testing) — usable today, but newer than the local single-player path; feedback welcome via a GitHub issue. Prepares a ready-to-run, self-hosted agami deploy bundle ON THE USER'S MACHINE so a team can stand up a shareable MCP server their Claude connects to. Conversationally gathers the hard-floor inputs (hostname, admin identity), auto-detects the local model, writes docker-compose.yml + Caddyfile + a filled agami.env (referencing the PUBLISHED image ghcr.io/agamiai/agami-core — no clone, no build), and stages the model artifacts. Generates the signing secret via deploy_preflight; the admin password is typed by the user into the file (never in chat). Then runs `docker compose up` if Docker is local, otherwise prints the exact VM steps + the shareable MCP URL. Username/password auth only on this paved path./agami-evalRuns the golden evaluation harness for a profile. Picks one golden dataset, regenerates SQL for every question in it, executes each statement against the org's own warehouse, scores the result against the confirmed answer key, and reports the verdicts — failures first, with the errored, the unscored and the unconfirmed each kept separate. Scoring is deterministic and happens in agami-core; the skill reports it and never re-judges it. Neither the answer key nor the generated statement is printed: both stay in a local JSON artifact the report points at./agami-queryAnswers natural-language questions about the user's database. Loads the agami semantic model (subject areas, tables, columns, relationships with join cardinality, entities, metrics) and few-shot examples from <artifacts_dir>/<profile>/, generates SQL via the examples-first traversal (pick subject area → match examples → resolve entities/metrics → compound table context), executes it locally via the user's chosen tool (psql / mysql / snowsql / sqlite3 native CLI, DuckDB binary, or the Python driver `execute_sql.py` — which runs the scope gates and reports fan-trap/chasm-trap and aggregation findings on the receipt), returns results as a markdown table with optional CSV export, and renders Chart.js HTML charts on request. All execution is local — no data leaves the machine./agami-reconcileReconciles known (label, expected_value) numbers from an existing dashboard against agami's answers. Input can be a SCREENSHOT of a Metabase / Power BI / Tableau / Looker dashboard (Claude's vision extracts the pairs), a CSV, or numbers pasted inline — the user doesn't need to know which; they can just ask. For each pair, the skill generates a matching NL question, runs it through the active profile's semantic model, diffs actual vs expected, and surfaces matches in green and mismatches in red with drill-down receipts. The strongest onboarding demo for a skeptical data engineer — either we agree with their numbers (trust earned via evidence) or we surface a real definitional disagreement (trust earned via transparency)./agami-save-correctionSaves a user correction so future queries learn from it. Always appends a (question, corrected_sql) pair to the subject area's example library under <artifacts_dir>/<profile>/prompt_examples/<area>/. Additionally, classifies the correction and — when applicable — applies a surgical edit to the semantic model itself (relationship fix, column metadata, or new metric) via the curation engine. Every model edit is validated before write; the validator is the binding gate, and a failed validation reverts. Shows the user a model diff for approval before any model mutation.Other plugins' skills for the same job