Reconstructs reference images into high-fidelity, editable Draw.io files with rendered previews: native Draw.io elements carry text and structure, SVG covers simple icons that match the reference, and cropped or transparent PNGs preserve complex visuals. Use when the user wants a diagram image, research figure, architecture diagram, slide, UI screenshot, or image folder turned into `.drawio` XML; batch requests use a manifest with bounded parallelism when available and a full-fidelity serial fallback otherwise.
72
88%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
Use this skill for high-quality reconstruction of diagram images into .drawio files.
Resolve SKILL_DIR to the absolute directory containing this SKILL.md before running any bundled helper. Use the resolved skill location provided by the runtime; never assume the skill is installed under ~/.codex, ~/.agents, or any other fixed directory.
All commands below use $SKILL_DIR to mean that resolved absolute directory.
The primary goal is visual fidelity to the reference image. Editability is secondary.
Do not treat semantic equivalence as success. A generic icon, generic curve, generic font size, approximate panel, or approximate background is a defect when the reference has a specific visual style.
Script checks only prove technical validity. A diagram is not complete merely because .drawio opens, exports, or passes check_drawio.py / batch_verify.py. Completion requires visual comparison against the reference at full size.
Work only in the target directory or target files named by the user. Do not repair, overwrite, or improve neighboring diagrams because they look related. If the requested target is ambiguous, inspect and report the ambiguity before editing.
Never silently rewrite the user's content. If the user asks for larger fonts or a more professional PPT style, first distinguish:
Use this workflow when the user provides a directory of images or asks for batch reconstruction.
Before opening images for detailed visual analysis, decide whether the request is a batch reconstruction task:
.drawio, exported .png, audit file, and private asset/crop directory. Reuse a free slot for the next image instead of trying to start every worker at once.Identify the input directory, output directory, naming convention, and overwrite policy.
Create a batch manifest:
python "$SKILL_DIR/scripts/batch_manifest.py" path/to/images --output-dir path/to/output --writeReview the manifest before editing. Process only entries in the manifest unless the user expands scope.
For each image, define the expected <stem>.drawio, <stem>.png, and lightweight <stem>.audit.md outputs in the target output directory.
Choose a bounded parallel schedule or a serial schedule:
.drawio, .png, and <stem>.audit.md; create the complete visible-element inventory; classify non-text visuals; use crops/SVG/native elements according to the normal medium rules; run required checks/exports; visually compare the exported preview against the reference; mark unresolved visual defects instead of claiming completion.After reconstruction, run batch verification:
python "$SKILL_DIR/scripts/batch_verify.py" path/to/output/drawio_batch_manifest.jsonOpen every exported preview and compare it with the reference. Do not trust worker completion or script success alone.
Report completed entries, skipped entries, failures, and any images that need review.
Default batch outputs:
drawio_batch_manifest.json<image-stem>.drawio<image-stem>.png<image-stem>.audit.mdDo not overwrite existing outputs unless the user explicitly asks. If an output exists, either skip it or create a clearly named revision such as <stem>-v2.drawio.
Before reconstructing each image, create a visible-element inventory. For complex or batch work, write it to <stem>.audit.md; for a very small single image, maintain it in working notes and still perform the same checks.
The inventory must cover every visible region and element:
Each inventory item must include:
idDo not begin final delivery until all visible inventory items are accepted or explicitly reported as unresolved.
Use the best medium for visual fidelity. Do not globally default all non-text visuals to screenshots, and do not globally redraw all visuals as SVG. The deciding question is: which method best matches the reference after export?
Prefer Draw.io native elements for:
Use PNG crop / screenshot by default for:
Use SVG/native only for:
Do not use a generic standard icon just because the semantic label matches. Database, chart, document, target, brain, robot, phone, clipboard, cursor, lightbulb, molecule, beaker, monitor, and similar icons still require a shape/style check against the reference.
Classify each visual element before reconstructing it.
needs-fix in the audit instead of silently substituting a poor drawing.Blocking medium defects:
Before writing icon SVGs or embedding crops, make a role-to-symbol map from the reference. For example:
For each map entry:
After creating or editing icons, run check_drawio.py. Duplicate image payloads in evidence icons, core-strip icons, workflow-step icons, or outcome-row icons are blocking failures unless the reference intentionally repeats the same symbol.
Use screenshots/PNG crops when:
When using screenshots:
Avoid screenshots for editable text or structural layout.
Crop around the target foreground artwork, not around the whole surrounding region.
Start from a rough ROI, identify the foreground bbox, then add modest safe padding.
Use the crop helper when possible:
python "$SKILL_DIR/scripts/crop_assist.py" reference.png --roi x,y,w,h --anchor x,y --exclude x,y,w,h --output-dir crops --name icon_nameInspect the generated preview and candidates visually before embedding a crop. The script proposes bounds; the model still decides which candidate best matches the reference.
crop_assist.py requires Pillow. If Pillow is unavailable, request approval before changing the environment, then install the bundled optional dependency with python -m pip install -r "$SKILL_DIR/requirements.txt". Do not silently skip crop inspection.
Use --exclude boxes for nearby elements that are inside the rough ROI but not part of the target artwork, especially bullets, body text, title rules, numbered badges, panel borders, and divider lines.
Safe padding should preserve full strokes, arrowheads, shadows, antialiasing, and immediate intentional whitespace. It should not expand into general empty space.
Do not crop tightly to visible strokes unless tight cropping is required to avoid neighboring content. A clipped stroke, cut-off arrowhead, missing shadow, or artwork touching the crop edge is a blocking defect.
Do not include neighboring bullets, labels, title rules, card borders, divider lines, or unrelated same-color marks. If more padding would pull in a neighbor, use the tighter valid candidate and handle the background with transparency or color matching.
Prefer transparent PNG when the surrounding panel/background is not uniform.
If transparency is not possible or cleanup creates halos, place the crop on a same-color background block.
If the crop background color does not match the Draw.io panel, crop tighter, remove the background, recolor/match the crop background, or set the containing panel/background to match.
If the crop is complex and still has background mismatch after ordinary cleanup, use an available image editing/generation tool to repair or neutralize only the background; do not alter the semantic foreground.
Check exported PNG for visible seams, antialiasing halos, jagged transparency, blur, or mismatched background. Do not leave visible rectangular crop seams.
For every arrow or curve, match the reference before choosing implementation.
Create an arrow inventory:
Implementation order:
Large loop arrows, dashed feedback curves, and rounded return paths must match the reference path geometry. Do not replace them with approximate generic connectors.
Extract typography from the reference image before assigning sizes:
For every text role, capture approximate font size, weight, color, line height, alignment, and available box size. Do not apply SIGMOD running-example font baselines unless the reference is explicitly a SIGMOD-style running example.
Treat every text change as a box-model change:
text -> text box -> card/row -> containing panel -> neighboring layout.
Hard failures:
Default outputs:
<name>.drawio<name>.png<name>.audit.md for batch or complex reconstructionsBefore final response, compare the exported PNG against the reference at full size and explicitly check every inventory item.
Blocking defects:
needs-fixIf any item fails, continue editing. Do not present the diagram as finished.
For batch jobs, the parent agent must open every exported preview and every worker audit file before final response. Worker completion is not delivery acceptance.
If the user provides a manually adjusted screenshot or .drawio file as a quality reference, use it as the style source before changing another diagram.
Prefer the .drawio file when available because it exposes real geometry:
.drawio has stale page metadata but exports correctly, use the content bounding box and exported PNG for validation.If the user provides a screenshot with red boxes or annotations:
Always verify the .drawio after edits:
python "$SKILL_DIR/scripts/check_drawio.py" path/to/file.drawio
python "$SKILL_DIR/scripts/export_drawio.py" path/to/file.drawio path/to/preview.pngFor batch jobs:
python "$SKILL_DIR/scripts/batch_manifest.py" path/to/images --output-dir path/to/output --write
python "$SKILL_DIR/scripts/batch_verify.py" path/to/output/drawio_batch_manifest.jsonThe checker catches XML validity and common containment failures; it is not a substitute for visual inspection. After export, inspect the rendered PNG against the reference before final response.
Keep the final response short:
.drawio file..png preview.aff5de9
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.