Article Type: Technical Guide | Audience: Developers, AI agent users | Goal: Install the CLI and run your first command
CLI (Command Line)
The ConnectSafely CLI runs your own LinkedIn account from a terminal, a cron job, a CI pipeline or an AI agent. It is 86 commands in a single binary with no runtime dependencies, no server to host and no protocol to speak.
It is included in the API plan alongside the REST API and the MCP server, from $10 per month per LinkedIn account. There is no separate CLI plan and no extra charge.
Install
You need Node 20 or newer.
npm install -g @connectsafely/cliThe binary is connectsafely, with csly as a short alias. Both do the same thing.
Authenticate
Generate a key on the API key page, then set it as an environment variable. This is what works unchanged in CI, in a container and inside an agent sandbox, where an interactive login cannot happen.
export CONNECTSAFELY_API_KEY=your_key_here
csly list-linkedin-accounts
export CONNECTSAFELY_ACCOUNT_ID=your_account_idRun your first command
csly get-connections --limit 5You are not expected to memorise 86 commands, and neither is an AI agent. Three steps, cheapest first:
csly commands # the catalogue, one line each
csly commands --search invitation # filter it
csly commands --kind write # only the ones that change something
csly schema send-connection-request # exact parameters for the one you pickedcommands, schema, --help and skill need no API key and work offline — the API specification is bundled inside the binary.
Use it with Claude Code or Cursor
csly skill installThat writes eight skills into .claude/skills/. Claude Code, Cursor and any runtime that reads that convention load them automatically. A small always-loaded router skill carries the live command catalogue and points at exactly one specialist skill per job — prospecting, outreach, inbox, content, analytics, account or Sales Navigator. After that you ask in plain English and the agent picks the commands.
There are 55 worked use cases if you would rather start from a job than from a command.
CLI or MCP server?
Both do the same things to the same account through the same API, and every CLI command has the same name as the matching MCP tool — so a prompt written for one works with the other unchanged. The difference is where the work runs.
- Use the MCP server when a person is chatting in Claude Desktop, ChatGPT or Cursor and wants LinkedIn available in that conversation. Pasting a URL into a settings panel beats asking someone to install a binary.
- Use the CLI everywhere else: cron jobs, CI pipelines, Docker containers, scripts, agent sandboxes and any coding agent that already has a shell.
The CLI is also considerably cheaper per AI agent session. An MCP client loads every tool definition into the model’s context before it reads your request — about 47,000 tokens for the full command set, every session. The CLI browses a catalogue (about 3,400 tokens) and reads one schema on demand (about 2,700), so a typical session spends roughly 6,200 instead of 47,000.
Many teams run both. They are the same contract, and both are in the same plan.
Running it unattended
--dry-runrehearses any write without sending it.- Batch operations pace themselves with a randomised 30–90 second gap between writes. Evenly timed bursts are what gets accounts flagged, so the gap is jittered rather than fixed.
- Every command returns a real exit code plus a JSON error envelope, so a cron job or CI pipeline can branch on a failure instead of parsing prose.
- The same server-side rate limits and daily caps as the rest of ConnectSafely apply. A script cannot exceed them.
--fieldsand--max-itemsprune a response before it is printed, which matters when an AI agent is paying for every token it reads.