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

# Examples

> Runnable programs for every part of the SDK, in the repository's examples directory.

The [`examples/`](https://github.com/planchon/rewind.codes/tree/main/examples) directory of the repository holds one
program per subject. Each `index.ts` is harness code you run; each `scripts/*.ts` is what a model would write, and runs in
Rewind's sandbox.

> [card] [Quickstart](https://github.com/planchon/rewind.codes/tree/main/examples/quickstart)
>
> A toolset with the `http` tool and a host tool, a worker, a run and its output.

> [card] [Agent loop](https://github.com/planchon/rewind.codes/tree/main/examples/agent)
>
> Claude (`anthropic.ts`) and the OpenAI Responses API (`openai.ts`) with the agent tools.

> [card] [Human approval](https://github.com/planchon/rewind.codes/tree/main/examples/human-approval)
>
> A refund that waits for a manager's signal, then for the harness to approve the payment call.

> [card] [Host tools](https://github.com/planchon/rewind.codes/tree/main/examples/host-tools)
>
> Failures the script catches, idempotency keys, a question answered days later by its token.

> [card] [Workflows](https://github.com/planchon/rewind.codes/tree/main/examples/workflows)
>
> A typed workflow, a script that fans out over its runs, a run started by name.

> [card] [End users](https://github.com/planchon/rewind.codes/tree/main/examples/end-users)
>
> Namespaces, an end user's token, quotas and their refusals, revocation.

> [card] [Webhooks](https://github.com/planchon/rewind.codes/tree/main/examples/webhooks)
>
> A subscription, verified deliveries, `run.suspended` and `run.completed`.

> [card] [Testing](https://github.com/planchon/rewind.codes/tree/main/examples/testing)
>
> Type-checking, scenarios in virtual time, a fork that fixes a failed run, a cassette.

## Run them

Node 22.18 or later, which runs TypeScript as is, and pnpm.

```bash theme={null}
git clone https://github.com/planchon/rewind.codes.git
cd rewind.codes/examples
pnpm install
cp .env.example .env    # REWIND_URL, REWIND_API_KEY, and a model's key for agent/
pnpm quickstart         # or: pnpm human-approval, pnpm workflows, pnpm testing…
```

The scripts reach `api.github.com` without credentials: GitHub allows 60 such requests an hour. `pnpm webhooks` needs
a URL Rewind can deliver to: a public `https://` URL (a tunnel to your machine, in `WEBHOOK_URL`), or a server of your
own started with `--allow-private-webhooks`.


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