handbook / guide / cli

Command reference

The whole CLI, run as pnpm hanji <command>. It reads HANJI_DATA_DIR for where to work, defaulting to ~/.hanji.

CommandWhat 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.
syncFetch every mount from its remote and reindex what changed.
rebuildDiscard 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.
listList 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

VariableUsed byFor
HANJI_DATA_DIReverythingWhere clones and the index live. Defaults to ~/.hanji.
HANJI_SESSION_SECRETthe frontSigns login sessions. Optional - first run generates and stores one; env overrides.
HANJI_OWNER_PASSWORDthe frontThe owner's password. Optional - the welcome screen stores one on first run; env overrides.
HANJI_GITHUB_TOKENproposeLets hanji_propose open real pull requests.
HANJI_GIT_AUTHOR_NAME, HANJI_GIT_AUTHOR_EMAILwritesThe name and email on the commits Hanji makes.
PORTthe MCP serverThe port it listens on. Defaults to 4101.
HANJI_TAILSCALE_OWNERthe frontTurns on On your tailnet and names the owner's tailnet login.
HANJI_WEBHOOK_SECRETthe frontTurns on push-to-sync at /api/webhook/git; deliveries must carry its signature.
HANJI_POLL_SECONDSthe frontSync 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.