
# Image Reconstruction
**Bring a reference. Choose what stays. Make your own version.**
An agent skill for breaking an image into named parts, saving its visual decisions, and writing the prompts to recreate, remix, or edit it. Includes a visual map, reconstruction JSON schema, prompt compiler, and a worked before/after example.
## Install
**Codex**
```sh
mkdir -p ~/.codex/skills
git clone https://github.com/codejunkie99/image-reconstruction.git ~/.codex/skills/image-reconstruction
```
**Claude Code**
```sh
mkdir -p ~/.claude/skills
git clone https://github.com/codejunkie99/image-reconstruction.git ~/.claude/skills/image-reconstruction
```
Git refuses to overwrite an existing installation. If the skill is not listed immediately, start a new session.
## Use it
Attach your reference image and any product image you want to use. In Codex:
```text
$image-reconstruction Recreate this look for my product. Keep the lighting and layout, and use my product and label.
```
In Claude Code, use `/image-reconstruction` with the same request.
You can also ask for a breakdown or a specific edit:
```text
$image-reconstruction Break down this reference into a visual map and reusable JSON. Do not generate an image yet.
$image-reconstruction Change the cap to black metal. Keep the bottle shape, label, lighting direction, and background.
```
The agent inspects the actual reference, identifies the parts and their relationships, records your changes, and compiles a rendering prompt. It uses its available image tool to create the result, then checks the intended changes and protected details.
Keep the JSON together with its reference images so the next edit starts from the same decisions.
## What is included
- [SKILL.md](SKILL.md): the complete agent workflow.
- [Visual map](visual-map.html): select named parts, plan changes, and export prompts or JSON.
- [Field guide](references/field-guide.md) and [JSON schema](references/reconstruction.schema.json): the reusable reconstruction format.
- [Python compiler](scripts/reconstruct.py): validate a record and compile reconstruction or edit prompts.
- [Worked example](examples/vellum-run.json): original input, exact prompt, result, and recorded review.
## All resources
The full [Image Loop collection](https://github.com/codejunkie99/image-loop) is open source, including all five agent skills and the complete Prompt Lab:
- [Illustrated guide with prompts and results](https://github.com/codejunkie99/image-loop/blob/main/prompt-lab/image-prompting-article-with-prompts-and-results.md).
- [Prompt library](https://github.com/codejunkie99/image-loop/blob/main/prompt-lab/article-package/prompt-library.md) and [saved prompt files](https://github.com/codejunkie99/image-loop/tree/main/prompt-lab/article-package/prompts).
- [50-page visual guide](https://github.com/codejunkie99/image-loop/blob/main/prompt-lab/article-package/visual-guide.pdf).
- [All five skills](https://github.com/codejunkie99/image-loop/tree/main/skills): image reconstruction, image loop, image edit map, reverse engineering, and inspiration.
- [Examples, visual maps, experiment records, and downloadable bundles](https://github.com/codejunkie99/image-loop/tree/main/prompt-lab).
Original code is MIT licensed. Credits and rights for third-party reference material remain as documented in the collection.
## The worked example
The VELLUM photograph was mapped into 15 named elements, including the cap, label, glass highlights, and reflection. The reconstruction used both the clean source image and the compiled prompt.
| Source | Reconstruction |
| --- | --- |
|  |  |
The recorded review found that the composition, bottle shape, and readable label text stayed close. Wood grain, paper texture, stone veins, and reflections changed. This is one reconstruction example, not a guarantee of identical pixels or a model benchmark.
[View the reconstruction JSON](examples/vellum.reconstruction.json) · [Read the exact prompt](examples/vellum-reconstruction-prompt.txt) · [Inspect the run record](examples/vellum-run.json)
## Open the visual map
From the repository folder:
```sh
python3 -m http.server 8000 --bind 127.0.0.1
```
Open [the local map](http://localhost:8000/visual-map.html). The bundled example is ready to inspect. For another image, ask your agent to prepare reconstruction JSON, then use **Import reconstruction JSON** and **Attach its clean source**.
The map prepares instructions; it does not analyze an upload or generate an image by itself. Its selection boxes and crop previews are approximate regions, not recovered layers.
## Validate and compile
Requires Python 3.9 or later; the compiler uses only the standard library.
```sh
python3 scripts/reconstruct.py self-check
python3 scripts/reconstruct.py validate examples/vellum.reconstruction.json
python3 scripts/reconstruct.py compile examples/vellum.reconstruction.json --format json --output compiled.json
```
For a JSON record containing a selected target and requested changes:
```sh
python3 scripts/reconstruct.py compile path/to/selected-edit.json --mode edit --format json --output edit-prompt.json
```
The output separates the rendering prompt, image attachments, requirements, and review flags. The compiler makes no generation or network calls. Actual generation requires an image-capable agent with an available image tool; a path in a prompt does not attach the image.
## Source and license
Extracted from `skills/image-reconstruction` in [Image Loop](https://github.com/codejunkie99/image-loop/tree/77a1b781b91a04f96afa6a3158d56fb8b4171870/skills/image-reconstruction), preserving the skill and its supporting files.
[MIT license](LICENSE). Not affiliated with OpenAI or Anthropic.