# Guides

Each guide covers one job, using the factory template and lib-factory. For why the rules are what they are, see [the method](/docs/method). For exact signatures, see the [lib-factory README](https://github.com/assemblyline-sh/lib-factory#exports).

## Build a line

| Guide | The job |
|---|---|
| [Write a station](/docs/guides/write-a-station) | The handler's folder, its config schema, what `execute` receives and returns |
| [Write a station that processes workpieces](/docs/guides/process-workpieces) | Run your code on each workpiece, report outcomes, create workpieces at a line head |
| [Connect stations with a conveyor](/docs/guides/connect-stations) | Pull workpieces from the previous station, a sub-bin, or several bins |
| [Start stations](/docs/guides/trigger-stations) | Run stations by hand, on a schedule, or when work arrives |
| [Hold a workpiece until someone decides](/docs/guides/hold-work) | A waiting station and the lane that releases approved work |

## Run a factory

| Guide | The job |
|---|---|
| [Lay out a factory repo and push its lines](/docs/guides/factory-repo) | Line and station files, and pushing them with al-orc |
| [Run a factory session](/docs/guides/run-a-factory-session) | Start, stop and keep a session running; how it finds stations |
| [Give stations their credentials](/docs/guides/environment-and-secrets) | Secrets in `.env`, never in a station file; one client per outside system |
| [Where a station keeps its data](/docs/guides/keep-station-data) | Workpiece files, run files, scratch, and what goes in the run's output |

## Report

| Guide | The job |
|---|---|
| [Report a run](/docs/guides/report-a-run) | Attach the run report and supporting documents, and read them |
| [Write reports from templates](/docs/guides/report-templates) | `report.md` and other templates next to the station's handler, rendered with `renderLocal` |

## When things go wrong

| Guide | The job |
|---|---|
| [Throw errors from a station](/docs/guides/station-errors) | Which errors fail a run, how it retries, and why a station must be safe to rerun |
| [Run and test a station](/docs/guides/test-a-station) | Run it locally, and test it in Jest |
| [Find out why a workpiece failed, and retry it](/docs/guides/handle-failures) | Read the error, group failures, and send work back |
| [Debug a run](/docs/guides/debug-a-run) | From the run's status to the session log to the usual causes |
| [Redo work through the line](/docs/guides/redo-work) | Send finished workpieces back through a fixed station |

## Recipes

| Guide | The job |
|---|---|
| [Call a command-line tool from a station](/docs/guides/run-command-line-tools) | Wrap a tool so its failures land on the right workpiece |
| [Read, render and split PDFs](/docs/guides/work-with-pdfs) | Text layer, page images for a model, split and rotate |
