CLI

Use the CLI with AI agents

Give Claude Code, Cursor, or any terminal-capable AI agent safe, scoped access to your Zanfia workspace.

4 min readLast updated Jul 9, 2026

The CLI is designed to be driven by AI agents as much as by humans: every command has a --json mode, errors carry machine-readable reasons, and authentication works from an environment variable. An agent that can run terminal commands can run your whole workspace.

Prefer MCP when your client supports it

If your AI client speaks MCP (Claude, Cursor, VS Code, ChatGPT), the MCP connection is the more direct route — typed tools, no shell required. The CLI approach below works everywhere else, and is the right choice for scripted pipelines and CI.

Setup

1

Create a scoped API key

In the dashboard, Integrations → API, MCP and CLI → create a key with only the permissions the agent needs (see Authentication). For a content agent that's typically Products read/write; add Communities only if it should post.

2

Install the CLI where the agent runs

npm install -g @zanfia-dev/cli
export ZANFIA_API_KEY=YOUR_SCOPED_KEY
3

Tell the agent how to use it

Paste instructions like the block below into your agent's configuration (a CLAUDE.md, Cursor rules, a system prompt, …).

Instruction block to give your agent

Adjust the confirmation rules to your risk tolerance — the key's scopes are the hard boundary; the instructions are the soft one.

Patterns that work well

  • Content pipelines — agent drafts lessons in Markdown files, then courses lesson update … --content-file and a final human courses publish.
  • Community digestscommunities posts --json on a schedule, summarize, post the digest with communities post create.
  • Sales reportingstats overview --period 7d --json piped into whatever writes your Monday report.
  • Bulk operations — anything repetitive over ids from a list command; the strict-permutation reorder commands make ordering changes safe to script.

Was this article helpful?

Related articles

Spotted something off? Tell us at support@zanfia.com.