← All docs

Scripts

Claunity can read any script in your project, write new ones from scratch, edit existing files, and attach them to GameObjects — all automatically. After any script change, it triggers a recompile so your changes are live immediately.

Claunity always reads before editing

Before modifying a script, Claunity reads the current file content to understand the existing structure. It then writes the complete updated file — never a partial snippet that could break surrounding code.


Reading scripts

Read a script before editing

"Read the PlayerController script and tell me how movement is implemented"

Use @ to add a file to context

"@EnemyAI what does the patrol logic do and is there a performance issue?"

Read multiple scripts at once

"@GameManager @ScoreManager how do these two scripts communicate?"

Creating scripts

Write a new script

"Create a HealthSystem script in Assets/Scripts with TakeDamage, Heal, and Die methods"

Create and attach immediately

"Write a FloatingEffect script that makes the object bob up and down, and attach it to the "Coin" object"

Create from a description

"Create a Singleton GameManager script that persists between scenes and holds the current score and level"

Create with interface/inheritance

"Create an Enemy base class and two subclasses: MeleeEnemy and RangedEnemy, each with their own Attack() method"

Editing scripts

Fix a bug

"@PlayerController there is a NullReferenceException on line 47 — fix it"

Add a feature

"@CameraFollow add a smooth damping effect so the camera follows with a slight lag (use SmoothDamp)"

Refactor

"@EnemySpawner refactor the spawning logic to use an object pool instead of Instantiate/Destroy"

Add a method

"@ScoreManager add a ResetScore() method and call it when a new game starts"

Attaching scripts

Attach to a GameObject

"Attach the HealthSystem script to the "Player" object"

Attach and configure

"Attach the EnemyAI script to "Enemy" and set its patrol speed to 3 and chase speed to 6"

Recompiling

Trigger recompile manually

"Recompile all scripts"


Tips

Use @ for faster context

Typing @ScriptName in the chat adds the script content directly to your message. This is faster than describing the script — Claunity reads it instantly.

Describe the behavior, not the code

You don't need to know the Unity API — just describe what you want the script to do. Claunity picks the right methods, components, and patterns.

Write a script that spawns enemies every 5 seconds, with a maximum of 10 active at a time. If the max is reached, stop spawning until one is destroyed.

Ask for Unity best practices

Claunity knows Unity patterns. Ask it to apply them:

@AudioManager refactor this to use a proper Singleton pattern with DontDestroyOnLoad