agentleFS
Baba01hacker666Baba01hacker666/dummyskills/skills/json-schema-converter/SKILL.md

json-schema-converter

Skill0 starsChanged 2 months agoMITView on GitHub

Transforms unstructured or semi-structured data into strictly schema-conforming JSON with type validation.

The file

We split this skill into the rules it gives an agent

9 rules. About 0 are common, 3 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill when:

    line 14
  2. Very specific:

    Do not use for tabular CSV verification.

    line 20
  3. Very specific:

    Do not use to extract isolated fields.

    line 21
  4. Very specific:

    If raw_input is missing: stop and ask: "Please provide the data to convert."

    line 28
  5. Very specific:

    If target_schema is missing: ask for the expected schema or generate a minimal typed schema and request confirmation.

    line 29
  6. Very specific:

    If a required schema field is absent in raw_input: set to null if nullable, or list under missing fields.

    line 30
  7. Distinctive:

    Follow these numbered actions:

    line 33
  8. Very specific:

    If raw data contains fields not in schema: omit them if additionalProperties: false, or include under extra_metadata if allowed.

    line 47
  9. Distinctive:

    Stop and ask the user when:

    line 81

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

JSON Schema Converter

Converts unstructured text, logs, or informal records into valid, schema-compliant JSON. Ensures exact type mapping, required keys, and deterministic output.

1. Purpose

Turn loose data into machine-readable JSON that validates against a provided JSON Schema (Draft 7 / 2020-12). Enforces data types (string, integer, boolean, array, object).

2. When to Use

Use this skill when:

  • Converting email summaries, logs, or transcripts into structured API payloads.
  • Normalizing messy data before database ingestion.
  • User requests: "Convert this text into JSON matching this schema."

3. When Not to Use

  • Do not use for tabular CSV verification; use csv-validator.
  • Do not use to extract isolated fields; use field-extractor.

4. Required Inputs

  • raw_input: Text, table, or key-value snippets to convert.
  • target_schema: JSON schema specification defining expected keys and types.

5. Missing-Input Behavior

  1. If raw_input is missing: stop and ask: "Please provide the data to convert."
  2. If target_schema is missing: ask for the expected schema or generate a minimal typed schema and request confirmation.
  3. If a required schema field is absent in raw_input: set to null if nullable, or list under missing fields. Do not hallucinate values.

6. Procedure

Follow these numbered actions:

  1. Action 1: Parse Schema Keys & Types
    • Identify required fields and expected types (integer, boolean, string, array).
  2. Action 2: Map Raw Data to Schema Keys
    • Cast strings to numbers/booleans where safe (e.g. "true" -> true, "42" -> 42).
  3. Action 3: Validate Against Schema
    • Run validator helper:
      python3 skills/json-schema-converter/scripts/validate_json.py <json_file>
  4. Action 4: Emit JSON Payload
    • Output clean, indented JSON per Section 8.

7. Decision Rules

  • If raw data contains fields not in schema: omit them if additionalProperties: false, or include under extra_metadata if allowed.
  • Dates must be formatted as ISO-8601 (YYYY-MM-DDTHH:MM:SSZ) if schema format is date-time.

8. Output Format

Emit the JSON conversion using this template:

### JSON Conversion Result

- **Validation**: [VALID | INVALID]
- **Target Schema Keys Met**: [Count] / [Total]

```json
{
  "key": "value"
}

Field Mapping Notes

  • [key]: [Mapped from raw text]

## 9. Verification Checklist
- [ ] Output is 100% valid JSON (passes `json.loads`).
- [ ] All required schema fields are present.
- [ ] Types conform strictly to schema specifications.
- [ ] Companion script [validate_json.py](./scripts/validate_json.py) confirms syntax.

## 10. Common Failures and Recovery
| Failure Symptom | Cause | Recovery Action |
| :--- | :--- | :--- |
| Trailing comma error | Invalid JSON formatting | Strip trailing commas before returning. |
| Type mismatch (string vs int) | Failing to cast `"10"` to `10` | Check schema type property and cast numeric strings. |

## 11. Stop or Escalation Conditions
Stop and ask the user when:
- Raw input contains none of the required schema fields.

## 12. Examples

### Example 1: Successful Execution
**Input:**
```text
Raw input: Customer Alice Smith (id: 402), signed up 2026-05-10, plan: Pro, active.
Schema: {
  "type": "object",
  "required": ["id", "name", "plan", "is_active"],
  "properties": {
    "id": { "type": "integer" },
    "name": { "type": "string" },
    "plan": { "type": "string" },
    "is_active": { "type": "boolean" }
  }
}

Output:

### JSON Conversion Result

- **Validation**: VALID
- **Target Schema Keys Met**: 4 / 4

```json
{
  "id": 402,
  "name": "Alice Smith",
  "plan": "Pro",
  "is_active": true
}

Field Mapping Notes

  • id: Cast string 402 to integer 402.
  • is_active: Inferred true from "active".

### Example 2: Ambiguous or Missing Input
**Input:**
```text
Raw input: Just a random note without customer data.
Schema: (Requires id, name, plan)

Output:

### JSON Conversion Result

- **Validation**: INVALID - Missing Required Fields
- **Target Schema Keys Met**: 0 / 3

The raw input does not contain the required fields `id`, `name`, or `plan`. Please provide customer data matching the schema.

Example 3: Expected Final Output

Output:

### JSON Conversion Result

- **Validation**: VALID
- **Target Schema Keys Met**: 2 / 2

```json
{
  "event": "user_signup",
  "timestamp": "2026-09-10T12:00:00Z"
}

Field Mapping Notes

  • ISO-8601 timestamp formatted per schema date-time requirement.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.