Use the CLI with AI agents
Give Claude Code, Cursor, or any terminal-capable AI agent safe, scoped access to your Zanfia workspace.
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
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.
Install the CLI where the agent runs
npm install -g @zanfia-dev/cli
export ZANFIA_API_KEY=YOUR_SCOPED_KEYTell 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-fileand a final humancourses publish. - Community digests —
communities posts --jsonon a schedule, summarize, post the digest withcommunities post create. - Sales reporting —
stats overview --period 7d --jsonpiped into whatever writes your Monday report. - Bulk operations — anything repetitive over ids from a
listcommand; the strict-permutation reorder commands make ordering changes safe to script.
Was this article helpful?

