CodeStencil CLI
Overview
codestencil-cli runs CodeStencil from the command line: one command takes you from a database to a generated, modernized web app, with no windows or wizards. It uses the same stencils, schema library, projects and settings as the CodeStencil desktop app, so anything the CLI creates opens in CodeStencil and the other way round.
The CLI supports the two database-first ways of starting a project:
Path | Command | Starts from | Database |
Path 1 — Database First (DB import) | new db-import | A connection string to a database you already have | Your existing database |
Path 2 — Database First (Schema import) | new schema | A schema from the CodeStencil schema library | A new database the CLI creates and names for you |
A full run does the following, in order:
1. Create a project from the stencil you pick.
2. Build the schema dictionary from your database (Path 1) or from the library schema (Path 2), creating the database first for Path 2.
3. Seed test data with AI (Path 2 only, optional).
4. Generate the app — the same code the desktop app generates.
5. Modernize the UI with Claude Code and one of your predefined prompts (optional).
codestencil-cli · two paths into one project
Path 1 reads a database you already have; Path 2 creates a new one from a library schema. Both produce an ordinary CodeStencil project, from which the app is generated and, optionally, modernized.
Each step is also a command of its own (generate, seed, modernize), so you can rerun any of them later. Recipes save a whole run as a JSON file you can repeat on demand or in a build pipeline.
Requirements and installation
The CLI runs on Windows next to CodeStencil and needs only CodeStencil itself for listing and generating; the other tools are needed only by the features that use them.
Requirement | Needed for | Notes |
Windows 10 or 11 | Everything | The CLI reuses CodeStencil's Windows libraries. |
CodeStencil, installed and opened once | Everything | Provides the data folder %USERPROFILE%\CodeStencil (stencils, schema library, prompts, projects, settings). |
.NET SDK (the version your stencil targets) | new db-import; building and running generated apps | new db-import uses dotnet ef to read your database. |
dotnet-ef tool | new db-import | Installed automatically on first use if missing. |
Git | modernize | Used for the before/after snapshots. |
Claude Code, signed in | modernize | See Setting up Claude Code below. |
An AI API key (OpenAI, Anthropic or Google) | seed with an AI provider | Not needed for manual seeding. |
Installing the CLI
The CLI is installed with CodeStencil: codestencil-cli.exe is part of the CodeStencil package, next to CodeStencil.exe. There's nothing extra to install or add to PATH. Open a new Command Prompt or PowerShell window anywhere and type codestencil-cli. (Windows makes it available through an app execution alias. If the command isn't found, check that Settings → Apps → Advanced app settings → App execution aliases has CodeStencil CLI switched on.) codestencil-cli --version shows the installed version, which matches CodeStencil's.
Check that it can find your CodeStencil data:
codestencil-cli doctor
doctor lists the folders the CLI resolved and how many stencils, schemas and prompts it found, and flags anything missing. Its "Data folder chosen by" line says why it uses that data folder (see Data folder).
Setting up Claude Code
modernize starts Claude Code, Anthropic's command-line coding agent, on your PC. It is a separate install from the Claude desktop or web app.
1. In PowerShell, run irm https://claude.ai/install.ps1 | iex.
2. Open a new terminal and run claude once. Sign in with your Claude account (type /login if asked), then type /exit.
3. Check it with where claude in cmd (or where.exe claude in PowerShell).
If where finds nothing, the installer's folder (%USERPROFILE%\.local\bin) is not on your PATH. The CLI still finds Claude Code there, but adding the folder lets you run claude yourself.
AI keys for seeding
The CLI looks for a key in this order: an environment variable (OPENAI_API_KEY, ANTHROPIC_API_KEY, GEMINI_API_KEY or GOOGLE_API_KEY), then the keys saved in CodeStencil's settings.
Quick start
Pick a stencil, then run one new command: it creates the project and generates the app in one go.
1. See what you have:
codestencil-cli stencils list --schema-only
codestencil-cli schemas list scuba
codestencil-cli prompts list -f UIUX
2a. Path 1 — generate an app from an existing database:
codestencil-cli new db-import --stencil BlazorWebApp --connection "Data Source=C:\data\shop.sqlite" --name shop
2b. Path 2 — generate an app from a library schema, with a new SQLite database and 50 rows of AI test data:
codestencil-cli new schema --stencil BlazorWebApp --schema "Travel & Vacation\scuba-diving" --provider sqlite --name scuba --seed-rows 50 --seed-ai manual
3. Run the app:
dotnet run --project c:\temp\codestencil\shop\src\shop
The app's location is printed at the end of each new command (the Output folder and Solution lines). The admin login for apps that use ASP.NET Identity is in AdminCredentials.txt in the output folder.
4. Optional — modernize the UI with Claude Code:
codestencil-cli modernize shop --prompt UIUX\modernize-blazorWebApp
You can also add --modernize UIUX\modernize-blazorWebApp to step 2 to do everything in one command.
Key concepts
The CLI works with the same building blocks as the desktop app; this table says how each one is named on the command line.
Concept | What it is | How the CLI refers to it | Where it lives |
Stencil | The template that defines what kind of app is generated (for example BlazorWebApp, MudBlazorWebApp, DevExpressWebApp). | --stencil <name>, as shown by stencils list | %USERPROFILE%\CodeStencil\Stencils |
Schema library | Ready-made database designs, grouped by category. | --schema "<Category>\<schema>", a unique schema name, or a file path | The schema library folder shown by doctor |
Project | A .codestencilproj file: the stencil, the schema dictionary, settings and the output folder. Open it in CodeStencil like any other project. | The project name (e.g. scuba) or the file path | %USERPROFILE%\CodeStencil\Projects |
Schema dictionary | The project's description of your tables, columns, keys and lookups, used to generate the code. | Built by new db-import / new schema | Inside the project file |
Output folder | Where the generated app is written. | --output <folder>; default is CodeStencil's Output Folder setting plus the project name | Your choice |
Prompt | A predefined instruction file for modernize, managed in CodeStencil's Prompt Explorer. | --prompt <Folder\name> (e.g. UIUX\modernize-blazorWebApp), a unique name, or a file path | %USERPROFILE%\CodeStencil\PromptFolder |
Recipe | A JSON file listing CLI commands to run in order. | run <recipe> | Anywhere; samples in the CLI's Recipes folder |
Names with spaces or & (such as Travel & Vacation) must be in double quotes, otherwise cmd and PowerShell split the command at the &.
Project names use letters, digits and underscores. If you leave --name out, the CLI suggests one from the schema or database name and makes it unique.
Data folder
The CLI and the desktop app keep their working data in %USERPROFILE%\CodeStencil (for example C:\Users\you\CodeStencil): settings, stencils, the schema library, prompts, projects, SQLite databases, model folders and logs. doctor shows the folder in use.
To keep the data somewhere else, close CodeStencil and run codestencil-cli data move --to <folder> (add --dry-run first to see what it would do). It copies the folder, updates the paths stored in your projects, stencils and settings, and sets the CODESTENCIL_HOME environment variable so the CLI and the app both find the new location. The original folder is left as it is; delete it once the new one works.
Editions
The CLI uses the same license as the desktop app on that PC and applies the same limits. doctor shows your edition, who it's licensed to and when it expires.
Edition | Database providers | Tables per project |
Community (no license) | SQLite | up to 5 |
Professional | SQLite, SQL Server | no limit |
Enterprise and trials | SQLite, SQL Server, PostgreSQL, MySQL | no limit |
If your edition doesn't allow the provider or the number of tables, new schema and new db-import stop before creating anything (exit code 1) and say why. On Community, schemas list and the schema picker show schemas with more than 5 tables in yellow; with new db-import, choose up to 5 tables with --tables.
Database providers
Both paths work with SQLite, SQL Server, PostgreSQL and MySQL. Each was tested end to end with the BlazorWebApp stencil on both paths: import or create the database, seed it, generate the app, then add, edit, validate and delete records in the running app. The regression test (under Recipes) also generates and builds both paths on all four databases for the BlazorWebApp, MudBlazorWebApp and DevExpressWebApp stencils.
Database | --provider | Path 1 connection string (example) | Path 2 server (--server) | EF Core package in the app |
SQLite | sqlite | Data Source=C:\data\shop.db | Not used: the database is a new .sqlite file in --db-folder | Microsoft.EntityFrameworkCore.Sqlite |
SQL Server | sqlserver | Server=localhost\SQLEXPRESS;Database=shop;Integrated Security=True;TrustServerCertificate=True | Optional. Default: Server=localhost;Integrated Security=True;TrustServerCertificate=True | Microsoft.EntityFrameworkCore.SqlServer |
PostgreSQL | postgresql | Host=localhost;Port=5432;Database=shop;Username=postgres;Password=… | Required, e.g. Host=localhost;Port=5432;Username=postgres;Password=… | Npgsql.EntityFrameworkCore.PostgreSQL |
MySQL | mysql | Server=localhost;Port=3306;Database=shop;Uid=root;Pwd=… | Required, e.g. Server=localhost;Port=3306;Uid=root;Pwd=… | Microting.EntityFrameworkCore.MySql |
Server databases in Path 2
• --server is a connection string to the server without a database name. The CLI connects, creates the new database, and saves a connection string that includes it. To avoid typing it each time, set the CODESTENCIL_SERVER environment variable instead.
• The login must be allowed to create databases.
• On PostgreSQL and MySQL the generated database name is lowercase, for example scuba_diving_20261124_200139.
• A named SQL Server instance needs its name in the connection string. Run Get-Service MSSQL* in PowerShell: a service called MSSQL$SQLEXPRESS means the server is localhost\SQLEXPRESS. LocalDB is (localdb)\MSSQLLocalDB.
• Passwords in connection strings are masked in the CLI's output.
Things to know
• Desktop app. PostgreSQL and MySQL are still marked experimental in the CodeStencil desktop app. The CLI supports all four without extra settings.
• MySQL package. Pomelo, the usual MySQL provider, has no release for .NET 11, so BlazorWebApp apps (.NET 11) use Microting.EntityFrameworkCore.MySql, a maintained fork with the same API; MudBlazorWebApp and DevExpressWebApp apps (.NET 9) use Pomelo 9. Each app's Program.cs passes new MySqlServerVersion(new Version(8, 0, 36)), which suits MySQL 8.x; change it for MariaDB or older servers.
• MySQL table names. MySQL on Windows stores table names in lowercase. The generated app maps them, so nothing needs changing.
• Seed data must fit the columns. Some library schemas store phone numbers or postcodes as int, which can't hold a 10-digit number. The seed prompt asks the AI for values that fit, so expect short numbers such as 5550101 in those columns.
• Upgrading the CLI. Fixes to model classes (column types, required fields) reach an existing schema-library project only when its models are rebuilt: run generate <project> --all --refresh-models.
Path 1 — Import an existing database (new db-import)
new db-import turns a database you already have into a CodeStencil project and a generated app. Supported databases: SQLite, SQL Server, MySQL and PostgreSQL.
codestencil-cli new db-import --stencil <name> --connection "<connection string>" [options]
What it does
1. Connects and lists your tables and views before creating anything, so a wrong connection string fails straight away.
2. Creates the project from the stencil and saves the connection in it.
3. Reads the database with Entity Framework (dotnet ef dbcontext scaffold), exactly as the desktop import wizard does.
4. Builds the schema dictionary from the scaffolded classes, including keys, relationships and lookup columns (drop-downs show a name, not an ID).
5. Runs the post-import tasks (table labels, search columns, menus).
6. Generates the app.
Which tables are imported
All tables and views, except these, which the desktop wizard's users normally leave unticked: sqlite_*, __EFMigrationsHistory, sysdiagrams and the ASP.NET Identity tables (AspNet*). Use --tables to import exactly the ones you list, or --exclude to leave out more:
codestencil-cli new db-import --stencil BlazorWebApp --connection "..." --tables Customer,Order,OrderLine
codestencil-cli new db-import --stencil BlazorWebApp --connection "..." --exclude "Log*,Audit"
Changes made to your database
Important: if the stencil uses ASP.NET Identity (as BlazorWebApp does), the import adds the Identity tables to the database you import from, and replaces an existing admin user, just as the desktop app does. The CLI prints a note before it does this. Use --no-identity to leave your database untouched, or import a copy.
Nothing else in your database is changed.
Options
Option | Meaning |
-s, --stencil <name> | Stencil to use. Asked for if omitted. |
-c, --connection <string> | Connection string. Defaults to the CODESTENCIL_CONNECTION environment variable, which keeps passwords out of your command history. Asked for (hidden) if neither is given. |
-p, --provider <name> | sqlite, sqlserver, mysql or postgresql. Detected from the connection string if omitted; set it when detection is ambiguous (Data Source= is used by both SQLite and SQL Server). |
-n, --name <project> | Project name. Defaults to the database name, made unique. |
-o, --output <folder> | Folder the app is generated into. |
--namespace, --organization, --organization-label | Override the defaults from CodeStencil's settings. |
-t, --tables <list> | Comma-separated tables/views to import. |
-x, --exclude <list> | Extra tables/views to leave out; * and ? wildcards allowed. Not with --tables. |
--no-identity | Don't add ASP.NET Identity tables to the database. |
--modernize <prompt> | Modernize the app with Claude Code after generating it. |
--no-generate | Create and import only; generate later with generate. |
-f, --force | Overwrite an existing project with the same name. |
Examples
:: SQLite
codestencil-cli new db-import --stencil BlazorWebApp --connection "Data Source=C:\data\shop.sqlite" --name shop
:: SQL Server, password kept out of the command line
set CODESTENCIL_CONNECTION=Server=.;Database=Sales;User Id=app;Password=...;TrustServerCertificate=True
codestencil-cli new db-import --stencil BlazorWebApp --provider sqlserver --name sales
Things to know
• Column types come from Entity Framework: SQLite INTEGER becomes long (keys int), REAL becomes double, and date-only data or SQL Server date columns become DateOnly.
• Scaffolded model classes are written to the stencil's scaffold folder (EF_SCAFFOLD_FOLDER), which is shared by all projects, so a second import replaces the first one's classes there.
Path 2 — Start from the schema library (new schema)
new schema creates a brand-new database from a library schema, fills it with AI test data and generates the app, all in one command. The new database is a SQLite file, or a new database on a SQL Server, PostgreSQL or MySQL server (see Database providers above).
codestencil-cli new schema --stencil <name> --schema "<Category>\<schema>" [options]
What it does
1. Creates the project from the stencil.
2. Creates a new database with a name that doesn't exist yet, for example scuba_diving_20261124_040449.sqlite in %USERPROFILE%\CodeStencil\Databases, or scuba_diving_20261124_040449 on the server given by --server.
3. Imports the schema: creates the tables and the schema dictionary, then the model classes and post-import tasks (including ASP.NET Identity when the stencil uses it).
4. Seeds test data with AI: at least --seed-rows rows in the main table (the one with the most relationships), plus matching rows in the tables it refers to.
5. Generates the app.
If seeding fails (for example, the AI service is busy), the project, database and app are still created; the command reports it and exits with code 4, and you can seed later with seed.
Finding a schema
:: everything
codestencil-cli schemas list
:: name or key contains "scuba"
codestencil-cli schemas list scuba
:: one category
codestencil-cli schemas list -c "Travel & Vacation"
Pass the schema as its key ("Travel & Vacation\scuba-diving"), its name (scuba-diving), part of its name (scuba), or the path to a .codestencilschema file.
If one schema matches, the CLI uses it and prints its full key. If several match, you pick from a list of just those. With --non-interactive (and in recipes), the command stops instead and lists the matches, so give recipes a value that matches one schema. Leave --schema out to search the whole library: you're asked for an optional filter, then pick from a searchable list.
Options
Option | Meaning |
-s, --stencil <name> | Stencil to use. Asked for if omitted. |
--schema <key> | Library schema: its key, name, part of its name, or a file path. Several matches open a picker. Asked for (with a search) if omitted. |
-p, --provider <name> | Database type: sqlite (default), sqlserver, postgresql or mysql. |
-n, --name <project> | Project name. Defaults to the schema name, made unique. |
-o, --output <folder> | Folder the app is generated into. |
--namespace, --organization, --organization-label | Override the defaults from CodeStencil's settings. |
--db-name <name> | Database name, or auto (default): <schema>_<date>_<time>, made unique. |
--replace-db | With --db-name: drop an existing database of that name and create it again. For repeatable test runs; its data is lost. |
--server <connection> | Server to create the database on, without a database name. Required for PostgreSQL and MySQL; optional for SQL Server (default: local default instance). Falls back to CODESTENCIL_SERVER. Not used with SQLite. |
--db-folder <folder> | Folder for the database file. Default: %USERPROFILE%\CodeStencil\Databases. |
--seed-rows <n> | Minimum rows in the main table. Default 50. |
--seed-ai <provider> | openai, anthropic, google or manual. Default: the provider of CodeStencil's default AI model setting. |
--seed-model <id> | A specific model, e.g. gemini-3.6-flash. |
--no-seed | Leave the database empty. |
--modernize <prompt> | Modernize the app with Claude Code after generating it. |
--no-generate | Create the project and database only. |
-f, --force | Overwrite an existing project with the same name. |
Example
codestencil-cli new schema --stencil BlazorWebApp --schema "Travel & Vacation\scuba-diving" --provider sqlite --name scuba --seed-rows 50 --seed-ai google --modernize UIUX\modernize-blazorWebApp
Regenerate an app (generate)
generate regenerates the app for an existing project, producing the same output as Generate in the desktop app. Use it after changing the project in CodeStencil, or after updating a stencil.
codestencil-cli generate <project> [--all] [--truncate]
Option | Meaning |
<project> | Project name (from %USERPROFILE%\CodeStencil\Projects) or the path to a .codestencilproj file. |
-a, --all | Regenerate everything. Without it, generation is incremental, like the desktop app: tables and nodes unchanged since the last run are skipped. |
--truncate | Empty the output folder first, then regenerate everything (implies --all). |
--refresh-models | Rebuild the model classes and DbContext from the schema dictionary before generating. Use it after upgrading the CLI. Projects from new schema only; for an imported database, run new db-import --force again. |
The summary shows the output folder, the nodes processed and skipped, the files generated, any generation errors, and the path of the solution.
Regenerating replaces modernized UI. generate rewrites the generated files, so changes made by modernize are overwritten. They stay in the app's git history (see Modernize). Modernize after your last regeneration, or run it again.
Fill the database with test data (seed)
seed asks an AI to write realistic test data for a project created from the schema library, and runs it against the project's SQLite database in one transaction. If the script fails, nothing is changed.
codestencil-cli seed <project> [--rows 50] [--ai <provider>] [--model <id>] [--truncate]
Choosing the AI
--ai | What happens | Default model |
openai | Calls the OpenAI API with your key. | gpt-4o |
anthropic | Calls the Anthropic (Claude) API with your key. | claude-sonnet-5-5 |
Calls the Gemini API with your key. | gemini-3.8-flash | |
manual | No API key needed: the prompt is copied to your clipboard; paste it into any AI chat (ChatGPT, Claude, Gemini) and copy the SQL reply. The CLI picks it up from the clipboard by itself. Press Esc to cancel. | — |
Without --ai, the CLI uses the provider of CodeStencil's default AI model setting. Use --model for one run, or set CODESTENCIL_SEED_MODEL to change the default.
Busy services (errors 429, 500, 502, 503, 504, 529) are retried after 5, 15 and 30 seconds. If a model stays busy, try an older or lighter one, for example --model gemini-3.6-flash or --model gemini-3.5-flash-lite, or use --ai manual.
Options
Option | Meaning |
-r, --rows <n> | Minimum rows in the main table (the one with the most relationships). Default 50. The related tables get as many rows as they need. |
--ai <provider> | openai, anthropic, google or manual. |
--model <id> | The model to use. |
-t, --truncate | Empty the schema's tables first, in the same transaction, and restart their IDs at 1. User and login tables are not touched. Use it to reseed or to compare two AIs on the same database. |
--prompt-only | Only write the prompt to a file and the clipboard; don't seed. |
--sql <file> | Run this SQL file instead of asking an AI (for example, a reply you saved after --prompt-only). |
Examples
codestencil-cli seed scuba --rows 50 --ai google
codestencil-cli seed scuba --rows 100 --ai manual --truncate
codestencil-cli seed scuba --prompt-only
codestencil-cli seed scuba --sql C:\temp\scuba-seed.sql --truncate
Each run saves the prompt and the SQL in CodeStencil's AI-generated folder (%USERPROFILE%\CodeStencil\AIGeneratedFolder), named <project>-seed-<date>_<time>. The summary shows the rows in each table.
Seeding works with schema-library projects and SQLite databases. Each AI run is a paid API call on your account.
Modernize the UI with Claude Code (modernize)
modernize hands a generated app to Claude Code with one of your predefined prompts, and Claude redesigns the user interface: layout, navigation, dashboard, list and form pages, and styling. Every run is saved in git, so you can review the changes or undo them with one command.
codestencil-cli modernize <project> --prompt <prompt>
codestencil-cli modernize --folder <app folder> --prompt <prompt>
What it does
1. Snapshots the app in git. If the output folder isn't a git repository yet, the CLI creates one (with a .gitignore for bin, obj and .vs) and commits the generated code as the baseline.
2. Sends the prompt to Claude Code, plus a short set of ground rules the CLI always adds (below).
3. Shows Claude's progress as it works: each file it reads, edits or writes, and each build it runs.
4. Builds the app itself (dotnet build) to check that it still compiles.
5. Commits the result and prints a summary: turns, time, reported cost, files changed, build result, Claude's own summary of the changes, and the commands to review or undo them.
A typical run on a four-table app takes 8 to 11 minutes and changes 30 to 35 files.
Ground rules added to every prompt
• Change the UI only (Razor components, CSS, layout, navigation, static files).
• Don't change the database, the DbContext, the model classes, migrations, connection strings or package versions.
• Keep every list, create, edit, details and delete page and route working.
• Finish with dotnet build passing, and end with a summary of the changes.
The prompt also tells Claude which stencil, database provider and entities the app uses. Claude Code may edit files without asking, and may run only dotnet build, dotnet restore, git status and git diff; anything else (such as starting the app) is refused. Use --allow-tools to allow more.
Review or undo
The summary prints both commands with the real commit IDs:
git -C "c:\temp\codestencil\shop" diff <baseline> <result> --stat
git -C "c:\temp\codestencil\shop" reset --hard <baseline>
Options
Option | Meaning |
<project> or --folder <dir> | The project (its output folder is used) or any generated app's folder. One of the two. |
-p, --prompt <prompt> | Prompt key (e.g. UIUX\modernize-blazorWebApp), a unique prompt name, or a file path. Asked for if omitted. |
--extra "<text>" | Extra instructions added to the prompt. |
--show-prompt | Print the full prompt that would be sent, then stop. Nothing is changed. |
-m, --model <id> | Claude model for Claude Code (default: Claude Code's own). |
--max-turns <n> | Stop Claude Code after this many turns. |
--allow-tools "<list>" | Extra tools Claude Code may use without asking, e.g. "Bash(npm install:*)". |
--no-build | Skip the CLI's build check. |
--no-git | Don't commit before and after. The changes then can't be undone with git. |
--allow-dirty | If the app's repository has uncommitted changes, commit them as the baseline instead of stopping. Not needed after a regeneration in a repository the CLI created. |
Pick the prompt that matches the stencil: prompts list -f UIUX shows modernize-blazorWebApp, modernize-mudblazorWebApp and modernize-devexpressWebApp, among others.
Costs: Claude Code runs on the Claude account you signed in with; the summary shows the cost it reports. Two runs on a four-table BlazorWebApp app reported $2.67 and $3.15.
Recipes (run)
A recipe saves a whole run — create, seed, generate, modernize — as a JSON file, so you can repeat it with one command, share it, or run it in a build pipeline. Each step is an ordinary CLI command with its options.
codestencil-cli run <recipe> [--set name=value ...] [--dry-run] [--from <step> | --only <steps>]
Example
// Scuba diving demo: create, seed, modernize.
{
"name": "Scuba diving demo",
"variables": {
"project": "scuba_${timestamp}",
"seedAi": "google"
},
"steps": [
{
"title": "Create ${project}",
"run": "new schema",
"args": {
"stencil": "BlazorWebApp",
"schema": "Travel & Vacation\\scuba-diving",
"provider": "sqlite",
"name": "${project}",
"noSeed": true
}
},
{
"title": "Seed 50 rows",
"run": "seed",
"project": "${project}",
"args": { "rows": 50, "ai": "${seedAi}" },
"continueOnError": true
},
{
"title": "Modernize the UI",
"run": "modernize",
"project": "${project}",
"args": { "prompt": "UIUX\\modernize-blazorWebApp" }
}
]
}
File format
Key | Meaning |
name | Shown when the recipe runs. |
variables | Values used as ${name} anywhere in the recipe. A variable can use earlier ones. |
interactive | false (default): steps run with --non-interactive, so they never stop to ask. |
steps[].run | The command: new schema, new db-import, generate, seed, modernize, doctor, stencils list, schemas list or prompts list. |
steps[].project | The project argument for generate, seed and modernize. |
steps[].args | The command's options. Names can be camelCase (seedAi) or as typed (seed-ai). true adds a switch; false, null and [] leave it out; lists become comma-separated. |
steps[].title | Shown in the progress and the summary. |
steps[].continueOnError | Carry on with the next step if this one fails (useful for seeding). |
steps[].interactive | Let this step ask questions. Needed for --ai manual seeding. |
steps[].yes | Answer Yes to every question CodeStencil asks in this step. |
Comments (//) are allowed. Backslashes in JSON strings are written twice ("UIUX\\modernize-blazorWebApp").
Variables
• ${name} — a variable from variables, or one set on the command line with --set name=value, which overrides the file.
• ${env:NAME} — an environment variable. Use it for connection strings and other secrets, so they aren't stored in the recipe. The run stops if it isn't set, unless you give a fallback: ${env:NAME:-fallback} (the fallback may be empty).
• ${timestamp} (e.g. 20261124_040449), ${date} (e.g. 20261124) and ${recipeDir} (the recipe's folder) are built in.
Running and resuming
:: preview: shows each command, passwords masked, runs nothing
codestencil-cli run scuba-demo --dry-run
:: run it with your own project name
codestencil-cli run scuba-demo --set project=scuba9
:: a step failed: fix the cause, then continue from that step
codestencil-cli run scuba-demo --set project=scuba9 --from 3
:: run one step only
codestencil-cli run scuba-demo --set project=scuba9 --only 2
:: run several steps: a range or a list
codestencil-cli run regression --only 1-4,9-12
Each step runs in its own process with a heading and its command line. A failed step stops the recipe, unless it has continueOnError. At the end, a table shows each step's result and time, and the exit code is that of the first failed step.
A recipe is found by path, or by name in the Recipes folder next to codestencil-cli.exe. Three are included: scuba-demo (Path 2: create, seed, modernize), db-import-demo (Path 1, with the connection string from CODESTENCIL_CONNECTION) and regression (see below).
Regression test
codestencil-cli run regression checks both paths on all four databases in 16 steps. For each database it creates reg_<db>_schema from the scuba-diving schema (the database is dropped and recreated every run, and isn't seeded), imports that database into reg_<db>_import, and builds both apps with build. Every step continues on error, so the closing table shows the whole matrix. A full run takes about 7 minutes.
The servers come from environment variables:
setx CS_TEST_SQLSERVER "Server=localhost\SQLEXPRESS;Integrated Security=True;TrustServerCertificate=True"
setx CS_TEST_POSTGRESQL "Host=localhost;Port=5432;Username=postgres;Password=..."
setx CS_TEST_MYSQL "Server=localhost;Port=3306;Uid=root;Pwd=..."
SQL Server falls back to the local default instance. Steps for a server that isn't set fail and are reported, and the rest still run. Steps 1–4 are SQLite, 5–8 SQL Server, 9–12 PostgreSQL and 13–16 MySQL, so --only 9-12 reruns PostgreSQL alone.
In a build pipeline
Run recipes on a Windows machine with CodeStencil installed and set up. Keep secrets in the pipeline's secret variables and read them with ${env:…}; non-interactive steps never wait for input, and the exit codes tell the pipeline which step failed. Claude Code needs to be signed in on that machine for modernize steps.
Reference
All commands
Command | What it does |
doctor | Shows the folders and settings the CLI found, with counts and any problems. |
stencils list [--schema-only] | Lists installed stencils. --schema-only keeps those that need a database. |
schemas list [filter] [-c <category>] | Lists library schemas, optionally filtered by text or category. |
prompts list [-f <folder>] | Lists predefined prompts, optionally from one folder (UIUX, Architecture, Code, Database, Security, Testing). |
new db-import | Path 1: existing database → project → app. |
new schema | Path 2: library schema → new database → project → app. |
generate <project> | Regenerates an app. |
build <project> | Compiles the generated app with dotnet build and lists its errors. Generating without errors doesn't guarantee the app compiles, so this is the check to use in recipes and pipelines. |
seed <project> | Fills the database with AI test data. |
modernize <project> | Redesigns the app's UI with Claude Code. |
run <recipe> | Runs a recipe. |
data move --to <folder> [--dry-run] | Moves the data folder to another location and updates the paths stored in it. See Data folder. |
Add --help to any command for its options, e.g. codestencil-cli new schema --help.
Options for every command
Option | Meaning |
--non-interactive | Never ask. Missing options are errors, and questions raised by CodeStencil get their safe answer (usually No). Use it in scripts. |
-y, --yes | Answer Yes to every question CodeStencil raises. |
--verbose | Show CodeStencil's detailed output and full error details. |
--json | Machine-readable output for doctor and the list commands. |
Exit codes
Code | Meaning |
0 | Success. |
1 | Invalid input: a missing or wrong option, an unknown stencil, schema, project or prompt. |
2 | Database problem: connecting, creating, scaffolding or importing. |
3 | Generation problem: the app was not (fully) generated. |
4 | AI problem: seeding failed. After new schema, the project and app still exist. |
5 | Modernize problem: Claude Code didn't finish, or the app no longer builds. |
6 | Build problem: build found compile errors, or no generated solution. |
99 | Unexpected error (details are printed; add --verbose for more). |
run returns the code of its first failed step.
Environment variables
Variable | Used for |
CODESTENCIL_CONNECTION | Connection string for new db-import when --connection isn't given. |
CODESTENCIL_SERVER | Server connection for new schema when --server isn't given. |
CODESTENCIL_SEED_MODEL | Default seeding model. |
OPENAI_API_KEY | OpenAI key for seeding. |
ANTHROPIC_API_KEY | Anthropic key for seeding. |
GEMINI_API_KEY or GOOGLE_API_KEY | Google Gemini key for seeding. |
CODESTENCIL_HOME | The data folder, when it isn't %USERPROFILE%\CodeStencil. Set by data move --to. Used by both the CLI and the desktop app. |
Troubleshooting and FAQ
Running the CLI
Problem | Fix |
codestencil-cli is not recognized | Open a new window after installing CodeStencil. If it still isn't found, switch on CodeStencil CLI under Settings → Apps → Advanced app settings → App execution aliases. When running a build of the CLI from its own folder instead, PowerShell needs .\codestencil-cli. |
The command stops at a &, or is not recognized appears for half a schema name | Put names containing spaces or & in double quotes: --schema "Travel & Vacation\scuba-diving". |
Unknown command for a command in this guide | An older codestencil-cli.exe is being run. Check which one with where codestencil-cli. |
Stencil 'X' is not installed / Schema not found / Prompt not found | Check the exact name with stencils list, schemas list or prompts list, and run doctor to see which folders the CLI is reading. |
Importing a database
Problem | Fix |
Could not connect to the database | Check the connection string, and set --provider if it wasn't detected correctly. Make sure the database server is reachable from this PC. |
Could not tell the database type from the connection string | Add --provider sqlite, sqlserver, mysql or postgresql. |
dotnet ef dbcontext scaffold failed | The message shows Entity Framework's own error, with passwords masked. Install the .NET SDK if dotnet is missing, or install the tool yourself with dotnet tool install --global dotnet-ef. |
There are no tables or views to import | All tables were left out by --exclude, or the database is empty. |
A column is missing, or the generated app doesn't compile | Some column types aren't supported by every stencil's forms (for example Guid and byte columns in BlazorWebApp). Leave the table out with --exclude, or change the column type. |
Seeding
Problem | Fix |
503 … high demand (after three retries) | The AI service is busy. Try again later, use an older or lighter model (--model gemini-3.6-flash), or seed with --ai manual. |
429 insufficient_quota or credit balance is too low | The API account has no credit. Add credit, use another provider, or use --ai manual. |
did not answer within 10 minutes | Use a faster model, fewer --rows, or --ai manual. |
Manual seeding needs an interactive console | Manual seeding can't run with --non-interactive. In a recipe, add "interactive": true to the seed step. |
The SQL script fails | The CLI rolls back, then asks the AI once more with the error. If that fails too, nothing in the database was changed; rerun, or use another model. |
Modernizing
Problem | Fix |
Claude Code ('claude') was not found | Install Claude Code (see Requirements), then open a new terminal. |
Login expired / Run /login | Run claude in a terminal, sign in with /login, type /exit, then run modernize again. |
has uncommitted changes | Someone changed the app since the last commit. Commit or discard the changes, or add --allow-dirty to include them in the baseline. |
git was not found | Install Git for Windows, or use --no-git (the changes then can't be undone with git). |
Exit code 5 and Build: FAILS | Claude's changes don't compile. The result is committed as modernize: … (BUILD FAILS): review it with the printed git diff, undo it with the printed git reset --hard, or run modernize again with --extra instructions. |
Common questions
Can I open a CLI project in the desktop app? Yes. Projects are ordinary .codestencilproj files in %USERPROFILE%\CodeStencil\Projects, and the CLI uses the same stencils and settings.
Why didn't generate rewrite every file? Generation is incremental, like the desktop app: unchanged tables and nodes are skipped. Use --all to regenerate everything.
Can I keep modernized changes after regenerating? Regenerating overwrites the generated files. The modernized version stays in git, so you can compare or restore it, or run modernize again after regenerating.
Is my database changed by new db-import? Only when the stencil uses ASP.NET Identity: its tables are added and an existing admin user is replaced. Use --no-identity to prevent that.
Where do my passwords end up? Use CODESTENCIL_CONNECTION or ${env:…} in recipes to keep them off the command line. The project file stores the connection string, exactly as the desktop app does, so treat project files as sensitive. The CLI masks passwords in everything it prints.