> For the complete documentation index, see [llms.txt](https://docs.coherence.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.coherence.io/2.0/manual/networking-state-changes/sync-and-command-attributes.md).

# \[Sync] and \[Command] Attributes

Aside from configuring your CoherenceSync bindings from within the *Configure* window, it's possible to use the `[Sync]` and `[Command]` C# attributes directly on your scripts. Your Prefabs will get updated to **require** such bindings.

## Sync Attribute

Mark **public** fields and properties to be synchronized over the network.

```csharp
[Sync]
public int health;
```

It's possible to migrate the variable automatically, if you decide to change its definition:

```csharp
[Sync("health")]
public float hp;
```

If a variable is never updated after it is first initialized, it can be flagged to only be synchronized when the GameObject is created. This will improve performance, as **coherence** won't need to continually sample its value for changes like it would normally do.

```csharp
[Sync(DefaultSyncMode = SyncMode.CreationOnly)]
public Color teamColor;
```

## Command Attribute

Mark **public** methods to be invoked over the network. Method return type must be `void`.

```csharp
[Command]
public void Heal(int amount)
{
    ...
}
```

It's possible to migrate the command automatically, if you decide to change the method signature:

```csharp
[Command("Heal", typeof(int))]
public void IncreaseHp(float hp)
{
    ...
}
```

### Command Meta

Commands can include metadata by setting `UseMeta = true`. This allows access to timing and sender information:

```csharp
[Command(UseMeta = true)]
public void CommandWithMeta()
{
    if (CoherenceSync.TryGetCurrentCommandMeta(out var meta))
    {
        // Access frame timing and sender information
        Debug.Log($"Frame: {meta.Frame}, Sender: {meta.Sender}");
    }
}
```

For more details on using command metadata, see [Command Meta](/2.0/manual/networking-state-changes/commands.md#command-meta).

{% hint style="warning" %}
Note that **marking** a command attribute only marks it as programmatically usable. It does not mean it will be automatically called over the network when executed.

You still need to follow the guidelines in the [Messaging with Commands](/2.0/manual/networking-state-changes/commands.md) article to make it work.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.coherence.io/2.0/manual/networking-state-changes/sync-and-command-attributes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
