salvage

Extract and repair valid JSON from malformed language model outputs.

6|1|Updated Jun 23, 2026
One-click install
npx skills add https://github.com/JGalego/Bag-of-Tricks --skill salvage-jgalego
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: salvage
Source: https://github.com/JGalego/Bag-of-Tricks/tree/main/salvage
Command: npx skills add https://github.com/JGalego/Bag-of-Tricks --skill salvage-jgalego

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

This Skill addresses the issue of extracting and repairing valid JSON from the verbose, often malformed output generated by language models, ensuring that downstream systems receive structured data.

Core Features & Use Cases

  • JSON Extraction: Pulls out clean JSON from chatty LLM responses.
  • Damage Repair: Corrects common issues like trailing commas, Python literals, and smart quotes.
  • Use Case: When working with LLMs, you might receive a response with malformed JSON. This Skill can be used to clean up the output and make it usable for further processing.

Quick Start

Use the salvage skill to extract and repair JSON from the model's response: salvage "Here's the model's response with malformed JSON."

Frequently Asked Questions about salvage

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I extract valid JSON from an LLM response that includes markdown fences and trailing commas?

Extracting valid JSON from chatty LLM output involves filtering the response through a stdin-to-stdout pipe that removes markdown fences and repairs trailing commas. This ensures downstream systems receive clean, structured data without manual edits.

What is the best way to fix malformed JSON containing Python literals and smart quotes from language model output?

Fixing malformed JSON with Python literals and smart quotes requires a data repair filter that normalizes these characters into standard JSON syntax. The salvage tool operates as a CLI filter to automatically correct these common LLM formatting issues.

Do I need to install additional dependencies to parse and repair JSON from CLI tool output?

No additional dependencies are required to parse and repair JSON from CLI tool output. The salvage skill operates independently as a stdin-to-stdout filter, ensuring you can clean LLM responses without adding extra packages to your environment.

Can I use a stdin-to-stdout filter to clean up verbose LLM responses for downstream data processing?

Yes, you can use a stdin-to-stdout filter to clean verbose LLM responses for data processing. The salvage skill intercepts chatty model output, strips non-JSON text, and outputs repaired JSON directly to standard output for immediate downstream consumption.

Why does JSON parsing fail on language model output that includes conversational text?

JSON parsing fails on language model output because conversational text, markdown fences, and Python-style literals violate strict JSON syntax rules. Data repair tools isolate the JSON structure and correct these formatting deviations to restore validity.