> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superwire.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Schemas

> Define reusable structured types for input, agent outputs, tool contracts, and final output.

Schemas define reusable object shapes.

```wire theme={"languages":{"custom":["/languages/wire.tmLanguage.json"]}}
schema task {
    title: string
    priority: enum { low, medium, high }
    tags: [string]
}
```

Use schemas anywhere a type is expected.

```wire theme={"languages":{"custom":["/languages/wire.tmLanguage.json"]}}
input {
    task: schema.task
}

agent summarize {
    model: model.fast
    instruction: "Summarize {{ input.task.title }}."

    output {
        summary: string
        priority: schema.task.priority
    }
}
```

## Nested reusable fields

A schema field can be referenced from another schema.

```wire theme={"languages":{"custom":["/languages/wire.tmLanguage.json"]}}
schema shared {
    status: enum {
        draft
        ready
        published
    }
}

schema article {
    title: string
    status: schema.shared.status
}
```

## Supported schema field types

Schemas support the full type system. Common options:

* Primitive: `string`, `number`, `float`, `boolean`, `null`
* Any object: `object`
* Arrays: `[string]`, fixed length `[string; 3]`
* Tuples: `(string, number)`
* Objects: `{ title: string, score: number }`
* Enums: `enum { draft, ready, published }`
* Unions: `string | number`
* Nullable values: `maybe string`
* Schema references: `schema.shared.status`
* Variants (tagged unions): `variant kind { ... }`

Example with multiple types:

```wire theme={"languages":{"custom":["/languages/wire.tmLanguage.json"]}}
schema typed_example {
    name: string
    age: number
    ratio: float
    active: boolean
    metadata: object
    nickname: maybe string
    tags: [string]
    fixed_tags: [string; 3]
    coordinates: (number, number)
    status: enum { draft, ready, published }
    fallback: string | number
}
```

## Variants

Use `variant` when a value can be one of multiple structured cases, each identified by a discriminator field.

```wire theme={"languages":{"custom":["/languages/wire.tmLanguage.json"]}}
schema event_payload {
    payload: variant type {
        user_created {
            user_id: string
        }

        "user.deleted" {
            user_id: string
            reason: maybe string
        }
    }
}
```

In this example, `type` is the discriminator and each case defines its own object shape.

## Field descriptions

Use triple-slash comments to document schema fields. These descriptions are preserved for schema-aware tooling and can improve structured output quality.

```wire theme={"languages":{"custom":["/languages/wire.tmLanguage.json"]}}
schema release_note {
    /// Short title shown to the user
    title: string

    /// Severity bucket
    impact: enum { low, medium, high }
}
```

## Enum formatting

Inline enum variants use commas:

```wire theme={"languages":{"custom":["/languages/wire.tmLanguage.json"]}}
enum { draft, ready, published }
```

Multiline enum variants do not require commas:

```wire theme={"languages":{"custom":["/languages/wire.tmLanguage.json"]}}
enum {
    draft
    ready
    published
}
```
