Urgent.News

the world's headlines, one feed

Editions

Tech

Structured Context vs Pixel Context: What Coding Agents Actually Need

Context is becoming the bottleneck in AI-assisted development. Not model capability — models are improving fast enough that they're regularly not the constraint. What limits the quality of AI-generated code is the quality of context those models receive. For Figma-to-code workflows, context comes in two fundamentally different forms: pixel context (screenshots, rendered images) and structured…

Structured context versus pixel context is emerging as a crucial bottleneck in AI-assisted development. While models are advancing rapidly, the quality of context they receive remains the limiting factor for the accuracy of AI-generated code. In Figma-to-code workflows, context comes in two fundamentally different forms: pixel context and structured context.

These are not merely different formats for the same information; they represent distinct categories of input, each with unique properties, loss characteristics, and limitations on what an AI agent can produce from them. Currently, the industry predominantly relies on pixel context, which is a mistake.

Pixel context refers to any rasterized representation of a design, such as a screenshot exported from Figma or a PNG from the Export frame. Vision-capable Large Language Models (LLMs) can process pixel context impressively, recognizing UI patterns, identifying layout regions, inferring component types from visual appearance, and generating plausible code from images alone.

This is evident when using Claude or GPT-4V for screenshot-to-code tasks. However, the outputs often "look right" but lack the depth and fidelity needed for reliable code generation. The discrepancy between "looks right" and "is right" highlights the critical gap between appearance and meaning, which encompasses design system compliance, token fidelity, component identity, and reproducibility.

Structured context, on the other hand, is a typed, machine-readable representation that preserves the semantics of the design—what each element is, not just what it looks like. It includes typed nodes (such as FRAME, TEXT, INSTANCE, VECTOR), named values (colors as token references, spacings as token keys), spatial relationships (layout direction, gap, padding, alignment), identity links (component instances carrying their source component ID), hierarchy (full node tree with parent-child relationships), and resolved layout properties (auto-layout properties if applicable, component IDs on instances).

Structured context provides the AI agent with the necessary meaning to write accurate code, rather than relying on mere appearance. Visual tests are designed to verify appearance, whereas structured context ensures correctness in code generation.

The core failure mode of pixel context lies in irreversible information loss. Exporting a Figma frame as a PNG discards essential information required for code generation. The layer tree collapses, and the agent must reconstruct the tree structure from visual evidence—a process prone to approximation errors. Token bindings, such as colors mapped to colors/actions/primary, become hardcoded hex codes, creating liabilities when colors change, dark mode is supported, or token usage needs auditing.

Component identity is lost when multiple instances of the same component are treated as similar-looking rectangles rather than identifiable, reusable elements. Layout intent is also ambiguous, as the pixels do not explicitly indicate whether a layout is a flex row or a grid, or the type of spacing between items.

Comparatively, structured context offers a more robust approach. It preserves the design tree's explicit node tree, including kind, name, absoluteBoundingBox, children, fills (resolved to token references), auto-layout properties, and componentIds on instances. Each node has a defined kind, enabling the agent to map these directly to code primitives based on predefined rules in the CONTEXT.md file for the target framework.

For instance, INSTANCE nodes map to specific React components, FRAME nodes with auto-layout generate container components, and TEXT nodes with specific styles generate corresponding components. This compiler-style mapping ensures predictability and consistency, minimizing the risk of errors and ensuring composability across screens and agents.

Consider the Figma-to-React pipeline with and without structured context. With pixel context, the process involves exporting PNGs, pasting them into Claude for JSX generation, manually reviewing for correctness, correcting hardcoded values, and reconciling component structures. This iterative process often results in outputs that do not compose, necessitating repeated hand-editing to align with the design system before shipping.

In contrast, utilizing structured context involves exporting a bundle (one click, browser-based), passing the CONTEXT.md file and screen IR to Claude with clear system prompts specifying the framework and design system conventions. The resulting JSX accurately uses token names, component names, and correct layout structures, enabling seamless composition across screens and agents.

This approach eliminates the need for repeated corrections and ensures consistent outputs, significantly enhancing development efficiency and reliability.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — it may contain errors, so check the original before relying on it.

Read the original at dev.to →

More in Tech

Postgres Full-Text Search in Production: How to Load-Test the Index and Pin Down Relevance

Adding full-text search to Postgres is a two-line migration. Running it in production without surprises is not. The GIN index that makes search fast also adds write amplification and a background…

  • GIN index accelerates searches but increases write amplification in PostgreSQL.
  • Load testing required to validate search capabilities under real write rates.
  • Relevance contract measures configuration changes and defines expected query results.

Flock Accused of Reactivating Its Cameras Without Notifying a Town

A Massachusetts newspaper reports that officials from the town of Littleton (population: 10,141) "claim that five of Littletonâ(TM)s Flock Safety cameras were switched back on by the company without…

  • Five Flock Safety cameras reactivated in Littleton, Massachusetts.
  • Town officials canceled contract with Flock Safety after discovery.
  • Flock Safety considered installing dashcams in Uber, Lyft drivers' vehicles.