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
.claude/rules/measuring-dom-nodes.mdWhat 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.mdThe paths frontmatter field limits the files
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.cursor/rules/measuring-dom-nodes.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/measuring-dom-nodes.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/measuring-dom-nodes.mdManually: put the files in place
.clinerules/measuring-dom-nodes.mdStep 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.