> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.simplified.com/cli/use-from-an-ai-agent/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.simplified.com/_mcp/server. # Use from an AI agent Any assistant that can run terminal commands can use the Simplified CLI. Install it in the environment where that assistant runs, authenticate there, and give the assistant a clear outcome and workspace context. ## Start with discovery A reliable workflow first identifies the resources it needs: 1. Run `auth:whoami` and `teamspace:current` to confirm scope. 2. Use `accounts:list` for social tasks, `brandkit:list` for brand work, or `projects:list --type ...` for project work. 3. For generation, query the model catalog and inspect the selected capability's fields. 4. Save returned identifiers and verify the result after a write. Social account IDs are needed for posts and analytics, not for every command. Avoid selecting the first account automatically when several are available. ## Read command output In **1.8.0**, output is not uniformly JSON-only. Social and analytics commands can print a heading before a JSON payload; authentication and teamspace commands also include human-readable output. AI generation and several asset, brand, and project commands print JSON directly. There is no global JSON-only flag in this release. Errors and waiting progress are written to stderr. For a command that emits one JSON object or array after an optional heading, save stdout and extract the trailing JSON explicitly. Create `extract-json.cjs`: ```javascript const fs = require('node:fs'); const text = fs.readFileSync(0, 'utf8'); const lines = text.split(/\r?\n/); for (let i = 0; i < lines.length; i++) { if (!/^\s*[\[{]/.test(lines[i])) continue; try { const value = JSON.parse(lines.slice(i).join('\n')); process.stdout.write(JSON.stringify(value) + '\n'); process.exit(0); } catch { // A later line may start the JSON payload. } } console.error('Expected one trailing JSON object or array. Inspect the raw output.'); process.exit(1); ``` Then capture and validate an account response: ```bash simplified accounts:list --network linkedin > accounts-output.txt node extract-json.cjs < accounts-output.txt > accounts.json ``` Inspect the actual response shape before extracting IDs. This helper is for a single trailing JSON payload, not commands that print multiple data blocks such as some task-progress views. Preserve stderr separately when diagnosing errors. ## Example: generate a visual and create a draft This Bash script requires `jq`, a verified account ID, and an image model whose `prompt` capability supports a 1:1 aspect ratio. Set `SIMPLIFIED_ACCOUNT_ID` and `SIMPLIFIED_IMAGE_MODEL` before running it. Confirm the active workspace first. ```bash #!/usr/bin/env bash set -euo pipefail : "${SIMPLIFIED_ACCOUNT_ID:?Set the intended account ID}" : "${SIMPLIFIED_IMAGE_MODEL:?Choose a model from ai-image:models}" simplified ai-image:generate \ --model "$SIMPLIFIED_IMAGE_MODEL" \ --prompt "Studio photograph of a ceramic mug on linen, soft natural light." \ --aspect-ratio 1:1 --count 1 --wait > generated-images.json image_url=$(jq -er '.[0].url | select(type == "string" and length > 0)' generated-images.json) simplified posts:create \ --accounts "$SIMPLIFIED_ACCOUNT_ID" \ --content "Made for slow mornings." \ --media "$image_url" --action draft > draft-result.txt ``` The image generation command's successful waiting result is a JSON array. The post command's output is saved as text because it includes a heading. Review the created draft before choosing a publishing action. ## Track asynchronous work | Work | Save | Resume with | Waiting limit | | ------------------------- | --------------------------- | --------------------------------------- | ------------------------------------------------------ | | Image editing | `task_id` | `image:task --id` | 120 seconds | | Video editing | `task_id` | `video:task --id` | 300 seconds | | Narrated video production | `task_id`, any export ID | `video:task --id` | 300 seconds for the task, plus up to 300 for an export | | AI image generation | `art_variation_id` | `ai-image:status --id` | 180 seconds | | AI video generation | `id` and `art_variation_id` | `ai-video:status --art-id ... --id ...` | 600 seconds | | Asset processing | Asset `id` | `assets:get --id` | Inspect until ready; no `--wait` flag | For durable jobs, submit without `--wait` and persist the response immediately. A script can then resume polling after a restart. A waiting timeout does not mean the server cancelled the work. ## Handle retries deliberately Check the command's exit status before using its output. Retry reads after a transient error with a bounded delay. Before retrying a create, schedule, upload, or generation request, inspect whether the first attempt succeeded; rerunning it may duplicate content or spend additional credits. For CI, inject the API key through your secret manager and use an explicit `--teamspace` where appropriate. Keep generation results and content IDs as job artifacts, but exclude credentials. See [authentication precedence](/cli/install-and-authenticate#use-a-secret-in-ci) when a saved profile is present. > Build reliable terminal workflows with explicit context, structured inputs, and job tracking.