
# What goes into a snapshot

`agc ship` packs your working tree into one gzipped tar, the snapshot, and that is what gets built, rehearsed, released and recorded. It holds every file git would ship, minus a fixed list and `.agentcloudignore` patterns. Build inputs too big for it go in `[[asset]]`.

You don't need to commit. Past 64 MiB compressed or 320 MiB raw, `agc ship` fails locally with `ship.too_large` before anything is sent.

## Ask your agent

```text
My agc ship says the snapshot is too large. Find out what's taking the space,
keep build output and data out of the snapshot, and ship again. If the build
needs the big files (the CSVs in data/csv), make them an Agent Cloud asset.
```

## Steps

See what git would ship, the snapshot's starting list in a git repo:

```bash
git ls-files --cached --others --exclude-standard
```

Leave more out:

```text
# .agentcloudignore (gitignore syntax, read from the app root)
fixtures/large/
*.parquet
```

Ship:

```bash
agc ship
```

If the big files are something the build needs (reference data, a model), declare them as an [asset](#large-build-inputs-assets) instead of ignoring them.

## How it works

**The file list.**

- **In a git repo:** `git ls-files --cached --others --exclude-standard`. A tracked file ships even if a later `.gitignore` line matches it; untracked files follow `.gitignore`.
- **Outside git:** agc walks the folder and applies every `.gitignore` it finds, nested ones and `!` negations included, pruning ignored folders before descending.
- **Always left out, either way:** `node_modules/`, `.git/`, `.agentcloud/`, `.env*`, `.DS_Store`, `._*`, `.venv/`, `venv/`, `__pycache__/`, `.claude/settings.local.json`, and every pattern in the root `.agentcloudignore` (only the one at the app root is read).
- **An app folder inside another repository:** if an ignore rule from outside the app (a `.gitignore` above it, its `info/exclude`, or git's global excludes file) means git lists none of its files, or not its `agentcloud.toml`, `agc ship` stops with `ship.ignored_by_outer_repo`, naming the rule, its line and its file. Run `git init` in the app folder, move it out, or change that rule; for the global excludes file, change the rule or `git add -f agentcloud.toml`.
- **Assets:** paths declared with `[[asset]]` are left out of the snapshot and uploaded separately.

`.env*` matches `.env.example` and `.env.mirror` too: no file whose name starts with `.env` ever ships. Production reads secrets from `agc secret set`, never from a file, so an app that reads `.env` at start-up crashes in production with cause `env_given` or `env_missing`.

**Which folders take the space?** A ship with more than 25 MiB of uncompressed source that still fits the limits goes ahead, and its answer adds a warning to `data.warnings` naming the three largest top-level entries with their sizes, plus `data.snapshot` (`bytes`, `largest`). If the build doesn't need them, add them to `.agentcloudignore`.

**Same tree, same bytes.** Paths are sorted and gzip carries no timestamp, so packing an unchanged tree twice gives the same sha256. That hash is the snapshot's id, and shipping the same snapshot again joins the operation already running instead of starting a second one.

**Symlinks.** agc never reads through a link out of the app: every path is checked without following links, the file and every folder above it.

| Link | Result |
|---|---|
| Relative, ending inside the app | Ships as a link, never as the file it points to |
| Ends outside the app, or loops | Refused: `ship.symlink_outside` |
| By absolute path, even into the app | Refused: `ship.symlink_absolute` |
| A folder above a file links out of the app | Refused: `ship.symlink_outside`, even for a file git still lists |

The same check covers asset files, and the migration files that `agc ship`, `agc migrate`, `agc check` and `agc import` read, in the snapshot or not. `agc verify` refuses the same way. Nothing is sent before it passes.

**Commits instead of the working tree.** `agc ship --from-git <sha>` packs a commit's tree under the same exclusions and limits; see [CI/CD with deploy keys](/docs/ship/ci-cd-with-deploy-keys.md).

## Large build inputs (assets)

An asset is a file or folder in your repo that the build needs but that's too big for the snapshot: reference CSVs, a model, a dataset. `agc ship` packs it separately, uploads it only when Agent Cloud doesn't already hold that exact content, and unpacks it at the same path before the image is built. Success is a ship that prints `Uploading the asset data/csv (… MB)` the first time, nothing the second, and ends `"outcome": "live"` with exit 0.

```toml
[[asset]]
path = "data/csv"

[[asset]]
path = "models/classifier.onnx"
```

A Dockerfile copies them like any other file (`COPY data/csv ./data/csv`). The files must still be ones git would ship. On your mirror nothing changes: `agc up` uses the files in the folder. The app's GitHub repo never holds an asset, so `agc ship --from-git <sha>` on a commit with no files at a declared path reuses the live release's asset for it, unchanged, with nothing uploaded; with no live release holding it, that's `ship.asset_not_found`.

| Stage | What happens |
|---|---|
| Check and pack | Every asset first. agc takes the files git would ship under each path (minus `.DS_Store`, `._*`, `.agentcloudignore` and the snapshot's default exclusions) and writes a deterministic `tar.gz`: sorted names, fixed time and owners, modes kept, relative links kept as links. It streams to a temporary file, hashing on the way, so memory stays at about one chunk. If any asset fails a check, nothing has been uploaded |
| `.dockerignore` check | The build context follows the root `.dockerignore`, read as Docker does (`*`, `?`, `[…]`, `**`, `!`, a leading `/`, the last matching line decides). If it would leave out every file of an asset, agc refuses with `ship.asset_ignored`, naming the line; leaving out some files is allowed |
| Upload once | agc asks whether Agent Cloud holds that sha256; if not, it sends the missing 8 MB chunks. Agent Cloud recomputes the hash and scans every file, line by line and inside gzipped members, for the secret patterns it refuses in app repos (`asset.secret`) |
| Resume | Chunks are keyed by sha256 and index, so an interrupted upload resumes at the next ship. Incomplete uploads are swept after an hour |
| Build | The runner copies each asset into the build's storage once per sha256 and unpacks it at its path before `docker build` |
| Show | `agc status` lists the live release's assets, the receipt lists each path, sha256 and size, and the app's GitHub repo gets an `ASSETS.md` instead of the files |

Asset paths don't count toward the snapshot's 64 MiB. A changed file means a new pack and a full upload of that asset, so split large, independently changing data into separate assets.

| `[[asset]] path` rule | |
|---|---|
| Characters | letters, digits, `.`, `_`, `-`, `/`; at most 200 |
| Must be | relative, inside the repo, no `.`, `..` or empty segments |
| Can't be | the repo root, `agentcloud.toml`, under `migrations/` or `.git` |
| Must hold | at least one file git would ship |

## Errors

Every code, its exit and fix: [Error code catalog](/docs/reference/error-code-catalog.md).

```json
{
  "ok": false,
  "product": "agent.cloud",
  "command": "ship",
  "error": {
    "retryable": false,
    "code": "ship.too_large",
    "message": "The compressed snapshot exceeds 64 MiB.",
    "fix": "Check the named command error. Exclude dependencies and build output in .gitignore or .agentcloudignore; use [[asset]] for large build inputs, then retry."
  },
  "next": [{ "cmd": "agc help manifest", "why": "snapshot ignore rules and large build inputs" }]
}
```

## Limits

Per snapshot: 64 MiB compressed and 320 MiB raw. Per app: 8 assets, 256 MB each compressed and 1 GB in all; an asset may decompress to at most 2 GB. A too-big asset fails the same way every time, so split it into smaller assets or keep only what the build needs. The upload chunk and the rest are in [Limits and quotas](/docs/reference/limits-and-quotas.md). The source the build unpacks has the same 320 MiB ceiling. Agent Cloud keeps every asset named by the last 5 releases or one in progress; others go after a day.

## Agent notes

- Don't commit build output (`dist/`, `web/dist`) to get it into the image. The image runs `build`; committed output wastes the snapshot budget and can go stale.
- A `.venv` or `node_modules` never ships, so a lockfile (`uv.lock`, `package-lock.json`) must.
- `.agentcloudignore` applies to `migrations/` too. Never ignore migration files: production applies only what the snapshot carries.
- An asset is a build input, not storage. Data the app writes at run time belongs in the database.
- Keep `[[asset]]` files out of `.gitignore`. An ignored folder fails `ship.asset_not_found`, even though the files are on disk.
- Large files tracked by git still make the repo heavy. If the data is generated, generate it in the build instead.

## Related

- [How your image is built](/docs/build/how-your-image-is-built.md)
- [.env.mirror and the shell environment](/docs/build/env-mirror-and-shell-environment.md#envmirror-and-the-shell-environment)
- [The app's GitHub repo](/docs/ship/the-apps-github-repo.md)
- [Secrets](/docs/build/secrets.md)
- [Limits and quotas](/docs/reference/limits-and-quotas.md)

<!-- feedback:start -->
---
Wrong, outdated or unclear? Run `agc feedback docs "build/what-goes-into-a-snapshot: <what is wrong>" --body <file>` with the sentence quoted in the file. No code or app data is sent.
<!-- feedback:end -->
