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

# Scripts and agents

> Call pp from shell scripts, programs and proof-search agents.

`pp` behaves like the command it wraps, so a script that calls `lake` or `lean`
can call `pp lake` or `pp lean` instead. Output, exit codes and standard input
follow rules that are predictable in automation. On a machine without a browser,
authenticate with an API token in `PROOFPOD_TOKEN`; see
[Sign-in and API tokens](https://docs.proofpod.dev/guide/authentication.md).

## Output and exit codes

* Only the command's own output goes to stdout. ProofPod's messages go to
  stderr.
* When stderr is not a terminal, ProofPod prints warnings and errors only. Add
  `--verbose` to also log sync details, the environment and the cost summary,
  or `--quiet` for nothing but the command's output.
* `pp` exits with the command's exit code. Codes produced by ProofPod itself,
  such as 125 when the command could not be run, are listed under
  [Exit codes](https://docs.proofpod.dev/reference/cli.md#exit-codes).

```bash theme={null}
if pp --quiet lake env lean Candidate.lean > result.txt 2> errors.txt; then
  echo "proof accepted"
fi
```

## Checking many files

A common automation pattern is checking a stream of candidate proofs. Inside a
project, check each file against the project's dependencies:

```console theme={null}
$ pp lake env lean Candidates/Attempt_0412.lean
```

`pp` never reads standard input unless you pass `--stdin`, so it is safe to call
from a loop that is itself reading a list, and from harnesses that leave stdin
open. See [Standard input](https://docs.proofpod.dev/guide/stdin.md).

```bash theme={null}
while read -r file; do
  pp --quiet lake env lean "$file" || echo "$file" >> failed.txt
done < candidates.txt
```

The sandbox stays warm for two minutes after each command, so consecutive
checks skip the cold start. Each check of a file importing all of Mathlib takes
about 7 seconds and costs about \$0.0002.

## Running checks in parallel

Checks in one workspace run one at a time. To run checks in parallel, use
several named workspaces (`--workspace checks-1`, `--workspace checks-2`, …),
up to your account's limit of 8 concurrent commands.

```bash theme={null}
pp --quiet --workspace checks-1 lake env lean Candidates/A.lean &
pp --quiet --workspace checks-2 lake env lean Candidates/B.lean &
wait
```

## Calling from a program

Starting a run involves uploading a sync archive first, which is what the CLI
is for. To start runs from your own program, invoke the CLI:

```python theme={null}
import subprocess

result = subprocess.run(
    ["pp", "--quiet", "lake", "env", "lean", "Candidate.lean"],
    capture_output=True, text=True,
)
accepted = result.returncode == 0
```

To read runs, usage and account information from a program, use the
[HTTP API](https://docs.proofpod.dev/reference/api.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.