Skip to main content
rule CX Codex

measuring-dom-nodes — Claude Code rule: what it does, how to install

The measuring-dom-nodes rule covers measuring DOM element sizes inside Remotion compositions without the video container's scale distorting the numbers.

no license ★ 849 updated 2026-01-24

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/rules/measuring-dom-nodes.md
Open on GitHub

What measuring-dom-nodes does

Remotion wraps the video output in a CSS scale() transform, which throws off raw values from getBoundingClientRect(). The rule shows how to correct for that using the useCurrentScale() hook, dividing the measured width and height by the current scale factor.

The included snippet pairs a ref, useEffect and useState to recalculate an element's dimensions whenever the scale changes. Claude Code reaches for this pattern on layout code in Remotion projects.

Skip the scale correction and any measurement taken during a scaled render comes out wrong.

What it helps with

  • get accurate width and height of a DOM node inside a Remotion composition
  • account for container scale when measuring layout
  • read dimensions from getBoundingClientRect without distortion
  • build a component that re-measures a node on scale change

Example prompts for the agent

  • Add a measurement for this text block using getBoundingClientRect adjusted for the current scale
  • Fix the width calculation in this Remotion composition so it doesn't break when the video is scaled
  • Write a component that tracks a DOM node's dimensions with useCurrentScale

How to install measuring-dom-nodes

Manually: put the files in place

.claude/rules/measuring-dom-nodes.md

The paths frontmatter field limits the files

Step by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use

Questions about measuring-dom-nodes

How do I install measuring-dom-nodes in Claude Code?

Place the rule file at .claude/rules/measuring-dom-nodes.md.

What does measuring-dom-nodes do?

It teaches Claude Code to measure DOM elements correctly in Remotion by correcting getBoundingClientRect readings for the container's scale, using the useCurrentScale hook.

Why does getBoundingClientRect return wrong values in Remotion?

Remotion applies a CSS scale transform to the video container, which skews raw getBoundingClientRect readings. Dividing the measured width and height by the value from useCurrentScale gives the real dimensions.

Similar IDE rules

All IDE rules for Frontend and UI →

From the same set33

The whole set →

Project sponsors

Companies that keep this analytics open