# Chapter 30. Shipping Claude Applications: Files, Surfaces and Resilience (/building-ai-workers/shipping-claude-applications/overview)

---
type: Document
title: "Chapter 30. Shipping Claude Applications: Files, Surfaces and Resilience"
description: Find out, before a reader does, what changes when the same request runs on your laptop, in staging and in production, by writing each environment's values and proofs in one table with a check on every pull request.
status: stable
order: 330
ksor:
  owner: team:panaversity
  audience:
    - public
  approval:
    by: process:panaversity
    at: 2026-11-30T10:58:03Z
chapter: '30'
part: III
expert_status: builder-only
objectives:
  - id: CCDV-F.D2.S5
    label: supporting
  - id: CCDV-F.D2.S6
    label: supporting
word_budget: 3500
prerequisites:
  - '01'
  - '02'
  - '03'
  - '04'
  - '05'
  - '06'
  - '07'
  - '08'
  - '09'
  - '10'
  - '11'
  - '12'
  - '13'
  - '14'
  - '15'
  - '16'
  - '17'
  - '18'
  - '19'
  - '21'
  - '22'
  - '23'
  - '24'
  - '25'
  - '26'
  - '27'
  - '28'
  - '29'
build_step: The AP worker's environments written as one table with a check on every pull request, invoice photos and scans taken in through the Files API with one file id reused, recorded ingestion faults answered by error class with fallback only to a model the suite ran, and the extraction prompt's next version promoted with the ingestion from staging to production behind the Chapter 24 suite, then a port
artifact: brightline-ap with docs/environments.md (the table of environments), npm run check:environments in the pull-request job, scripts/ingest.ts, data/file-ids.json, tests/fixtures/errors/, config/prompts.yaml with staging and production entries, tag ch30
lab_data: https://github.com/panaversity/agentfactory-v2-resources/releases/latest/download/brightline-lab-ch30.zip
delta_entries: []
concepts:
  - '30.1'
  - '30.2'
  - '30.3'
  - '30.4'
  - '30.5'
  - '30.6'
  - '30.7'
  - '30.8'
last_verified: '2026-11-30'
sources:
  - id: anthropic-vision
    title: Vision (Claude API docs, verified 2026-11-30)
    resource: https://platform.claude.com/docs/en/build-with-claude/vision
generated:
  at: 2026-11-30T10:58:03Z
  by: esl-rewrite/1.2.0+ksor.1
trust_tier: unverified
build_id: sha256:d6ce3f28a2cf8e492a60bae1b426b7cc6466e35e83d70c3b9763db2c55009f4b
dirty: true
ksor_version: 0.0.60
---

<!-- EDITOR: which objective ids does the front matter carry? Guide 1.1's ids for this chapter's objectives are CCDV-F.D2.O2 to O4, but the book still carries the projected S ids (spec, raised point 5). Projected D2.S5 is primary in Chapter 22 and D2.S6 in Chapter 21, so this draft labels both "supporting", as Chapter 27 did with D1.S3. Objective 2.4 has no projected id, so none is listed for it. The other option: wait for the renumbering and list D2.O2, O3 and O4 as primary. -->

<!-- EDITOR: the prerequisites copy Chapter 27's list, as the spec asks, with '27', '28' and '29' added. Chapter 27's list leaves out '20', and so does this one. Chapter 27 writes 8 and 9 without quotes. This draft quotes them, '08' and '09', to match the others (round-1 reader review). -->

## Start here if you skipped Chapter 29

*If you read Chapter 29, skip this. These are the words from it, and from the chapters before it, that this chapter builds on.*

<!-- OPEN: Chapter 29 is not yet in the repository, so "Chapter 29" carries no link here, and the one row below that comes from it is worded from its spec's topic (29.5, release planning). Check that row's words against the published Chapter 29 before this page is approved. -->

| Word | What it means | Where this chapter uses it |
| --- | --- | --- |
| **Workspace** | A separate space on the platform for keys, resources and spending. Brightline has one for staging and one for production ([23.4](../hosted-agents/resources-as-code.md)) | Everywhere |
| **Staging key** | The key your laptop uses. It reaches only the staging workspace, and it sits in `.secrets/anthropic.env`, a file git ignores ([Lab 23](../hosted-agents/lab.md), Task 0) | The point, 30.1, 30.3 |
| **Lock file** | The record of which hosted resources, at which versions, belong to one workspace: `claude-lock.staging.json` for staging (23.4) | 30.1, 30.6 |
| **The hosted worker, its agent file** | The AP worker that runs inside Brightline's portal on a hosted runtime. Its instructions are in `agents/ap-worker.md` (23.4) | 30.1, 30.5 |
| **The portal** | Brightline's own product, one portal for every customer company. Its scheduled session runs at 7:10 each weekday ([23.16](../hosted-agents/loops-check-feedback-and-stop.md)) | Everywhere |
| **The extraction step** | One Messages API call for each new invoice, outside the hosted session. The portal's morning job makes it before 7:10, and gets the invoice's fields back as JSON ([Lab 24](../evaluating-ai-workers/lab.md), Chapter 25) | Everywhere |
| **The suite, a required check** | Chapter 24's cases, each with the answer Ana Morales expects. On every pull request, CI runs them on recorded answers, with no key. A required check must pass before a pull request can merge ([24.3](../evaluating-ai-workers/checks-and-regression-tests-in-ci.md), [15.7](../code-review/checks-that-block.md)) | Everywhere |
| **The suite's report** | The file each run of the suite writes. It names the model each case ran on ([25.10](../prompts-and-structured-output/defensive-parsing.md)), and, from Lab 30's kit on, the prompt version too | 30.4, 30.6 |
| **A named prompt version** | 25.1's rule: "a prompt reaches production only as a named version that the suite has read" ([25.1](../prompts-and-structured-output/a-prompt-is-code.md)) | The point, 30.5, 30.6 |
| **Pin** | The exact model id, written in one place, so the model changes only when you choose ([21.13](../agent-loop-by-hand/versions-models-and-keys.md)) | 30.4, 30.6 |
| **The SDK's retries** | Both SDKs retry some failed requests twice by default: connection errors, and statuses 408, 409, 429 and 500 and above. So the loop itself does not retry ([21.9](../agent-loop-by-hand/when-the-loop-goes-wrong.md)) | 30.4 |
| **Workload identity** | The way CI proves who it is with no stored key ([23.13](../hosted-agents/keys-that-expire-and-no-keys-at-all.md)) | 30.6 |
| **`settingSources`** | The Agent SDK option that names which settings files a run loads. Lab 22's worker sets it to an empty list, so it reads no settings files ([22.9](../agent-sdks/what-an-sdk-still-leaves-to-you.md)) | 30.1, 30.5 |
| **Release plan** | Chapter 29's written decision about when a change, such as a newer model, goes out (29.5) | 30.6 |

## The point

**Monday, May 17, 2027.** You are the builder. Today's change is one change, with two parts. Brightline's small vendors still send some invoices on paper, and Ana Morales, Brightline's AP analyst, photographs them. So the worker must now read scanned and photographed invoices. With them comes the extraction prompt's next version. Ana tried that version first in her own Claude project this morning, and she liked its answers.

<!-- EDITOR: the day, Monday, May 17, 2027, and Tuesday, May 18, 2027, below, are proposed in the chapter's spec (raised point 3a) and are not yet in specs/labs/part-2-facts.md. So are paper invoices from Brightline's small vendors, photographed by Ana (3b), and Ana trying the extraction prompt's next version in her Claude project first (3c). -->

On your laptop, everything works. [A photo] and [a PDF scan] each go up once. They go up through the **Files API**, Anthropic's store for files you upload once and then name by an id ([30.3](#303-images-documents-and-the-files-api)). The worker answers three questions about each. [INV-9103] is a photo in HEIC, a format the API does not take. It accepts JPEG, PNG, GIF and WebP.[^anthropic-vision] The worker's own check of the file's type refuses it before any request is sent, and a test proves that it does. The suite passes, [n of N].

<!-- OPEN: the photo's and the scan's invoice numbers, and the suite's count, are filled from the kit and from recorded runs. The spec writes them as blanks. -->

<!-- EDITOR: the invoice numbers INV-9101 to INV-9103 come from the plan's Lab 30 outline. They sit outside Brightline's INV-83NN range and next to Cedar Ridge Supply's INV-9001, so a reader could take them for Cedar Ridge's (spec, raised point 22). This draft keeps the number in brackets until a range is chosen. -->

This morning, before the change, you wrote `docs/environments.md` from what the repository already holds. It is one table. Each row is one thing that is set separately for each place the worker runs, in a file and not in the loop's code. Each column is one **environment**: a place where the same code runs, with its own keys, files and settings. Brightline has three. *Development* is your laptop. *Staging* is CI and the staging workspace, where the hosted agent's staging version runs ([23.4](../hosted-agents/resources-as-code.md)) and the portal's staging copy calls it ([Lab 23](../hosted-agents/lab.md)). *Production* is the portal every customer uses.

<!-- EDITOR: round 2 design points, proposed beside spec point 23. (1) The kit starts with the plan's `config/prompts.yaml`, a prompt for each of staging and production and nothing else, and Tuesday's change adds `model` and `fallbacks`. Development's pin stays in Lab 21's `src/loop/config.json`. (2) Row 3's production proof is `config/prompts.yaml#production.workspace`, and the ingestion reads only ids whose workspace matches it, so the check can compare the cell with a key. (3) Production's expiry, `fileExpirySeconds`, arrives in Task 4 with production's first uploads. -->

<!-- EDITOR: the table is now written on Monday morning, before the change (Lab 30, Task 0), as the round-1 reader review proposed, so the story and Task 0 happen on the same day. Proposed in the spec's terms, not yet in specs/labs/part-2-facts.md. -->

Each cell holds a value and its **proof**, which says how the value can be checked. A proof is one of three kinds. It can be a file and a key in it: the check, `npm run check:environments`, reads that key and compares it with the cell. It can be "by a person", and the check only lists the cell. Or it can be **waiting**: a file that a named later step makes. The check lists it, like a cell proved by a person, until the file exists, and then compares it. This chapter writes a file and a key in it as `file#key`, and `[*]` means every entry in a list.

When a pull request changes a file that a row's proofs name, the check fails on any empty cell in that row. This morning `config/prompts.yaml` named only a prompt version for staging and for production, and no file held rows 3 and 4 for them. So those four cells are empty. Row 3 says which workspace the file ids belong to. Row 4 says which models may answer.

**Tuesday, May 18, 10:00 a.m.** You open the pull request. The change touched `data/file-ids.json` and `config/prompts.yaml`, where it added each entry's `model` and `fallbacks`. Rows 3 and 4 name those files in their proofs. So the check fails on four empty cells.

At 10:40 you fill them, and the check fails twice more.

- *Row 3.* Production's cell says "workspace: production", with its proof `config/prompts.yaml#production.workspace`. That key does not exist, so the check fails. Without it, the ingestion would read every id in `data/file-ids.json`, and every one says "staging". A file belongs to the workspace it was uploaded to, so in production those ids would answer 404, not found. The kit's recording in `tests/fixtures/errors/` shows that answer.
- *Row 4.* Staging's list of fallback models, the models to try when the pinned one is overloaded, names [a model] that you copied from an example. The suite's report has never named it. No case has ever run on it.

<!-- EDITOR: a staging fallback list that names a model copied from an example, which the suite never ran, is proposed in the spec (raised point 3d) and is not yet in specs/labs/part-2-facts.md. -->

<!-- OPEN: which model the fallback list names, and the time of the merge below, are filled from the kit. The spec writes both as blanks. -->

You set `production.workspace` to `production`. You make the ingestion read only ids whose workspace matches it, so production uploads its own files. And you drop the fallback until the suite has run on it. The check passes. The merge at [11:15] applies the change to staging. After a week of right answers to real questions in staging, a person applies it to production.

<!-- EDITOR: "a week of real questions in staging" is the spec's gate (row 6), and a proposed story fact, not yet in specs/labs/part-2-facts.md. The book has a staging copy of the portal (Lab 23, Task 10a), but Chapter 23's reference says the staging workspace holds "test data only" (hosted-agents/reference.md:632). So who asks real questions on the staging copy, such as Brightline's own people, is new and needs the editor's word. -->

No test on your laptop could have seen either value. Your laptop uses the staging key, so every file id it made belongs to staging, and every id worked. The suite ran on the pinned model, so it never sent a request to the fallback. The loop's code was the same in all three places. What surrounded it was not.

**You have met every piece of this before.**

- [12.7](../agentic-coding/outside-the-app.md) asked it of the coding agent: "So check that each seat loads the rules and settings you intend."
- [23.4](../hosted-agents/resources-as-code.md) gave staging and production a workspace and a lock file each.
- [25.10](../prompts-and-structured-output/defensive-parsing.md) said: "An answer from a model the suite never ran has passed no test."

The one new thing is the table and its check. This chapter asks 12.7's question of the worker.

So before you change anything else, answer one question. **The extraction worked in Ana's Claude project and on my laptop. What is different about the same request in CI, staging and production, and how do I find out before Ana does?**

## Why it matters

Tests catch faults in the code. The table and its check catch values that differ by place. A value that nobody wrote down is not empty. A default fills it, and that is where the request breaks.

The rule is the same for every row. A value that differs between columns differs on purpose, in a file, with a proof. A cell equal to the one on its left says "same".

There is a price. A cell proved "by a person" is not checked. The check lists it, and someone must read it.

<!-- FIGURE 30.1: "Six rows, three columns, and every cell still empty." A table. Its three column heads, left to right, each name the places in that environment: "Development: the laptop, Ana's Claude project", "Staging: CI, the staging workspace", "Production: the portal". Its six row heads, top to bottom: (1) "Who sends, and what it adds", (2) "What leaves, and what is kept", (3) "Which workspace the file ids belong to", (4) "Which models may answer", (5) "Which configuration the run reads", (6) "How a change arrives". All eighteen cells are blank. Under the table, one note in the chapter's warning color, with a mark that reads without color: "An empty cell is filled by a default." No arrows. The alt text must give all three column heads with their places, all six row heads in order, say that every cell is empty, and give the note. -->

*Figure 30.1. The table's heads. Each row is one thing set per place, in files. Each column is one environment. The chapter fills one row at a time.*

## How this chapter works

Read the eight concepts in order. Sections 30.1 to 30.5 each fill one row of the table. Section 30.6 fills row 6 and shows the whole table once. Section 30.7 shows row 6's gates on the pull request. Section 30.8 shows the products, Claude first, then OpenAI, then open source. Sections 30.3 and 30.4 each have two halves. The first half is what is the same in every environment. The second half is the row, what differs by place.

Some subjects belong to other chapters. Guardrails and prompt injection are Chapter 28's. The decision to move to a newer model is 29.5's, and cache breakpoints and batches are 29.7's and 29.8's. The settings order is 12.8's, and AI review of a pull request is 15.6's. This chapter points to each and does not teach it again. Running a worker reliably at scale goes further in Chapter 42.

<!-- OPEN: Chapters 28, 29 and 42 are not yet in the repository, so they carry no link. Check each pointer against the published chapter before approval. -->

## What you will build

**Who's who.** You are the builder. Ana Morales is Brightline's AP analyst, who reads each morning's report. Dave Kowalski is Brightline's controller. Brightline Wholesale Supply is the invented wholesale distributor whose AP worker you have built since Chapter 16. Cedar Ridge Supply is Brightline's second customer in the portal.

**Where you are.** At the end of Lab 29 the worker runs in the portal. Its extraction step reads invoices that arrive as text, and the suite runs on every pull request. No file says which values differ between your laptop, staging and production.

<!-- OPEN: what Lab 29 leaves in place (its release plan, its model, and its files) is not in the repository yet. This paragraph names only what Labs 23 to 25 built. Check it against Lab 29 once it is published. -->

**What you build** in Lab 30 takes three sittings, from tag `ch29` to tag `ch30`. First come the table and its check. Then come files in, faults on purpose, one move for each class of error, a promotion to production, and a port to OpenAI.

As in Chapters 17 to 29, coding agents write every file and run every command. You specify, check and approve.

<!-- OPEN: the lab page's name and anchor are not fixed, so "Lab 30" carries no link in this part, and the task numbers the concepts name follow the spec's lab plan until the lab is built. -->

## In this chapter

| Section | The question it answers |
| --- | --- |
| [30.1](#301-one-model-many-surfaces) One model, many surfaces | Who sends the request, and what does each surface add to it? |
| [30.2](#302-what-crosses-the-application-boundary) What crosses the application boundary | What leaves, what comes back, and what is kept, in each environment? |
| [30.3](#303-images-documents-and-the-files-api) Images, documents and the Files API | How do files go in, what goes wrong, and which workspace owns each id? |
| [30.4](#304-errors-by-class-retry-fall-back-or-fix) Errors by class: retry, fall back or fix | Which move fits each error, and which models may each environment end on? |
| [30.5](#305-configuration-that-travels) Configuration that travels | Which configuration does each run read, and what does a default load? |
| [30.6](#306-one-change-three-environments) One change, three environments | How does one change cross the table, column by column? |
| [30.7](#307-claude-in-ci-and-the-release-pipeline) Claude in CI and the release pipeline | Which checks hold a change on the pull request? |
| [30.8](#308-how-todays-tools-realize-it) How today's tools realize it | On each product, what are the six rows? |
| Lab 30 | The table and its check, then files, faults, a move for each class, a promotion and a port, from tag `ch29` to tag `ch30` |
| Check yourself | One open question for each concept, with an outline of its answer |

[^anthropic-vision]: Vision, Claude API docs, Anthropic.
