Appearance
CLI Templates
Gryd.IO provides CLI templates for dotnet new to quickly scaffold new projects with the correct structure and dependencies.
Installation
From NuGet (Production)
Install all Gryd.IO templates from NuGet:
bash
dotnet new install Gryd.IO.TemplatesFrom Local Packages (Development)
Template sources contain GRYD_PACKAGE_VERSION placeholders, and pack-local-packages.sh only packs the framework projects. Use the maintained end-to-end smoke flow to substitute one version, pack the template, install it in an isolated CLI home, generate all nine targets, and build them. The flow also runs seven generated-module tests and three bounded runtime hosts; it requires Docker for the disposable PostgreSQL host. It is setup evidence, not deployed-service or production-load assurance:
bash
cd /path/to/Gryd.IO
TEMPLATE_TEST_VERSION=99.0.0-local bash scripts/test-templates.shOn success, the flow leaves the generated package at local-packages/Gryd.IO.Templates.99.0.0-local.nupkg. Install that package in your own CLI home when you want to create projects outside the smoke run:
bash
dotnet new install ./local-packages/Gryd.IO.Templates.99.0.0-local.nupkgRestore generated projects with a NuGet configuration that lists the repository's local-packages folder and NuGet.org. The generated project package references use 99.0.0-local, so both sources are needed. Do not install raw template directories as local packages.
Verify Installation
List all installed Gryd templates:
bash
dotnet new list grydExpected output:
Template Name Short Name Language Tags
-------------- ----------- -------- ----
Gryd API gryd-api [C#] Web/API/Gryd
Gryd Minimal gryd-minimal [C#] Web/API/Gryd
Gryd Module gryd-module [C#] Library/Gryd/ModuleAvailable Templates
| Template | Short Name | Description |
|---|---|---|
| Gryd API | gryd-api | API with Auth and CRUD enabled by default; other modules are selected by flags |
| Gryd Minimal | gryd-minimal | Minimal API with core and observability packages |
| Gryd Module | gryd-module | Clean Architecture module structure |
gryd-api
Complete API template with optional GrydAuth and GrydCrud integration, Docker support, and database configuration.
Usage
bash
# Create with defaults (Auth + Crud + PostgreSQL + Docker)
dotnet new gryd-api -n MyApiProject
# Create without authentication
dotnet new gryd-api -n MyApiProject --IncludeAuth false
# Create with SQL Server instead of PostgreSQL
dotnet new gryd-api -n MyApiProject --UsePostgres false --UseSqlServer true
# Create without Docker support
dotnet new gryd-api -n MyApiProject --IncludeDocker falseParameters
| Parameter | Type | Default | Description |
|---|---|---|---|
--IncludeAuth | bool | true | Include GrydAuth for authentication/authorization |
--IncludeCrud | bool | true | Include GrydCrud for CRUD operations |
--UsePostgres | bool | true | Configure PostgreSQL as database |
--UseSqlServer | bool | false | Configure SQL Server as database |
--IncludeDocker | bool | true | Include Dockerfile and docker-compose.yml |
--IncludeJobs | bool | false | Include GrydJobs for background jobs |
--IncludeReports | bool | false | Include GrydReports. Brings GrydFiles, GrydJobs and the ClamAV scanner registration with it |
--IncludeNotifications | bool | false | Include GrydNotifications. Brings GrydFiles, GrydJobs and the ClamAV scanner registration with it |
Reports and Notifications keep their files in GrydFiles (generated reports, e-mail attachments), so either flag also registers the object storage, AddGrydFiles with the ClamAV engine and GrydJobs, which runs the file checks. The GrydFiles section of appsettings.json declares the gryd.report and gryd.notification-attachment profiles the two modules require. GrydReports cannot run without GrydFiles; GrydNotifications needs it only for e-mail attachments, so a product that sends none can remove the GrydFiles registration and its section (see Email with Attachments).
Generated Structure
MyApiProject/
├── MyApiProject.csproj # Project with Gryd packages
├── Program.cs # Startup with DI configuration
├── appsettings.json # Production configuration
├── appsettings.Development.json # Development configuration
├── README.md # Project documentation
├── Controllers/
│ └── ProductsController.cs # Example CRUD controller
├── Data/
│ └── AppDbContext.cs # EF Core DbContext
├── Domain/
│ └── Product.cs # Example entity
├── DTOs/
│ └── ProductDtos.cs # DTOs for Product entity
├── Dockerfile # (if IncludeDocker=true)
├── docker-compose.yml # (if IncludeDocker=true)
└── .dockerignore # (if IncludeDocker=true)Generated startup source
The compiled example is maintained at templates/gryd-api/Program.cs. It contains the actual conditional service and middleware registration, API versioning, Swagger, health checks, telemetry and Development migration calls. Use that file as the reference for module composition.
gryd-minimal
Minimal API template with the core and observability packages. Suitable as a starting point for APIs that do not need the optional Auth or CRUD modules.
Usage
bash
# Create with defaults (PostgreSQL)
dotnet new gryd-minimal -n MyMinimalApi
# Create with SQL Server
dotnet new gryd-minimal -n MyMinimalApi --UsePostgres false --UseSqlServer trueParameters
| Parameter | Type | Default | Description |
|---|---|---|---|
--UsePostgres | bool | true | Configure PostgreSQL as database |
--UseSqlServer | bool | false | Configure SQL Server as database |
Generated Structure
MyMinimalApi/
├── MyMinimalApi.csproj # Project with Gryd.Core packages
├── Program.cs # Minimal startup configuration
├── appsettings.json # Production configuration
├── appsettings.Development.json # Development configuration
├── README.md # Project documentation
├── Controllers/
│ └── HelloController.cs # Example controller
└── Data/
└── AppDbContext.cs # EF Core DbContextGenerated startup source
The compiled example is maintained at templates/gryd-minimal/Program.cs.
gryd-module
Clean Architecture module template. Creates a complete module structure following Domain-Driven Design principles, ready to be integrated into a host application.
Usage
bash
# Create with the default name, tests and API layer
dotnet new gryd-module -n Catalog
# Choose the generated name; the sourceName token uses this value for project and namespace names.
dotnet new gryd-module -n Products -o Catalog
# Create without tests
dotnet new gryd-module -n Catalog --IncludeTests false
# Create without API layer (library only)
dotnet new gryd-module -n Catalog --IncludeApi falseParameters
| Parameter | Type | Default | Description |
|---|---|---|---|
--IncludeTests | bool | true | Include test project with xUnit |
--IncludeApi | bool | true | Include API layer with controllers |
--IncludeAuth | bool | false | Include GrydAuth |
--IncludeCrud | bool | false | Include GrydCrud |
--IncludeCustomListEndpoint | bool | false | Generate a QueryKit list endpoint sample; requires CRUD |
--IncludeAudit | bool | false | Include GrydAudit |
--IncludeJobs | bool | false | Include GrydJobs |
--IncludeReports | bool | false | Include GrydReports; also includes Files and Jobs setup |
--IncludeNotifications | bool | false | Include GrydNotifications; also includes Files and Jobs setup |
--UsePostgres / --UseSqlServer | bool | true / false | Select the generated application context provider |
IncludeApi and IncludeTests default to true. IncludeFiles and UseJobs are computed by the template; they are not user-facing flags. There is no --ModuleName option: use -n to name the generated solution and projects. The generated module does not dynamically switch Jobs storage by tenant; Jobs uses its configured PostgreSQL storage connection.
Generated Structure
Catalog/
├── Catalog.sln # Solution file
├── README.md # Module documentation
│
├── src/
│ ├── Catalog.Domain/ # Domain Layer
│ │ ├── Catalog.Domain.csproj
│ │ ├── GlobalUsings.cs
│ │ ├── CatalogDomainAssemblyMarker.cs
│ │ └── Entities/
│ │ └── SampleEntity.cs # Example aggregate root
│ │
│ ├── Catalog.Application/ # Application Layer
│ │ ├── Catalog.Application.csproj
│ │ ├── GlobalUsings.cs
│ │ ├── CatalogApplicationAssemblyMarker.cs
│ │ ├── DTOs/
│ │ │ └── SampleEntityDtos.cs # DTOs for CRUD operations
│ │ └── Features/
│ │ └── SampleEntities/
│ │ ├── Commands/
│ │ │ └── SampleEntityCommands.cs # Create, Update, Delete
│ │ ├── Queries/
│ │ │ └── SampleEntityQueries.cs # GetById, GetPaged
│ │ └── Validators/
│ │ └── SampleEntityValidators.cs
│ │
│ ├── Catalog.Infrastructure/ # Infrastructure Layer
│ │ ├── Catalog.Infrastructure.csproj
│ │ ├── GlobalUsings.cs
│ │ ├── CatalogInfrastructureAssemblyMarker.cs
│ │ └── CatalogServiceCollectionExtensions.cs
│ │
│ └── Catalog.API/ # API Layer (if IncludeApi=true)
│ ├── Catalog.API.csproj
│ ├── GlobalUsings.cs
│ ├── CatalogApiServiceCollectionExtensions.cs
│ └── Controllers/
│ └── SampleEntitiesController.cs
│
└── tests/ # (if IncludeTests=true)
└── Catalog.Tests/
├── Catalog.Tests.csproj
├── GlobalUsings.cs
└── Domain/
└── SampleEntityTests.cs # Unit tests for domainGenerated module source and local setup
The maintained module template already supplies the sample entity, API, registrations, configuration, and generated contract tests. Review the executable source in templates/gryd-module/, especially its Program.cs, template options, and standalone setup guide. Those files are the source of truth for generated namespaces and registration; the repository's nine-target template smoke compiles these generated variants.
Use -n to choose the generated solution and project names. A project name is not a separate --ModuleName option. IncludeFiles and UseJobs are computed template values, not CLI switches. Reports and Notifications cause the generated setup to include Files and Jobs; standalone Jobs uses its configured global PostgreSQL storage connection.
Uninstalling Templates
To remove installed templates:
bash
dotnet new uninstall Gryd.IO.TemplatesThe local development flow also installs the Gryd.IO.Templates package from its generated .nupkg, so the same package uninstall command removes it.
List Installed Templates
bash
dotnet new list grydOutput:
Template Name Short Name Language Tags
-------------- ----------- -------- ----
Gryd API gryd-api [C#] Web/API/Gryd
Gryd Minimal gryd-minimal [C#] Web/API/Gryd
Gryd Module gryd-module [C#] Library/Gryd/ModuleDatabase Setup
Prerequisites
Projects created with gryd-api or gryd-module (with --IncludeAuth true) require:
- PostgreSQL for GrydAuth, including when
UseSqlServerselects SQL Server for the application database. - Redis when the generated Auth cache configuration uses Redis.
v5 security configuration (required)
GrydAuth v5 signs tokens with an asymmetric key and validates configuration at boot, so a new project will not start until you provide:
JwtSettings:Algorithm(RS256/ES256),JwtSettings:ActiveKeyIdandJwtSettings:PrivateKeyPem(from a secret manager — never commit the key);JwtSettings:ExpirationMinutesbetween 1 and 15 (default 10);GrydAuth:Cors:AllowedOrigins(CORS is deny-by-default outside Development).GrydAuth:Security:SecretProtection:ActiveKeyIdand its matching 32-byte Base64URL entry underGrydAuth:Security:SecretProtection:Keys(required in every environment).
See the v4 → v5 migration guide for key generation and full configuration. The secret protection guide documents the key ring. When running dotnet run, supply secrets through environment variables, user-secrets, or a secret manager; .NET does not expand ${...} placeholders inside JSON files. For Development, generate and save the localdev key once, then reuse it after restarts:
bash
export GrydAuth__Security__SecretProtection__Keys__localdev="$(openssl rand -base64 32 | tr '+/' '-_' | tr -d '=\n')"Keep old key IDs and values available while encrypted secrets still reference them. See the secret protection guide for key generation and rotation.
Step 1: Start Infrastructure with Docker Compose
The gryd-api and gryd-module templates include docker-compose.yml; gryd-minimal does not. For a generated API or module that you will run on the host, set the local passwords and start only PostgreSQL and Redis so Compose does not also bind the API port:
bash
# From the generated gryd-api or gryd-module project root
cd MyProject
export POSTGRES_PASSWORD="$(openssl rand -base64 32)"
export REDIS_PASSWORD="$(openssl rand -base64 32)"
docker-compose up -d postgres redisTIP
Provision PostgreSQL separately for gryd-minimal. Run API/module hosts locally with dotnet run; their Compose files can also start the API service when that is desired.
Step 2: Module and Application Migrations
Install the matching Entity Framework CLI once with dotnet tool install --global dotnet-ef --version 10.0.10. For a flat gryd-api or gryd-minimal project, run application migrations from the generated project directory you entered in Step 1. The app-owned context has no migrations until you create them:
bash
dotnet ef migrations add InitialCreate --context AppDbContext
dotnet ef database update --context AppDbContext
dotnet run --urls http://localhost:5000For the module commands below, first generate a separate module named GrydModule, then run EF commands from its API startup project so the migration is stored in the Infrastructure project:
bash
dotnet new gryd-module -n GrydModule
cd GrydModule/src/GrydModule.API
dotnet ef migrations add InitialCreate --project ../GrydModule.Infrastructure \
--startup-project . --context GrydModuleDbContext
dotnet ef database update --project ../GrydModule.Infrastructure \
--startup-project . --context GrydModuleDbContext
dotnet run --urls http://localhost:5000In Development, API and module startup explicitly applies included GrydAuth, GrydAudit, GrydFiles, GrydReports, and GrydNotifications migrations. GrydJobs has no template migration call. Review the generated Program.cs to confirm which optional migration extensions are included.
Production Environment
For production deployments, apply both application and included-module migrations through a CI/CD pipeline or a controlled migration step before deployment.
Health and Telemetry
Generated hosts expose anonymous GET /health/live, GET /health/ready, and GET /health; the last route remains a liveness alias. Liveness runs no dependency checks. Readiness checks whether the generated application context can connect to its database using a bounded three-second check. This confirms reachability only, not migration or table validity.
When GrydJobs is included, readiness also checks for a provider server heartbeat within the last five minutes. That is a coarse worker availability signal and does not prove each queue or job ran. When GrydNotifications is included, readiness checks its optional queue depth and fails above 10,000; it does not verify SMTP, push delivery, or notification database health. Protected routes retain their configured Auth middleware.
Development uses the console OpenTelemetry exporter. The base settings select OTLP over gRPC at http://localhost:4317. Set Observability:OpenTelemetry:Enabled=false to disable it. The ServiceName setting names the Gryd ActivitySource and metrics meter and is exported as service.name. InstrumentNpgsql enables PostgreSQL driver spans; leave it false for SQL Server, which is not instrumented by that option. Keep CaptureNpgsqlStatements false to avoid SQL text in spans. Standard HTTP telemetry uses method, route, and response status attributes; never add tenant IDs, user IDs, secrets, or personal data as metric labels.
For Jaeger traces only, use Exporter=jaeger and set JaegerEndpoint to its OTLP gRPC endpoint. Set MetricsOtlpEndpoint to a metrics-capable OTLP collector to export metrics separately; leave it empty for traces only. Put collector credentials in a secret provider, not checked-in settings.
UseSqlServer chooses SQL Server for the generated application context. Optional modules can use separate providers or connections; verify their own requirements before changing provider settings. Included GrydAuth always uses PostgreSQL through ConnectionStrings:DefaultPostgresConnection, so configure that independent connection for API/module deployments with Auth enabled, even when the generated application context uses SQL Server.
Step 3: Verify Database
After applying migrations, your database should have the following tables:
Users- User accountsRoles- Role definitionsPermissions- Permission definitionsUserRoles- User-Role associationsRolePermissions- Role-Permission associationsUserPermissions- Direct user permissionsUserTenants- Multi-tenancy user associationsUserAppIds- Multi-app user registrationsRefreshTokens- JWT refresh tokensFailedLoginAttempts- Brute-force protection__EFMigrationsHistory- EF Core migrations tracking
Configure Auth
The templates do not seed a default admin login or publish default credentials. Use the generated Auth onboarding flow to provision a local user; configure its application identifier to match the generated JwtSettings:AppId.
Do not rely on a copied user ID or a default admin record; provision the user through the Auth flow.
Quick Start Examples
Install the released template package from the configured Azure Artifacts feed, then create one of its three supported project shapes:
bash
dotnet new install Gryd.IO.Templates
dotnet new gryd-api -n MyStore --IncludeAuth true --IncludeCrud true
dotnet new gryd-minimal -n MyMicroservice
dotnet new gryd-module -n Inventory --IncludeAuth trueEach command above is an independent example. gryd-module includes its API and test projects by default; its name comes from -n, and there is no separate module-name flag. The exact generated startup, appsettings, flags and migration behavior are maintained in templates/gryd-api/, templates/gryd-minimal/, and templates/gryd-module/. Use the standalone README in the chosen template for local database, secret, migration and run instructions. Package references alone do not register module services or create user records.
Troubleshooting
Database does not exist
If PostgreSQL reports that a database does not exist, first confirm the local PostgreSQL service is running and that the configured connection string names the intended development database. Create that named database in your local PostgreSQL instance or update the connection string; avoid deleting Docker volumes, which can remove unrelated local data.
Invalid application ID
If login fails with Invalid application ID, verify that the JwtSettings:AppId used by the host matches the application identifier associated with the provisioned Auth user. The templates do not seed a default user; use the Auth onboarding flow and its supported record-management APIs.
NuGet cache issues
If a generated project cannot restore packages, check its configured package sources and the exact package version first. Then retry only that project with dotnet restore --no-cache; this avoids clearing the machine-wide NuGet caches.
Port already in use
If port 5000 is already in use, configure a different local application URL for the generated host, or stop the identified service through its normal controls. On macOS, AirPlay Receiver may use this port; its setting is under System Settings.