Generation Tools

The Tier 2 tools draft table definitions, diagrams and change scripts for you to review. They also store the database connections the Deploy tools use. None of them writes to your schema package.

By the SchemaSmith Team · Last reviewed

Ask Forge generation tools

Tools that produce new content: table definitions, migration scripts, change analysis.

The Generate Tier

The Tier 2 tools produce content and hand it back to you: table definitions, a diagram of your data model, or an analysis of a change with the scripts it needs. They do not write to your schema package. Writing is the job of the Modify tools. schemasmith_manage_connection is the one Tier 2 tool that saves anything: it writes a database connection to your settings file, not to the package.

None of these tools asks for confirmation. Over MCP they take no confirm parameter, and on the CLI they run without a prompt. In the REPL, the conversational agent can use them at the default assistant trust level; Trust Levels covers what each level allows.

Over MCP, schemasmith_generate_schema and schemasmith_suggest_changes are in the server's tool list. schemasmith_generate_diagram and schemasmith_manage_connection are not, so an AI assistant reaches them through schemasmith_execute_tool, passing generate_diagram or manage_connection as tool_name. Tool Visibility explains which tools the server lists.

On the CLI, each tool is a subcommand and each parameter an option, both in kebab-case: schemasmith_suggest_changes with default_value becomes ask-forge suggest-changes --default-value. Add --help to any command for its full list of options.

Schema Generation

Describe the tables you want, and the tool turns the description into table JSON for your package's platform.

schemasmith_generate_schema

Generates table JSON from a blueprint: a JSON description of the tables you want, their columns, and the relationships between them. An AI assistant builds the blueprint from your plain-language request. The tool picks each platform's data types, adds a primary key, wires the foreign keys, and creates a junction table for each many-to-many relationship. When a template is selected, it follows that template's existing naming conventions. Nothing is written to disk. Inside a schema template, the generated tables carry no schema, so each tenant's schema is resolved at deploy time.

ParameterRequiredDescription
blueprintYesThe blueprint, as a JSON string. It has a Name and a list of Tables. Each table has Columns, each with a Name and optionally a Type, Required, Unique, Description and Default, and Relationships, each naming a TargetTable and a Type of one-to-many, many-to-many or one-to-one. Options adds audit or soft-delete columns and sets the primary-key strategy
platformNoThe platform to generate for. Defaults to the loaded package's platform

A Type can be a portable type, such as string(200), int or datetime, which the tool maps to each platform's own type. Any other value is passed through as a platform type. This blueprint describes two tables, where each post belongs to an author:

{
  "Name": "Blog",
  "Tables": [
    { "Name": "Authors",
      "Columns": [{ "Name": "DisplayName", "Type": "string(100)",
                    "Required": true }] },
    { "Name": "Posts",
      "Columns": [{ "Name": "Title", "Type": "string(200)", "Required": true },
                  { "Name": "PublishedAt", "Type": "datetime" }],
      "Relationships": [{ "TargetTable": "Authors", "Type": "one-to-many" }] }
  ],
  "Options": { "IncludeAuditColumns": true }
}
ask-forge generate-schema --blueprint <json>

Generate, Review, Apply

Generating and writing are two steps by design, so you see what will be created before any file is written. From an AI assistant over MCP:

  1. Ask. For example: "Generate a schema for a blog system with Posts, Authors, Tags, and Comments. Posts have many Tags and many Comments. Authors write Posts."
  2. Generate. The AI builds the blueprint and calls schemasmith_generate_schema. The result lists each table with its column count and marks the junction tables.
  3. Review. Read the tables, ask for changes, and generate again until they are what you want.
  4. Apply. Ask the AI to write them. It calls schemasmith_apply_generated_schema, a Modify tool, which writes one JSON file per table into the template and runs only with confirm: true. Every table is checked before any is written, so one refused table means none are written.
  5. Commit. Review the new files in source control and commit them. SchemaQuench creates the tables at the next deployment.

For a single table, or a change to a table you already have, use the Modify tools directly: schemasmith_create_table creates a table that follows the template's conventions, and schemasmith_apply_change adds or changes a column, an index, or a key. Both are described under Tables and Columns.

Diagrams

The data model, as text you can paste into a README, a wiki page, or an issue.

schemasmith_generate_diagram

Emits the selected template's tables, and the foreign keys between them, as Mermaid or DBML. Mermaid renders in GitHub, GitLab and most wikis with nothing installed. DBML renders at dbdiagram.io and carries more type and index detail. The template scope draws every table and its relationships. The table scope shows one table's columns and keys, and in DBML its indexes, and draws no relationships. Inside a schema template, tables keep the {{SchemaName}} token as written, because the diagram describes the package rather than one tenant's deployment. A table that cannot be read is reported in the output rather than left out. The tool needs a loaded package and a selected template.

ParameterRequiredDescription
scopeNotemplate, the default, for every table and the foreign keys between them, or table for one table
tableNoThe table to diagram. Required when the scope is table
formatNomermaid, the default, or dbml
ask-forge generate-diagram --format dbml

Change Analysis

Before you change a table, check what the change could break.

schemasmith_suggest_changes

Analyzes a proposed change and generates the scripts it needs. It covers four kinds of change: making a column NOT NULL (nullability), adding a foreign key (add_fk), changing a column's data type (change_type), and adding a unique constraint (add_unique). It returns a risk level, the issues the change could run into, and suggested actions in priority order. Each action that needs one comes with a script, such as a query that reviews the rows the change affects. In generate or both mode it also returns the migration script for a nullability, foreign-key or type change, such as the UPDATE that replaces NULLs before a column becomes NOT NULL. It works from the package, not the database, so run its review queries against your data to see what they find. In both mode, materialized views (PostgreSQL) and indexed views (SQL Server) that reference the table are flagged too. The tool needs a selected template, and the table must be in it.

ParameterRequiredDescription
change_typeYesnullability, add_fk, change_type or add_unique
tableYesThe table the change is on
columnNoThe column the change is on. Needed for every change type but add_unique when a migration script is generated
modeNoboth, the default, for the analysis and the migration script; analyze for the analysis only; generate for the migration script only
default_valueNoThe value NULLs are set to. Needed for a nullability change when a migration script is generated
ref_tableNoThe table a new foreign key references
ref_columnNoThe column a new foreign key references
new_typeNoThe new data type, for a type change
columnsNoThe columns of a new unique constraint, comma-separated
ask-forge suggest-changes --change-type add_unique --table Users --columns Email

Connection Management

The Deploy tools connect to a database through the connection stored for its platform.

schemasmith_manage_connection

Stores or clears a platform's database connection in the connections section of your settings file, one connection per platform. MariaDB has its own connection, separate from MySQL's. set creates a connection or updates one, so you can give the server first and the database later; the fields you leave out keep their values. clear removes the connection and its stored password. A literal password goes to your operating system's credential store and is never written to the file. On a host with no credential store it is not saved: the connection works for the rest of the session, and the tool says so. A ${ENV_VAR} reference is stored as written and read from the environment each time the connection is used. Connections lists every field.

ParameterRequiredDescription
actionYesset or clear
platformYesSqlServer, PostgreSQL, MySQL or MariaDb
serverNoThe server or host. Needed for a new connection
portNoThe port, when it is not the platform's default
databaseNoThe database
userNoThe user
passwordNoThe password, or a ${ENV_VAR} reference
connection_propertiesNoExtra connection-string properties, as a JSON object
integrated_securityNoSQL Server only. Use Windows Authentication for this connection, in place of a stored user and password
ask-forge manage-connection --action set --platform PostgreSQL --server db01

Shape. Strengthen. Succeed.

Free schema-as-code for SQL Server, PostgreSQL, MySQL, and MariaDB.

The source is on GitHub for anyone to read.

Get Started on GitHub