viewport-change — Claude Code rule: what it does, how to install
viewport-change — a rule that teaches the agent a virtual camera in GSAP scenes: zoom, pan and focus-lock on a moving element, all through one wrapper.
AGPL-3.0 ★ 78,316 updated 2026-10-24
.claude/rules/viewport-change.mdWhat viewport-change does
This rule sets up a virtual camera for an HTML and GSAP scene. All scene content sits inside one .world block, and the agent moves that block opposite to the camera you want. Pan right and the block slides left. Zoom in and it gets scale above 1. To follow an element, the X offset is recalculated every frame.
Camera state lives in a cam object with scale, x and y. applyCamera() turns it into translate(x, y) scale(S), and a GSAP tween updates the object through onUpdate. CSS applies the scale first, so centering a target takes T = -offset × S. The rule ships HTML, CSS and a three-phase timeline skeleton, plus a scale table: 1.02 to 1.05 is barely noticeable, 1.5 to 2.5 fills the screen with the element.
The formula is specific to this rule. coordinate-target-zoom uses two nested wrappers and T = -offset, so copying one setup into the other pushes the target off center. For 2-3 discrete phases with drift there is a separate rule, multi-phase-camera. Placeholders such as {Brand} and HERO_FONT_SIZE need your own values.
What it helps with
- zoom the camera onto the
#ctabutton at the end of a clip - pan the whole frame right with one wrapper instead of moving each element
- keep a moving cursor at a fixed screen X
- combine two scale tweens into one compound zoom
- pick a zoom strength from a scale table
Example prompts for the agent
- Add a virtual camera to
viewport-scenewith theviewport-changerule and zoom in on#cta. - Make the camera follow
.moving-cursorand hold it at a fixed screen X, followingviewport-change. - Pan the scene right with a single transform on
.world, perviewport-change.
How to install viewport-change
Manually: put the files in place
.claude/rules/viewport-change.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/viewport-change.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/viewport-change.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/viewport-change.mdManually: put the files in place
.clinerules/viewport-change.mdStep by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use
Questions about viewport-change
How do I install viewport-change in Claude Code?
Put the rule file at .claude/rules/viewport-change.md.
What does viewport-change do?
It teaches the agent to fake zoom, pan and element-following. All scene content sits in one block, and the agent translates and scales that block as a whole.
How is viewport-change different from coordinate-target-zoom?
This rule uses one wrapper with translate(x, y) scale(S) and T = -offset × S. coordinate-target-zoom uses two nested wrappers with T = -offset, which fits better when scale and translate tween independently with a shared ease.