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 and project references

Checks Performed

The doctor command runs five categories of checks:

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

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 only handles structural wiring (slnx entries and project references). 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.