-
Notifications
You must be signed in to change notification settings - Fork 3
DEV-1233: CLI improve help with descriptions and examples #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
AivanF
merged 5 commits into
main
from
aivan/dev-1233-cli-improve-help-with-descriptions-and-examples
Apr 10, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| # CLI Setup — Terminal Users | ||
|
|
||
| Query your database from the command line. No Python code needed — just install and go. | ||
|
|
||
| ## Install | ||
|
|
||
| ```bash | ||
| uv tool install motley-slayer | ||
| ``` | ||
|
|
||
| For databases other than SQLite, add the driver extra (see [full list](../configuration/datasources.md#database-drivers)): | ||
|
|
||
| ```bash | ||
| uv tool install 'motley-slayer[postgres]' | ||
| ``` | ||
|
|
||
| ## Connect a database | ||
|
|
||
| Create a datasource — either from a YAML file or inline: | ||
|
|
||
| ```bash | ||
| # Inline (quick setup — use ${ENV_VAR} for secrets) | ||
| slayer datasources create-inline my_pg \ | ||
| --type postgres \ | ||
| --host localhost \ | ||
| --database myapp \ | ||
| --username analyst \ | ||
| --password-stdin | ||
|
|
||
| # Or from a YAML file | ||
| slayer datasources create datasource.yaml | ||
| ``` | ||
|
|
||
| YAML file format: | ||
|
|
||
| ```yaml | ||
| # datasource.yaml | ||
| name: my_pg | ||
| type: postgres | ||
| host: localhost | ||
| port: 5432 | ||
| database: myapp | ||
| username: analyst | ||
| password: ${DB_PASSWORD} | ||
| ``` | ||
|
|
||
| Test the connection: | ||
|
|
||
| ```bash | ||
| slayer datasources test my_pg | ||
| # OK — connected to 'my_pg' (postgres). | ||
| ``` | ||
|
|
||
| ## Ingest models | ||
|
|
||
| Auto-generate models from your database schema: | ||
|
|
||
| ```bash | ||
| slayer ingest --datasource my_pg | ||
| # Ingested: orders (6 dims, 12 measures) | ||
| # Ingested: customers (4 dims, 5 measures) | ||
| # Ingested: regions (3 dims, 2 measures) | ||
| ``` | ||
|
|
||
| Optionally filter tables: | ||
|
|
||
| ```bash | ||
| slayer ingest --datasource my_pg --schema public --include orders,customers | ||
| slayer ingest --datasource my_pg --exclude migrations,django_session | ||
| ``` | ||
|
|
||
| ## Query | ||
|
|
||
| ```bash | ||
| # Count orders by status | ||
| slayer query '{"source_model": "orders", "fields": [{"formula": "count"}], "dimensions": ["status"]}' | ||
|
|
||
| # From a file | ||
| slayer query @query.json | ||
|
|
||
| # Output as JSON (pipe-friendly) | ||
| slayer query @query.json --format json | ||
|
|
||
| # Preview the generated SQL without running it | ||
| slayer query @query.json --dry-run | ||
|
|
||
| # Show execution plan | ||
| slayer query @query.json --explain | ||
| ``` | ||
|
|
||
| ## Explore models | ||
|
|
||
| ```bash | ||
| slayer models list | ||
| slayer models show orders | ||
| slayer datasources list | ||
| ``` | ||
|
|
||
| ## Verify it works | ||
|
|
||
| After install + ingest, this should return data: | ||
|
|
||
| ```bash | ||
| slayer query '{"source_model": "orders", "fields": [{"formula": "count"}]}' | ||
| ``` | ||
|
|
||
| Expected output: | ||
|
|
||
| ``` | ||
| orders.count | ||
| ------------ | ||
| 42 | ||
|
|
||
| 1 row(s) | ||
| ``` | ||
|
|
||
| If you see "Model 'orders' not found", check that `slayer ingest` ran successfully and that `--storage` points to the right location. | ||
|
|
||
| ## Start a server (optional) | ||
|
|
||
| If you also want a REST API or MCP endpoint: | ||
|
|
||
| ```bash | ||
| slayer serve # REST API at http://localhost:5143 | ||
| slayer serve --storage slayer.db # Using SQLite storage | ||
| ``` | ||
|
|
||
| See the [CLI Reference](../reference/cli.md) for all commands and flags. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # Getting Started | ||
|
|
||
| SLayer is a semantic layer that sits between your database and whatever consumes the data — AI agents, apps, scripts, or dashboards. You define your data model once (or let SLayer auto-generate it), and consumers query using measures, dimensions, and filters instead of writing SQL. | ||
|
|
||
| ## Which interface is right for you? | ||
|
|
||
| | I want to... | Use | Guide | | ||
| |---|---|---| | ||
| | Connect an AI agent (Claude, Cursor) to my database | **MCP Server** | [MCP Setup](mcp.md) | | ||
| | Query from the terminal or scripts | **CLI** | [CLI Setup](cli.md) | | ||
| | Build an app that queries data (any language) | **REST API** | [REST API Setup](rest-api.md) | | ||
| | Use SLayer as a Python library | **Python SDK** | [Python Setup](python.md) | | ||
|
|
||
| All four interfaces use the same query language and the same models — pick the one that fits your workflow. You can use multiple interfaces simultaneously (e.g., MCP for your agent + REST API for your dashboard). | ||
|
|
||
| ## Supported Databases | ||
|
|
||
| SLayer works with most SQL databases. The base install includes SQLite support (no extras needed). | ||
|
|
||
| | Database | Install | Status | | ||
| |---|---|---| | ||
| | SQLite | included | Fully tested | | ||
| | PostgreSQL | `motley-slayer[postgres]` | Fully tested | | ||
| | MySQL / MariaDB | `motley-slayer[mysql]` | Fully tested | | ||
| | ClickHouse | `motley-slayer[clickhouse]` | Fully tested | | ||
| | DuckDB | `motley-slayer[duckdb]` | Fully tested | | ||
| | Snowflake, BigQuery, Redshift, Trino, Databricks, MS SQL, Oracle | Covered by sqlglot | SQL generation tested | | ||
|
|
||
| ## Next Steps | ||
|
|
||
| After setting up your interface, explore: | ||
|
|
||
| - [Terminology](../concepts/terminology.md) — key terms and concepts | ||
| - [Models](../concepts/models.md) — define custom dimensions and measures | ||
| - [Queries](../concepts/queries.md) — query structure and parameters | ||
| - [Formulas](../concepts/formulas.md) — transforms, arithmetic, filters | ||
| - [Examples](../examples/01_dynamic/dynamic.md) — interactive notebooks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| # MCP Setup — AI Agents | ||
|
|
||
| Connect your AI agent (Claude Code, Cursor, etc.) to your database through SLayer's MCP server. No Python knowledge required. | ||
|
|
||
| ## Install | ||
|
|
||
| ```bash | ||
| uv tool install motley-slayer | ||
| ``` | ||
|
|
||
| For databases other than SQLite, add the driver extra (see [full list](../configuration/datasources.md#database-drivers)): | ||
|
|
||
| ```bash | ||
| uv tool install 'motley-slayer[postgres]' | ||
| ``` | ||
|
|
||
| ## Connect to your agent | ||
|
|
||
| ### Claude Code (stdio — recommended) | ||
|
|
||
| ```bash | ||
| claude mcp add slayer -- slayer mcp --storage ./slayer_data | ||
| ``` | ||
|
|
||
| If SLayer is in a virtualenv, use the full path to the executable: | ||
|
|
||
| ```bash | ||
| claude mcp add slayer -- $(which slayer) mcp --storage /absolute/path/to/slayer_data | ||
| ``` | ||
|
|
||
| ### Remote agents (HTTP/SSE) | ||
|
|
||
| Start the server, then point your agent at the SSE endpoint: | ||
|
|
||
| ```bash | ||
| slayer serve --storage ./slayer_data | ||
|
|
||
| # In another terminal / agent config: | ||
| claude mcp add slayer-remote --transport sse --url http://localhost:5143/mcp/sse | ||
| ``` | ||
|
|
||
| ## Connect a database | ||
|
|
||
| Once the agent is connected, it handles everything conversationally. A typical exchange: | ||
|
|
||
| > **You:** Connect to my Postgres database at localhost, database "myapp", user "analyst" | ||
| > | ||
| > **Agent:** *calls `create_datasource` → auto-ingests models → calls `datasource_summary`* | ||
| > | ||
| > "Connected! I found 4 tables: orders (12 dims, 8 measures), customers (5 dims, 3 measures), ..." | ||
| > | ||
| > **You:** How many orders per status? | ||
| > | ||
| > **Agent:** *calls `query(source_model="orders", fields=[{"formula": "count"}], dimensions=["status"])`* | ||
|
|
||
| The agent uses these MCP tools in order: | ||
|
|
||
| 1. `create_datasource` — connect to DB (auto-ingests models by default) | ||
| 2. `datasource_summary` — discover available models and their schemas | ||
| 3. `inspect_model` — see dimensions, measures, and sample data for a model | ||
| 4. `query` — run queries | ||
|
|
||
| See the [MCP Reference](../reference/mcp.md) for the full tools list. | ||
|
|
||
| ## Verify it works | ||
|
|
||
| Ask your agent: | ||
|
|
||
| > "List the available SLayer models" | ||
|
|
||
| The agent should call `datasource_summary` and return a list of your tables/models. If it says "no models found", check that: | ||
|
|
||
| 1. The `--storage` path is correct | ||
| 2. You've connected a datasource (or the agent has via `create_datasource`) | ||
| 3. Models were ingested (auto-ingest runs by default with `create_datasource`) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.