> For the complete documentation index, see [llms.txt](https://krynix.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://krynix.gitbook.io/docs/connect-your-agents/connect-claude-code.md). Agents can also search and read this documentation through its [MCP server](https://krynix.gitbook.io/docs/~gitbook/mcp).

# Claude Code

Krynix connects to Claude Code with **one managed settings file** and nothing else on the machine: no script, no `node`, no admin-owned folder. Claude Code sends each tool call to Krynix over HTTP before it runs and reports the result after, and streams its telemetry under the same agent name. Installed as managed settings, the file is applied above every user and project setting, and a developer cannot switch it off.

Requires Claude Code **2.1.295** or later. The file pins that version; an older Claude Code refuses to start rather than running without the hooks.

## 1. Open the connect page

Go to **Agents**, open the agent with **What we see** (register it first if it is new; see [Register an agent](https://krynix.gitbook.io/docs/getting-started/register-an-agent.md)), and press **Connect with Claude Code**. Make sure the **Claude Code** tab is selected. Creating an install needs the owner or admin role, because it creates a key.

![The connect page](https://3117100259-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fwf1LKKia6wIa5IW8R9Sp%2Fuploads%2Fgit-blob-34befcdb0d5723228d4428b9ab355b8f033a7eb1%2Fdashboard-connect-claude-code.png?alt=media)

## 2. Make three choices

**How will you deliver it?**

| Choice                      | When to use it                                                                                                                                                                                                                |
| --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **claude.ai admin console** | Recommended for Claude Team and Enterprise plans. You paste the settings once, and every Claude Code in your organisation picks them up when it next starts.                                                                  |
| **Your device management**  | You manage developer machines with a tool such as Jamf or Intune. You deliver one file to each machine. This is the strongest route: a developer cannot remove the file, and your tool puts it back if an administrator does. |
| **Just this machine**       | One machine, such as your own for a trial. You run one command there as an administrator; it installs everything and creates the machine's key on the machine. macOS and Linux.                                               |

**If Krynix can't be reached.** What the install does while Krynix is down or cannot decide a call:

| Choice                             | What happens                                                                   | What it costs                                                            |
| ---------------------------------- | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------ |
| **Block tool calls** (recommended) | The call is refused with a reason. Prompts are never blocked; the agent waits. | A Krynix outage stops your agents' tool calls until it is over.          |
| **Keep agents working**            | The call runs.                                                                 | A call made while Krynix is unreachable is not checked and not recorded. |

An agent with no policy bound and no baseline covering it is a call Krynix cannot decide, so the same choice applies to it. With [the default policy](https://krynix.gitbook.io/docs/using-the-dashboard/policies.md#the-default-policy) in your baselines, that happens only if an owner removed it.

**Capture prompts.** On by default: the text of each prompt **and of Claude's replies** is kept with the session, so a reader sees what the agent was asked and what it answered, not only what it did. Off keeps the tool calls and leaves the prompt and reply text out.

**Advanced** holds one more setting: **Only allow hooks your organisation manages** also switches off every hook a user, project or plugin adds on the machine. It is not needed for Krynix's refusals to hold; turn it on only if that is already your policy.

Press **Create install**.

## 3. Follow the steps on the screen

The page first says **what happens to this agent's tool calls**: decided by its policies, or, with nothing bound, refused or allowed by your outage choice, with a link to bind a policy. You can bind one later without changing the install: Krynix looks the policy up on every call.

Then it shows the install for the route you chose. For the admin console and device management, Krynix creates a key named for the install (for example `Claude Code install · claude-code-platform`) and writes it into the settings. **The key is shown once**; copy it now.

**claude.ai admin console**

1. Press **Copy managed settings**.
2. In claude.ai, open **Organization settings → Claude Code → Managed settings**, paste them and save. Every Claude Code in the organisation fetches them when it starts and every hour after.
3. Developers restart Claude Code. Each is asked once to approve the Krynix hook; declining exits Claude Code.

Settings from the admin console are a client-side control: on a machine your organisation does not manage, a developer can still run a Claude Code that ignores them, and they are skipped when a developer points Claude Code at a third-party provider or a non-default `ANTHROPIC_BASE_URL`. Use device management for those machines.

**Your device management**

1. Press **Copy managed settings**.
2. Deliver them as the managed settings file on each machine:

   | System        | Where                                                                                                                                             |
   | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
   | macOS         | A configuration profile in the `com.anthropic.claudecode` domain, or the file `/Library/Application Support/ClaudeCode/managed-settings.json`     |
   | Linux and WSL | `/etc/claude-code/managed-settings.json`                                                                                                          |
   | Windows       | The `Settings` value under `HKLM\SOFTWARE\Policies\ClaudeCode`, holding the JSON, or the file `C:\Program Files\ClaudeCode\managed-settings.json` |

   Anthropic publishes templates for common tools: [anthropics/claude-code examples/mdm](https://github.com/anthropics/claude-code/tree/main/examples/mdm). Redeploy on a schedule, so an edited file is put back.
3. Developers restart Claude Code.

**Just this machine**

No key is created in the browser. The page shows one command instead:

```bash
curl -fsSL https://api.krynix.dev/install/claude-code.sh | sudo sh -s -- --url https://api.krynix.dev --code <code>
```

1. Press **Copy command** and run it on the machine as an administrator.
2. Restart Claude Code.

The code in the command works once, for 15 minutes; the page shows when it expires, and **Create a new install** gives you a fresh one. The installer checks the machine before it uses the code, so a refusal leaves the code usable. It writes the managed settings file, creates the machine's key there (named for the install, and listed under **Settings → API keys** so you can revoke it), and says when it is connected. To see every step before anything runs, open **Read the installer before it runs** and press **Copy these commands**.

## 4. See it connect

At the bottom, **Is it connected?** waits for the first record from the agent and updates on its own. When a session starts it says so, with **Open it** to go straight to the session.

## What the file contains

The generated file, abridged. `<KRYNIX_API_KEY>` stands where the install's key is written literally; Claude Code sends the header as written and does not read it from a variable a shell could override.

```json
{
  "env": {
    "CLAUDE_CODE_ENABLE_TELEMETRY": "1",
    "CLAUDE_CODE_ENHANCED_TELEMETRY_BETA": "1",
    "OTEL_LOGS_EXPORTER": "otlp",
    "OTEL_TRACES_EXPORTER": "otlp",
    "OTEL_EXPORTER_OTLP_PROTOCOL": "http/json",
    "OTEL_EXPORTER_OTLP_LOGS_ENDPOINT": "https://api.krynix.dev/v1/otlp/v1/logs",
    "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT": "https://api.krynix.dev/v1/otlp/v1/traces",
    "OTEL_EXPORTER_OTLP_HEADERS": "Authorization=Bearer <KRYNIX_API_KEY>",
    "OTEL_RESOURCE_ATTRIBUTES": "agent.id=claude-code-platform",
    "OTEL_LOG_TOOL_DETAILS": "1",
    "OTEL_LOG_USER_PROMPTS": "1"
  },
  "hooks": {
    "PreToolUse": [{ "matcher": "*", "hooks": [{
      "type": "http",
      "url": "https://api.krynix.dev/v1/hooks/claude-code/claude-code-platform?unjudged=block",
      "timeout": 30,
      "headers": { "Authorization": "Bearer <KRYNIX_API_KEY>" },
      "onFailure": "block"
    }]}],
    "PostToolUse": [{ "matcher": "*", "hooks": [{
      "type": "http",
      "url": "https://api.krynix.dev/v1/hooks/claude-code/claude-code-platform",
      "timeout": 30,
      "headers": { "Authorization": "Bearer <KRYNIX_API_KEY>" }
    }]}],
    "UserPromptSubmit": [{ "hooks": [{
      "type": "http",
      "url": "https://api.krynix.dev/v1/hooks/claude-code/claude-code-platform?capture_prompts=1",
      "timeout": 30,
      "headers": { "Authorization": "Bearer <KRYNIX_API_KEY>" }
    }]}]
  },
  "requiredMinimumVersion": "2.1.295"
}
```

* `PreToolUse` asks Krynix. A deny comes back with the rule's reason; an allow comes back as no opinion, so Claude Code's own permission prompts keep working. Krynix never answers "allow": a monitoring tool must not switch off the user's prompts.
* `PostToolUse` records the call, its arguments, its output and its duration.
* `UserPromptSubmit` records the prompt before the model runs.
* "Keep agents working" turns `?unjudged=block` into `?unjudged=allow` and drops `onFailure`. "Capture prompts: off" drops `OTEL_LOG_USER_PROMPTS` and the `?capture_prompts=1` query. Claude Code also logs its replies whenever `OTEL_LOG_USER_PROMPTS` is on, because `OTEL_LOG_ASSISTANT_RESPONSES` falls back to it when unset, so turning prompt capture off turns reply capture off too.
* The telemetry lines send Claude Code's own logs and traces (tokens, cost, model, plugins and hooks loaded) under the same agent, which is what fills the cost and model panels.

## 5. Check one machine

1. Run `claude doctor`, then `/status` inside a session: the managed source should be listed.
2. Ask Claude Code to run a command your bound policy denies. It should be refused, citing the Krynix rule.
3. Put `"disableAllHooks": true` in `~/.claude/settings.json` and try again. Still refused.
4. If you chose Block, block the Krynix host and try a tool call. Refused.

## What this does not cover

* **Calls made while Krynix is unreachable are not recorded.** An HTTP hook keeps nothing on the machine. Measured on Claude Code 2.1.310 with Krynix cut off for one, ten and sixty seconds during fifteen tool calls: with Keep agents working, 0, 2 and 11 of the calls were recorded nowhere; with Block, the calls were refused instead, and only a call already running when the outage began went unrecorded. Claude Code's logs exporter does not fill the gap past about a second.
* **A local administrator can edit the managed file.** Device management puts it back on its schedule; nothing on the machine stops root.
* **Managed settings bind Claude Code only.** Another tool on the same machine is not covered.
* **The key is readable** by anyone who can read the file. It is an ingest key: it can send records and ask for decisions, not read the fleet or change a rule. Revoke it under Settings → API keys if the file leaks.
* **Edits to the settings file are not yet reported** to Krynix.
