Multi-level validation (spec, schema, code, runtime) for SpecForge projects
Runs comprehensive multi-level validation across your SpecForge project: OpenAPI specs, database schemas, generated code, compilation, and runtime behavior. Use it after any spec or schema changes to catch issues early.
/plugin marketplace add claude-market/marketplace/plugin install claude-market-specforge-specforge@claude-market/marketplacePerform comprehensive validation across all levels of your SpecForge project: OpenAPI spec, database schema, generated code, and runtime behavior.
Validate the OpenAPI specification for correctness and best practices.
// Validate OpenAPI spec
await invokeSkill("openapi-expert", {
action: "validate-spec",
spec_path: "spec/openapi.yaml",
});
Checks:
Tools:
redocly lint spec/openapi.yamlValidate database schema for consistency and best practices.
// Read CLAUDE.md to get database plugin
const config = await readCLAUDEmd();
const dbPlugin = config.specforge.database;
// Validate database schema
await invokeSkill(`specforge-db-${dbPlugin}/migrations-expert`, {
action: "validate-schema",
migrations_dir: "migrations/",
database_url: process.env.DATABASE_URL,
});
Checks:
Tools:
Validate that code generation succeeded and generated code is correct.
// Read CLAUDE.md to get tech stack
const config = await readCLAUDEmd();
const backendPlugin = config.specforge.backend;
const codegenPlugin = config.specforge.codegen;
// Validate generated code exists
await invokeSkill(`${codegenPlugin}/diagnostics-expert`, {
action: "validate-generated-code",
generated_db_path: `${backendPlugin.path}/src/generated/db`,
generated_api_path: `${backendPlugin.path}/src/generated/api`,
database_schema_path: "migrations/",
});
Checks:
Ensure the project compiles successfully.
// Run compilation
const config = await readCLAUDEmd();
const backendPlugin = config.specforge.backend;
await invokeSkill(`${backendPlugin}/testing-expert`, {
action: "compile-check",
project_path: backendPlugin.path,
});
Checks (Technology-Specific):
Rust:
cd backend && cargo check
cargo clippy -- -D warnings
TypeScript:
cd backend && npm run type-check
npm run lint
Python:
cd backend && mypy .
pylint src/
Go:
cd backend && go build ./...
go vet ./...
Validate runtime behavior through tests and contract testing.
// Run test suite
await invokeSkill("test-orchestrator", {
action: "run-all-tests",
project_path: ".",
});
// Contract testing against OpenAPI spec
await invokeSkill("openapi-expert", {
action: "contract-test",
spec_path: "spec/openapi.yaml",
api_url: "http://localhost:3000",
});
Checks:
Tools:
┌─────────────────────────────────────────────┐
│ /specforge:validate │
└─────────────────┬───────────────────────────┘
│
┌─────────────┼─────────────┬──────────────┬───────────────┐
▼ ▼ ▼ ▼ ▼
┌────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌─────────────┐
│ Spec │ │ Schema │ │ Codegen │ │ Compile │ │ Runtime │
│ Valid. │ │ Valid. │ │ Valid. │ │ Valid. │ │ Valid. │
└────┬───┘ └─────┬────┘ └─────┬────┘ └─────┬────┘ └──────┬──────┘
│ │ │ │ │
└────────────┴─────────────┴─────────────┴──────────────┘
│
▼
┌────────────────────┐
│ Validation Report │
└────────────────────┘
# Read CLAUDE.md to get tech stack configuration
cat CLAUDE.md | grep "SpecForge configuration" -A 10
Extract:
Run each validation level and collect results:
const results = {
spec: { status: "pending", errors: [] },
schema: { status: "pending", errors: [] },
codegen: { status: "pending", errors: [] },
compile: { status: "pending", errors: [] },
runtime: { status: "pending", errors: [] },
};
// Level 1: Spec Validation
try {
await validateSpec();
results.spec.status = "passed";
} catch (error) {
results.spec.status = "failed";
results.spec.errors.push(error);
}
// Level 2: Schema Validation
try {
await validateSchema();
results.schema.status = "passed";
} catch (error) {
results.schema.status = "failed";
results.schema.errors.push(error);
}
// Continue for other levels...
If any validation fails, invoke the validation agent (Sonnet) for deep debugging:
if (
results.spec.status === "failed" ||
results.schema.status === "failed" ||
results.codegen.status === "failed" ||
results.compile.status === "failed" ||
results.runtime.status === "failed"
) {
await invokeAgent("validation-agent", {
model: "sonnet",
results: results,
project_path: ".",
});
}
# SpecForge Validation Report
## Summary
- ✓ Spec Validation: PASSED
- ✓ Schema Validation: PASSED
- ✗ Codegen Validation: FAILED
- - Compile Validation: SKIPPED
- - Runtime Validation: SKIPPED
## Details
### Codegen Validation Errors
1. **Missing generated type**: `Order` type not found in `src/generated/db/models.rs`
- Expected: `pub struct Order { ... }`
- Actual: File does not exist
- Fix: Run `/specforge:build` to regenerate code
2. **Type mismatch**: `user_id` field type mismatch
- Database schema: `INTEGER`
- Generated type: `String`
- Fix: Update sql-gen.toml type overrides
## Recommendations
1. Run code generation: `/specforge:build`
2. Fix type overrides in sql-gen.toml
3. Re-run validation: `/specforge:validate`
Run spec, schema, and compile validation (skip runtime tests):
/specforge:validate
Run all validation levels including runtime tests:
/specforge:validate --full
Run a specific validation level:
/specforge:validate --level spec
/specforge:validate --level schema
/specforge:validate --level codegen
/specforge:validate --level compile
/specforge:validate --level runtime
0: All validations passed1: Spec validation failed2: Schema validation failed3: Codegen validation failed4: Compilation failed5: Runtime validation failedExample GitHub Actions workflow:
name: SpecForge Validation
on: [push, pull_request]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install SpecForge
run: |
/plugin install specforge
/plugin install specforge-backend-rust-axum
/plugin install specforge-db-sqlite
/plugin install specforge-generate-rust-sql
- name: Run Full Validation
run: /specforge:validate --full
Error: Missing required field 'description' for operation POST /users
Fix: Add description to OpenAPI spec:
paths:
/users:
post:
description: Create a new user
# ...
Error: Migration 002 references non-existent table 'users'
Fix: Ensure migrations are sequential and applied in order.
Error: Generated type 'User' does not match database schema
Fix: Re-run code generation with updated schema:
/specforge:build
Error: Type mismatch in handler - expected i64, found String
Fix: Update type overrides in codegen config or fix handler implementation.
Error: API response does not match OpenAPI spec for GET /users/:id
Expected type: object
Actual type: array
Fix: Update handler implementation or OpenAPI spec to match.
Validation ensures your SpecForge project maintains integrity across all layers - from specs to runtime.