Installing Leafen
This guide is for people and for the agents they ask to install Leafen. Both follow the same steps. From 0.2 on, your data carries over when you update Leafen, data made with 0.1.0 included.
Pick one way (For agents says which one an agent takes):
- Desktop app (macOS, Windows) — for one person, or a few people on one computer that stays on, and to try Leafen: it needs nothing else installed. The app is the server; phones and other devices join it.
- Docker — for a server that is always on, such as a company server or a hosted machine, and for Linux, which has no desktop app: Leafen runs in Docker there and is used in a browser.
- From source — to change Leafen or build it yourself. Trying it needs no build.
Running a server for others (proxies, backups, restores, upgrades, settings) is covered in the self-hosting guide; this guide stops once Leafen is running.
On a server (Docker or the server alone), keep its port closed to the internet until its first administrator is made. From the server's own network the setup asks no code, and a port mapping that hides where a visitor comes from — rootless Podman's, Docker Desktop's and Colima's, Docker's own proxy for visitors over IPv6 — makes a visitor from the internet look like one from that network.
For agents
Don't stop once Leafen is installed: take the person through its first run in conversation, asking what Leafen's first screens ask, one thing at a time, in their language, and doing each step with a command. The person never has to open Leafen for it: everything from installing to using it can go through your conversation. A Leafen window that is open follows each step you finish, so a person who looks sees where things stand.
- Ask first: start new, log in, or restore. "Start a new Leafen on this
computer, log in to a Leafen you use already — a company or team server,
or another device — or bring back a Leafen you used before from its
backups?" For logging in, ask for the invite link or the address
and a one-time code from a device logged in there (the workspace name in
the sidebar → Add a device; with no device, its administrator gives one);
install the desktop app, then run
leafen setup sign-in <invite link or address> --code <code>: the app logs in with it and opens that Leafen, and the command says whom it logged in as, or why the code was refused and what to ask next. Without a code the app's window shows that Leafen's login for the person (in a browser, open the address). That Leafen's administrator set it up, so skip to connecting yourself. - Restoring an old Leafen from its backups. Install Leafen the way the
old one ran (below), but don't run
leafen setup start: the old server's name, accounts, workspaces, agent connections and outside address all come back from the backup. Have the person open Leafen's first screen and, under the name, choose "Used Leafen before? Restore it from a backup" → "Leave it to an agent". It asks where you are: on their computer, or elsewhere (a chat app on the web), in which case it first opens a way in from outside for the restore alone — a one-time link, or Tailscale — and closes it when the restore ends. They paste you a sentence with Leafen's restore MCP address, which takes no login, and a one-time restore code. Pass the code asrestore_codeto every tool:leafen_restore_statussays what to do next,leafen_restore_findlooks in the place the old Leafen backed up to (a folder the server reads, a WebDAV server or S3-compatible storage) andleafen_restore_runrestores what the person chooses (or the same over JSON:POST <address>/api/leafen/v1/setup/restore/agent/status,/find,/runwith{"restoreCode": "…"}). Never ask for the backup's password, its recovery code or the storage's keys: the tools don't take them — tell the person which field on that screen to fill, and they type it there. The code does this one restore on a server with no administrator and nothing else, and ends when the restore is done or after 30 minutes. Once the server starts again on the restored data, the screen signs the person in as the old server's owner; ask them to check that their workspaces are back, and connect yourself again (step 4) if your old connection doesn't answer. When the old data is in a backup zip or a snapshot folder and the server can't start at all,leafen restore(the self-hosting guide) is the way. - Which way: on macOS and Windows, the desktop app. Install the desktop app there, also when the person only asks you to try Leafen or to see what it is like: it needs nothing else on the computer, and you can look around it yourself (next). Copying the app into Applications (on Windows, unzipping its folder), by command or as its steps say, is the install. Take Docker or a build from source only when the person asks for one, or on Linux, which has no desktop app; don't install Docker, Go or Node.js to try Leafen. Of the install, the person's hands do one thing at most: the system's question or warning when the app first opens (below). Ask them for that one press and wait, then go on with "The first run by commands".
- Looking around yourself. To try Leafen or compare it with Notion in a
browser of your own (such as the Claude app's), log that browser in once
the first run has the person's name (step 1 below):
leafen account device-code --name "<their name>"prints a one-time link for ten minutes,http://127.0.0.1:<port>/device/<code>until Leafen has an address of its own. Open it in a tab of your own: the tab logs in as the person, as one more of their devices, follows the first run's steps until they are done or left for later, and then opens their workspace. The app's window stays theirs.leafen setup statusnames the same address ("Address on this computer"). - Asked for a new server's setup link ("Get me my Leafen setup link"):
where Leafen's program runs,
leafen setup linkprints it, waiting for a server that is starting — with Docker,docker compose exec leafen leafen setup linkin the folder ofcompose.yaml, ordocker exec <container> leafen setup link. Once Leafen is set up and none of its administrators has it open on a device, the same command prints their one-time login code instead ("Get me a Leafen administrator login code"). From elsewhere,GET <address>/api/leafen/v1/setup/statustakes no login and, before the first administrator, says whether the server was started withLEAFEN_SETUP_CODE(codeGiven) and the hosting platform where Leafen knows it (platform). On Railway the link is the Leafen service's variableLEAFEN_SETUP_LINKand the codeLEAFEN_SETUP_CODE, asrailway variablesshows them; other platforms are in Hosting templates. Give the link or the code to the person alone. - Asked why Leafen's update didn't finish ("Why didn't Leafen's update
finish?"):
leafen update-failureon the server (docker compose exec leafen leafen update-failure) prints the update that failed, its reason in full and the way back; say them to the person in their words. - Do not bypass the operating system's checks. The Mac app is signed and notarized by Apple, so its first launch only asks whether to open an app downloaded from the internet; the Windows build is not signed yet, so its first launch shows a warning. Do not remove quarantine attributes, change security settings or disable protections; tell the person what to click (below) and wait for them.
- Do not create accounts for the person or enter passwords for them. Leafen
starts with a name only once the person says yes to it in this
conversation, in the words
leafen setup startgives; pass on their own yes, never yours. Your connection, and anything Leafen asks before you do it, you ask them in the conversation too: never answer for them. The person's own hands are only for other services: logging in to Tailscale or Notion, and the operating system's question or warning at the first launch (below). - Keep secrets out of what you share: no setup links' codes, tokens or keys
in files or in messages to anyone but the person. A Notion token you got
in your browser, or one they paste into this conversation, goes straight
to Leafen (
leafen_notion_migration_connect, step 5) — don't repeat it — and when the move is done, tell them to delete that connection in Notion or make it a new token, since the conversation keeps it. A one-time login link or code (leafen account device-code) is the person's: give it to them alone, or open it in a tab of your own to look around (above); one they give you for the app goes only toleafen setup sign-in --code.leafen setupprints no secret but one: while no administrator has Leafen open on a device,leafen setup statusshows the administrator's one-time login code (its "Logged in:" line), theirs alone as above.leafen connect --approvedhands your key to Claude Code without printing it (--add-to claude-code), and prints another program's once, for its MCP settings only. - When a step fails, report the exact message and stop rather than trying workarounds that change the system.
The first run by commands
leafen below is the program you installed: for the desktop app,
/Applications/Leafen.app/Contents/MacOS/leafen-desktop on a Mac and
.\leafen-desktop in its folder on Windows (without .exe, so the terminal
waits for it and shows what it says), which work on the app's own data; for
Docker, docker compose exec leafen leafen; from source,
./dist/leafen --dir=<its data folder> (.\dist\leafen.exe on Windows).
They work while Leafen runs.
leafen setup status says, at any time, what is done and the one thing next.
-
Language and name. Ask which language Leafen should use (
ko,en,ja,zh-Hans, …) and the name others will see. Runleafen setup start --name "<their name>" --language <code>: it answers with the question to ask the person, in their language, and the command that passes their yes on. Ask it in this conversation and wait for their own answer. Only on a yes, run that command (leafen setup start … --confirmation <id>): Leafen is set up with that name as its first administrator, and their first workspace is ready. A Leafen window open on its first screen logs itself in and goes on; none needs to be. The language can change later:leafen setup language <code>. -
Logging in. When the person wants to open Leafen — on this computer or on a phone —
leafen account device-code --name "<their name>"gives a one-time link and code for ten minutes: give it to them, and they open it on that device (or choose "Log in with a code" on Leafen's login). Until Leafen has an address of its own (step 3), the link names this computer's (127.0.0.1), so another device opens Leafen at the address it reaches and enters the code there. The same adds another device later. In the desktop app, another Leafen (a company or team server) is added beside this one the same way:leafen setup sign-in <address> --code <code>, with a code from a device logged in there. -
Public address. Explain why it matters: phones, the people they work with and AI chat apps on the internet (Claude, ChatGPT) reach Leafen by an address of its own; for this computer alone it can wait. Ask whether and how:
- Tailscale (recommended, a free account):
leafen tailscale. It prints an address to log in to Tailscale, then one to allow the public address. With a browser tool that works in their own browser, open them in a tab of your own: after one yes from them to add this server to their Tailscale and allow its public address, they log in there and you go through the rest. Without one, open them in their browser yourself (open <address>on a Mac): their one step is logging in, then the pages' own buttons to connect the server and allow its address, which you name as the pages do.leafen tailscalenotices each step by itself and goes on, so don't wait to be told. It ends with the address; Leafen's window shows it with a QR code for their phone. - Their own domain, with their own certificate or proxy:
leafen address --address https://…(seeleafen address --help). - Later:
leafen setup skip address.
- Tailscale (recommended, a free account):
-
Connect yourself, asking first. Before you run anything to connect, ask the person the one question Leafen asks about it:
leafen setup statusgives it at this step, in their language — which agent (your program's name in place of<your program's name>), as whom, what it may do in which workspaces. Ask it as it is and wait for their own answer. Ask nothing else with it: every folder, all their workspaces and everything they may do are what an agent connection is, not choices to offer (--this-folderkeeps it to one folder if the person asks; to give a program less, the person makes an MCP token for one workspace in Settings → Features → Agents → MCP address and keys → Create key). Only if they say yes, connect:- Claude Code where Leafen's program runs (the desktop app, from
source):
leafen connect --name "Claude Code" --approved --add-to claude-code. It connects you with no browser and adds Leafen to Claude Code's settings for every folder itself, so the key never shows in your output. - Claude Code with Leafen in Docker, whose program runs in the
container, where Claude Code isn't: one line hands the key from the
container to Claude Code without it showing,
claude mcp add-json --scope user leafen "$(docker compose exec -T leafen leafen connect --name "Claude Code" --approved --claude-code-json)"— the same oversshto the server Leafen runs on. A container started withoutcompose.yaml'sLEAFEN_PUBLISHED_PORTand with no public address can't tell where its host publishes it: the command then says to add--url <the address Leafen is opened at>. - Another program:
leafen connect --name "<your program's name>" --approvedconnects you and prints Leafen's MCP address and its key, once, with the lines to add it (Cursor: theurlandheadersundermcpServersin~/.cursor/mcp.json). Don't repeat the key in your messages.
Outside the first run, once the person asks you to connect,
leafen connect --name "<your program's name>"with nothing added gives the same question and changes no settings;--add-toand--approvedcome only with their yes.Then do what its answer says: tell the person, in the words it gives, that Leafen is in every folder and that one folder is just a word away, and ask them where the instruction lines it prints go, offering the two alike with what each changes — every project (your own user-wide instruction file, whichever you read:
AGENTS.md,CLAUDE.mdand the like), so you search Leafen before answering about their work in every folder, or this project only (that same file in the project's folder) — and write them only where they choose. Go on in the same conversation: Claude Code in a terminal loads a server added during a conversation once the person types/reload-plugins(you can't run it yourself), and that gives you no turn, so the answer's words ask them to type it and then send “continue”, and you go on when they do; Leafen's tools then show here. Never say you'll go on as soon as they type it. Claude Code without a terminal (the Claude app) shows them from the next conversation and/reload-pluginsdoesn't bring them, so there you go on throughleafen mcp call(alone it lists Leafen's tools,<tool> --schemasays what one takes,<tool> '<arguments as JSON>'calls it as you, with the key Claude Code holds; in Windows PowerShell, which hands a program its argument without the JSON's double quotes, the JSON goes on standard input:$OutputEncoding = [Text.UTF8Encoding]::new($false); '<arguments as JSON>' | leafen mcp call <tool> -) — or, where Leafen's program isn't beside you (Docker, ssh), by calling Leafen's MCP over HTTP with the line the answer gives. Don't send the person to a new conversation. The instruction lines hold the address only:<!-- leafen:begin -->Leafen (<address>) is my shared workspace and memory: search and read it before answering about my work, and save lasting knowledge there. When Leafen says its address changed, update the address in these lines.<!-- leafen:end -->Codex adds for every folder, so for one folder the instruction lines in that folder alone keep Leafen to it; its tools show from a new Codex session on. Once you are connected, the window's agents step passes; to leave it,
leafen setup skip agents. A chat app (Claude, ChatGPT) can't run commands: tell the person to add a custom connector with the public MCP address (in Claude, Customize → Connectors → Add → Add custom connector; in ChatGPT, Plugins → + → Add custom MCP server) and to log in when Leafen asks. Claude's connector connects only to an https address without a port (443): at an address on another port, tell the person that only the connector fails there — browsers, Leafen's apps and agents such as Claude Code work at it as it is — and that a connector takes Leafen's Tailscale, their own Cloudflare tunnel, or an address opened on port 443 (leafen_remote_accesswithstatussays so). An agent on another computer, which can't run Leafen's program, connects first with the text from Leafen's Settings → Features → Agents (Copy text) on a device the person is logged in on: its one-time code goes, in one command the text gives, from Leafen straight into your own settings — no login and no browser (see MCP.md, Connection lifecycle). With no such device at hand, it asks to connect withPOST <address>/api/leafen/v1/mcp/device-connectionsand{"name": "<its program's name>"}: it gets a code for the person, who says to an agent already connected "Allow the Leafen connection <code>" (that agent asks them once more), and polls the token address it was given until its key comes; Claude Code polls with"check": true, and once the person allows it, runs the line the answer gives, which hands the key to Claude Code the same way (see MCP.md, Connection lifecycle). - Claude Code where Leafen's program runs (the desktop app, from
source):
-
Notion. Ask whether to move their Notion workspace here. If so, read
leafen_notion_migration_guideover MCP and follow it: you make the Notion connection —leafen_notion_migration_sourcesgives Notion's page and the steps there. With a browser — theirs (such as Claude in Chrome) or your own (such as the Claude app's, where they log in to Notion once) — you say what you'll open and why, and after one yes from them (making a connection agrees to Notion's developer terms) you do the steps yourself in a tab of your own: the connection they made for Leafen before, or a new one that only reads, with all their top pages. Then you hand its token toleafen_notion_migration_connect, which keeps it encrypted in Leafen — no Leafen screen for them. Without a browser, you open Notion's page in their browser (open <address>on a Mac), go through the steps with them one at a time, and they paste the token into this conversation for you to hand over the same way. Only if they'd rather not paste it here, it goes into Leafen's own field, whichleafen setup notionopens in their window, andleafen_notion_migration_sourceswithwait_secondsanswers once it is in. A token that went through this conversation stays in it, so when the move is done tell them to delete that connection in Notion or make it a new token. Then you start, scan and plan the migration, ask the person the plan's questions (which Notion people are which accounts, what to change) and run it, following it withleafen_notion_migration_status(leafen setup statusshows its state too). The migration's tools are your MCP connection's, so connect yourself (step 4) first; in a conversation that can't show them yet (step 4), call them throughleafen mcp call, such asleafen mcp call leafen_notion_migration_guide.
leafen setup status then says nothing is left of the first run.
Desktop app
-
Open the repository's latest release (the Releases section of the repository page, then Latest).
-
Download the file for the computer:
System File macOS, Apple silicon (M1 or later) leafen-desktop-<version>-darwin-arm64.dmgmacOS, Intel leafen-desktop-<version>-darwin-amd64.dmgWindows, Intel or AMD (x64) leafen-desktop-<version>-windows-amd64.zipWindows on Arm leafen-desktop-<version>-windows-arm64.zipOn macOS, Apple silicon or Intel is shown under Apple menu › About This Mac (Chip or Processor). The Mac app needs macOS 13 Ventura or later. On Windows, Settings › System › About shows it under System type (x64-based or ARM-based processor). There is no Linux desktop app: on Linux, use Docker and a browser.
-
Open it:
- macOS — open the file and drag Leafen onto Applications, then open Leafen from Applications. The app is signed and notarized by Apple: the first time, macOS asks whether to open an app downloaded from the internet. Click Open.
- Windows — Leafen for Windows is to come from the Microsoft Store,
which installs and updates it without a warning; it isn't there yet. Until
then, unzip the folder and run
leafen-desktop.exe. When "Windows protected your PC" appears, click More info, then Run anyway. The zip doesn't update itself: when a new version is out, the app says so at the top of its window, and Open download page opens the release. Quit Leafen, unzip the new zip in place of the old folder and run it again; your data stays in%APPDATA%\Leafen. Once Leafen is in the Microsoft Store, installing it from there opens the same data, and the store keeps it up to date.
-
Choose Start new on this computer (or Log in for a Leafen you use already) and enter your name. That is the first account, and the app opens your workspace.
To use it from a phone or another computer, choose the workspace name in the sidebar › Add a device (also in Settings › Account, the row with your name) and scan its QR code with the other device's camera (or the Leafen app, once released), or choose Log in with a code on that device's login screen and type the code it shows. To reach it from outside your network, open the server settings' Access from outside and choose Tailscale (free public address).
Docker
You need Docker with Compose. On Ubuntu:
sudo apt install docker.io docker-compose-v2; on other systems, Docker's
own guide (docs.docker.com/engine/install).
On Linux, Docker's commands take sudo (sudo docker compose up -d) unless
your user is in the docker group (sudo usermod -aG docker $USER, then sign
in again) — a group that can do anything as root on that machine. The
commands below are shown without sudo.
The server needs no screen and no agent: its first run is a page that opens in a browser on any computer that reaches it (below), and an agent can do the same by commands instead ("The first run by commands" above). Keep port 8090 closed to the internet until the first administrator is made: some port mappings make a visitor from outside look like one from the server's own network, where the setup asks no code.
-
Put Leafen's
compose.yamlin a new folder, start the server there and have it print its setup link:mkdir leafen && cd leafencurl -fsSLO https://raw.githubusercontent.com/leafen-org/leafen/main/compose.yamldocker compose up -ddocker compose exec leafen leafen setup linkDocker pulls Leafen's image (
ghcr.io/leafen-org/leafen) for the computer's processor. The data lives in theleafen-datavolume. In a copy of the repository, the twodocker composelines in its folder do the same. -
Open the setup link the last command printed.
It waits for the server to start, then prints a
http://127.0.0.1:8090/setup#code=…address with a one-time code, as the server's own computer opens it; run it again to see the link again. From another computer on the same network (a home's or an office's, or Tailscale), openhttp://<the server's name or IP address>:8090/setup: from there the setup asks no code. Where port 8090 isn't open to that computer, forward it over SSH instead and open the address as printed:ssh -L 8090:127.0.0.1:8090 <you>@<server>From the outside internet the setup takes the code: keep it to yourself, as it makes whoever enters it the administrator.
-
Enter the first administrator's name.
The server listens on port 8090. Settings such as the image's tag or another
port go in a .env file beside compose.yaml (LEAFEN_PORT=8091, one a
line; see the self-hosting guide). For
phones, other people and AI chat apps, give it an address of its own: the
first run's address step offers Tailscale's, which needs no domain,
certificate or open port. To serve it on your own domain with HTTPS instead,
put a reverse proxy in front as the self-hosting guide
describes, and write that address in .env as
LEAFEN_PUBLIC_URL=https://…: the setup link, links and device codes then use it.
It is the server's first address, not a lock: a way chosen later under
Settings → Server → Access from outside (Tailscale, another domain) takes
over at once, with no new container, and the earlier address forwards to it
while your proxy still sends it to the server.
To build the image from the source instead of pulling it, run this in the repository's folder; the first build takes several minutes:
docker compose -f compose.yaml -f compose.source.yaml up -d --build
Updating
When Settings → Server → Updates says a new version is out, update in
the folder of compose.yaml:
docker compose pull
docker compose up -d
Compose makes the container again from the new image with the same
leafen-data and leafen-backups volumes and the same .env, so the data,
settings and connections stay. As it starts, the new version keeps the data
from before in the data's backups/migrations/ folder and brings the data up
to date; meanwhile a browser shows that Leafen is updating, and the health
check answers migrating. docker compose images leafen then shows the image
that runs.
On a NAS the same is a few presses:
- Synology Container Manager, with Leafen as a project made from
compose.yaml: Project → Leafen's project → Stop, then Build, which pulls the image again and starts the project. A container made from thelatestimage alone shows Update available under Image once Container Manager has seen the new one; Update there makes it again with its settings. - Portainer: Stacks → Leafen's stack → Editor → Update the stack with Re-pull image and redeploy on; a container made alone: Containers → Leafen's container → Recreate with Re-pull image on.
We don't suggest an automatic image updater beside Leafen: it updates without the administrators knowing, and Watchtower, the best known, has been archived since December 2025.
If the update fails, Leafen's address says so, with the version to go back
to and how, and the new version waits rather than trying again each time it is
started; a newer version tries again. Go back as
Upgrades in the self-hosting guide says: the
earlier version (LEAFEN_IMAGE=ghcr.io/leafen-org/leafen:<version> in .env)
runs on the data as it is when the update didn't change it, and otherwise on a
copy of the folder the update kept.
From source
You need Go 1.27, Node.js 22.12 or later, and on macOS the Xcode command line tools the desktop window needs (Windows needs no C tools).
npm --prefix web ci --ignore-scripts
npm --prefix web run build
go build -trimpath -buildvcs=false -o dist/leafen ./desktop
./dist/leafen
On Windows, in Command Prompt or PowerShell:
npm.cmd --prefix web ci --ignore-scripts
npm.cmd --prefix web run build
go build -trimpath -buildvcs=false -o dist\leafen.exe .\desktop
.\dist\leafen.exe
npm.cmd, because PowerShell's default execution policy refuses npm's
npm.ps1; leafen.exe, because Go adds .exe only to a name it picks itself.
./dist/leafen (.\dist\leafen.exe on Windows) opens the desktop app; enter
your name as above. To run the server alone, without a window — as on Linux,
which has no desktop app — build ./cmd/leafen instead and see the self-hosting guide.
Build from a clone as above: go install leafen.org/leafen/...@latest does not
work, because the program embeds the web build, which the repository doesn't
carry, and uses the copy of a library kept in third_party/.