# Install Knotworking with an AI agent

Use this guide to install a fresh copy of Knotworking on a machine the user controls. Run commands on that machine. If you can only run commands elsewhere, ask how to access the target host.

## 1. Check the host and choose an address

Before installing, confirm which machine should run Knotworking and whether it should be reachable only from that machine, on the local network, or over the internet. Ask the user if either is unclear.

- Check for Git, OpenSSL, a running Docker engine and the Docker Compose plugin (`git --version`, `openssl version`, `docker info` and `docker compose version`). If anything is missing, use the official installation instructions for the host OS and ask the user if you need administrator access.
- Choose the URL for the access the user requested. Use `http://localhost:3000` for access from the host itself or the host's LAN address, such as `http://192.168.1.20:3000`, for access from other devices. Check that the chosen port is free. The default Compose configuration publishes port 3000 on the host's interfaces. Keep it on a trusted network or restrict access at the host if the user wants a local-only install.
- For an internet-facing install, establish its public hostname and follow the [HTTPS guide](https://knotworking.dev/docs/https) before starting the stack.
- Check `docker compose ls --all` and the target directory for an existing installation. If there is one, preserve its configuration and data and use the [operations guide](https://knotworking.dev/docs/operations) for updates or recovery.

## 2. Prepare the configuration

Clone the public product repository into a new directory. Run the remaining commands from that checkout.

```bash
git clone https://github.com/knotworking-oss/knotworking.git
cd knotworking
cp -n deploy/env.example deploy/.env
chmod 600 deploy/.env
```

Set these values in `deploy/.env`:

| Setting | Value |
| --- | --- |
| `APP_URL` | The exact URL users will open, including the scheme and any non-default port. |
| `HTTP_PORT` | The host port for HTTP, normally `3000`. For direct HTTPS, use the settings in the HTTPS guide. |
| `BETTER_AUTH_SECRET` | Generate with `openssl rand -base64 32`. |
| `POSTGRES_PASSWORD` | Generate with `openssl rand -hex 24`. |

Capture the generated values directly into the file without showing them in terminal output or chat. Keep the file out of version control and preserve the secrets across restarts and retries. Leave `SETUP_TOKEN` commented out so the API generates a one-time setup link. Keep demo seeding disabled.

Leave `KNOTWORKING_MODULES` unset for the default server selection (all modules except Calendar, Accounting, Invoicing and Dashboards). The owner can choose a workspace preset and adjust its modules during or after setup. If the user requests an explicit comma-separated list instead, include every required dependency; a missing dependency prevents startup. Assets is required by Maintenance, Site programmes and Food safety records. Site's food checks also need Checklists. See [Modules](https://knotworking.dev/docs/modules) for the catalogue and access rules.

## 3. Start and verify

```bash
docker compose --env-file deploy/.env config --quiet
docker compose --env-file deploy/.env up -d --build
docker compose --env-file deploy/.env ps --all
```

Check that the database and API are healthy and that Caddy, the web app and MCP server are running. Open the configured `APP_URL` from a device that should be able to reach it and confirm the web app responds. If a service fails, inspect its Compose logs for build, migration or startup errors. Redact credentials and setup links from any output you share. Preserve the database and upload volumes when retrying.

## 4. Hand off to the owner

Give the user the verified app URL and the checkout path. On the host, the owner can run this command from the checkout to retrieve the current setup link:

```bash
docker compose --env-file deploy/.env logs --no-color api | grep -F 'Finish setting up Knotworking:' | tail -n 1
```

The setup link grants control of a fresh workspace. Keep it out of chat transcripts and shared logs. Have the owner open the link in their browser and choose their workspace name and sign-in credentials. Setup is available only while the database has no users. Once the owner has signed in, they can invite teammates.

See [Quickstart](https://knotworking.dev/docs/quickstart), [backups and updates](https://knotworking.dev/docs/operations), and [connecting an agent to a running workspace](https://knotworking.dev/docs/agents).
