Codeart2d

From gabrielmoreira/agent-skills-mirror · View interactive version

Codeart2d is an AI agent skill from the GitHub repository gabrielmoreira/agent-skills-mirror. Explicit-only last resort. Draws game art from code, with no image model - pixel sprites from a PixelSpec, flat vector props, UI and icons from portable SVG, rigged characters with planted feet, FX with a JS runtime, seam-proven autotiles, playable top-down layouts with collision, stylized parallax

How to use this skill

Skill file

Code Art 2D

You write the art as text (PixelSpec JSON, portable SVG, rig, FX, material, layout or parallax

specs); the scripts render, check and package it. No image model is involved. It is a declared art

source (art_source: "code"), not a placeholder.

Use when

Do not use when

Capability check (once per session)

Run python "<skill-dir>/../generate2dmedia/scripts/route_media.py" resolve --kind image (or --kind video): when it names a route, the image or video skill takes the request unless the user asked for code art. forge_doctor.py in the same folder shows the full picture. If encoding.stdout fails, set PYTHONUTF8=1. For SVG work also run svg_render.py doctor --report <new.json> once per machine.

Art source

This skill is the explicit-only last resort of the route order: the API when a key is configured, then the local image tools, then code art, only when the user asks for it or no route exists. Never substitute it silently for generated art. Before you draw, check what code art can and cannot draw well in style-envelope.md (its table describes strengths, not the route order), and tell the user when a request needs an image model. Disclose every result: "code-drawn, no image model" (codeart-meta.json records "art_source": "code"); never present it as image-model output.

Host notes

Commands

Run each tool as one line from the user's project root: python "<skill-dir>/scripts/<tool>.py" .... <skill-dir> is this skill's folder; sibling skills sit beside it (--build-clips calls <skill-dir>/../generate2dsprite/scripts/build_animation_clips.py). Keep specs and outputs inside the project. Every tool writes a new --output-dir: it refuses an existing one and publishes only a complete result; with --strict-qc a failed check publishes nothing (exit 1). Success prints one JSON line; errors print error: ... and exit 1 (nothing usable is published); usage errors exit 2; a result published for inspection with QA status fail exits 4. Examples to copy: examples/.

Dependencies: numpy and Pillow for everything; PixelSpec rendering and pixel_qa.py need nothing else. SVG art also needs one rasterizer: resvg-py (python -m pip install "resvg-py>=0.5,<0.6", preferred), the resvg-js CLI on PATH, or Chrome/Edge (set CHROME_PATH) (rasterizers.md). Never PyMuPDF, skia-python or cairosvg: they silently ignore crispEdges, <style>, clipPath or gradients. fx_verify.mjs needs node.

Hello sprite

  1. Write gem.pixelspec.json (the "Hello sprite" block in pixelspec.md).
  2. python "<skill-dir>/scripts/render_pixelspec.py" --spec gem.pixelspec.json --output-dir out/gem-v1 --preview-scale 8 --strict-qc
  3. Open out/gem-v1/preview-x8.png; the frames are in out/gem-v1/<variant>/frames/.
  4. Tell the user it is code-drawn (no image model).

Pipeline

| Need | Route |

|---|---|

| Pixel character, prop or FX with palette variants | PixelSpec (pixelspec.md), then render_pixelspec.py --spec <spec> --output-dir <new> --build-clips --strict-qc; review with pixel_qa.py |

| Flat vector character, prop, UI or icon set | portable SVG with palette classes (svg-profile.md), then svg_render.py render --svg <svg> --palette <palette.json> --output-dir <new> --zoom N |

| Crisp pixel art drawn with SVG shapes | svg_render.py render --crisp --zoom N --strict-qc |

| Check an SVG before rendering | svg_render.py lint --svg <svg> --profile portable (add --compile --palette <p>) |

| Small character that walks, idles or attacks with planted feet | rig SVG plus a rig_anim.v1 file (rig-animation.md), then rig_animate.py --rig <svg> --anim <json> --output-dir <new> --build-clips --strict-qc; look at review/*.png |

| Slash, sparks, impact ring, hit flash, dust, projectile | fx.v1 spec (fx-language.md), then fx_build.py --spec <json> --output-dir <new> --build-clips --export-runtime; baked frames for pixel games, fx-runtime.mjs for gameplay-timed FX (fx-runtime-contract.md) |

| Check an fx.v1 runtime | node "<skill-dir>/scripts/fx_verify.mjs" <module.mjs> --report <file> |

| Terrain transitions, roads meeting water, paths over ground, walls and ledges | material spec, then autotile_build.py --material-spec <json> --output-dir <new> --strict-qc (Wang-16, three materials, blob-47, bevel; tiles-and-maps.md) |

| An image-tool texture inside exact tile masks | autotile_build.py --material-texture NAME=PATH --quantize-textures (one tile that wraps) |

| Playable top-down map: roads, props, exits, collision, reachability | layout_build.py --spec <layout.json> --output-dir <new> --preview --strict-qc (--tiles <tileset manifest> for real tiles); open debug.png (layouts-and-parallax.md) |

| Stylized parallax background | parallax_build.py --spec <parallax.json> --output-dir <new> --validate --sweep-frames 49; review sweep-sheet.png |

| Ambient motion on a static plate | ambient_bake.py --plate <png> --spec <effects.json> --output-dir <new> --preview --strict-qc; encode with generate2dmap scene_motion.py |

| QA any pixel frames | pixel_qa.py --input "<glob>" --palette <palette, spec or codeart-meta.json> --review <new.png> --onion --strict --report <new.json> |

Hand-offs: clips go to generate2dsprite export_engine.py (never generate2dsprite.py process); a layout's map_bundle.v2 goes to generate2dmap map_bundle.py validate, map_nav.py check and export_tiled.py / export_godot.py / export_ldtk.py.

Rules

Acceptance

Look at the preview and review sheets at game size and 1x before reporting (style-envelope.md has the review loop). Quote the QA status and failed checks from the JSON summary.

Report every WARN or FAIL check verbatim (id, value, threshold, files) from each published QA envelope; never say "all checks passed" when any published envelope has a warn. Deliver specs, rendered frames or tiles, clips or bundles, codeart-meta.json and the disclosure line. Data contracts: references/schemas/codeart.schema.json.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.