Rules for agents
What a coding agent must know before it writes and deploys an app for SmallRun. Includes the AGENTS.md snippet.
This page is written for a coding agent. Read it before you write the app.
The short version
- Do not write login code. The platform signs visitors in.
- Read the person from the
X-SmallRun-User-*headers. - Keep data in SQLite on the volume, or declare one database.
- Listen on one HTTP port.
- Run
smallrun deploy --jsonwithSMALLRUN_TOKENset.
Do not write login code
SmallRun authenticates every visitor at the edge, in front of the app. On a private app, the default, an unauthenticated request never reaches app code. On a public app it does, without identity headers: treat it as anonymous.
Do not add any of these to the app:
- A login or signup page
- A user table with passwords
- Session cookies or JWT handling for sign-in
- An OAuth client
The app learns who the user is by reading plain request headers. See access and identity.
Add the snippet to the project
Save this file as AGENTS.md in the project root, or append it to the existing one. It is served at /AGENTS.md.
# Deploying to SmallRun
This project runs on SmallRun, a runtime for small server apps.
Docs for agents: https://www.smallrun.app/llms.txt
## Rules
- For a new app, do not build login, signup, sessions or password storage.
SmallRun signs the visitor in before a request reaches the app.
- Read the signed-in person from the request headers and trust them as they are:
`X-SmallRun-User-Email`, `X-SmallRun-User-Name`, `X-SmallRun-User-Id`.
- Identify a person by `X-SmallRun-User-Id`, not by email. The email can change.
- Roles inside the app, such as "HR manager", are the app's own data. Store
them by user id. SmallRun has no roles and sends none.
- On a private app (the default) the headers are present on every request.
SmallRun has already decided that this person may use the app: a coworker
on the owner's company domain, or a person the owner invited. Do not build
an allow-list.
- On a public app the headers are present only for a signed-in visitor. Treat
a request without `X-SmallRun-User-Id` as anonymous. To sign a visitor in,
link to `/.smallrun/login?next=<path>`.
- A public app has no company-only pages. If the user wants internal pages,
deploy them as a separate private app. Never decide access by the domain
of an email address.
- Keep data in SQLite or in files, anywhere the app likes: every file the app
writes is kept across restarts and deploys. Or declare `database: postgres`
or `database: mysql` in the manifest and read `DATABASE_URL`.
- Listen on one HTTP port. Read `PORT` if the framework supports it; SmallRun
also finds the port by itself. Plain HTTP: TLS ends at the edge.
- The real client IP is in `X-Forwarded-For` and `X-Real-IP`.
- If the project already has its own login, keep it. Tell the user to make the
app public (`smallrun visibility public`) so visitors do not sign in twice.
- There is no shell access: no SSH, no exec, no database shell. Debug from
the logs. Run schema changes from the app at startup.
- A `.env` file is deployed with the source unless it is listed in
`.smallrunignore`. For values that must not be in the source, use
`smallrun secrets` and refer to them in the manifest as `${secrets.NAME}`.
- If the app expects database variables other than `DATABASE_URL`, map them
in the manifest's `env:`, for example `DB_PASSWORD: ${database.password}`.
- Background workers run in the same microVM. If they are not detected,
declare them in the manifest under `workers:`.
- Scheduled tasks (cron) are not run. If the deploy output warns
`schedule_not_supported`, tell the user which task will not run.
- Do not write a Dockerfile; it is ignored. The build is detected from the source. If
detection fails, set `build:` and `start:` in the manifest.
## Deploy
```sh
smallrun deploy --json
```
- Authentication is the `SMALLRUN_TOKEN` environment variable. Do not run
`smallrun login`; it is interactive.
- The command blocks until the deployment is `RUNNING` or `FAILED`.
- On `RUNNING`, report the URL to the user.
- On `FAILED`, read the error code and the suggested next action in the
output, fix the cause, and deploy again.
- The app is owned by the account the token belongs to. Only that account
can manage it.
- To let in a person from outside the company, or to approve an access
request: `smallrun share <email>`. Pending requests: `smallrun access --json`.
Invite a person only when the user asks for it. The command sends the
person an invite email; `smallrun access --json` shows whether it arrived
and whether the person has opened the app.
- Do not run `smallrun visibility public` unless the user asks for the app to
be open to everyone.
- A rollback does not revert data.Machine-readable files
| URL | Content |
|---|---|
/llms.txt |
Index of every page, with a Markdown link for each |
/llms-full.txt |
Every page in one Markdown file |
/AGENTS.md |
The snippet above |
/manifest.schema.json |
JSON Schema of the app manifest |
<page>.md |
Each page as Markdown, for example /docs/deploy.md |
What needs a person
Every function is a command you can run. Three steps need a person:
- The first sign-in that creates the token
- Entering a payment card
- A visitor signing in to the app
When something fails
- Every error carries a stable code, a message and a suggested next action. Act on the suggested action.
- A failed deploy prints the last log lines of the phase that failed.
- If build detection picks the wrong commands, set
build:andstart:in the manifest. - If a deploy is refused because the account reached its app limit, stop and tell the user. Do not delete other apps.