> For AI agents: the complete documentation index is available at https://docs.hod.sh/llms.txt, the full documentation bundle is available at https://docs.hod.sh/llms-full.txt.

# Files and outputs

Each job starts from a fresh copy of the repository. Only two things pass between jobs: the files a step declares, and its typed outputs.

## Files

`files:` on a step lists files or directories it produces. When the job succeeds, they are copied into every job that directly `needs` it, at the same paths. A job that fails keeps the ones that exist, so you can look at what it left behind.

```yaml
version: 0
on: [push]
jobs:
  build:
    image: node:22
    steps:
      - run: npm ci && npm run build
        files: [dist/]
  deploy:
    needs: [build]
    image: node:22
    steps:
      - run: ls dist/
```

## Outputs

`outputs:` on a step declares typed values it writes, one file each, in `$HOD_OUTPUTS/<name>`:

| Type           | The file holds                      |
| -------------- | ----------------------------------- |
| `string`       | Text; trailing newlines are dropped |
| `bool`         | `true` or `false`                   |
| `int`          | A decimal 64-bit integer            |
| `list(string)` | A JSON array of strings             |

The jobs that directly need this one read them as `jobs.<job>.outputs.<name>`, type-checked, in `if:`, `image:`, `env:`, services and steps. Later steps of the same job read `steps.<id>.outputs.<name>`, which needs an `id:` on the step that writes them.

```yaml
version: 0
on:
  push:
    branches: [main]
jobs:
  plan:
    image: alpine:3.22
    steps:
      - id: version
        run: |
          ./scripts/version.sh > "$HOD_OUTPUTS/version"
          echo true > "$HOD_OUTPUTS/publish"
        outputs: {version: string, publish: bool}
      - run: echo "next version $VERSION"
        env:
          VERSION: ${{ steps.version.outputs.version }}
  release:
    needs: [plan]
    if: jobs.plan.outputs.publish
    image: alpine:3.22
    env:
      VERSION: ${{ jobs.plan.outputs.version }}
    steps:
      - run: ./build.sh "$VERSION"
        files: [dist/]
```

Each value is at most 16 KiB, and a job's outputs at most 64 KiB: anything bigger belongs in `files`. A declared output the step didn't write fails the job with `missing_output`, and a value that isn't of its type with `bad_output`. Only a job that succeeded has outputs.
