Skill: aronchick/expanso-json-validate (version 1.0.0)

# json-validate "Validate JSON syntax and structure" ## Requirements - Expanso Edge installed (`expanso-edge` binary in PATH) - Install via: `clawhub install expanso-edge` ## Usage ### CLI Pipeline ```bash # Run standalone echo '<input>' | expanso-edge run pipeline-cli.yaml ``` ### MCP Pipeline ```bash # Start as MCP server expanso-edge run pipeline-mcp.yaml ``` ### Deploy to Expanso Cloud ```bash expanso-cli job deploy https://skills.expanso.io/json-validate/pipeline-cli.yaml ``` ## Files | File | Purpose | |------|---------| | `skill.yaml` | Skill metadata (inputs, outputs, credentials) | | `pipeline-cli.yaml` | Standalone CLI pipeline | | `pipeline-mcp.yaml` | MCP server pipeline |

path: README.md
content: # json-validate

Validate JSON syntax and structure with detailed error reporting.

## Overview

This skill validates JSON content locally without any API calls. It parses the JSON and returns whether it's valid, any error messages, and statistics about the structure.

## Usage

### CLI Mode

```bash
# Validate JSON string
echo '{"key": "value"}' | expanso-edge run pipeline-cli.yaml

# Validate JSON file
cat data.json | expanso-edge run pipeline-cli.yaml
```

### MCP Mode

```bash
# Start server
PORT=8080 expanso-edge run pipeline-mcp.yaml &

# Make request
curl -X POST http://localhost:8080/validate \
  -H "Content-Type: application/json" \
  -d '{"json": "{\"key\": \"value\", \"array\": [1, 2, 3]}"}'
```

## Output

### Valid JSON

```json
{
  "valid": true,
  "error": null,
  "parsed": {
    "key": "value",
    "array": [1, 2, 3]
  },
  "stats": {
    "type": "object",
    "length": 35
  },
  "metadata": {
    "skill": "json-validate",
    "mode": "cli",
    "trace_id": "abc123...",
    "timestamp": "2024-01-15T10:30:00Z"
  }
}
```

### Invalid JSON

```json
{
  "valid": false,
  "error": "Invalid JSON syntax",
  "parsed": null,
  "stats": null,
  "metadata": { ... }
}
```

## Use Cases

- Validating API responses
- Pre-commit hooks for JSON files
- CI/CD pipeline validation
- Data ingestion validation


path: pipeline-cli.yaml
content: # Expanso Pipeline: json-validate (CLI mode)
# ===========================================
#
# Usage:
#   echo '{"key": "value"}' | expanso-edge run pipeline-cli.yaml
#   cat data.json | expanso-edge run pipeline-cli.yaml
#
# No API key needed - runs entirely locally.

name: "json-validate-cli"
type: pipeline

config:
  input:
    stdin:
      codec: all
      max_buffer: 10485760

  pipeline:
    processors:
      - mapping: |
          meta input_hash = content().hash("sha256").encode("hex")
          meta input_length = content().length()
          meta trace_id = uuid_v4()

          # Try to parse JSON
          let parsed = content().parse_json().catch(null)
          let error = if $parsed == null { "Invalid JSON syntax" } else { null }

          root.valid = $parsed != null
          root.error = $error
          root.parsed = $parsed
          root.stats = if $parsed != null {
            {
              "type": $parsed.type(),
              "length": content().length()
            }
          } else { null }
          root.metadata = {
            "skill": "json-validate",
            "mode": "cli",
            "input_hash": meta("input_hash"),
            "input_length": meta("input_length"),
            "trace_id": meta("trace_id"),
            "timestamp": now()
          }

      - log:
          level: INFO
          message: |
            [json-validate] Valid: ${! root.valid } (trace: ${! meta("trace_id").slice(0, 8) })

  output:
    stdout:
      codec: json_object


path: pipeline-mcp.yaml
content: # Expanso Pipeline: json-validate (MCP mode)
# ===========================================
#
# Usage:
#   PORT=8080 expanso-edge run pipeline-mcp.yaml &
#   curl -X POST http://localhost:8080/validate \
#     -d '{"json": "{\"key\": \"value\"}"}'

name: "json-validate-mcp"
type: pipeline

config:
  http:
    enabled: true
    address: "0.0.0.0:${PORT:-8080}"

  input:
    http_server:
      path: /validate
      allowed_verbs: [POST]
      timeout: 30s

  pipeline:
    processors:
      - mapping: |
          let json_content = this.json.or(content())
          meta input_hash = $json_content.hash("sha256").encode("hex")
          meta input_length = $json_content.length()
          meta trace_id = uuid_v4()

          let parsed = $json_content.parse_json().catch(null)
          let error = if $parsed == null { "Invalid JSON syntax" } else { null }

          root.valid = $parsed != null
          root.error = $error
          root.parsed = $parsed
          root.stats = if $parsed != null {
            {
              "type": $parsed.type(),
              "length": $json_content.length()
            }
          } else { null }
          root.metadata = {
            "skill": "json-validate",
            "mode": "mcp",
            "input_hash": meta("input_hash"),
            "input_length": meta("input_length"),
            "trace_id": meta("trace_id"),
            "timestamp": now()
          }

      - log:
          level: INFO
          message: |
            [json-validate] Valid: ${! root.valid } (trace: ${! meta("trace_id").slice(0, 8) })

  output:
    sync_response: {}


path: skill.yaml
content: # Skill: json-validate
# Version: 1.0.0
#
# Validate JSON syntax and optionally check against a schema.
# Runs locally without API calls.

name: "json-validate"
version: "1.0.0"
description: "Validate JSON syntax and structure"

author:
  name: "Expanso Team"
  url: "https://expanso.io"
  avatar: "EX"

credentials: []  # No API key needed

inputs:
  - name: json
    type: string
    required: true
    description: JSON content to validate

outputs:
  - name: valid
    type: boolean
    description: Whether the JSON is valid
  - name: error
    type: string
    description: Error message if invalid
  - name: parsed
    type: object
    description: Parsed JSON object (if valid)
  - name: stats
    type: object
    description: Statistics about the JSON (keys, depth, etc.)

backends:
  - name: local
    type: local
    requires: []
    description: Pure local validation

components:
  inputs:
    - stdin
    - http_server
  processors:
    - mapping
  outputs:
    - stdout
    - sync_response


path: test/fixtures/input.txt
content: {
  "name": "example",
  "version": "1.0.0",
  "config": {
    "enabled": true,
    "settings": {
      "timeout": 30,
      "retries": 3
    }
  },
  "items": [
    {"id": 1, "name": "first"},
    {"id": 2, "name": "second"}
  ]
}


path: test/test.yaml
content: # Test cases for json-validate skill

tests:
  - name: "Valid simple JSON"
    input: '{"key": "value"}'
    expected:
      has_field: valid
      has_field: parsed
      metadata_has: [skill, trace_id, timestamp]

  - name: "Valid complex JSON"
    input_file: fixtures/input.txt
    expected:
      has_field: valid
      has_field: stats

  - name: "Invalid JSON"
    input: '{"key": value}'
    expected:
      has_field: valid
      has_field: error


Security scan verdicts — ClawScan: clean | static analysis: clean | VirusTotal: clean | SkillSpector: clean (LOW)