dev/agent-skills/cocoindex-diagrams/references/workflow.md
Diagrams are visual artifacts. "The build compiled" is not sufficient evidence that they render correctly — always screenshot and look.
The docs site configures base: '/docs' in astro.config.mjs. As a
result, the built HTML references CSS at /docs/_astro/.... If the
local preview server is rooted at dist/ without mirroring that prefix,
the CSS returns 404, all CSS variables are undefined, and every SVG
fill: var(--cream) resolves to black.
Symptom: All diagram boxes render as solid black rectangles, but text labels are visible. This is NOT a code bug. Fix the server, not the diagram.
The scripts/preview.sh script handles this correctly by rsyncing the
dist/ output into a docs/ subdirectory before serving.
scripts/preview.sh <docs-slug> [crop-y-top]
# Example: scripts/preview.sh programming_guide/core_concepts
# Example: scripts/preview.sh programming_guide/core_concepts 3300
The script:
npm run build inside docs/.docs/dist/ → a temp directory under docs/.1400x5200, scale 1.Read the PNGs back with the Read tool. Claude Code is multimodal — it
can see and critique the rendered output.
Full-page screenshots are tall. To find your diagram:
magick /tmp/dg-preview/full.png -crop 1400x500+0+3300 /tmp/dg-preview/crop.png
+2500, +3500, +4000)..astro file.scripts/preview.sh <slug>.Read the PNG.Expect 2–4 cycles for any non-trivial diagram. First render almost always surfaces issues invisible from code (e.g., labels overlapping icons).
Minor text/label edits that don't affect layout (e.g. fixing a typo in a label string) can skip preview if the diagram otherwise passed a recent review. Everything that touches coordinates, shape choices, or new primitives needs a preview.
The preview script writes to /tmp/dg-preview/ and starts a local HTTP
server. Both clean up on next run. If a port gets stuck:
lsof -ti:8765 | xargs kill -9