---
name: cross-validate-stack
description: Cross-stack validation backend .NET / frontend React — 5 coherence checks
group: validation
cli: cli/
allowed-tools: [Read, Glob, Grep, Bash]  # Bash: CLI invocation
---

# Skill: Cross-Validate Stack

> Verifies coherence between .NET backend and React frontend.
> Analysis via file scanning + JSON specs — lightweight and fast.

## When to use this skill

- After backend + frontend code generation for a module
- Before a merge/PR to verify both sides are aligned
- To audit that no route, permission or resource is missing

## The 5 Checks

| # | Check | Source / Target |
|---|-------|-----------------|
| 1 | `routes-have-endpoints` | Each endpoint in JSON specs has a corresponding .NET controller |
| 2 | `endpoints-are-consumed` | Each .NET endpoint is called by at least one React service |
| 3 | `permissions-aligned` | `[RequirePermission]` .NET and `PermissionGuard`/`usePermission` React are aligned |
| 4 | `resources-have-screens` | Each resource (meta.json) has a .NET controller and at least one .tsx page |
| 5 | `rbac-consistent` | All permissions declared in permissions.json are used in code |

## CLI Invocation

```bash
# Complete cross-stack validation
npx tsx skills/validation/cross-validate/cli/index.ts --specs <specs-dir> --src <src-dir>
```

## Arguments

| Argument | Description | Required |
|----------|-------------|----------|
| `--specs` | Directory containing JSON specs (meta.json, endpoints.json, permissions.json) | Yes |
| `--src` | Directory containing source code (.cs and .tsx/.ts) | Yes |
| `--help` | Display help | No |

## JSON Output

```json
{
  "timestamp": "2026-03-31T...",
  "checks": [
    { "id": "routes-have-endpoints", "status": "ok", "count": 5 },
    { "id": "permissions-aligned", "status": "error", "details": "crm.clients.Delete — .NET: ok, React: missing" }
  ],
  "errors": 1,
  "warnings": 0
}
```

## Expected Behavior

1. User requests a cross-stack validation
2. Claude Code identifies the specs directory and source directory
3. Claude Code calls the CLI with `--specs` and `--src`
4. CLI returns JSON with the results of 5 checks
5. Claude Code presents results and suggests corrections

## Conversation Example

```
User: Verify that my backend and frontend are coherent
Claude Code: Launching cross-stack validation...
> npx tsx skills/validation/cross-validate/cli/index.ts --specs ./specs --src ./src
< { "checks": [...], "errors": 0, "warnings": 0 }
Claude Code: All 5 cross-stack checks pass. Backend and frontend are aligned.
```

## Exit Codes

| Code | Meaning |
|------|---------|
| 0 | Success — no errors |
| 1 | Errors detected |
| 2 | Internal CLI error (invalid input, missing directory) |
