Skip to content
Limited timeStarter is now $9 a month instead of $20.See plans
charmotion

Writing CLAUDE.md and .cursorrules for Rive Data Binding Mascot Integrations

By the Charmotion team · Updated · How we write guides

Cover illustration for the guide: Writing CLAUDE.md and .cursorrules for Rive Data Binding Mascot Integrations, with Charmotion demo characters

To write CLAUDE.md and .cursorrules for Rive Data Binding, describe one contract in each file: the ViewModel name, every property with its type and default, the runtime and version you ship, and the calls the agent must not guess. Claude Code reads CLAUDE.md. Cursor reads .cursor/rules/*.mdc files and also CLAUDE.md, and treats .cursorrules as legacy.

Key takeaways

  • Keep one ViewModel contract, with property names, types and defaults, in every instruction file.
  • Claude Code reads ./CLAUDE.md or ./.claude/CLAUDE.md and skips any file larger than 4 MiB.
  • Cursor needs .mdc files with frontmatter in .cursor/rules, because a plain .md file there is ignored.
  • Name the runtime package and version, and tell the agent not to guess property paths.
  • Treat .cursorrules as legacy and move its content into a rule file.

Already have a character or logo? See examples in real app screens: splash, onboarding, loading and empty-state screens, with the animation that plays in each.

What should a Rive instruction file contain?

Learning how to write CLAUDE.md and .cursorrules for Rive Data Binding animations starts with one decision: the ViewModel is the contract between the designer's .riv file and your app code. Your instruction files should describe that contract, so a coding agent stops guessing property names.

Each file needs four parts:

  • The ViewModel. Its name, every property with its type (Number, String, Boolean, Color, Enum, Trigger, Image, nested View Model or List), and its default value.
  • The asset. Where the .riv file lives, and the artboard and state machine the app loads.
  • The runtime. The package and version you ship, such as @rive-app/react-native or the Flutter rive package.
  • Forbidden moves. Things the agent must not do, such as inventing a property path or copying an older runtime tutorial.

Keep the file short. Claude Code reads it at the start of each session, so a contract that fits on one screen is easier to keep correct than a long document that nobody updates.

Where do Claude Code and Cursor read these files?

Claude Code reads project instructions from ./CLAUDE.md or ./.claude/CLAUDE.md. A personal file at ~/.claude/CLAUDE.md applies to all of your projects, and ./CLAUDE.local.md holds personal notes for one project. Add CLAUDE.local.md to .gitignore so it stays out of the repository.

Claude Code skips any CLAUDE.md larger than 4 MiB and loads none of its content. A contract for one mascot is far below that limit, but a file that collects every design note can cross it without warning, so keep the Rive section focused.

When a CLAUDE.md is found, Claude reads it instead of AGENTS.md unless the Project instructions setting is changed to claude-md-and-agents-md. If your repository already has an AGENTS.md for other tools, decide which file holds the Rive contract before you start.

Cursor stores project rules in the .cursor/rules folder, where they are version-controlled. Each rule must use the .mdc extension. A plain .md file in that folder is ignored because it has no frontmatter. Cursor also reads a CLAUDE.md placed in the project root, in the same way it reads AGENTS.md.

FileRead byLocationScope
CLAUDE.mdClaude Code./CLAUDE.md or ./.claude/CLAUDE.mdProject
~/.claude/CLAUDE.mdClaude CodeHome folderAll your projects
CLAUDE.local.mdClaude CodeProject root, listed in .gitignoreYour copy only
.cursor/rules/*.mdcCursorProject .cursor/rules folderProject, version-controlled
CLAUDE.md in rootCursorProject rootProject
.cursorrulesCursor (legacy)Project rootBeing phased out

Cursor lists four rule types: Project Rules, User Rules, Team Rules (on Team and Enterprise plans), and AGENTS.md as a simple markdown alternative.

How should the file describe the ViewModel and its properties?

Name the ViewModel and each property exactly as they appear in the Rive editor. An agent writes code from text, so a property called Mood in one file and mood in another produces a binding that connects to nothing. Copy names from the editor, not from memory.

Rive properties can be Number, String, Boolean, Color, Enum, Trigger, Image, nested View Model or List. Write the type next to each name so the agent picks the right setter. For a state that must persist, such as a mood that stays on sad until the app changes it, use a Number or Enum rather than a Trigger, which is meant for one-off events.

An example section for a mascot looks like this in CLAUDE.md:

## Rive mascot contract
File: assets/mascot.riv, artboard Character, state machine CharacterStateMachine
ViewModel: MascotViewModel, one instance per screen
- mood: Number. 0 idle, 1 happy, 2 wave, 3 thinking, 4 sad, 5 loading, 6 listening, 7 talking, 8 sleeping, 9 attention
- accents: Boolean, default true. False hides small accent marks.
Rules: set mood and let the file blend between moods; do not tween it in code. Do not add triggers for success or error. Show success with 1 and error with 4.

The mood values above follow the fixed numbering in Charmotion's character export, which is a useful model for your own file. Its .riv carries a CharacterViewModelMachine with a number property named mood, and the export includes an AI_README for coding assistants that describes the integration. The MCP server at /mcp-server can create that set for an agent, while your instruction file still decides how the app reads and writes mood. For the app side of this pattern, see driving mood states from app state.

Which runtime calls should the rules name for each platform?

Each runtime exposes data binding through its own calls, and an agent will mix versions unless the file names the one you ship. Put one line per platform in the instructions, and pin the version in your lockfile.

PlatformWhat to name in the fileVersion note
WebviewModelInstance getter, viewModel(path), setViewModelInstance, bind() and getBindableArtboard(name)Check the Web runtime docs for your version
React NativeuseViewModelInstance hook, which can create an instance from a RiveFile, a ViewModel or a RiveViewRefThe async option needs @rive-app/react-native 0.4.18 or later
FlutterViewModel instances created blank, default, by index or by name, and disposed when finishedFrom 0.15.0, binding happens when RiveWidgetController is created and dataBind was removed; minimum Flutter 3.32.0 (Dart 3.8.0)
Apple (SwiftUI and UIKit)Authored default instances bind automaticallyFrom v6.28.0; Rive.viewModelInstance returns nil with the new initializers and DataBind is deprecated
AndroidFont data binding and PropertyDataType ASSET_BLOBAdded in v11.13.0; confirm Compose and View API names in the official docs
UnityFonts and Global View ModelsAdded in v0.4.5; confirm against the Unity runtime docs

A useful rule is: pin the version, then name only the calls that version documents. A line such as Flutter 0.15 or later: bind in RiveWidgetController, and do not call dataBind keeps an agent from copying an older tutorial that calls a method the runtime no longer uses.

Version figures come from Rive's release notes and from third-party summaries, which can lag behind. Treat Rive's own runtime docs as the authority, and recheck the numbers when you upgrade.

For a framework walkthrough, read Rive data binding in React and Next.js and Rive data binding in Flutter. Unity projects have their own setup, covered in Rive mascot in Unity UI. For the difference between bindings and state machine inputs, see data binding vs state machine inputs.

How do you write a Cursor .mdc rule for a Rive mascot?

A Cursor project rule is a Markdown file with frontmatter. The frontmatter sets description, globs and alwaysApply. Use globs so the rule applies to the files where mascot code lives, and leave alwaysApply false unless every task in the repository needs the contract.

---
description: Rive mascot data binding contract
globs: src/mascot/**/*.tsx,src/mascot/**/*.ts
alwaysApply: false
---

File: assets/mascot.riv, artboard Character.
ViewModel: MascotViewModel. Bind mood (Number, 0 to 9) on the instance.
Do not invent property names. Copy them from the list in docs/rive-contract.md.
Do not write a second state machine in code.

Write the description as a one-line summary of the contract, so anyone scanning the rules folder knows what the file covers. Keep one rule per concern: a data binding rule in one file, and asset rules in another, rather than one long file.

Two file mistakes cause most failures. The first is saving a rule as .md, which Cursor ignores. The second is keeping a .cursorrules file next to a .cursor/rules folder. Cursor's help page describes .cursorrules as legacy and due to be deprecated, and it says to copy its content into a new rule file and delete the old one.

Cursor's docs do not say how its agent ranks CLAUDE.md against .cursor/rules when both exist (as of December 2026), so do not keep two different versions of the contract in them.

How do you stop the contract drifting between files?

Write the contract once and point to it. A practical layout is one docs/rive-contract.md with the ViewModel table and runtime versions, then one short line in CLAUDE.md and one line in each .mdc rule that tells the agent to read it. When the contract changes, the instruction files still point at the right source.

Change the contract in the same pull request as the .riv file. When a designer adds or renames a property, the file, the code and the instruction files change together. Before you merge, check the following:

  1. Each property name and type matches the Rive editor.
  2. The runtime version in package.json, pubspec.yaml or your Apple project matches the version the file names.
  3. No file mentions a method your runtime version has removed.
  4. CLAUDE.local.md is listed in .gitignore if you use it.
  5. An agent that binds one property changes the expected state when you run the app.

Four mistakes show up most often:

  • Typing property names from memory instead of copying them from the editor.
  • Using a Trigger for a state that should persist, such as a mood that stays sad.
  • Letting CLAUDE.md grow past 4 MiB, at which point Claude Code loads none of it.
  • Leaving an old .cursorrules file in place after moving to .cursor/rules.

For the wider workflow of an agent producing a mascot and its files, see animating a logo or character from Claude, Cursor or VS Code with MCP.

Write CLAUDE.md and .cursorrules for Rive Data Binding

  1. Export the ViewModel contract. Open the .riv file in the Rive editor and list the ViewModel name, every property with its type and default value, and the artboard and state machine names. Copy the names exactly.
  2. Write the project CLAUDE.md. Create ./CLAUDE.md or ./.claude/CLAUDE.md with the contract, the file path, the runtime package and pinned version, and a list of forbidden moves such as inventing property names.
  3. Set personal notes apart. Put preferences that apply to all your projects in ~/.claude/CLAUDE.md. Put notes for one project in ./CLAUDE.local.md and add that file to .gitignore.
  4. Create the Cursor rule. Add .cursor/rules/rive-mascot.mdc with frontmatter for description, globs and alwaysApply, then repeat the contract in plain Markdown below it. Do not save the rule as a plain .md file.
  5. Retire .cursorrules. If the project has a .cursorrules file, copy its content into a rule in .cursor/rules and delete the old file, as Cursor's help page advises.
  6. Test one binding. Ask the agent to bind one property, such as mood, and run the app. Confirm the animation changes to the expected state before you add more properties.

Frequently asked questions

Should a Rive project use CLAUDE.md or AGENTS.md?

Use CLAUDE.md if Claude Code is your main agent. When a CLAUDE.md is found, Claude Code reads it instead of AGENTS.md unless you change the Project instructions setting to claude-md-and-agents-md. Cursor also reads a CLAUDE.md in the project root, in the same way it reads AGENTS.md. For a team that uses several agents, keep the Rive contract in one file and have the others point to it.

Does Cursor still read .cursorrules?

Cursor's help page describes .cursorrules as legacy and due to be deprecated, as of December 2026. Copy its content into a rule in .cursor/rules, use the .mdc extension with frontmatter, then delete the old file. Check Cursor's rules documentation for the current status before you rely on either format.

Can an agent write Rive data binding code without these files?

It can produce code, but it will guess property names and may copy calls from an older runtime. The instruction files reduce both problems. Rive's runtime docs remain the reference for each platform, so link them in the instructions.

Does Charmotion provide files an agent can use?

Yes. Character exports include a Rive file with a CharacterViewModelMachine that has a number property named mood, plus web, React and SwiftUI code, a README and an AI_README for coding assistants. The MCP server can return download links for the set. Your own instruction file should still name the properties your app reads.

Sources

Related guides