agentleFS
tscircuittscircuit/tscircuit-autorouter/.agents/skills/tscircuit-visualization/SKILL.md

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.

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
  1. Very specific:

    Use GraphicsObject for solver debug views, final SRJ output views, SVG snapshots, PNG artifacts, and interactive debug fixtures.

    line 8
  2. Very specific:

    Import types from graphics-debug:

    line 12
  3. Distinctive:

    Do not redefine or explain those shapes in repo docs or tests.

    line 28
  4. Very specific:

    Use these library functions from graphics-debug:

    line 32
  5. Distinctive:

    Call them with white backgrounds for stable snapshots/artifacts:

    line 38
  6. Distinctive:

    Do not hard-code the error count.

    line 70
  7. Distinctive:

    Prefer minimal SVG snapshot tests over large debug dumps.

    line 72
  8. Distinctive:

    Use one of these patterns:

    line 74
  9. Very specific:

    Use createRectFromCapacityNode for capacity-node rectangles.

    line 103
  10. Distinctive:

    Use line width to mean physical or solver-relevant width.

    line 119
  11. Very specific:

    Use layer: "z0", layer: "z1", or layer: "z0,1" for layer-aware geometry.

    line 149
  12. Distinctive:

    Use helper functions instead of hand-mapping layer strings:

    line 151
  13. Distinctive:

    Use solver-native visualization for internal state, candidates, failed geometry, staged progress, and labels.

    line 197
  14. Very specific:

    Use convertSrjToGraphicsObject(solver.getOutputSimpleRouteJson()) for final emitted routes, vias, jumpers, and obstacles.

    line 199
  15. Distinctive:

    Use component-topology visualization for pipeline 7 structure.

    line 201
  16. Distinctive:

    Keep SVG and PNG backgrounds white.

    line 203

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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.ts
  • tests/fixtures/getLastStepSvg.ts
  • lib/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 test

Relevant paths:

  • tests/fixtures/svg-matcher.ts
  • tests/fixtures/getLastStepSvg.ts
  • lib/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.ts
  • lib/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.ts
  • lib/solvers/ComponentTopologyGeneratorSolver/ComponentTopologyGeneratorSolver.ts
  • lib/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-debug types first, then match nearby solver usage before adding new style.

Relevant paths:

  • lib/utils/convertSrjToGraphicsObject.ts
  • lib/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:

  • getGraphicsLayerFromLayerNames
  • getGraphicsLayerForConnectionPoint
  • getGraphicsLayerForObstacle

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: red
  • bottom: blue
  • inner1: green
  • inner2: yellow

Relevant paths:

  • lib/utils/getGraphicsObjectLayer.ts
  • lib/utils/convertSrjToGraphicsObject.ts
  • lib/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.ts
  • lib/solvers/CapacityPathingSolver/CapacityPathingSolver.ts
  • lib/solvers/ComponentTopologyGeneratorSolver/ComponentTopologyGeneratorSolver.ts
  • lib/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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.