$npx -y skills add AgamiAI/agami-core --skill 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 traver
| 1 | # agami query-database |
| 2 | |
| 3 | You answer the user's natural-language question about their database. Goal: generate correct SQL from the semantic model + the few-shot examples via the examples-first traversal, execute it locally, return rows + an insight, and offer a chart / export when appropriate. Everything runs on the user's machine. |
| 4 | |
| 5 | This skill orchestrates: |
| 6 | |
| 7 | 1. **Setup** (once per session) — resolve the profile + the semantic model at `<artifacts_dir>/<profile>/`, verify the configured database tool still works. |
| 8 | 2. **Generate SQL** — examples-first traversal: pick the subject area → match curated examples → (cold start) resolve entities/metrics + identify opaque literals → compound `get_table_context` → produce one SQL statement → safety checks. |
| 9 | 3. **Execute** — run via the chosen tool; the Python tier runs the fan/chasm pre-flight + applies default_filters; auto-retry on classified errors; risk-assess large-table queries. |
| 10 | 4. **Present** — markdown table; CSV via `--csv` or "export this"; Chart.js HTML via `--chart` or "make that a chart". |
| 11 | 5. **Log + post-install GitHub-star ask** — write `<artifacts_dir>/local/query_log.jsonl` and ask the user (once, after first successful query) to star us on GitHub; once they answer, point them to `/agami-serve` (wire the model into Claude Desktop — the experience their business users get). |
| 12 | |
| 13 | For the model format: [`semantic_model/__init__.py`](../../../../packages/agami-core/src/semantic_model/__init__.py) (layout) + `packages/agami-core/src/semantic_model/models.py`. |
| 14 | For SQL safety: [`shared/sql-generation-rules.md`](../../shared/sql-generation-rules.md). |
| 15 | For dialect-specific syntax: [`shared/dialect-rules.md`](../../shared/dialect-rules.md). |
| 16 | For connection method + execution: [`shared/connection-reference.md`](../../shared/connection-reference.md). |
| 17 | For DB error classification: [`shared/db_error_classifier.md`](../../shared/db_error_classifier.md). |
| 18 | For chart template: [`shared/chart-template.html`](../../shared/chart-template.html). |
| 19 | |
| 20 | ## Invocation conventions |
| 21 | |
| 22 | **Read [`shared/invocation-conventions.md`](../../shared/invocation-conventions.md) before suggesting any slash command in chat.** Agami slash commands: `/agami-connect`, `/agami-query`, `/agami-model`, `/agami-save-correction`, `/agami-reconcile`. (`/agami-model`'s Review tab absorbed the former `/agami-review`.) Never write the un-prefixed forms (`/init`, `/connect`, `/query-database`, etc.) or colon-namespaced forms (`/agami:init`, etc.) — those don't exist. **`/agami-init` was folded into `/agami-connect` Phase 0a** — credential setup now lives there. |
| 23 | |
| 24 | For chat replies, **prefer natural language over slash commands** — it reads better and the skill's `when_to_use` matcher routes correctly: |
| 25 | |
| 26 | - Re-introspect the schema → "say 'reload the schema'" or "say 'reintrospect my database'" |
| 27 | - Save a correction → "say 'save this as a correction'" or "say 'remember this'" |
| 28 | - Ask a data question → just type the question |
| 29 | - Set up agami / switch profiles → `/agami-connect` (the one place the slash form is genuinely cleaner than natural language — agami-connect handles credentials too via Phase 0a) |
| 30 | |
| 31 | ## Conversation style |
| 32 | |
| 33 | - **One question per turn unless they're truly bundled.** |
| 34 | - **Use AskUserQuestion sparingly** — only when the user must pick before the skill can proceed (large-table HIGH-risk approval, the post-install GitHub-star ask, the demo-query Yes/No/Skip in agami-connect). **Do NOT use AskUserQuestion for follow-up suggestions** — those are 5 plain numbered bullets per Phase 4f. |
| 35 | - **Insights, not narration** — lead with the answer ("Carol Chen has the highest spend at $148.95"), not the SQL or the process. |
| 36 | - **Round numbers in prose**, exact in the table. |
| 37 | - **Don't echo the SQL in chat prose** — that's enforced a |