Skill

Validate Application Configurations

Validates, tests, and secures application configuration - JSON Schema validation, environment-specific rules, runtime watching, migrations, and secret scanning.

Works with githubjest

70
Spark score
out of 100
Updated last month
Version 13.1.0

Add to Favorites

Why it matters

Ensure your application configurations are robust, secure, and consistent across all environments. This skill provides expert validation, schema implementation, and testing strategies to prevent configuration-related errors.

Outcomes

What it gets done

01

Analyze configuration files for potential security and consistency issues.

02

Implement JSON Schema validation for robust type checking and data integrity.

03

Define and enforce environment-specific configuration rules.

04

Automate configuration testing to catch errors before deployment.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/ag-deployment-validation-config-validate | bash

Overview

Configuration Validation

A configuration validation skill covering JSON Schema validation, environment-specific rules, runtime watching, migrations, and secret scanning. Use for configuration validation tasks - schema validation, environment consistency, runtime watching, migrations, or secret scanning.

What it does

This skill acts as a configuration management expert validating, testing, and ensuring the correctness of application configurations, creating comprehensive validation schemas, testing strategies, and security checks to keep configuration secure, consistent, and error-free across environments.

Its configuration analysis step scans a project for config files (JSON, YAML, TOML, INI, .env, config.js) and flags potential hardcoded secrets by matching patterns like API keys, passwords, tokens, and AWS credentials against file contents. Its schema validation step uses Ajv (JSON Schema) with custom formats - an url-https format requiring HTTPS URLs, a port format validating the 1-65535 range, and a duration format matching strings like 30s/5m - to validate configuration objects against named schemas (e.g. a database config schema requiring host/port/database/user/password with a minimum password length).

Its environment-specific validation applies different rules per environment (development allows debug mode and shorter passwords with HTTP; production requires HTTPS, disables debug, and enforces stricter password length). Its configuration testing step uses Jest to assert valid configs pass and invalid ones (e.g. an out-of-range port) are rejected by the validator. Its runtime validation component loads and validates configuration on startup, watches the config file for changes via chokidar, re-validates on each change, and emits config:changed/validation:error events - throwing in non-development environments if validation fails, to prevent bad config from silently taking effect.

Its configuration migration system defines versioned migration classes with up/down methods, using semver comparison to determine which migrations apply between a config's current _version and a target version, applying them in order and stamping the resulting version. Its secure configuration component covers encrypting sensitive configuration values. Its documentation generation step auto-generates a Markdown configuration reference from the JSON Schema and example values, including type, default, description, and a YAML example per property.

Its output format covers seven deliverables: a configuration analysis (current assessment), validation schemas (JSON Schema definitions), environment-specific rules, a configuration test suite, migration scripts for version changes, a security report of issues and recommendations, and auto-generated documentation.

export class ConfigValidator {
  private ajv: Ajv;

  constructor() {
    this.ajv = new Ajv({ allErrors: true, strict: false, coerceTypes: true });
    ajvFormats(this.ajv);
    this.addCustomFormats();
  }

  private addCustomFormats() {
    this.ajv.addFormat('url-https', {
      type: 'string',
      validate: (data) => {
        try { return new URL(data).protocol === 'https:'; }
        catch { return false; }
      }
    });

    this.ajv.addFormat('port', {
      type: 'number',
      validate: (data) => data >= 1 && data <= 65535
    });
  }

  validate(configData, schemaName) {
    const validate = this.ajv.getSchema(schemaName);
    if (!validate) throw new Error(`Schema '${schemaName}' not found`);
    const valid = validate(configData);
    return valid ? { valid: true } : { valid: false, errors: validate.errors };
  }
}

When to use - and when NOT to

Use this skill when working on configuration validation tasks or workflows needing guidance, best practices, or checklists - validating config files against a schema, ensuring environment-specific consistency, watching config at runtime, migrating config versions, scanning for hardcoded secrets, or generating configuration documentation.

Not for tasks unrelated to configuration validation, or where a different domain or tool is needed.

Inputs and outputs

Inputs: a project's configuration files (JSON/YAML/TOML/INI/.env) and their target environment.

Outputs: JSON Schema validation definitions with custom formats, environment-specific validation rules, a configuration test suite, a runtime config watcher emitting change/error events, versioned migration scripts, a security report flagging potential hardcoded secrets, and auto-generated Markdown documentation.

Integrations

Ajv (JSON Schema validation), ajv-formats, Jest, chokidar (file watching), semver.

Who it's for

Developers who need to validate, test, and secure application configuration across environments with schema enforcement, runtime watching, and migration support.

FAQ

Common questions

Discussion

Questions & comments ยท 0

Sign In Sign in to leave a comment.