coordinate-target-zoom — Claude Code rule
coordinate-target-zoom — a rule that teaches the agent to zoom into an element displaced from viewport center by pairing scale with counter-translation — the target lands at center after the zoom.
AGPL-3.0 ★ 78,316 updated 2026-10-24
.claude/rules/coordinate-target-zoom.mdWhat coordinate-target-zoom does
A bare scale > 1 on a wrapper pushes off-center content off-canvas. The rule defines a method to zoom into a chosen element: an outer wrapper scales the scene, an inner wrapper counters the target's offset with translate(x, y) equal to minus the target's displacement from viewport center. The formula is independent of zoom factor — the shift stays the same at 1.5×, 2× or 3×, as long as the outer wrapper's transform-origin is set to 50% 50%.
The rule requires measuring the element's real position via getBoundingClientRect once after font load — hand calculation works only for symmetric rows of equal-width cards, otherwise it yields the wrong sign. The measurement happens before timeline registration, inside an async setup. Without overflow: hidden on the scene wrapper, the rule breaks. Peak scale is capped so the target occupies no more than 88% of the frame — a two-pixel centering error at 3× zoom becomes six and shoves the element off-edge.
What it helps with
- zoom into a card or chip off viewport center so it ends up in the middle of the frame
- scale a non-centered element without pushing it beyond the viewport boundary
- pair scale with compensating translate for focus animation on an offset target
Example prompts for the agent
- Add a 2.5× zoom into
target-card— it sits on the right, but needs to land at center. - Enlarge the third price out of four in a row, 5-second scene — element is offset right, measure its displacement.
- Focus on
#winner-badge— it's on the side, timeline should center it after zoom.
How to install coordinate-target-zoom
Manually: put the files in place
.claude/rules/coordinate-target-zoom.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/coordinate-target-zoom.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/coordinate-target-zoom.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/coordinate-target-zoom.mdManually: put the files in place
.clinerules/coordinate-target-zoom.mdStep by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use
Questions about coordinate-target-zoom
How to install coordinate-target-zoom in Claude Code?
Place the rule file at .claude/rules/coordinate-target-zoom.md in your project root. Claude Code will pick it up automatically.
What does coordinate-target-zoom do?
The rule teaches the agent to zoom into an element displaced from viewport center by pairing scale with counter-translate — the target ends up centered. It needs two wrappers: the outer applies scale, the inner shifts content by minus the target's offset.
Do I need to hand-calculate the offset?
Only if the row is symmetric and all cards have equal width. For everything else, measure position via getBoundingClientRect after document.fonts.ready — the hand formula yields the wrong sign for asymmetric layouts, and the zoom will push the element off-frame.