| name | tikz-constraint-harness |
| description | Comprehensive TikZ generation, reference-image replication, revision, and constraint-verification workflow. Use when Codex must create or repair TikZ figures, reproduce TeXample-style diagrams, build a TikZ benchmark/harness, retrieve reusable TikZ templates, run compile/render/QA loops, preserve revision invariants, or coordinate planner/generator/verifier/repair agent roles. |
TikZ Constraint Harness
Core Rule
Do not jump straight to TikZ code. First convert the task into constraints, retrieve a matching pattern/template, generate standalone code, compile/render it, then verify constraints and repair locally.
Load Only What You Need
- For task workflows, read
references/workflows.md.
- For planner/generator/verifier/repair role prompts, read
references/agent_roles.md.
- For failure taxonomy and repair recipes, read
references/error_taxonomy_repair.md.
- For TeXample-derived pattern choices, query
references/texample_pattern_index.jsonl first; for broader search, query references/texample_full_index.jsonl.
- For ready-to-adapt code, inspect
templates/ and examples/.
Default Pipeline
- Parse: extract objects, relations, geometry, style, text, and revision invariants.
- Retrieve: run
scripts/query_patterns.py or inspect templates/ for the closest family.
- Draft IR: write a compact Constraint IR before code.
- Generate: produce a standalone
.tex document with explicit libraries and named nodes.
- Compile: use XeLaTeX for CJK-safe output; save
compile.log.
- Render/Inspect: compare against target/reference constraints, not only compile status.
- Repair: patch only violated constraints; revision tasks must preserve
unchanged_constraints.
- Report: output code path, source patterns, compile status, unresolved violations, and QA note.
Constraint Layers
object: nodes, shapes, endpoints, legends, subfigures.
relation: edges, hierarchy, containment, adjacency, dependency, feedback loops.
geometry: relative position, alignment, spacing, angle, scale, bounding boxes.
style: color, line style, arrow style, fill, opacity, emphasis.
text: labels, formulas, numbering, captions, legends.
revision: what changed and what must remain unchanged.
Template Selection
Use scripts/query_patterns.py "<task words>" --top-k 8 to retrieve TeXample families. Then choose a local template:
templates/flowchart_process.tex for process, CONSORT, data flow, workflows.
templates/graph_network.tex for graphs, neural networks, dependency networks.
templates/tree_hierarchy.tex for trees, decision/probability trees, family trees.
templates/state_machine.tex for automata, state diagrams, Turing-machine-like control.
templates/feedback_system.tex for control systems, signal flow, block diagrams.
templates/logic_circuit.tex for gates, circuits, ports, quantum/circuit-like drawings.
templates/geometry_angles.tex for angles, triangles, force diagrams, math geometry.
templates/pgfplots_chart.tex for plots, axes, bar/line/scatter charts.
templates/dense_grid.tex for periodic-table-like grids and dense labeled matrices.
templates/mindmap_radial.tex for radial maps and concept diagrams.
templates/bayesian_network.tex for probabilistic graphical models.
templates/revision_overlay.tex for local edits, highlights, before/after overlays.
Validation Commands
From this skill folder:
python3 scripts/query_patterns.py "control feedback block diagram" --top-k 5
python3 scripts/validate_skill.py .
For a generated figure:
xelatex -interaction=nonstopmode -halt-on-error figure.tex
Attribution
TeXample.net content is licensed under Creative Commons Attribution-ShareAlike 4.0 International License. Preserve source URLs, site attribution, and license notes whenever using TeXample-derived examples or pattern summaries.