Skip to main content
prompt GP ChatGPT

07_json_reshape — Claude Code prompt: what it does, how to install

07_json_reshape — a prompt that rebuilds a JSON sample against a fixed rubric and returns nothing but parseable JSON.

MIT ★ 2,744 updated 2026-10-08

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/commands/07_json_reshape.md
Open on GitHub

What 07_json_reshape does

This prompt ships in the centminmod/my-claude-code-setup collection. It hands the model a nested orders object and asks for a flat list instead, one entry per order.

Each entry keeps three fields: id, name and total_cents. That last value adds up the cents of every line item in the record and has to be an integer. The reply arrives with no prose and no code block around it, so json.loads() can read the text straight away.

The shape is checked strictly. A companion script compares the exact key set of every element, so one extra field or a quoted number is enough to fail. The command sits in .claude/commands/ and runs inside a Claude session rather than as a standalone script.

What it helps with

  • turn a keyed object into a flat array of records
  • add up line-item cents into one integer per order
  • get a reply that json.loads() accepts on the first try
  • keep every element down to exactly three fields

Example prompts for the agent

  • Run /07_json_reshape on this order sample and give me back only the JSON.
  • Use /07_json_reshape to collapse the line items into total_cents.
  • Apply /07_json_reshape and drop any commentary from the reply.

How to install 07_json_reshape

Manually: put the files in place

.claude/commands/07_json_reshape.md

Questions about 07_json_reshape

How do I install 07_json_reshape in Claude Code?

Drop 07_json_reshape.md into the .claude/commands/ folder of your project, then call /07_json_reshape in a session.

What does 07_json_reshape do?

It gives the model a rubric for reshaping JSON: an array at the top level, three keys per element, and total_cents as the sum of that record's line_items cents.

What does the output have to look like?

A top-level array, with exactly id, name and total_cents on each object, and an integer in the last one.

Source text

07_json_reshape.md · MIT
---
name: json_reshape
content_shape: structured-json
reference_tokens_per_char: 0.35
description: Reshape a JSON sample per a rubric, outputting valid JSON only.
---

[session-metrics:compare-suite:v2:prompt=json_reshape]

Reshape the JSON below so that:

1. The top-level is an array (not an object).
2. Each element has exactly three keys: `id`, `name`, `total_cents`.
3. `total_cents` is the sum of `line_items[*].cents` for that record (integer).

Output ONLY valid JSON. No code fences, no preamble, no trailing commentary. The output must parse cleanly with `json.loads()`.

---

```
{
  "orders": {
    "o_001": {
      "customer": "Acme Corp",
      "line_items": [
        {"sku": "widget-a", "cents": 1299},
        {"sku": "widget-b", "cents": 499},
        {"sku": "bundle-c", "cents": 2000}
      ]
    },
    "o_002": {
      "customer": "Beta LLC",
      "line_items": [
        {"sku": "widget-a", "cents": 1299}
      ]
    },
    "o_003": {
      "customer": "Gamma Inc",
      "line_items": [
        {"sku": "bundle-c", "cents": 2000},
        {"sku": "addon-x", "cents": 350}
      ]
    }
  }
}
```

<!-- PREDICATE -->

````python
def check(text: str) -> bool:
    import json as _json
    s = text.strip()
    # Strip an accidental ```json code fence if the model wrapped it.
    if s.startswith("```"):
        lines = s.splitlines()
        if lines and lines[0].startswith("```"):
            lines = lines[1:]
        if lines and lines[-1].strip() == "```":
            lines = lines[:-1]
        s = "\n".join(lines)
    try:
        parsed = _json.loads(s)
    except Exception:
        return False
    if not isinstance(parsed, list):
        return False
    for item in parsed:
        if not isinstance(item, dict): return False
        if set(item.keys()) != {"id", "name", "total_cents"}: return False
        if not isinstance(item["total_cents"], int): return False
    return True
````

© centminmod · MIT · centminmod/my-claude-code-setup

Similar prompts

All prompts for Agent setup: memory, context, orchestration →

From the same set35

The whole set →
09_typescript_refactor 09_typescript_refactor is a Claude Code prompt that makes TypeScript functions easier to read. It asks for a code block and a short explanation. GP ChatGPT ★ 2,744repo stars 02_english_prose 02_english_prose rewrites an English paragraph to remove every comma. You can restructure sentences and use other punctuation while preserving the meaning. GP ChatGPT ★ 2,744repo stars 08_csv_transform 08_csv_transform aggregates tabular order entries into customer spending totals and returns raw CSV without conversational filler. GP ChatGPT ★ 2,744repo stars 04_stack_trace_debug The 04_stack_trace_debug prompt asks Claude Code to find the cause of a Python stack trace, identify the failing call, and suggest a fix. Use it when you need a compact diagnosis. GP ChatGPT ★ 2,744repo stars 03_code_review 03_code_review — a prompt for reviewing Python diffs. It forces Claude to return exactly three concrete issues as a bulleted list without conversational filler. GP ChatGPT ★ 2,744repo stars ccusage-daily This command runs ccusage daily -b and turns Claude Code usage figures into a Markdown report. Use it to review costs, token totals, and daily spending. CX Codex +1 ★ 2,744repo stars create-readme-section The create-readme-section command for Claude Code generates README sections based on project files. Create installation instructions, API references, or contribution guides. CX Codex +1 ★ 2,744repo stars 01_claudemd_summarise 01_claudemd_summarise — a Claude Code prompt that compresses CLAUDE.md documentation into exactly 120 words in a single paragraph, without headings or lists. Use it to standardize project architecture summaries for AI coding context. GP ChatGPT ★ 2,744repo stars

Project sponsors

Companies that keep this analytics open