tscircuit-visualization
Skill101 starsChanged 3 months agoMITView on GitHub
Work with tscircuit visualization in this repo. Use when changing `GraphicsObject` solver `visualize()` or `preview()` output, `convertSrjToGraphicsObject`, layer-aware SVG/PNG rendering, visual snapshot tests, final routed-output graphics, topology graphics, capacity-node rects, or graphics-debug image export.
In this repository5 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- blacksmith-testboxSkill
- tscircuit-create-solverSkill
- tscircuit-performance-improvement-workflowSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
16 rules. About 0 are common, 10 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈10
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 8
Use GraphicsObject for solver debug views, final SRJ output views, SVG snapshots, PNG artifacts, and interactive debug fixtures.
- Very specific: line 12
Import types from graphics-debug:
- Distinctive: line 28
Do not redefine or explain those shapes in repo docs or tests.
- Very specific: line 32
Use these library functions from graphics-debug:
- Distinctive: line 38
Call them with white backgrounds for stable snapshots/artifacts:
- Distinctive: line 70
Do not hard-code the error count.
- Distinctive: line 72
Prefer minimal SVG snapshot tests over large debug dumps.
- Distinctive: line 74
Use one of these patterns:
- Very specific: line 103
Use createRectFromCapacityNode for capacity-node rectangles.
- Distinctive: line 119
Use line width to mean physical or solver-relevant width.
- Very specific: line 149
Use layer: "z0", layer: "z1", or layer: "z0,1" for layer-aware geometry.
- Distinctive: line 151
Use helper functions instead of hand-mapping layer strings:
- Distinctive: line 197
Use solver-native visualization for internal state, candidates, failed geometry, staged progress, and labels.
- Very specific: line 199
Use convertSrjToGraphicsObject(solver.getOutputSimpleRouteJson()) for final emitted routes, vias, jumpers, and obstacles.
- Distinctive: line 201
Use component-topology visualization for pipeline 7 structure.
- Distinctive: line 203
Keep SVG and PNG backgrounds white.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
tscircuit Visualization
Use GraphicsObject for solver debug views, final SRJ output views, SVG snapshots, PNG artifacts, and interactive debug fixtures.
Graphics Object Types
Import types from graphics-debug:
import type {
GraphicsObject,
Point,
Line,
InfiniteLine,
Rect,
Circle,
Polygon,
Arrow,
Text,
} from "graphics-debug"Do not redefine or explain those shapes in repo docs or tests.
Image Functions
Use these library functions from graphics-debug:
import { getSvgFromGraphicsObject } from "graphics-debug"import { getPngBufferFromGraphicsObject } from "graphics-debug"import { InteractiveGraphics } from "graphics-debug/react"
Call them with white backgrounds for stable snapshots/artifacts:
- SVG:
getSvgFromGraphicsObject(graphics, { backgroundColor: "white" }) - PNG:
await getPngBufferFromGraphicsObject(graphics, { backgroundColor: "white", pngWidth: 1536, pngHeight: 1536 })
Repo helpers:
tests/fixtures/getLastStepGraphicsObject.tstests/fixtures/getLastStepSvg.tslib/testing/PipelineStageDebugRunner.ts
Minimal SVG Tests
For solved bug-report boards, use getBugReportSnapshotSvg from
lib/testing/getBugReportSnapshotSvg. It renders the board with a relaxed-DRC
error-count overlay, using the same evaluator as benchmarks. Supply the original
input, the solver's point-paired SRJ, and newly routed traces. The helper includes
preloaded copper and honors replacement metadata in both DRC and the drawing.
expect(solver.solved).toBe(true)
await expect(
getBugReportSnapshotSvg({
inputSrj: input,
srjWithPointPairs: solver.srjWithPointPairs!,
routedTraces: solver.getOutputSimplifiedPcbTraces(),
}),
).toMatchSvgSnapshot(import.meta.path)Defaults are benchmark relaxed rules. If a report intentionally uses a board's
custom clearances, pass explicit drcOptions and document that policy in the test.
Do not hard-code the error count. The bug-report creation script uses this helper.
Prefer minimal SVG snapshot tests over large debug dumps.
Use one of these patterns:
expect(solver.visualize()).toMatchGraphicsSvg(import.meta.path)expect(getLastStepSvg(solver.visualize())).toMatchSvgSnapshot(import.meta.path)const result = solver.getOutputSimpleRouteJson()
expect(convertSrjToGraphicsObject(result)).toMatchGraphicsSvg(import.meta.path)Update snapshots with:
BUN_UPDATE_SNAPSHOTS=1 bun testRelevant paths:
tests/fixtures/svg-matcher.tstests/fixtures/getLastStepSvg.tslib/utils/convertSrjToGraphicsObject.ts
Rect Norms
Use createRectFromCapacityNode for capacity-node rectangles.
Rect defaults:
- Capacity rects: blue/cyan fill from
availableZ - Obstacle rects: red translucent fill
- Multi-layer capacity rects: neutral translucent fill
- Jumper pads: orange translucent fill with orange stroke
Relevant paths:
lib/utils/createRectFromCapacityNode.tslib/utils/convertSrjToGraphicsObject.ts
Line Norms
Use line width to mean physical or solver-relevant width. Do not use width only as decoration.
Line defaults:
- Final top-layer traces: solid and visually dominant
- Final non-top traces: dashed and lower opacity
- Through-obstacle lines: translucent with short dash
- Jumper body lines: gray and narrower than pads
- Topology edges: solid; encode state with color and stroke width
Relevant paths:
lib/utils/convertSrjToGraphicsObject.tslib/solvers/ComponentTopologyGeneratorSolver/ComponentTopologyGeneratorSolver.tslib/autorouter-pipelines/AutoroutingPipeline7_MultiGraph/AutoroutingPipelineSolver7_MultiGraph.ts
Other Type Norms
- Points: use connection color, layer helpers, and terse labels for points-to-connect.
- Circles: use blue fill for vias and
layer: "z..."across the via span. - Labels/text: keep semantic and terse; prefer multiline labels only when IDs,
availableZ, state, or connection names matter. - Polygons/arrows/infinite lines: check
graphics-debugtypes first, then match nearby solver usage before adding new style.
Relevant paths:
lib/utils/convertSrjToGraphicsObject.tslib/utils/createRectFromCapacityNode.ts
Layer And Connection Colors
Use layer: "z0", layer: "z1", or layer: "z0,1" for layer-aware geometry.
Use helper functions instead of hand-mapping layer strings:
getGraphicsLayerFromLayerNamesgetGraphicsLayerForConnectionPointgetGraphicsLayerForObstacle
Connection colors come from getColorMap(srj) when available. Preserve per-connection colors; use layer styling through dash, opacity, and layer, not by replacing a known connection color.
For Pipeline 7 visuals colored by net instead of layer, use
bun scripts/run-sample.ts ... --net-colors.
Fallback layer colors for final routed output:
top: redbottom: blueinner1: greeninner2: yellow
Relevant paths:
lib/utils/getGraphicsObjectLayer.tslib/utils/convertSrjToGraphicsObject.tslib/solvers/colors.ts
Gaps For Stacked Rects
Separate stacked layer rects with a small deterministic diagonal offset only when overlap hides information.
Use createRectFromCapacityNode(node, { rectMargin, zOffset }).
Normal values:
- Debug capacity nodes:
rectMargin: 0.025,zOffset: 0.01 - Component topology:
rectMargin: 0.01,zOffset: 0.02
The helper applies z-based drift from the lowest available layer. Keep exact alignment when alignment is the information being tested.
Relevant paths:
lib/utils/createRectFromCapacityNode.tslib/solvers/CapacityPathingSolver/CapacityPathingSolver.tslib/solvers/ComponentTopologyGeneratorSolver/ComponentTopologyGeneratorSolver.tslib/solvers/SingleLayerNodeMerger/SingleLayerNodeMergerSolver.ts
Choosing The View
Use solver-native visualization for internal state, candidates, failed geometry, staged progress, and labels.
Use convertSrjToGraphicsObject(solver.getOutputSimpleRouteJson()) for final emitted routes, vias, jumpers, and obstacles.
Use component-topology visualization for pipeline 7 structure.
Keep SVG and PNG backgrounds white. Treat colors, dash arrays, opacity, stroke widths, labels, and z offsets as snapshot-sensitive.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

