SDKs and platforms

How do I start an Offline Protocol project with the CLI?

Install the Offline Protocol CLI with npm install -g @offline-protocol/cli, which gives you the offline command. Run offline plan to get a recommended workflow and the exact offline create command, or offline init inside an existing JavaScript project. Planning, scaffolding and the local MCP server need no login; offline login is for API keys and portal resources.

TL;DR

The offline CLI installs from npm and runs on macOS, Linux and Windows. Its plan command recommends a workflow, create scaffolds a React Native app and init configures an existing project, all without an account. Signing in stores an app API key in a plain JSON file, and the CLI sends no analytics.

Learning objectives

After reading this article you will be able to:

  • Install the offline CLI on macOS, Linux or Windows and check its version
  • Scaffold a new project or configure an existing one with offline create and offline init
  • Explain what offline login stores on your machine and what the CLI sends

Installing the offline CLI

The Offline Protocol CLI is the npm package @offline-protocol/cli, and it installs a command named offline. It needs Node.js 18 or later and ships prebuilt binaries for macOS (arm64 and x64), Linux (x64 and arm64) and Windows (x64).

npm install -g @offline-protocol/cli
offline --version

The npm package is a small Node.js launcher. npm installs only the native binary for your machine, from a per-platform optional dependency such as @offline-protocol/cli-darwin-arm64, so an install downloads about 10 MB rather than all five binaries. Keep optional dependencies enabled: installing with --omit=optional or --no-optional leaves you without the binary.

To run a command without a global install, prefix it with npx:

npx -y @offline-protocol/cli --version

offline update asks the npm registry for a newer release and prints the upgrade command; it does not install it. The CLI is licensed Apache-2.0, separately from the AGPL-3.0-only SDK.

Planning and scaffolding with offline create

The fastest start is offline plan, which takes a description of what you are building and recommends a workflow, the packages it needs and the exact offline create command. Three workflows cover common integrations, and each scaffolds a React Native app with no login:

WorkflowScaffold
local-handoffoffline create local-handoff --platform react-native --name my-app
backend-deliveryoffline create backend-delivery --platform react-native --name my-app
nearby-serviceoffline create nearby-service --platform react-native --name my-app

offline create --template offers three starter apps, orderup, stocksync and cowrite. Useful flags include --dir <dir> to write somewhere other than ./<name>, -y to run without prompts, and --pol to add Proof of Location to a React Native scaffold. offline registry list workflows and offline registry list templates show everything available, and offline add <package> --dry-run prints what adding a package would change without writing files. Scaffolding runs npm install, which contacts the registries you have configured. The workflows themselves are explained in the docs’ local handoff, backend delivery and nearby service guides.

The registry also covers the bindings beyond React Native, including Java, the C API and the Flutter preview, and Flutter and Java prompts are answered with that package rather than a React Native plan. To compare them yourself, see which Offline Protocol SDK to use.

Configuring an existing project with offline init

offline init adds Offline Protocol configuration to an existing JavaScript or TypeScript project. Run it from a directory that contains package.json; for a new application, use offline create instead.

offline init --app-id app_your_application_id

It writes offline.config.json, an AGENTS.md section and, when the project has none, a .mcp.json that starts the local MCP server through npx. The App ID is public metadata from the developer portal, so it can live in these files; API keys should not. Review the generated changes with the rest of your code. There is no offline link command, and initialization takes --app-id, not --project-id.

Signing in with offline login

You only need to sign in when you want an API key or want to manage portal resources from the terminal. offline login prints a confirmation code and opens https://dev.offlineprotocol.com/cli-auth, where you choose the application, enter the code and approve. Each login creates a new app API key for that terminal; organization keys are not accepted.

offline login            # opens the developer portal in your browser
offline login --email    # email code sign-in in the terminal
offline whoami

offline login --no-browser suits a headless machine, with approval from another browser. offline login --email stores a developer session instead of an API key, and the setup, orgs, apps and keys commands need it. That session lasts 30 days, renews while you use the CLI, and ends 90 days after sign-in at the latest. offline whoami --verify checks the stored key and App ID against the developer API, and offline logout clears local credentials and revokes the key that login created.

Offline CLI stored credentials and network calls

Signing in writes ~/.offline/config.json (or $OFFLINE_CONFIG_DIR/config.json): the app API key, the developer session token from email sign-in, your email address, and your developer, organization and application IDs. The file is plain JSON, not encrypted and not in the system keychain. On macOS and Linux it is created owner-only (0600) inside an owner-only directory; on Windows it keeps your profile folder’s default permissions. Anyone who can read the file can use the key.

The CLI sends sign-in requests, including your computer’s hostname as the device name you see when approving, and the developer API calls each command makes. offline update contacts the npm registry only when you run it. The CLI and the local MCP server send no usage analytics and no crash reports.

Running the local MCP server from the CLI

The CLI also contains the Offline Protocol MCP server, which gives a coding agent the same registry, guidance and scaffolding tools. It runs over standard input and output and needs no login or API key:

npx -y @offline-protocol/cli@0.2.9 mcp serve

Once the CLI is installed globally, offline mcp serve starts the same server and offline mcp tools lists its tools. offline mcp install <client> prints configuration for claude-code, claude-desktop, codex, cursor or vscode; it does not edit your client’s files. Its output starts the server with offline mcp serve, so it needs the offline command on the PATH your client uses. What is the Offline Protocol MCP server? covers the local and hosted modes, and Claude and Cursor each have a setup article.

Offline CLI command reference

These are the commands in CLI 0.2.9. offline <command> --help shows each one’s options.

CommandPurpose
login, logout, whoamiManage credentials and inspect authentication state
setup, orgs, apps, keysCreate or list organizations, applications and API keys; requires offline login --email
initConfigure an existing project
create, addScaffold a project or add packages
planPlan an integration
doctor, updateCheck the toolchain and credentials, and check npm for a newer release
registry, skillsInspect available packages and integration guidance
mcp serve, mcp install, mcp toolsRun local MCP, print client configuration or list tools
completionsGenerate shell completions

OFFLINE_APP_ID and OFFLINE_ORG_ID override the IDs saved in config.json when no flag is passed. Each CLI release pins the SDK release it was tested with, so scaffolds are repeatable. From the scaffold, you build the app and run it on your devices.

Frequently asked questions

Do I need an account to use the offline CLI?

No for planning, scaffolding a workflow and running the local MCP server. You need offline login to store an app API key, and offline login --email for the setup, orgs, apps and keys commands.

Can I run the offline CLI without installing it globally?

Yes. Put npx -y @offline-protocol/cli in front of any command, for example npx -y @offline-protocol/cli --version. The first run downloads the release from npm and later runs use the npm cache.

Where does offline login save my credentials?

In ~/.offline/config.json, or $OFFLINE_CONFIG_DIR/config.json, as plain JSON that is not encrypted or in the system keychain. On macOS and Linux it is owner-only. offline logout deletes it and revokes the key that login created.

Is the offline CLI on crates.io?

The crates.io package named offline-cli is a placeholder, not the released CLI. Install the CLI from npm.

Which SDK version does the offline CLI install?

Each CLI release pins the SDK release it was tested with, so a scaffold builds on the same versions every time. offline update checks npm for a newer CLI release and prints the upgrade command.

How do I use the offline CLI in CI?

Supply an app API key as OFFLINE_API_KEY through your secret manager, or run offline login --api-key with the key. Keep keys out of source control and logs.

Sources

Build it with Offline Protocol

The CLI and MCP page has every command, flag and environment variable, the three workflows with their scaffold commands, and the local and hosted MCP setup.

Read the CLI and MCP docs