The CLI

The sidecar

The sidecar is the part of Knwlge that runs on your machine: a small background service your AI coding agent talks to. You install it once, and afterwards mostly forget it — this page is for when you do not.

What the sidecar is

A Node.js process that listens on 127.0.0.1 only, started by your operating system when you log in. It does the work behind every prompt:

  • Briefs. Your agent's prompt hook hands it each prompt; it works out the folder's project and asks that project's Enterprise Server for context, within 1.5 seconds.
  • Session capture and learning. At the end of each turn it captures what the organization's policy allows, redacted on your machine, and may ask the agent to record what it learned (Session capture and learning).
  • Upkeep. It keeps each project's repository list fresh (every six hours), reports usage counts to Knwlge Global every ten minutes for your Dashboard, and runs the background upkeep of the team's documents.

Your agent's tools — context.search, knowledge.lookup and the rest — do not go through the service: the MCP entry install wrote starts knwlge sidecar mcp-stdio for each agent session, which talks to the project's server itself. So when the service is down, tools still work but prompts arrive without a brief.

Run it as a service

knwlge sidecar start installs the sidecar as a service for your user, starts it, and waits until it answers. Run it again whenever you like: it reconciles what is installed with this copy of the CLI and changes nothing that is already right.

shell
knwlge sidecar start
zsh — ~/code/acme
$ knwlge sidecar start
  ██   ▄█▀   Knwlge CLI v1.0.0
   █▄▄█▀     ● signed in as ada@acme.example · project Acme Platform
   █▀▀█▄     ~/.team-context-gateway · node v22.20.0 · darwin arm64  ·  Docs https://knwlge.com/docs
  ██   ▀█▄   Give your agent the context it's been missing.

───────────────────────────────────────────────────────────────────────────────

{
  "command": "sidecar service-install",
  "changed": true,
  "plan": { … },
  "activation": {
    "attempted": true,
    "activated": true,
    "healthUrl": "http://127.0.0.1:32770/healthz",
    "healthOk": true,
    "commands": [ … ]
  }
}
Installing the service on macOS (abridged). On a terminal every knwlge command opens with this banner: the version, who is signed in and where the CLI keeps its files.
SystemWhat is installed
macOSA LaunchAgent, com.team-context-gateway.sidecar, in ~/Library/LaunchAgents/
LinuxA systemd --user unit, team-context-gateway.service, in ~/.config/systemd/user/
WindowsA Scheduled Task for the current user

It listens on 127.0.0.1:32770; pass --port to choose another. The service runs the exact Node binary and CLI copy you ran the command with, so re-run sidecar start after moving to a new Node installation. If the new service does not come up healthy, the one that was there before is put back.

Run it in the foreground

For a first look, or to watch it while you debug, run it in your terminal instead. It prints where it listens and stays until you press Ctrl+C. It is a separate process from the service, on a port of its own.

shell
knwlge sidecar start --foreground
zsh — ~/code/acme
$ knwlge sidecar start --foreground
{
  "command": "sidecar start",
  "status": { … },
  "baseUrl": "http://127.0.0.1:53817",
  "healthUrl": "http://127.0.0.1:53817/healthz",
  "httpMcpEnabled": false,
  "tokenStorage": "macos-keychain"
}
A foreground sidecar (abridged, banner left out). The environment switches below apply to a sidecar started this way.

Check that it is running

The quickest look is the control panel: run knwlge and the line under Projects says ● sidecar running · pid … · 127.0.0.1:32770, with each AI client's hook beside it. From a script:

shell
knwlge doctor --repo-root "$PWD"     # the whole install, end to end
knwlge sidecar status                # what the sidecar and your session report, as JSON

Or ask the operating system:

shell
# macOS
launchctl print gui/$UID/com.team-context-gateway.sidecar
# Linux
systemctl --user status team-context-gateway.service

Restart, stop and remove it

ToRun
Restart it (after a new build, say)/sidecar restart in the control panel, or launchctl kickstart -k gui/$UID/com.team-context-gateway.sidecar on macOS and systemctl --user restart team-context-gateway.service on Linux
Stop it until you log in againlaunchctl kill TERM gui/$UID/com.team-context-gateway.sidecar on macOS, systemctl --user stop team-context-gateway.service on Linux
Remove the serviceknwlge sidecar service-uninstall --platform darwin (or linux, win32)
Remove everything install addedknwlge uninstall --repo-root "$PWD" — hooks, MCP entries and rules blocks, restored from their backups

Switches

The sidecar reads a few environment variables when it starts. The service sidecar start installs does not read your shell's environment, so these apply to a sidecar started with them — in the foreground, say. To stop capture for good, opt out in your server's console instead (Turning it off).

SettingValueNotes
KNWLGE_SESSION_CAPTURE_ENABLEDtruefalse turns session capture off for this sidecar; the organization's policy and your opt-out still apply when it is on.
KNWLGE_LEARNING_NUDGEonoff stops the sidecar asking the assistant to record what it learned.
KNWLGE_UPKEEPonoff stops the background upkeep of the team's documents.
KNWLGE_UPKEEP_MAX_PER_DAY20Upkeep runs per project per day.
KNWLGE_UPKEEP_WITH_MODEL(the client's small model)session runs upkeep on the model the session used; anything else is a model name given to the client.

Switching copies of the CLI

The hooks, MCP entries and service run one exact copy of the CLI. A different copy — a build you want to try, a new release in another place — refuses to overwrite that wiring, with a message such as Refusing to overwrite a modified claude_code Team Context Gateway hook. It was written by another knwlge copy. Run reinstall from the copy that should take over:

shell
knwlge reinstall --dry-run    # each file it would change, old launcher → new
knwlge reinstall

It rewrites only entries in the exact shape the installer writes, keeps your other hooks and settings, backs up every file it changes, moves the service over and health-checks it — and puts everything back if the new service does not come up. You stay signed in. Anything it does not recognise stops it before it changes anything, naming the file to look at. Restart open agent sessions afterwards.

Troubleshooting

What you seeWhat to do
Prompts get no brief, but Knwlge's tools workThe service is not running or not answering. Run knwlge sidecar start, then check the control panel.
◇ knwlge no suitable project foundThe folder's repositories are in no connected project, so Knwlge stays off there. See knwlge projects which, and pin the folder if it should use one.
signed out — /init beside a projectThe 30-day session ended or was revoked by an admin. Run knwlge init --api-url with that project's server.
knwlge requires Node.js 22 or newer, or the service fails after a Node upgradeInstall a supported Node through a durable channel, then run knwlge sidecar start again so the service pins the new binary.
Refusing to replace a macOS LaunchAgent without a verified sidecar health capabilityThe LaunchAgent at that path cannot be proven to be Knwlge's. Remove it yourself after checking what it is, then run knwlge sidecar start.
403 sign_in_not_accepted from a serverThe server does not accept the way you signed in. Sign in again the way it accepts: knwlge login --api-url <server> --via-global.
503 server_enrollment_requiredThe server is waiting for a new enrollment key from its admins; nothing is wrong on your machine (When the server needs a key).
Upkeep log says client_not_foundThe service could not find claude or codex on its path. It also looks in ~/.local/bin, /opt/homebrew/bin, /usr/local/bin and next to its Node; install the client in one of those.

When in doubt, checks the install end to end and fixes what it safely can.