cogx CLI
Use iCog memory from a terminal or coding agent with the zero-dependency cogx CLI.
cogx is the command-line interface for CognitiveX and a client for the
Persistent Memory Protocol (PMP). It gives you (and any
coding agent that can run a shell command) direct access to iCog memory:
recall, remember, talk, and wire iCog into your editor as an MCP server. It is
pure Node.js with zero dependencies, so it behaves the same on macOS, Linux,
and Windows.
The package is @cognitivx/cli
(binary: cogx), currently v1.5.0. It talks to the same backend as the web app
and the MCP, at https://api.cognitivx.io.
Every command supports --json for machine-readable output. Agents that
cannot load an SDK or MCP client can shell out to cogx ... --json and parse
the result. See JSON mode.
Install
Requires Node.js 18 or newer (the CLI uses the built-in fetch, and exits
with an error on older runtimes).
npm install -g @cognitivx/clinpm install -g github:ParsaBarati/cogxRun once without installing globally:
npx github:ParsaBarati/cogx talk "what did we ship today"Verify the install:
cogx --version # → 1.5.0Run cogx doctor at any point to diagnose your setup (Node version,
credentials, API reachability, MCP installs, and whether a newer CLI is
published).
Authenticate
cogx resolves an API key in this order, highest precedence first:
- The
--api-key <key>flag (one-off override on a single command) - The
ICOG_API_KEYenvironment variable - Saved credentials at
~/.icog/credentials.json
If none are present, commands that need auth exit with
not authenticated. Run: cogx auth login.
Sign in with the device flow
cogx auth loginThis opens your browser to a verification URL, polls until you authorize, then
saves the key to ~/.icog/credentials.json (file mode 0600). If
ICOG_API_KEY is already set in your environment, login is skipped and that
key is used.
Or use an environment variable
For CI, scripts, and remote machines, export a key created at developers.cognitivx.io/keys:
export ICOG_API_KEY=icog_xxx...The env var always wins over stored credentials.
Or save a key directly
cogx auth set icog_xxx...
# or pipe it:
echo "icog_xxx..." | cogx auth setauth set validates the key against the API before writing it to
~/.icog/credentials.json, so a bad key fails fast instead of being saved.
auth subcommands
| Command | Purpose |
|---|---|
cogx auth login | Sign in via browser device flow; saves credentials. |
cogx auth status | Show current auth state (env key or saved file, with email if known). |
cogx auth logout | Remove ~/.icog/credentials.json. Does not affect ICOG_API_KEY. |
cogx auth set <key> | Validate and save an API key, skipping the device flow. Reads stdin if no arg. |
cogx auth status
# ✓ authenticated as [email protected]
# /Users/you/.icog/credentials.jsonauth login and auth set do not retry on failure (the device flow is
interactive). If auth login reports authorization expired or
authorization timed out, run it again.
Memory
The core verbs. All four read text from positional arguments, from piped stdin, or both combined.
| Command | Purpose | METHOD + path |
|---|---|---|
cogx recall <query> | Semantic search across your memories | POST /api/consciousness/recall |
cogx remember <text> | Store a memory | POST /api/consciousness/remember |
cogx update <id> <text> | Replace a memory (re-embeds) | POST /api/consciousness/update |
cogx forget <id> | Soft-delete a memory | POST /api/consciousness/forget |
Memory types
remember and recall --type accept these values. semantic is the default
for remember.
| Type | Use for |
|---|---|
semantic | Facts, decisions, architecture. The default. |
episodic | Events, sessions, "what happened". |
procedural | How-tos, repeatable steps, coding patterns. |
foundational | Identity, values, core preferences. |
See the memory concepts page for when to reach for each type.
remember
Store a memory. Flags: --type, --project, --deep, --json.
cogx remember "Auth bug: double-encoded JWT in the refresh path. Fixed in tryRefresh()."
cogx remember --type episodic "Spent 2h debugging the websocket reconnect"
cat NOTES.md | cogx remember --type episodic
cogx remember --project myapp "Switched to PostgreSQL 16"The --deep flag runs a curated remember: it recalls related memories first,
classifies the new content as new / duplicate / refinement, skips duplicates,
and streams a live chain to the terminal.
cogx remember --deep "We chose adaptive memory recall for iCog"cogx remember "test" --json{ "ok": true, "memory_id": "019e0b...", "memory_type": "semantic" }In deep mode, JSON output includes the streamed events plus the final action
(write_new, skip_duplicate, or refine):
{ "ok": true, "deep": true, "action": "skip_duplicate", "memory_id": "019e0b...", "reason": "near-identical to existing", "events": [ ... ] }recall
Semantic search. Flags: --type, --limit (default 8), --project,
--deep, --json.
cogx recall "what was the auth bug from last week"
cogx recall "ssh setup" --type procedural --limit 5
echo "auth" | cogx recall --json --limit 3--deep runs adaptive multi-step recall: it plans sub-queries, searches,
reflects on coverage, and synthesizes. It is slower (roughly 3 to 8 seconds)
and uses more LLM calls, but it is the right tool for cross-memory questions.
cogx recall --deep "how did we end up handling memory isolation"cogx recall "ssh keys" --json --limit 2{
"ok": true,
"query": "ssh keys",
"count": 2,
"memories": [
{
"id": "019e0b...",
"text": "Use ed25519 keys everywhere; rotate yearly.",
"memory_type": "procedural",
"age_days": 3,
"similarity": 0.82
}
]
}In human mode, each result prints its index, type, age, similarity score, the
text, and the memory id you can pass to update or forget.
update and forget
cogx update <memory-id> "Corrected version of the memory"
cogx forget <memory-id>update re-embeds the memory and returns a new id (new_memory_id). forget
is a soft delete. Both take an id from a recall result.
Project tags
Set ICOG_PROJECT or pass --project <name> to prefix the query or content
with [Project: <name>] . This applies to recall, remember, talk, and
save-session.
# Per call
cogx remember --project myapp "Switched to PostgreSQL 16"
# Or a default for the shell session
export ICOG_PROJECT=myapp
cogx recall "schema migrations" # searches "[Project: myapp] schema migrations"Errors. Memory commands with no text and no stdin exit with a usage
message (status 1). With --json, that becomes
{"ok": false, "error": "usage: ..."}. Server failures surface as
HTTP <status> <statusText> (for example HTTP 401 for a rejected key, or
HTTP 429 when over quota). Transient 502 / 503 / 504 and network errors
are retried automatically (see Resilience).
Talk and chat
talk is a one-shot question answered with full memory context. chat is an
interactive REPL with persistent history.
| Command | Purpose | METHOD + path |
|---|---|---|
cogx talk <message> | Ask iCog, with memory context | POST /api/consciousness/talk |
cogx chat | Interactive REPL | (calls talk per line) |
# One-shot
cogx talk "should I refactor the auth interceptor?"
# Pipe a question or a file to critique
echo "review this approach" | cogx talk
cat ARCHITECTURE.md | cogx talk "Critique this architecture"cogx talk "what did we decide about auth" --json{ "ok": true, "response": "Last week you chose to ...", "context_used": 6 }context_used is the number of memories iCog recalled to answer. talk
accepts --project and --json.
Interactive chat
cogx chatInside the REPL, type a message to talk to iCog, or use slash commands:
you ❯ /recall ssh keys
you ❯ /remember decided to use ed25519 everywhere
you ❯ /reflect
you ❯ /quitHistory is saved to ~/.icog/history and reloaded across sessions
(up-arrow recalls previous lines). cogx chat does not support --json.
Cognition
Introspection and consolidation commands.
| Command | Purpose | METHOD + path |
|---|---|---|
cogx reflect | Consciousness level, memory count, narrative | GET /api/consciousness/reflect |
cogx introspect | Full cognitive mirror: mood (VAD) and personality traits | GET /api/introspect/mood, /api/introspect/personality, /api/consciousness/reflect |
cogx learn <outcome> | Record a learning signal | POST /api/consciousness/learn |
cogx dream | Trigger dream consolidation | POST /api/mind/dreams/trigger |
cogx dream-status | Check progress of a running dream job | GET /api/mind/dreams/progress |
cogx save-session <summary> | Store an episodic session summary | POST /api/consciousness/remember + learn |
cogx reflect # consciousness level + memory count + narrative
cogx introspect # mood (VAD) + personality traits
cogx learn bug_fixed # record a learning signal
cogx dream # trigger consolidation
cogx dream-status # check progress
cogx save-session "shipped the install page" --project cogx-clicogx reflect --json{ "ok": true, "consciousness_level": "3", "memory_count": 847, "narrative": "..." }learn takes an optional --metadata '{...}' (parsed as JSON).
save-session takes --project and --decisions '...'; it stores an episodic
memory and records a claude_code_session learning signal.
dream-status errors. When no dream job is running, the progress endpoint
returns 404, which the CLI reports as no dream job running
({"ok": true, "running": false} in JSON mode), not as an error.
MCP install
Wire iCog into a coding agent. The CLI writes the remote MCP config that
points the agent at https://api.cognitivx.io/mcp/ over HTTP. There is no
local process, no Python, and no native modules. After install, restart the
agent and iCog appears as MCP tools (mcp__icog__recall,
mcp__icog__remember, and so on).
| Command | Purpose |
|---|---|
cogx mcp install [agent|all] | Write the iCog MCP entry into an agent's config. Default agent: claude. |
cogx mcp list | Show which agents have iCog installed, plus which supported agents are detected. |
cogx mcp update [agent|all] | Refresh existing iCog entries (new key or URL). Defaults to all. |
cogx mcp uninstall <agent|all> | Remove iCog from one or all agent configs (leaves other servers intact). |
Supported agents
The agent argument is one of the following keys (or all):
| Agent key | Tool | Config path |
|---|---|---|
claude | Claude Code | ~/.claude.json |
claude-desktop | Claude Desktop | <app-data>/Claude/claude_desktop_config.json |
cursor | Cursor | ~/.cursor/mcp.json |
windsurf | Windsurf | ~/.codeium/windsurf/mcp_config.json |
cline | Cline (VS Code) | <app-data>/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json |
vscode | VS Code (native) | ~/.vscode/mcp.json |
<app-data> is ~/Library/Application Support on macOS, %APPDATA% on
Windows, and ~/.config on Linux.
cogx mcp install claude # default agent if omitted
cogx mcp install cursor
cogx mcp install --all # every detected agent
cogx mcp list
cogx mcp uninstall claudemcp install --all only writes to agents whose config directory already
exists. It will not create app-data directories for tools you have not
installed, and reports the rest as skipped.
The entry the CLI writes looks like this:
{
"mcpServers": {
"icog": {
"type": "http",
"url": "https://api.cognitivx.io/mcp/",
"headers": { "X-API-Key": "icog_xxx..." }
}
}
}Errors. Installing merges into the existing config and preserves every
other key. If a target config file exists but is not valid JSON, the CLI
refuses to overwrite it and exits, so a transient read glitch cannot wipe
your settings. mcp update only touches configs that already contain the
iCog entry; it never adds a new one (use mcp install for that).
JSON mode
Every command supports --json (alias -j) for machine-readable output. This
is the safest interface for agents: failures return
{"ok": false, "error": "..."} instead of styled terminal text.
cogx recall "ssh keys" --json --limit 2
cogx remember "test" --json
cogx reflect --jsoncogx remember --json{ "ok": false, "error": "usage: cogx remember <text> ..." }A minimal agent integration in Node, shelling out and parsing the result:
const { execFileSync } = require("child_process");
function cogx(args) {
const out = execFileSync("cogx", [...args, "--json"], { encoding: "utf8" });
const result = JSON.parse(out.trim());
if (!result.ok) throw new Error(`cogx ${args[0]}: ${result.error}`);
return result;
}
const stored = cogx(["remember", "Agent test memory"]);
const recalled = cogx(["recall", "agent test memory", "--limit", "3"]);
console.log(`stored ${stored.memory_id}, recalled ${recalled.count}`);If you are building a TypeScript service rather than shelling out, prefer the
@cognitivx/sdk package, which exposes the
same memory operations as typed functions.
Pipes and composition
Stdin is read on recall, remember, talk, update, search, and
save-session. When a positional argument is also present, stdin is appended
to it. Compose freely:
cat README.md | cogx remember --type semantic --project cogx-cli
git log --oneline -10 | cogx remember --type episodic --project myapp "Recent commits"
curl -s https://example.com/spec.md | cogx remember --type semantic
cogx recall "deploy steps" --json | jq '.memories[0].text'Web search
| Command | Purpose | METHOD + path |
|---|---|---|
cogx search <query> | Web search via iCog | POST /api/consciousness/search |
cogx search "latest postgres lts release" --limit 5Flags: --limit (default 5), --json. Results print title, URL, and a
snippet; JSON mode returns a results array.
Agent identity
| Command | Purpose | METHOD + path |
|---|---|---|
cogx identify <name> | Register this agent with iCog so its talk exchanges are attributed | POST /api/agents/register |
cogx identify "deploy-bot" --type tool --description "CI orchestration agent"Flags: --type (one of tool, persona, view, peer), --description,
--task. Roles such as "orchestrator" belong in the description; type selects
the memory-policy class.
When more than one agent is registered, CogX fails closed on ambiguous agent
operations. Pass --agent <slug> per command or activate only the current
shell:
eval "$(cogx agent activate Aporta --notify --sense)"
cogx agent status
cogx agent notify status --agent Aporta
cogx remember "Barcode owns invoice authority" --share-with Abarcode,AutomaActivation checks the inbox and reports unread work on stderr without
polluting the export statement consumed by eval. --notify also starts the
detached notification supervisor for that identity; --sense connects its
events to Sense and the local Orb.
Multi-agent coordination is available directly from the CLI:
cogx team create aira-ecosystem --members Aporta,Abarcode,Automa
cogx orchestrate "Map quote-to-cash" --agent Aporta \
--agents Abarcode,Automa \
--tasks '{"abarcode":"map ERP authority","automa":"map automations"}'
cogx agent inbox --agent Abarcode
cogx agent wait --agent Abarcode
cogx agent watch --agent Abarcode --json
cogx agent handoff Automa "Implement the connector" \
--agent Abarcode --context "ERP boundary confirmed"agent wait blocks until an unread message arrives (300-second default;
--timeout 0 waits indefinitely). agent watch continuously emits newly
observed unread messages, and its JSON mode is NDJSON for a supervisor process.
Neither command acknowledges messages; use agent ack after the recipient has
accepted the work.
Background PMP notifications
The background supervisor polls an agent's PMP inbox independently of the
terminal that started it. It persists restart-safe message deduplication and a
bounded event log under ~/.icog/notifications/<agent-slug>/.
cogx agent notify start --agent Aporta
cogx agent notify status --agent Aporta
cogx agent notify test --agent Aporta
cogx agent notify logs --agent Aporta --limit 20
cogx agent notify stop --agent AportaWire the recipient to Sense and Orb:
cogx agent notify start --agent Aporta --sense
# Or activate the identity and start both in one eval-safe command:
eval "$(cogx agent activate Aporta --notify --sense)"CogX sends Sense a minimized event envelope. Sense redacts it, stores the local
timeline event, applies quiet hours and attention policy, then raises the Orb.
The actual message and receipt remain in PMP. Content is omitted unless
--preview is explicit. Daemons predating native PMP ingress automatically use
a metadata-only /events plus /orb/state compatibility path.
Desktop notifications are supported on macOS and Linux. Message content is
private by default; add --preview to include it. For a headless agent host,
disable desktop delivery and configure a wake webhook:
cogx agent notify start --agent Aporta --no-desktop \
--webhook https://runner.example/hooks/pmpUseful controls:
--interval <seconds>sets the poll interval, with a minimum of 0.25 seconds.--replayforgets saved deduplication IDs and redelivers current unread work.--forcereplaces an already running supervisor.--webhook nonedisables a previously configured webhook.--senseenables local Sense/Orb delivery at127.0.0.1:48200.--sense-url <url>overrides the Sense base URL; remote hosts require HTTPS.--no-sensedisables previously configured Sense delivery.--desktopand--no-desktopenable or disable local notifications.--previewand--no-previewcontrol whether desktop and Sense previews include content.
The webhook receives the full PMP event as JSON but never receives CognitiveX
credentials. Treat its URL as sensitive and use an authenticated HTTPS endpoint
you control. Notification delivery does not acknowledge the PMP receipt; the
recipient remains responsible for agent ack. The process survives its
invoking shell, but it must be started again after an operating-system reboot.
A notification makes work visible to the host. Waking or resuming an idle model conversation still requires the host runtime to consume the webhook or foreground NDJSON event and start that model.
Billing
Manage your subscription and credits from the terminal. Paid actions print a Stripe-hosted URL; the CLI never handles card data.
| Command | Purpose | METHOD + path |
|---|---|---|
cogx billing status | Plan, subscription state, renewal, credit balance | GET /api/billing/me, /api/billing/balance |
cogx billing usage | This cycle's usage vs your tier's caps | GET /api/billing/usage |
cogx billing tiers | List plans with prices and allowances (public) | GET /api/billing/tiers |
cogx billing subscribe <tier> | Start or upgrade a subscription | POST /api/billing/create-checkout |
cogx billing portal | Open the Stripe customer portal | POST /api/billing/create-portal |
cogx billing switch-to-payg | Move to pay-as-you-go (metered) billing | POST /api/billing/switch-to-payg |
cogx billing set-cap <usd|none> | Set or clear the monthly PAYG spend cap | PUT /api/billing/payg-cap |
cogx billing status # plan, subscription state, balance
cogx billing usage # cycle usage vs caps
cogx billing tiers # plans with prices (no auth needed)
cogx billing subscribe awakened # → Stripe Checkout URL (monthly)
cogx billing subscribe conscious --interval annual
cogx billing portal # → Stripe portal: card, invoices, cancel
cogx billing switch-to-payg # move to metered
cogx billing switch-to-payg --refund card
cogx billing set-cap 50 # cap PAYG spend at $50/month
cogx billing set-cap none # remove the capDetails:
subscribetiers areawakenedandconscious;--intervalismonthly(default) orannual.switch-to-paygtakes--refund credit(default, leaves proration on your Stripe balance) or--refund card(refunds the original payment method).set-capaccepts a dollar amount from1to10000, ornone/clear/offto remove the cap.
Errors. billing portal requires an existing billing account; without
one it exits with no billing account yet — run cogx billing subscribe <tier> first (the API returns 400). billing set-cap rejects amounts outside
1–10000 before any request is sent.
Maintenance
| Command | Purpose |
|---|---|
cogx doctor | Self-diagnostic: Node version, fetch, credentials, API reachability, auth validity, MCP installs, and whether a newer CLI is published. |
cogx self-update | Upgrade to the latest published @cognitivx/cli via npm install -g @cognitivx/cli@latest. |
cogx doctor
# cogx doctor
# ✓ Node.js v20.11.0
# ✓ Credentials /Users/you/.icog/credentials.json
# ✓ API reachable https://api.cognitivx.io → 200
# ✓ Auth key accepted
# ✓ MCP installs Claude Code, Cursor
# ✓ Version v1.3.0 (latest)
# all clear.
cogx self-update # no-op if already latest
cogx self-update --force # reinstall even if currentIf self-update cannot upgrade in place (permissions or an alternate package
manager), it prints fallback commands for sudo, pnpm, and yarn.
Reference
Commands
| Command | Purpose |
|---|---|
cogx auth login / status / logout / set <key> | Manage authentication |
cogx recall <query> | Semantic search |
cogx remember <text> | Store a memory |
cogx update <id> <text> | Replace a memory |
cogx forget <id> | Soft-delete a memory |
cogx talk <message> | Talk to iCog with full memory context |
cogx chat | Interactive REPL with persistent history |
cogx reflect | Consciousness level + memory count + narrative |
cogx introspect | Full cognitive mirror (mood, traits) |
cogx learn <outcome> | Record a learning signal |
cogx dream / dream-status | Trigger / monitor consolidation |
cogx save-session <summary> | Episodic session summary |
cogx search <query> | Web search via iCog |
cogx identify <name> | Register agent identity |
cogx mcp install [agent|all] | Install iCog MCP |
cogx mcp list / update / uninstall | Manage MCP installs |
cogx billing status / usage / tiers | View billing |
cogx billing subscribe / portal / switch-to-payg / set-cap | Manage billing |
cogx doctor / self-update | Diagnose / upgrade the CLI |
Run cogx <command> --help for detailed per-command help.
Global flags
| Flag | Purpose |
|---|---|
--json, -j | Emit JSON output |
--api-key <key> | One-off API key (overrides env and saved credentials) |
--project <name>, -p | Tag query / content with [Project: <name>] |
--type <t>, -t | Memory type (semantic / episodic / procedural / foundational) |
--limit <n>, -l | Result count (recall, search) |
--deep | Adaptive multi-step recall / curated remember |
--help, -h | Show help (or per-command: cogx remember --help) |
--version, -v | Print version |
Environment
| Variable | Purpose | Default |
|---|---|---|
ICOG_API_KEY | API key, overrides saved credentials | — |
ICOG_API_URL | Override the API base URL | https://api.cognitivx.io |
ICOG_PROJECT | Default project tag | — |
ICOG_TIMEOUT_MS | Request timeout in milliseconds | 60000 |
NO_COLOR | Disable colored output when set | — |
Files
| Path | Contents |
|---|---|
~/.icog/credentials.json | API key, email, and agent slug (file mode 0600) |
~/.icog/history | cogx chat REPL history |
Resilience
The CLI retries transient failures (502 / 503 / 504 and network errors)
with exponential backoff: roughly 1s, 3s, then 8s, for 4 attempts total.
Streaming commands (recall --deep, remember --deep) and the auth device
flow do not retry, so an interactive failure surfaces immediately. Override the
per-request timeout with ICOG_TIMEOUT_MS.