Set up with a coding agent
Let a coding agent add Runlane to your app and complete one local run.
With createLocalLane(), runlane dev owns the runs in its memory. The app, CLI, and worker reach that store over a loopback bridge: a token-protected connection that only accepts traffic from your own machine (127.0.0.1). The app never keeps runs in its own memory. Without dev, the first trigger or read fails with storage_unavailable. Start dev and retry; no app restart is needed.
Copy the setup prompt and paste it into a coding agent that can edit files and run commands, such as Claude Code, Codex, or Cursor. The agent reads this page, adds Runlane to your app, and proves the setup with one local run.
The rest of this page is written for the agent. Explain the local model above to the user: dev owns the memory; app, CLI, and worker use its authenticated 127.0.0.1 bridge. An app cannot queue runs in private memory. An app may start before dev, but its first trigger fails until dev is ready. Retry after starting dev; do not tell the user to restart the app or move queued runs.
Goal
Add Runlane to the user's app and complete one local run. You are done when the app has:
- the Runlane packages installed;
- one shared runtime module that uses
createTestLane()whenNODE_ENV=testandcreateLocalLane()otherwise; - a harmless example task;
- a
runlane.config.tsfile that loads that runtime; - a
runlane:devscript inpackage.json; - a
runlane devprocess that ran one test run tosucceeded.
Stay within local setup. Do not create cloud resources, run database migrations, or change deployment settings. Offer them as next steps instead. If you get blocked, tell the user what is done and what remains.
Work with the user
Start with one or two sentences about the plan: inspect the app, install Runlane, add an example task, and run it locally.
Ask only for choices you cannot infer safely. Ask them together, give concrete options, and recommend one. State the values you inferred so the user can correct them. Summarize command output instead of pasting it.
Read the docs first
Read these pages before you edit files. Fetch them from the same site as this page:
/get-started/add-runlane-to-an-app.mdfor the file layout and the shared runtime./guides/development/use-the-cli.mdfor the config file and local commands./recipes/load-environment-variables.mdif the runtime readsprocess.env.
Add .md to any docs URL to get Markdown. /llms.txt lists every page. Use only APIs and options that these pages document. Check runlane <command> --help before you use a CLI flag.
1. Inspect the app
Before you change files, read the repository's agent instructions, such as AGENTS.md or CLAUDE.md, plus package.json, the lockfile, the workspace configuration, and tsconfig.json.
| What you find | What to do |
|---|---|
An existing createRunlane() runtime or runlane.config.* file | Reuse it and add the example task to its tasks catalog. Do not create a second runtime. |
| An existing runtime that uses a Postgres or Redis lane | Ask before you start workers or trigger runs against that database. |
| Several apps in a workspace | Use the app the user named. Otherwise suggest the app with server code, and ask if more than one fits. Do not restructure the workspace. |
| Node.js older than 22.18.0 | Stop. Runlane requires Node.js 22.18.0 or newer. Ask the user to upgrade. |
No package.json | Ask whether to use another directory or create a small TypeScript project. Do not add a framework. |
Use the package manager that the lockfile shows. Run commands from the selected app's directory, not the workspace root. Follow the app's source folders, import style, and module format.
2. Add Runlane
Install the runtime, the local lane, and Zod. Install the CLI as a development dependency:
npm install @runlane/core @runlane/lane-local zod
npm install --save-dev @runlane/cliUse the matching pnpm, Yarn, or Bun commands when the app uses them. Task schemas follow Standard Schema. If the app already uses Zod or another Standard Schema library, use it instead of adding a second one.
With pnpm, compare the installed @runlane/core version with npm view @runlane/core version. pnpm 11 waits a day before it installs a newly published version, so it can install the previous release. If the installed version is older, tell the user and ask before you work around it, because that wait is a security setting. If they agree, install the exact latest version of every @runlane/* package, such as @runlane/core@<version>. Keep all Runlane packages on the same version.
Create a harmless example task. It takes a name and returns a greeting. Do not call external services or write data from it:
import { task } from '@runlane/core'
import * as z from 'zod'
export const hello = task({
id: 'setup.hello',
schema: z.object({ name: z.string().min(1) }),
output: z.object({ message: z.string() }),
run: ({ name }) => ({ message: `Hello, ${name}!` }),
})Create the shared runtime module. If the app already has one, add hello to its tasks catalog instead:
import { createRunlane, RunRetention, queue } from '@runlane/core'
import { createLocalLane, createTestLane } from '@runlane/lane-local'
import { hello } from './tasks/hello.js'
export const runlane = createRunlane({
retention: {
succeeded: RunRetention.deleteAfter('7d'),
cancelled: RunRetention.deleteAfter('7d'),
failed: RunRetention.deleteAfter('30d'),
expired: RunRetention.deleteAfter('7d'),
},
lane: process.env.NODE_ENV === 'test' ? createTestLane() : createLocalLane(),
queues: [queue({ name: 'default', default: true })],
tasks: { hello },
})The test switch lets app tests run in CI without dev. Confirm that the test runner sets NODE_ENV=test. Use drain() or executeNext() to control test execution.
Adjust the paths and import style to match the app. Then generate the CLI config:
npm exec -- runlane init config --runtime ./src/runlane.ts --runtime-export runlaneThis writes runlane.config.ts, which loads the runtime you just exported.
Add a script so the user can start the local worker by name. Keep the app's existing scripts as they are:
{
"scripts": {
"runlane:dev": "runlane dev"
}
}If the app already has a script with that name, pick another clear name and tell the user.
3. Run and verify
Tell the user you are starting the local worker. Start it as a long-running process and keep its output available:
npm run runlane:devWait for the dev started line. If you cannot run long-lived processes, give the user the command and directory, and ask them to run it in their own terminal. Reuse a runlane dev process that is already running for this config instead of starting another.
The local lane keeps runs in the memory of the dev process. Other CLI commands send their requests to that process, so run them from the same directory.
Trigger the example task:
npm exec -- runlane trigger setup.hello '{"name":"Ada"}' --jsonRead the run id from run.id in the output. Wait for the run to finish, then read the stored run:
npm exec -- runlane runs logs <run-id> --follow
npm exec -- runlane runs get <run-id> --jsonruns logs --follow exits when the run reaches a final status. Check that run.status is succeeded and run.output is {"message":"Hello, Ada!"}. A started worker does not prove the setup works. The stored succeeded run does.
If a command fails:
configuration_invalidmeans the CLI could not load the config. Check the runtime path and export name inrunlane.config.ts.- An unknown task means the runtime's
taskscatalog does not containsetup.hello. - If a value from
.envis missing, the runtime read it before the file loaded. Follow Load environment variables for the CLI. storage_unavailablemeans dev is absent, still starting, or disconnected. Start dev for the config path in the error and retry. Check that both commands use the same config and lane name.
Do not trigger an existing business task to test the setup.
4. Summarize and offer next steps
Keep the summary short:
- the files you created or changed;
- how to run it day to day:
runlane:devin one terminal, and the app's usual dev command in a second terminal; - whether
runlane devis still running, and how to stop it; - that local runs disappear when dev exits, while restarting the app leaves dev's runs in place.
If the user already described what they want to build, offer to build it next. Otherwise, ask what their first real task should do.
When you build a real task, read /guides/tasks/make-side-effects-safe.md first. Put each database write, payment, email, or API call in its own context.step.run() and pass the step's token as an idempotency key. Before you change a task that already has runs, read /production/change-tasks-safely.md.
When runs must survive dev restarts or need production workers, point the user to Choose a lane. Ask before you run migrations or create infrastructure.