Command reference
The whole CLI, run as pnpm hanji <command>. It reads HANJI_DATA_DIR for where to work, defaulting to ~/.hanji.
| Command | What it does |
|---|---|
add-mount <name> <repoUrl> <mountPath> [subpath] [--suggest] | Add a repository, or a folder of one, as a mount. --suggest makes it proposal-only. |
remove-mount <name> | Remove a mount and its indexed pages. The clone directory stays on disk. |
sync | Fetch every mount from its remote and reindex what changed. |
rebuild | Discard the index and rebuild it from the local clones. Always safe. |
token <name> <mount[/folder|/page.md]=read|read+propose|read+comments|read+propose+comments>... | Mint a bearer token for an agent, scoped to a mount, a folder, or one page - add +comments to also grant that scope's page comments. Prints it once. |
list | List every mount and how many pages it holds. |
export <outDir> [mount...] [--okf] | Publish everything open to everyone: a browsable static site, llms.txt, llms-full.txt, and every page as plain Markdown. Mount names narrow the set; nothing widens it. --okf also shapes the Markdown mirror into an Open Knowledge Format bundle, described in Publish to the web. |
rule <mount> [path] <everyone-read|everyone-propose|restricted|clear> | Set or clear a general-access rule from the command line - what Share's select does in the front. |
set <key> <value> | Write an instance setting - the workspace name, or the export settings Publish to the web describes. |
assets [mount] | List uploaded images no page references anymore, per mount or everywhere. |
digest <mount> [path] [--since <iso>] | Write "what changed, what awaits you" as a Markdown page into the mount (default digest.md), committed by Hanji itself. Covers since the previous digest; a quiet window with an empty review queue writes nothing. |
One caution on digest: the page is written with the owner's eyes and summarizes the whole workspace, so it belongs in a mount whose readers may see all of that. In a mixed-audience workspace, point it at a restricted mount.
Examples
pnpm hanji add-mount handbook git@github.com:you/product.git handbook docs
pnpm hanji sync
pnpm hanji token my-claude handbook=read+propose
pnpm hanji list
# the digest as a morning ritual: cron writes the page, you and your
# agents read it like any other page - no mail server involved
# 0 7 * * * cd /path/to/hanji && pnpm hanji digest notes
pnpm hanji digest notes
The environment it reads
| Variable | Used by | For |
|---|---|---|
HANJI_DATA_DIR | everything | Where clones and the index live. Defaults to ~/.hanji. |
HANJI_SESSION_SECRET | the front | Signs login sessions. Optional - first run generates and stores one; env overrides. |
HANJI_OWNER_PASSWORD | the front | The owner's password. Optional - the welcome screen stores one on first run; env overrides. |
HANJI_GITHUB_TOKEN | propose | Lets hanji_propose open real pull requests. |
HANJI_GIT_AUTHOR_NAME, HANJI_GIT_AUTHOR_EMAIL | writes | The name and email on the commits Hanji makes. |
PORT | the MCP server | The port it listens on. Defaults to 4101. |
HANJI_TAILSCALE_OWNER | the front | Turns on On your tailnet and names the owner's tailnet login. |
HANJI_WEBHOOK_SECRET | the front | Turns on push-to-sync at /api/webhook/git; deliveries must carry its signature. |
HANJI_POLL_SECONDS | the front | Sync every mount on this interval. The mechanism for tailnets and local mounts. |
For the agent side of this, read Agents. For what is coming, read Where we are.