CLI

The nextfarm command brings the NextFarm AI farm assistant and the developer platform to your terminal: type nextfarm to chat on your farm's real data, plus subcommands to call the API, manage API keys, receive webhooks locally and set up MCP for other assistants.

Install

macOS / Linux
curl -fsSL https://developers.nextfarm.vn/install.sh | sh
Windows (PowerShell)
irm https://developers.nextfarm.vn/install.ps1 | iex
Homebrew
brew install nextx-organization/nextfarm/nextfarm
npm (Node ≥ 20)
npm install -g nextfarm

Available for macOS (Apple Silicon and Intel), Linux (x64, arm64) and Windows x64. Source and releases: nextfarm-cli · version 0.3.3

Quickstart

Shell
nextfarm login            # browser; over SSH use --qr and scan with the NextFarm app
nextfarm                  # open the chat
nextfarm -p "which plots are due for harvest this week" --json
nextfarm doctor
  • The assistant writes only after you confirm. Anything that touches devices, automation or money (pumps, valves, rules that run on their own, cash entries) is confirmed in the NextFarm app only; the server also refuses it from the terminal.
  • Scripts and CI: set NEXTFARM_API_KEY and use nextfarm tools call, nextfarm api. Chatting with the assistant needs a user login.
  • The Free plan has 30 AI questions a week for the whole farm, reset at 00:00 Monday (Vietnam time). Run nextfarm ai usage to check.

Login

MethodUse when
nextfarm loginA machine with a browser — OAuth + PKCE, the session renews itself.
nextfarm login --qrOver SSH: scan the QR code with the NextFarm app.
nextfarm login --deviceNo browser and no app: enter the device code at id.nextfarm.vn/oauth/device on another device.
NEXTFARM_API_KEYScripts, servers, read-only CI — limited to the API key's scopes, no AI chat.
nextfarm login --ciGitHub Actions / GitLab CI: exchange the OIDC token for a 15-minute session, no secret in the repository. Register the repo with ci trust add.

Permission mode

ModeMeaning
readRead only — the assistant proposes no writes.
proposeDefault: the assistant creates write proposals and you confirm each one (y/N).
autoWrites routine changes on its own; large writes still need the number typed back.
Devices, automation and money (pumps, valves, irrigation schedules, cash entries) are confirmed in the NextFarm app only, in every mode — the server refuses them from the terminal.

Slash commands

CommandWhat it does
/helpCommands and shortcuts
/newNew conversation (keeps workspace, agent)
/resume [query]Resume an earlier conversation
/rename <name>Rename this conversation
/pinPin / unpin this conversation
/workspace [code]Switch workspace
/mode read|propose|autoPermission mode: read · propose · auto
/model [name]Switch model: NextFarm AI or your own
/attach <file>Attach an Excel / CSV / image / text file
/undo [id]Undo the last write
/why [runId]Why the AI answered that way (steps, tools)
/memoryWhat the AI remembers — edit, lock, forget
/schedule "question" daily 08:00Schedule a question daily / weekly / monthly
/sau-benh <photo>Diagnose pests and diseases from a photo
/thoi-tiet [plot]Weather for the farm or a plot in the coming days
/ban-tinThe farm's latest morning brief
/export md|json [file]Export the conversation to Markdown / JSON
/toolsAI tools you can use (by your real permissions)
/usageAI questions left this week
/feedback up|downRate the last answer
/statusAccount, workspace, environment, version
/doctorCheck connectivity, clock, token, plan
/config [key value]Settings: language, color, update notices
/initCreate NEXTFARM.md: instructions for this folder
/mcpInstall the MCP server into another client
/logoutLog out this profile
/clearClear the screen (keeps the conversation)
/exitExit
KeysWhat it does
Enter · Shift+Enter (\ + Enter)Send · new line
/Command menu
@Attach a file, pick an Agent for this message
#Quick note into this folder's NEXTFARM.md
Shift+TabCycle permission mode
EscStop the running answer
Esc EscEdit the last message
↑ / ↓Input history
Ctrl+OExpand / collapse steps
Ctrl+LClear screen
Ctrl+C · Ctrl+DClear input (twice to exit) · exit

Command reference

CommandWhat it does
nextfarm loginlog in (browser or QR, chosen automatically)
nextfarm logoutlog out this profile (revokes the server session)
nextfarm statusaccount, workspace, environment, AI plan, session
nextfarm sessionsyour login sessions on all devices
nextfarm sessions listlist sessions
nextfarm sessions revokerevoke one session, or --others for all other sessions
nextfarm workspaceyour workspaces (companies)
nextfarm workspace listlist workspaces
nextfarm workspace useswitch the working workspace (saved in the profile)
nextfarm aiAI assistant: ask, history, proposals, memory, schedules
nextfarm ai askask one question non-interactively (same as -p)
nextfarm ai historylist conversations
nextfarm ai showprint a whole conversation
nextfarm ai renamerename a conversation (empty = clear)
nextfarm ai pinpin a conversation
nextfarm ai deletedelete a conversation permanently
nextfarm ai whywhy the assistant answered that way: steps and tools
nextfarm ai applyapprove a proposed write (real write)
nextfarm ai rejectreject a proposed write
nextfarm ai undoundo a written proposal (within 24 hours)
nextfarm ai memorywhat the assistant remembers about the farm
nextfarm ai memory list
nextfarm ai memory forgetforget one item (farm owner only)
nextfarm ai schedulerecurring questions
nextfarm ai schedule list
nextfarm ai schedule add
nextfarm ai schedule run
nextfarm ai schedule delete
nextfarm ai brieflatest morning brief
nextfarm ai pestdiagnose pests and diseases from a photo
nextfarm ai usageAI questions left this week
nextfarm ai feedbackrate an answer: up / down
nextfarm modelyour own models for --model (keys stay in the keychain, never sent to NextFarm)
nextfarm model listmodels you added
nextfarm model addadd a provider: claude, gemini, gpt, grok, ollama
nextfarm model removeremove a model and delete its key
nextfarm model defaultmodel used by default (nextfarm = NextFarm AI)
nextfarm toolsAI tools you can use (by your real permissions)
nextfarm tools logingrant AI tool access to the CLI on this machine (once)
nextfarm tools logoutrevoke the CLI's AI tool access
nextfarm tools listlist tools
nextfarm tools describeparameters and an example for a tool
nextfarm tools callcall a tool. Write tools only create a proposal to confirm
nextfarm apicall the API directly (e.g. api GET /gis/parcels -f page_size=5)
nextfarm keysworkspace API keys
nextfarm keys listlist keys
nextfarm keys createcreate a key (printed once)
nextfarm keys revokerevoke a key (stops immediately)
nextfarm keys deletedelete a key
nextfarm keys usagecalls over 7 days
nextfarm keys callslast 50 calls of a key
nextfarm webhookswebhook events: browse, trigger, listen locally
nextfarm webhooks eventslist events
nextfarm webhooks schemapayload schema and example
nextfarm webhooks endpointsyour webhook endpoints
nextfarm webhooks endpoints list
nextfarm webhooks endpoints create
nextfarm webhooks endpoints delete
nextfarm webhooks endpoints rotate-secretrotate the signing secret (old one stays valid for a while)
nextfarm webhooks triggersend a sample event to an endpoint
nextfarm webhooks deliveriesrecent deliveries
nextfarm webhooks retryretry a delivery
nextfarm webhooks verifyverify a webhook signature locally (no server call)
nextfarm webhooks listenreceive real events on this machine and forward them locally
nextfarm openapidownload the public OpenAPI spec
nextfarm openapi pull
nextfarm docsopen the docs (cli, quickstart, api-keys, oauth, mcp, ai-tools, webhooks, sdk, errors, rate-limit, sandbox, changelog, versioning, security)
nextfarm changelogrecent API changes
nextfarm mcpconnect the MCP server to other AI assistants
nextfarm mcp urlprint the MCP server URL
nextfarm mcp installinstall into: chatgpt, claude, claude-desktop, codex, copilot, cursor, gemini, grok, vscode, windsurf
nextfarm mcp uninstall
nextfarm mcp serveserve MCP over stdio with the CLI's grant (for clients without OAuth)
nextfarm cisecretless CI login (OIDC)
nextfarm ci trustCI repositories allowed to log in to this workspace
nextfarm ci trust list
nextfarm ci trust addallow a repository to log in (tokens act as you, live 15 minutes)
nextfarm ci trust revokerevoke (immediate)
nextfarm ci policypre-approval policies: let CI write within a ceiling
nextfarm ci policy list
nextfarm ci policy kindskinds a policy can cover
nextfarm ci policy show
nextfarm ci policy requestask to let a CI repository write (an API-key manager approves; with that permission it is active at once)
nextfarm ci policy revokerevoke (the next write goes back to a link)
nextfarm ci exampleprint a sample GitHub Actions workflow
nextfarm doctorcheck connectivity, clock, token, plan, version
nextfarm configsettings
nextfarm config list
nextfarm config get
nextfarm config setlang · mode · updateChannel · updateCheck · telemetry · color · defaultProfile
nextfarm completionTab completion for bash | zsh | fish | powershell
nextfarm updateupgrade to the latest version
nextfarm initcreate NEXTFARM.md: instructions for this folder

nextfarm login

log in (browser or QR, chosen automatically)

FlagMeaning
--weblog in with the browser
--qrscan with the NextFarm app (SSH, headless machines)
--deviceenter a code on another device (RFC 8628)
--ciin GitHub Actions/GitLab CI: exchange the OIDC token for a short-lived token
--no-browserdo not open the browser, print the link only

nextfarm logout

log out this profile (revokes the server session)

FlagMeaning
--alllog out every profile on this machine

nextfarm sessions revoke [id]

revoke one session, or --others for all other sessions

FlagMeaning
--othersevery session except this one

nextfarm workspace use [code]

switch the working workspace (saved in the profile)

nextfarm ai ask <question...>

ask one question non-interactively (same as -p)

FlagMeaning
--conversation <id>continue this conversation

nextfarm ai history

list conversations

FlagMeaning
--search <text>filter by text
--limit <n>rows · default 30

nextfarm ai show <id>

print a whole conversation

nextfarm ai rename <id> [title...]

rename a conversation (empty = clear)

nextfarm ai pin <id>

pin a conversation

FlagMeaning
--offunpin

nextfarm ai delete <id>

delete a conversation permanently

nextfarm ai why [runId]

why the assistant answered that way: steps and tools

nextfarm ai apply <proposalId>

approve a proposed write (real write)

nextfarm ai reject <proposalId>

reject a proposed write

nextfarm ai undo <proposalId>

undo a written proposal (within 24 hours)

nextfarm ai memory forget <id>

forget one item (farm owner only)

nextfarm ai schedule add <question>

FlagMeaning
--at <HH:mm>time (Vietnam time)
--weekday <1-7>one weekday only (1 = Monday); omit = daily

nextfarm ai schedule run <id>

nextfarm ai schedule delete <id>

nextfarm ai pest <photo> [note...]

diagnose pests and diseases from a photo

nextfarm ai feedback <runId> <vote>

rate an answer: up / down

nextfarm model add <provider>

add a provider: claude, gemini, gpt, grok, ollama

FlagMeaning
--key-from-stdinread the API key from stdin (never put keys on the command line)
--name <model>model used when only the provider is given
--url <url>server address (Ollama or a compatible endpoint)

nextfarm model remove <name>

remove a model and delete its key

nextfarm model default <name>

model used by default (nextfarm = NextFarm AI)

nextfarm tools login

grant AI tool access to the CLI on this machine (once)

FlagMeaning
--no-browserdo not open the browser

nextfarm tools list

list tools

FlagMeaning
--module <m>filter by module (gis, iot, office…)
--kind <k>filter by kind (read | proposal | export)
--publicpublic catalog (no login)

nextfarm tools describe <name>

parameters and an example for a tool

nextfarm tools call <name>

call a tool. Write tools only create a proposal to confirm

FlagMeaning
--args <json>JSON arguments
--args-file <file>arguments from a JSON file (- = stdin)
-a, --arg <key=value>one argument (repeatable)

nextfarm api <method> <path>

call the API directly (e.g. api GET /gis/parcels -f page_size=5)

FlagMeaning
-f, --raw-field <key=value>string parameter: query for GET/DELETE, JSON body for POST/PUT/PATCH (repeatable)
-F, --field <key=value>like -f but typed: numbers, true/false, JSON
--input <file>request body from a JSON file (- = stdin)
-H, --header <K: V>extra header (repeatable)
--paginatefollow all pages (items/pageNumber results)
--select <path>print only part of the result, e.g. .items[0].name
-i, --includeprint status and headers too
--idempotency-key <key>idempotency key for POST

nextfarm keys create

create a key (printed once)

FlagMeaning
--name <name>
--scopes <codes>permission codes, comma separated, e.g. gis.parcels.view,iot.devices.view
--expires <dur>lifetime: 30d, 6m, 1y · default 90d
--description <text>

nextfarm keys revoke <id>

revoke a key (stops immediately)

nextfarm keys delete <id>

delete a key

nextfarm keys usage [id]

calls over 7 days

nextfarm keys calls <id>

last 50 calls of a key

nextfarm webhooks events

list events

FlagMeaning
--module <m>

nextfarm webhooks schema <event>

payload schema and example

nextfarm webhooks endpoints create <url>

FlagMeaning
--events <list>events, comma separated
--description <text>

nextfarm webhooks endpoints delete <id>

nextfarm webhooks endpoints rotate-secret <id>

rotate the signing secret (old one stays valid for a while)

nextfarm webhooks trigger <event>

send a sample event to an endpoint

FlagMeaning
--endpoint <id>target endpoint (default: first one subscribed)

nextfarm webhooks deliveries

recent deliveries

FlagMeaning
--status <s>success | failed | pending
--endpoint <id>
--limit <n> · default 30

nextfarm webhooks retry <deliveryId>

retry a delivery

nextfarm webhooks verify

verify a webhook signature locally (no server call)

FlagMeaning
--secret <secret>
--payload <file>raw received body (- = stdin)
-H, --header <K: V>received header (repeatable)
--signature <sig>signature from the *-Signature-256 header
--timestamp <ts>timestamp from the *-Timestamp header

nextfarm webhooks listen

receive real events on this machine and forward them locally

FlagMeaning
--forward-to <url>e.g. localhost:3000/hook
--events <list>events, comma separated (default: all)
--print-secretprint the full signing secret
--print-jsonprint event bodies

nextfarm openapi pull

FlagMeaning
--module <m>one module only
-o, --out <file> · default openapi.json

nextfarm docs [topic]

open the docs (cli, quickstart, api-keys, oauth, mcp, ai-tools, webhooks, sdk, errors, rate-limit, sandbox, changelog, versioning, security)

nextfarm mcp install [clients...]

install into: chatgpt, claude, claude-desktop, codex, copilot, cursor, gemini, grok, vscode, windsurf

nextfarm mcp uninstall <client>

nextfarm mcp serve

serve MCP over stdio with the CLI's grant (for clients without OAuth)

FlagMeaning
--stdiouse stdin/stdout (default)

nextfarm ci trust add

allow a repository to log in (tokens act as you, live 15 minutes)

FlagMeaning
--repo <owner/repo>
--provider <p>github | gitlab · default github
--ref <ref>branch or tag prefix, e.g. main · refs/tags/v* · default main
--environment <name>required GitHub environment (recommended for the main branch)
--expires <dur>lifetime: 90d, 1y
--name <name>

nextfarm ci trust revoke <id>

revoke (immediate)

nextfarm ci policy show <id>

nextfarm ci policy request

ask to let a CI repository write (an API-key manager approves; with that permission it is active at once)

FlagMeaning
--trust <id|owner/repo>CI trust (see: ci trust list)
--kinds <a,b>kinds (see: ci policy kinds)
--max <n>record ceiling (1–1000) · default 50
--expires <dur>lifetime, at most 30d · default 14d
--note <text>
--approveapprove now (needs API-key manage permission)

nextfarm ci policy revoke <id>

revoke (the next write goes back to a link)

nextfarm ci example

print a sample GitHub Actions workflow

FlagMeaning
--repo <owner/repo>
--workspace <code>
--writesample that writes (needs a policy: ci policy request)

nextfarm config get <key>

nextfarm config set <key> <value>

lang · mode · updateChannel · updateCheck · telemetry · color · defaultProfile

nextfarm completion <shell>

Tab completion for bash | zsh | fish | powershell

nextfarm update

upgrade to the latest version

FlagMeaning
--channel <c>latest | next

Scripting & CI

Shell
nextfarm -p "summarise this week's log" --json   # non-interactive, prints JSON
nextfarm tools call parcels_list --args '{"page_size":5}'
nextfarm api GET /gis/parcels -f page_size=5

In CI a nextfarm login --ci session has nobody to confirm: a write proposal is written only under a pre-approval policy for that repository (kinds, record limit, at most 30 days) — see nextfarm ci policy. Otherwise the command prints a link to confirm in the app and exits with code 7.

Global flags

FlagMeaning
-v, --versionprint the version
-p, --print [question]non-interactive: print the answer and exit (reads stdin too)
-c, --continuecontinue the last conversation
-r, --resume [id]resume a conversation (no id = pick from a list)
-f, --file <path>attach an Excel/CSV, image or text file (repeatable, max 3)
--profile <name>login profile
--sandboxuse the sandbox environment
-w, --workspace <code>run this command on another workspace
--agent <code>choose an Agent instead of the general assistant
--model <provider/name>use your own model over MCP: claude, gemini, gpt, grok, ollama/<name>
--mode <mode>permission mode
--output-format <format>output format
--jsonshorthand for --output-format json
--lang <lang>language
--no-colordisable colors
--quietprint results only
--verboseverbose output
--debugprint request ids and timings (never tokens)

Environment variables

NEXTFARM_API_KEY · NEXTFARM_TOKEN · NEXTFARM_PROFILE · NEXTFARM_ENV · NEXTFARM_WORKSPACE · NEXTFARM_LANG · NEXTFARM_DEBUG · NEXTFARM_NO_UPDATE_CHECK · NEXTFARM_NO_KEYCHAIN · NEXTFARM_ID_TOKEN

Exit codes

Exit codeMeaning
0Success
1General or server error
2Invalid usage
3Not logged in or session expired
4Missing permission, scope or plan
5AI quota used up or rate limited
6Network error
7Write proposal not confirmed
8Not found
130Interrupted (Ctrl+C)