## Documentation index

This index lists every available documentation page and its Markdown source.

- [About VDL](https://vdl.varavel.com/docs/about/index.md)
- [Guides](https://vdl.varavel.com/docs/guides/index.md)
  - [Installation](https://vdl.varavel.com/docs/guides/installation/index.md)
  - [CLI Commands](https://vdl.varavel.com/docs/guides/cli/index.md)
  - [Editor Integration](https://vdl.varavel.com/docs/guides/editors/index.md)
  - [Project Configuration](https://vdl.varavel.com/docs/guides/configuration/index.md)
  - [Creating Plugins](https://vdl.varavel.com/docs/guides/creating-plugins/index.md)
- [Language](https://vdl.varavel.com/docs/language/index.md)
  - [Start Here](https://vdl.varavel.com/docs/language/start-here/index.md)
  - [Files and Comments](https://vdl.varavel.com/docs/language/files/index.md)
  - [Includes](https://vdl.varavel.com/docs/language/includes/index.md)
  - [Docstrings](https://vdl.varavel.com/docs/language/docstrings/index.md)
  - [Types](https://vdl.varavel.com/docs/language/types/index.md)
  - [Field Types](https://vdl.varavel.com/docs/language/field-types/index.md)
  - [Enums](https://vdl.varavel.com/docs/language/enums/index.md)
  - [Constants and Literals](https://vdl.varavel.com/docs/language/constants/index.md)
  - [Annotations](https://vdl.varavel.com/docs/language/annotations/index.md)
  - [Spreads and References](https://vdl.varavel.com/docs/language/spreads-references/index.md)
  - [Naming and Validation](https://vdl.varavel.com/docs/language/naming-validation/index.md)
- [VDL Plugin Protocols](https://vdl.varavel.com/docs/protocols/index.md)
  - [Introduction](https://vdl.varavel.com/docs/protocols/introduction/index.md)
  - [VPP-0: Core](https://vdl.varavel.com/docs/protocols/core/index.md)
  - [VPP-1: Deprecations](https://vdl.varavel.com/docs/protocols/deprecations/index.md)
  - [VPP-2: HTTP-RPC](https://vdl.varavel.com/docs/protocols/http-rpc/index.md)
  - [VPP-3: Policy](https://vdl.varavel.com/docs/protocols/policy/index.md)
  - [VPP-4: Events](https://vdl.varavel.com/docs/protocols/events/index.md)
- [Reference](https://vdl.varavel.com/docs/reference/index.md)
  - [Language Specification](https://vdl.varavel.com/docs/reference/spec/index.md)
  - [Formatting Guide](https://vdl.varavel.com/docs/reference/formatting-guide/index.md)


## Documentation content

The documentation for the current page follows, reproduced verbatim.


## Why Includes Exist

As schemas grow, it is useful to split them into focused files.

For example:

```text
schema.vdl
shared.vdl
events.vdl
```

Use `include` to bring definitions from another `.vdl` file into the same compilation context.

## Basic Syntax

```vdl
include "./shared.vdl"

type UserSession {
  token string
  account Account
}
```

The included file can define types, enums, constants, or documentation used by the current file.

Example `shared.vdl`:

```vdl
type Account {
  id string
  email string
}
```

Example `schema.vdl`:

```vdl
include "./shared.vdl"

type Session {
  account Account
  token string
}
```

`Session.account` can use `Account` because `schema.vdl` includes `shared.vdl`.

## Relative Paths

Include paths are resolved relative to the file that contains the `include` statement.

```vdl
include "../shared/types.vdl"
include "./events/user_events.vdl"
```

This makes each file self-contained: moving the entry point does not change how nested includes are resolved.

## Include Graphs

Includes are recursive. If `schema.vdl` includes `orders.vdl`, and `orders.vdl` includes `money.vdl`, all three files are analyzed together.

```vdl
include "./orders.vdl"

type Checkout {
  order Order
}
```

Each file is processed once. Circular includes are reported as diagnostics.

## File Name Rules

Regular included schema files should have names matching this pattern:

```text
[a-z0-9_]+.vdl
```

Good names:

```text
shared.vdl
order_events.vdl
api_v1.vdl
```

Avoid names like:

```text
Shared.vdl
order-events.vdl
schema.backup.vdl
```

## Config Files Are Not Included

`vdl.config.vdl` is the project generation configuration file. It cannot be included as a normal schema file.

Keep language schemas and generation configuration separate:

```text
schema.vdl        # Your contracts
vdl.config.vdl    # Plugin generation configuration
```

## Practical Advice

- Put shared primitives, aliases, and base objects in files like `shared.vdl`.
- Put event contracts in files like `events.vdl` or `user_events.vdl`.
- Keep the main entry file small and readable.
- Prefer shallow include graphs when possible.
