---
name: validate
description: Validate SmartStack conventions using MCP
argument-hint: "[scope]"
model: sonnet
allowed-tools: Read, Grep, Glob, ToolSearch
---

<objective>
Validate the SmartStack project against established conventions using the SmartStack MCP server.
Use before commits, PRs, or as part of CI/CD to ensure code quality.
</objective>

<quick_start>
```bash
/validate                 # Run all validations
/validate:tables          # Validate table naming only
/validate:migrations      # Validate migration naming only
/validate:services        # Validate service patterns only
/validate:namespaces      # Validate namespace structure only
```
</quick_start>

<subcommands>

| Command | Checks | Description |
|---------|--------|-------------|
| `/validate` | all | Run all convention checks |
| `/validate:tables` | tables | SQL schemas, domain prefixes |
| `/validate:migrations` | migrations | Naming format, ordering |
| `/validate:services` | services | I*Service interfaces |
| `/validate:namespaces` | namespaces | Layer separation |

</subcommands>

<mcp_integration>

**Tool:** `mcp__smartstack__validate_conventions`

Call the MCP tool with appropriate checks:

```json
{
  "tool": "mcp__smartstack__validate_conventions",
  "parameters": {
    "checks": ["all"]
  }
}
```

For specific checks:
```json
{
  "checks": ["tables", "migrations"]
}
```

</mcp_integration>

<validation_rules>

### Tables (`checks: ["tables"]`)

| Rule | Valid | Invalid |
|------|-------|---------|
| Schema | `core`, `extensions` | `dbo`, custom |
| Prefix | `auth_Users`, `nav_Items` | `Users`, `Items` |

**Valid prefixes:** `auth_`, `nav_`, `usr_`, `ai_`, `cfg_`, `wkf_`, `support_`, `entra_`, `ref_`, `loc_`, `lic_`

### Migrations (`checks: ["migrations"]`)

| Rule | Valid | Invalid |
|------|-------|---------|
| Format | `core_v1.0.0_001_AddUsers` | `AddUsersTable` |
| Order | v1.0.0 before v1.1.0 | v1.1.0 before v1.0.0 |

**Format:** `{context}_v{version}_{sequence}_{Description}`

### Services (`checks: ["services"]`)

| Rule | Valid | Invalid |
|------|-------|---------|
| Interface | `IUserService` | `UserServiceInterface` |
| Implementation | `UserService : IUserService` | `UserService` (no interface) |

### Namespaces (`checks: ["namespaces"]`)

| Layer | Expected Namespace |
|-------|-------------------|
| Domain | `SmartStack.Domain.*` |
| Application | `SmartStack.Application.*` |
| Infrastructure | `SmartStack.Infrastructure.*` |
| Api | `SmartStack.Api.*` |

</validation_rules>

<output_format>

**If `valid: true` with no warnings:**
```
================================================================================
                    SMARTSTACK CONVENTIONS VALIDATION
================================================================================

STATUS: PASSED

Checks performed: tables, migrations, services, namespaces
Errors: 0
Warnings: 0

All conventions validated successfully!
================================================================================
```

**If `valid: false` or has warnings:**
```
================================================================================
                    SMARTSTACK CONVENTIONS VALIDATION
================================================================================

STATUS: {valid ? "PASSED (with warnings)" : "FAILED"}

ERRORS ({count})
--------------------------------------------------------------------------------
  [{category}] {message}
    File: {file}
    Suggestion: {suggestion}
--------------------------------------------------------------------------------

WARNINGS ({count})
--------------------------------------------------------------------------------
  [{category}] {message}
    File: {file}
    Suggestion: {suggestion}
--------------------------------------------------------------------------------
================================================================================
```

</output_format>

<options>

| Option | Description |
|--------|-------------|
| `--fix` | Auto-fix simple issues (rename suggestions) |
| `--json` | Output raw MCP JSON response |
| `--strict` | Treat warnings as errors |

</options>

<cicd_integration>

```yaml
# GitHub Actions
- name: Validate SmartStack conventions
  run: |
    OUTPUT=$(claude-code "/validate --json")
    VALID=$(echo $OUTPUT | jq '.valid')
    if [ "$VALID" != "true" ]; then
      echo "::error::SmartStack convention violations detected"
      exit 1
    fi
```

</cicd_integration>

<why_mcp>

1. **Centralized Rules:** Convention rules defined once in MCP config
2. **Consistency:** Same validation in CLI, CI/CD, and IDE
3. **Extensibility:** Add new checks in MCP, available everywhere
4. **Structured Output:** Typed responses for automation

</why_mcp>
