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

# Fragments

> Share environments and prompts through .auto/fragments/ imports, merge order, append, and remove.

Files under `.auto/fragments/` are validated but produce no resources themselves — they exist to be imported. Use them for anything two agents would otherwise duplicate.

The highest-value fragment is a shared runtime environment. Inline `environment:` blocks compile into generated resources, and two agents generating the same environment name must produce **identical** definitions or the apply fails with "Conflicting generated resource". A single fragment makes that guarantee structural:

```yaml .auto/agents/ship-digest.yaml (excerpt) theme={null}
imports:
  - ../fragments/environments/agent-runtime-base.yaml
```

Merge order is the contract to internalize: imports merge in listed order with **later imports winning**, `remove:` directives apply next, and the document's own body merges **last and wins**. This repo's PR reviewer depends on it — the local environment fragment is deliberately listed *after* the managed template import so the tooled environment overrides the template's default.

For prompts, prefer composition over copying. The `append:` directive layers text onto an imported `systemPrompt` instead of replacing it:

```yaml .auto/agents/pr-review.yaml (excerpt) theme={null}
imports:
  - "@auto/agents@latest/pr-review.yaml"
systemPrompt:
  append: |
    - Render YAML and code as fenced, language-tagged blocks.
```

Concatenation is exact — no hidden separator — so start appended text with a newline or list marker as needed. `remove:` supports exactly `tools`, `triggers`, and `env`; mounts merge by `name`/`mountPath` but cannot be removed. Full semantics in [imports and fragments](/reference/imports-and-fragments).

Build steps bake into a cached image, so sessions do not pay for them at start. Pin versions (and verify checksums for downloaded binaries) to keep the image reproducible when authoring environment fragments — see [environments and sandboxes](/concepts/environments).
