Skip to content

sm doctor

Validates your project structure and conventions against SimpleModule requirements. Reports issues as PASS, WARN, or FAIL, and can auto-fix common problems.

Usage

bash
sm doctor [--fix]

Options

OptionDescription
--fixAuto-fix missing .slnx entries, host project references, Pages/index.ts entries, and root package.json npm workspace globs

Checks Performed

The doctor command runs twelve checks, grouped below by concern:

  • SolutionStructure -- foundational directories and the .slnx solution file
  • ProjectReference -- host project references each module's implementation
  • SlnxEntries -- .slnx contains every module's contracts, implementation, and tests
  • CsprojConvention -- .csproj files follow SimpleModule conventions
  • ContractsIsolation -- contracts projects do not reference other modules
  • ModulePattern -- module directory layout matches the expected pattern
  • ModuleAttribute -- module class is decorated with [Module]
  • ViewEndpointNaming -- view endpoints follow naming conventions
  • PagesRegistry -- every view endpoint has an entry in Pages/index.ts
  • ViteConfig -- module has a valid vite.config.ts
  • PackageJson -- module has a valid package.json
  • NpmWorkspace -- the root package.json workspaces array includes each module

1. Solution Structure

Verifies the foundational directory layout exists:

CheckSeverity
.slnx solution file existsFAIL
src/ directory existsFAIL
src/modules/ directory existsFAIL
tests/ directory existsFAIL

2. Project References

For each discovered module, verifies the host/API .csproj has a <ProjectReference> to the module's implementation project.

CheckSeverityAuto-fixable
API project references each moduleFAILYes

3. Solution File Entries

For each discovered module, verifies the .slnx file contains folder entries for the module's projects (contracts, implementation, tests).

CheckSeverityAuto-fixable
Module entries exist in .slnxFAILYes

4. .csproj Conventions

Validates project file conventions for each module:

CheckSeverity
Module .csproj has <FrameworkReference Include="Microsoft.AspNetCore.App" />FAIL
Contracts .csproj only references Core (not other modules)WARN
Generator project targets netstandard2.0FAIL

5. Module Pattern

Validates that each module follows the expected file structure:

CheckSeverity
{Module}Module.cs existsWARN
{Module}Constants.cs existsWARN
{Module}DbContext.cs existsWARN
Endpoints/ directory existsWARN

Auto-Fix Behavior

When you pass --fix, the doctor attempts to repair the following issues:

  • Missing .slnx entries -- adds folder entries for the module's three projects
  • Missing project references -- adds a <ProjectReference> in the host .csproj pointing to the module
  • Missing Pages/index.ts entries -- adds a registry entry for each view endpoint that lacks one
  • Missing npm workspace globs -- adds the module's workspace paths to the root package.json

After auto-fixing, all checks are re-run and the results table reflects the current state.

bash
sm doctor --fix
# Attempting auto-fix...
#   Fixed: added Invoices to .slnx
#   Fixed: added Invoices reference to API csproj

INFO

Auto-fix handles structural wiring: .slnx entries, host project references, Pages/index.ts registry entries for view endpoints, and npm workspace globs in the root package.json. It does not create missing files like Module.cs or DbContext.cs -- use sm new module for that.

Output

The doctor displays a table with three columns:

| Status | Check                  | Details                              |
|--------|------------------------|--------------------------------------|
| PASS   | Solution file          | .slnx exists                         |
| PASS   | Directory src/         | exists                               |
| FAIL   | API -> Invoices        | missing project reference in API     |
| WARN   | Invoices/Endpoints/    | Endpoints directory missing          |

The command exits with code 0 when all checks pass (warnings are allowed) and code 1 when any check fails.

CI Integration

Add sm doctor to your CI pipeline to catch structural issues early:

yaml
- name: Validate project structure
  run: sm doctor

The non-zero exit code on failure makes it suitable for CI gates. Pair it with --fix in a pre-commit hook for local development if desired.

Next Steps

Released under the MIT License.