@anyslate/cli
@anyslate/cli
Your AI tools remember what you did. Automatically.
Lifecycle hooks, git commits and CI runs → your AnySlate memory, without you lifting a finger.
What is this?
AnySlate gives your AI tools a long-term memory — a place where decisions, tasks and work history live, so Claude, Cursor or Codex can pick up where you left off instead of starting cold every session.
This CLI is how that memory gets filled in when no AI is watching.
An AI can only record something if it decides to call a tool. But a lot of your real work happens outside that: you commit code, CI deploys, you run the test suite, you make a call while staring at a terminal. None of it has an AI present to write it down.
This CLI closes that gap. Your tools call it for you:
Claude Code fires a hook ─┐
git runs post-commit ─┼─→ anyslate ─→ AnySlate memory
CI finishes a deploy ─┘
Think of it like a fitness tracker for your engineering work. You don't tell a fitness tracker "I just took 47 steps." You wear it, you walk, the number goes up. Same idea: install this once, paste one config block, and capture happens in the background forever.
You will almost never type
anyslateyourself. It is plumbing that other tools call. Setup takes about five minutes and ends withanyslate doctorconfirming it works.
Quick start
npm i -g @anyslate/cli # 1. install
anyslate login # 2. sign in (opens your browser)
anyslate doctor # 3. confirm it works
Then paste the hook block into ~/.claude/settings.json — see
Wiring into Claude Code — and restart Claude Code. Done.
What actually gets captured
| Trigger | Who calls the CLI | What lands in your memory |
|---|---|---|
| You open a Claude Code session | SessionStart hook |
Session start + working directory; the AnySlate memory is created on first sight |
Claude edits routes/auth.ts |
PostToolUse hook |
Edited routes/auth.ts in the activity ledger |
Claude runs npm test |
PostToolUse hook |
Command + exit status in the activity ledger |
You git commit |
git post-commit hook |
Commit metadata and diff stats |
| A teammate merges your PR | GitHub webhook (no CLI needed) | PR-merged event |
| You close the laptop | Stop hook |
Session-end marker |
| You want to record a decision | you typing anyslate checkpoint |
Captured immediately, as a decision |
| You want to attach a file | you typing anyslate upload-artifact |
Stored, returns cloud://artifact/<id> |
The first six rows are automatic. The last two are the rare moments you'd type something.
What hook captures write — read this before forming expectations
Hook captures land in a dedicated ## Activity Ledger section of your memory page:
which files were touched, which commands ran, what exit status they returned. That is the
whole contract. The ledger is capped (25 files / 15 commands per entry) and is built
deterministically — no LLM runs in the hook path, so background capture never bills
against your AI quota.
Hook captures do not write to Key Decisions or Open Tasks. Those stay human-
and LLM-authored. A hook firing on Bash has no decision inside it to extract, and the
product no longer pretends otherwise.
If you want a decision recorded, say so:
anyslate checkpoint --note "Decided: Redis for session cache, not memcached"
Approval: hook captures auto-promote
Every lifecycle hook — Edit / Write / MultiEdit, Bash, and the session start/stop
markers — classifies low-risk and auto-promotes on its own, 30–90 seconds after
capture. An edit-heavy session does not build an approval queue.
Rows still wait for approval in AI Memory → Activity when they are genuinely riskier: a
capture aimed at a different session than the one that produced it, a decision that
supersedes an earlier one, a submission from an untrusted source, or one carrying
confidence < 0.8.
Why bother
- You stop forgetting to checkpoint. Capture happens whether you remember or not.
- You see what actually happened, not just what the AI claimed. If the agent says it
implemented
TokenRefreshServiceand the diff is whitespace, that discrepancy is visible. You trust the AI because you can check, not because you have to assume. - Your work follows you across tools. Claude Code at home, Cursor at work, a terminal in between — all feeding one memory. (Cursor and Windsurf feed it through the in-host MCP server rather than this CLI — see the FAQ.)
- Nothing is canonical until it is. Anything pending can be rejected without ever touching a memory page.
Install
npm i -g @anyslate/cli
# or run on demand without installing:
npx @anyslate/cli --help
Requires Node ≥ 20.
macOS users hitting
EACCESon global install: don't usesudo. Configure a user-writable npm prefix instead:mkdir -p ~/.npm-global npm config set prefix '~/.npm-global' echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.zshrc source ~/.zshrc npm install -g @anyslate/cli
Authenticate
anyslate login
That's it. login opens your browser, you approve the CLI on the AnySlate consent screen, and the credentials land in ~/.anyslate/cli.json (mode 0600). Nothing to copy, nothing to paste.
What happens under the hood, in case you're the kind of person who wants to know before you run it: OAuth 2.1 authorization code with PKCE. The CLI reads every endpoint from the server's discovery documents (/.well-known/oauth-authorization-server and /.well-known/oauth-protected-resource) rather than assuming any path, registers itself once via Dynamic Client Registration and caches the resulting client id, binds a short-lived listener on 127.0.0.1 for the callback, and verifies the resulting token with one live request before writing anything.
The access token lasts one hour; a refresh token lasts 30 days. The CLI refreshes automatically — five minutes ahead of expiry, and again if a call comes back 401 — so your hooks keep capturing without you thinking about it. Refresh tokens are single-use and rotate on every refresh; the new one is written to disk immediately.
Then confirm the whole install:
anyslate doctor
Signing in to a non-production environment
anyslate login --api-url https://anyslate-mcp-service-development.example.workers.dev
--api-url takes the service root (no /mcp suffix — see the two URL conventions). Every OAuth endpoint, and the OAuth resource identifier, is then read from that root's discovery documents. Dev and production issue different client ids, so the CLI caches one per root and reuses it.
If discovery fails, login says which host it tried and stops. It will not fall back to guessed endpoint paths.
Static tokens, for CI
Browsers are in short supply on a build agent. The token path is unchanged and stays supported:
anyslate login --token as_mcp_your_token_here
# or, with no config file at all:
export ANYSLATE_MCP_TOKEN=as_mcp_your_token_here
Mint the token in the AnySlate app: Avatar (top-right) → API Tokens → Tokens tab → Create Token. This is the same dialog on the desktop app and on the cloud app at https://cloud.anyslate.io; the dialog is titled MCP Tokens. MCP token minting is available on every plan - Free, Pro and Unlimited - with no token quota. Copy the token (it starts with as_mcp_; you only see it once).
login --token verifies the token against the server before writing anything. If the host is unreachable, the URL isn't an AnySlate MCP service, or the token is unrecognised/revoked/expired, it prints the reason, writes nothing, and exits non-zero. See anyslate login for the --force / --no-verify escapes.
Static tokens never expire and are never refreshed. That is the trade: convenient for CI, and the reason the browser flow is the default everywhere else.
Signing out
anyslate logout
Revokes the session server-side, then removes the credentials from ~/.anyslate/cli.json. Your apiUrl, handle and cached client registration are kept, so anyslate login afterwards is a one-liner.
Environment variables
export ANYSLATE_MCP_TOKEN=as_mcp_your_token_here
export ANYSLATE_API_URL=https://mcp.anyslate.io # optional; service ROOT, no /mcp
export ANYSLATE_HANDLE=mh_xxxxxxxx # optional, scope to one capability handle
export ANYSLATE_DISABLE=1 # optional, disables capture for this shell
export ANYSLATE_HOME=/path/to/dir # optional, overrides ~/.anyslate
export ANYSLATE_STDIN_TIMEOUT_MS=10000 # optional, stdin idle timeout (0 disables)
Env vars override ~/.anyslate/cli.json.
The bearer the CLI actually sends is resolved in this order, first hit wins:
ANYSLATE_MCP_TOKEN— a static token from the environment. Never refreshed.- The OAuth access token from
cli.json, refreshed if it is expired or close to it. - The static
mcp_tokenincli.json.
anyslate doctor prints which of the three won, so an ANYSLATE_MCP_TOKEN you exported weeks ago and forgot cannot silently shadow a browser sign-in.
ANYSLATE_DISABLE=1 stops hook / checkpoint / upload-artifact from making any network call (they exit 0). doctor and login still run, so you can diagnose and set up while capture is off. Any value counts as "on" except empty, 0, false, no, off.
Capability handles are mh_ + a 32-character id (e.g. mh_V1StGXR8Z5jdHi6BmyT0aQx3nKpL7cWe), minted alongside a scoped token in the Handles tab of the same dialog. A handle id that isn't yours or doesn't exist is rejected server-side - since 0.2.0 the CLI reports that as a failure instead of exiting 0 silently.
If your token was minted with a memory scope, it already carries that scope server-side and ANYSLATE_HANDLE / --handle is ignored. Scoped tokens cannot be widened per-call by design. To capture workspace-wide, mint an unscoped token. anyslate doctor reports which case you're in.
The two URL conventions - the one thing people get wrong
AnySlate ships two clients and they want different URLs. This trips up nearly everyone:
| Client | Variable / flag | Wants | Example |
|---|---|---|---|
@anyslate/mcp bridge (Claude Desktop, Cursor, Windsurf…) |
ANYSLATE_MCP_URL |
the MCP endpoint - with /mcp |
https://mcp.anyslate.io/mcp |
@anyslate/cli (this package) |
--api-url / ANYSLATE_API_URL |
the service root - without /mcp |
https://mcp.anyslate.io |
The CLI appends /mcp itself. Pasting the bridge's URL into --api-url used to produce …/mcp/mcp, a permanent 404 {"error":"Not found"} that masks every other diagnosis - because the 404 fires before authentication, so a wrong URL makes a valid token look invalid.
Since 0.2.0 the CLI accepts either form and normalizes, stripping any trailing /mcp segments (/mcp, /mcp/mcp, /MCP/, trailing slashes). Normalization happens on every read, so a cli.json written by an older version self-heals without re-running login. When it rewrites a value it tells you:
anyslate: apiUrl "https://mcp.anyslate.io/mcp" ends in /mcp — the CLI wants the service ROOT and appends /mcp itself.
anyslate: using "https://mcp.anyslate.io". Run `anyslate login --api-url https://mcp.anyslate.io` to persist.
Subcommands
anyslate hook <session-start|post-tool-use|stop> [--strict] [--session <id>] [--note <text>] [--host <hint>]
anyslate checkpoint --note "..." [--kind milestone] [--session <id>] [--host <hint>] [--source <source>]
anyslate upload-artifact --session <id> --kind <kind> [--file <path>] [--language <lang>] [--path-hint <path>]
anyslate login [--api-url <URL>] [--no-browser] [--timeout <seconds>] [--handle <ID>]
anyslate login --token <BEARER> [--handle <ID>] [--api-url <URL>] [--force] [--no-verify]
anyslate logout [--local]
anyslate doctor [--deep] [--refresh]
anyslate version | help
anyslate doctor
The one command whose job is to fail loudly. Run it after setup and any time capture seems dead. It exits non-zero if any check FAILs.
It checks, in order: which config layer won (env var vs cli.json) per key; that a credential is present; which auth mode is in use — OAuth or static token — and for OAuth how long the access token has left and whether a refresh token is stored; that the token looks like a token; that the URL parses and has the right shape (before any token verdict, because a wrong URL 404s ahead of auth and would otherwise be misread as a bad token); that the host is reachable and healthy; whether refresh works; that the token is valid (and, if not, whether it is unrecognised, revoked or expired); that the token carries memory:write; the effective handle scope; that anyslate is on the PATH a hook subprocess would get; and whether Claude Code's hooks are actually wired in ~/.claude/settings.json.
The refresh check runs after reachability on purpose: a refresh against a host that is down fails for a reason that has nothing to do with your credentials, and reporting that as "refresh is broken" sends you hunting for the wrong bug. If the access token is still comfortably valid, doctor reports the refresh token as present but does not spend it — pass --refresh to force a real refresh round trip (which rotates the token).
An expired OAuth access token is a WARN, not a FAIL: access tokens are supposed to expire hourly. The FAIL you care about is oauth-refresh, which means renewal itself is broken and you need to run anyslate login again.
Reading the output:
- PASS - checked and observed good.
- WARN - works, but something is narrower or more fragile than you probably intend (e.g. a project-scoped token, or a config key coming from an env var you forgot you exported).
- FAIL - this is why capture isn't working. Each FAIL prints the specific remedy.
doctor is not side-effect-free: verifying the token updates its last_used_at, consumes rate-limit budget, and writes an audit-log row. --deep additionally submits a real doctor_probe activity, which is visible in your Activity feed - that's why it's opt-in. --refresh forces an OAuth refresh, which rotates your refresh token - also why it's opt-in.
anyslate hook ...
Reads a JSON event payload from stdin (Claude Code lifecycle event format). Fails open by default - a network blip, an invalid token or a server-side rejection logs to stderr and exits 0, so your Claude Code session is never broken. Pass --strict to exit 1 on failure instead (useful in CI smoke tests).
Because fail-open means you won't see stderr in normal use, every run is recorded to ~/.anyslate/cli-last-run.json and a capped ring log at ~/.anyslate/cli-runs.ndjson (both mode 0600, token redacted). After repeated consecutive failures the SessionStart hook surfaces a message in Claude Code itself telling you to run anyslate doctor. One-off failures stay quiet.
Kind mapping: hook session-start → topic_shift; hook stop → conversation_end; hook post-tool-use maps Edit/Write/MultiEdit/Create and Bash/Shell/Run/GitCommit → task_completed, everything else → topic_shift.
Hooks never emit artifact_produced. That kind is a contract — "I stored an artifact, here is its id in artifact_refs" — and the server rejects it without one. A hook observes a file touch; it stores nothing. The touched path is carried in the files_touched ledger field instead, so edits auto-promote as activity entries rather than piling up an approval queue.
Session identity is handled for you. Claude Code's session_id is a UUID from its own namespace; AnySlate session ids are a different format entirely. The server resolves the incoming UUID against conversation_id_external, and creates the AnySlate session on first sight if there's no match, titling it from the host and working directory. You do not need to pass --session in the Claude Code hook config, and re-running under the same Claude Code session reuses the same AnySlate session. --session remains available for git hooks and CI, where you want to pin captures to one specific memory.
Fields read from the stdin payload: session_id (or sessionId), tool_name (or toolName), tool_input (or toolInput), tool_response (or toolResponse, JSON-stringified into conversation_excerpt), transcript_path, client_checkpoint_id. Anything else in the payload is ignored.
The activity ledger. From tool_input and tool_response the hook derives three structured fields — files_touched, commands_run and exit_status — and sends them as first-class payload fields. They record what a tool call did, and they land in the activity/ledger section of the memory page. They are deliberately not folded into notes: notes is the prose the server mines for Decisions and Open Tasks, and turning shell commands into decisions would manufacture entries you never made. Fields with nothing to record are omitted rather than sent empty. No LLM runs anywhere on this path.
anyslate checkpoint
User-initiated, exits non-zero on failure - including on server-side rejections, not just network errors. Defaults --kind milestone, --source api. Allowed kinds: topic_shift | decision_committed | task_completed | task_added | artifact_produced | milestone | conversation_end.
--host <hint> sets the advisory host_hint; --source <source> overrides the activity source.
Low-risk items reach your memory page after a 30-second quiet period plus the next once-a-minute promoter run - so 30-90 seconds, not instantly.
anyslate upload-artifact
Reads a file or stdin, calls the upload_artifact MCP tool. Prints cloud://artifact/<id> on stdout on success; on failure prints nothing to stdout, writes the reason to stderr and exits non-zero. Allowed kinds: code_block | file_path | error_message | shell_command | config_snippet | url_reference | fenced_quote. 5 MB content cap on both the --file and stdin paths.
Content is read as UTF-8. Binary files are not supported and are refused rather than silently mangled.
anyslate login
Two paths, one config file. --token selects the static path; its absence selects the browser flow.
Both end the same way: one live request to /mcp/auth/verify that proves reachability, URL shape, token validity and scopes in a single round trip, then a 0600 write to ~/.anyslate/cli.json. On verification failure it writes nothing and exits non-zero. Both preserve the handle you already had.
The sign-in target is explicit, never sticky. Omitting --api-url always means
production, even if your config currently points somewhere else — the stored value is
deliberately not inherited. If it does point elsewhere, the CLI says so and shows you the
flag to use:
anyslate: signing in to production (https://mcp.anyslate.io).
anyslate: your config points at https://…workers.dev — pass `--api-url https://…workers.dev` to sign in there instead.
This matters because the target ends up in a URL printed to your terminal and opened in a browser. A short command should never quietly aim at a non-production host.
A token missing the memory:write scope is a warning, not a block - but anyslate hook needs it, so heed it.
Browser flow flags
--api-url <root>- which environment to sign in to. Defaults to production. Every OAuth endpoint comes from that root's discovery documents.--no-browser- print the authorization URL instead of launching anything. For SSH sessions and containers. The URL is printed either way, so a browser that fails to appear never leaves you stuck.--timeout <seconds>- how long to wait for the callback. Default180.--handle <ID>- store a capability handle alongside the credentials.
Static-token flags
--force- write anyway, with a warning. For when you know the server is temporarily down.--no-verify- skip the probe entirely. For air-gapped or offline setup.
What gets stored. The browser flow writes an oauth block: the client id, the access token, the refresh token, the absolute expiry, and the token endpoint and resource it discovered (cached so a background refresh costs one request instead of three, and bound to the root so switching environments re-discovers rather than reusing the wrong one). The static flow writes mcp_token, exactly as before. Neither path touches the other's keys.
Refresh. Handled automatically by whichever command needs it — hook, checkpoint, upload-artifact, doctor. It happens five minutes before expiry, and once more on a 401. Since hooks can fire in parallel, refreshes are serialized with a lock file and the config is replaced atomically, so two concurrent hooks cannot lose each other's rotated token. A hook never opens a browser: if refresh fails there, it logs the reason and exits 0 like any other failure.
anyslate logout
Revokes the OAuth session at the server's revocation endpoint (refresh token first — it's the 30-day one), then removes oauth and mcp_token from ~/.anyslate/cli.json.
Revocation is best effort. If the host is unreachable the credentials are still cleared and you get a warning, because a logout that refuses to run offline is a logout you cannot use when you most need one.
apiUrl, handle and the cached client registration survive. The registration is not a credential, and re-registering costs one of the ten Dynamic Client Registrations allowed per hour.
--local- skip revocation and only clear the local file. The server-side session then stays live until it expires.
If ANYSLATE_MCP_TOKEN is set in your environment, logout says so: it overrides the config, so capture keeps working until you unset it.
Wiring into Claude Code
Claude Code is the only host today with a native lifecycle-hook surface. Edit ~/.claude/settings.json (create it if missing) and merge this into any hooks block already there - don't replace the file:
{
"hooks": {
"SessionStart": [
{ "hooks": [ { "type": "command", "command": "anyslate hook session-start" } ] }
],
"PostToolUse": [
{
"matcher": "Edit|Write|MultiEdit|Bash",
"hooks": [ { "type": "command", "command": "anyslate hook post-tool-use" } ]
}
],
"Stop": [
{ "hooks": [ { "type": "command", "command": "anyslate hook stop" } ] }
]
}
}
Restart Claude Code, then run anyslate doctor - it parses this file and tells you whether the wiring took.
If anyslate isn't found when the hook fires, Claude Code spawned it with a minimal PATH. Use the absolute path (command -v anyslate prints it) or npx --yes @anyslate/cli hook session-start. anyslate doctor checks this explicitly.
Git capture
Requires a global install (the template ships in the package). The guard on the first line means a missing template stops the recipe before it touches your hook file - it can never leave you with an empty one:
# from the repo root
src="$(npm root -g)/@anyslate/cli/templates/git/post-commit"
[ -s "$src" ] && install -m 0755 "$src" .git/hooks/post-commit \
|| echo "template not found - install @anyslate/cli globally first (npm i -g @anyslate/cli)"
Optional, exported before the next commit:
export ANYSLATE_SESSION=<anyslate_session_id> # routes commits into a specific memory
export ANYSLATE_HOST=git_post_commit # host_hint advisory
export ANYSLATE_QUIET=1 # swallow CLI stderr
ANYSLATE_SESSION is read by this git template only (it passes --session through); the CLI itself does not read it. It has no effect on Claude Code hooks, which don't need it - see the session-identity note above.
Commit metadata (repo, branch, sha, subject, author, stats) is JSON-encoded into the capture's conversation_excerpt. It is not a set of first-class queryable fields.
FAQ
Do I have to type anyslate ... regularly?
No. After setup, your AI tools call it automatically. The only commands you might type yourself are checkpoint, upload-artifact, and doctor when something looks wrong.
Will this slow down my AI tool?
Each hook invocation is three sequential HTTPS round trips (initialize, notifications/initialized, tools/call) sharing one 15-second timeout budget. Typically well under a second. It is fail-open, so a network blip logs to stderr and exits cleanly rather than blocking your session.
What if I want to disable capture for one session?
Set ANYSLATE_DISABLE=1 in the shell where you're running the AI tool. The CLI makes no network call and captures nothing for that shell.
Setting ANYSLATE_MCP_TOKEN= (empty) does not disable capture - an empty string falls through to the token in ~/.anyslate/cli.json, so capture keeps running. Earlier versions of this README claimed otherwise; that claim was wrong. Use ANYSLATE_DISABLE=1.
Where does the data live?
In your AnySlate workspace. The CLI is a stateless client; it sends events to the AnySlate MCP service over HTTPS and stores nothing locally beyond your credentials in ~/.anyslate/cli.json and the local run logs described under anyslate hook (all mode 0600). The run logs redact anything token-shaped before writing.
Do I need to log in again every hour?
No. The one-hour lifetime is the access token's; the CLI renews it in the background from a 30-day refresh token, including inside hooks running unattended. You'll re-authenticate roughly monthly, or whenever you run anyslate logout.
I'm on a headless box / over SSH. Can I still use the browser flow?
Yes - anyslate login --no-browser prints the URL, you open it on a machine that has a browser, and it redirects back to 127.0.0.1 on the port the CLI is listening on. That only works if the browser can reach that loopback address, so from a remote box you'll want an SSH tunnel - or just use --token, which is what it's there for.
Is the CLI adding dependencies to do OAuth?
No. It has no runtime dependencies. PKCE, the loopback listener and the browser launch are all node: builtins, and there's a test that fails the build if an import ever points outside them.
Can I see what was captured? Yes - AI Memory → Activity shows every captured row with its status (pending / merged / rejected / failed), and failures under the Failed tab carry the reason. High-risk items wait for approval; low-risk items promote on their own in 30-90 seconds.
How do I undo a bad capture? Open the Activity panel, find the row, click Reject. Pre-promotion rejections never touch your memory pages. Post-promotion: open the memory and edit or delete the merged content.
Does this work with tools that aren't Claude Code?
Auto-firing lifecycle hooks are Claude Code only - it's the only host with a native hook surface. For Cursor / Windsurf / Cline / Claude Desktop / ChatGPT, capture happens inside the host via the AnySlate MCP server (/anyslate-new, /anyslate-continue). The CLI on the side handles git capture, CI capture, and manual checkpoints from anywhere a shell command can run.
What's the privacy story?
Bearer-token auth, optional capability handles that scope a token to one project or topic, HTTPS-only transport, payload caps. Tokens are revocable from the same dialog you minted them in. notes is clipped at 4,000 characters and conversation_excerpt at 16,000 characters - both are string lengths, not bytes, and clipping applies to the hook path only (checkpoint --note is sent as given).
What if I'm offline?
Hooks fail open - no error to your AI tool, just no capture for those events. There is no offline queue, so events missed while offline are not retroactively captured. The failure is recorded locally and surfaced by anyslate doctor.
Tests
npm test # node --test, no external deps
License
MIT