nc://claude-code

v0.1.0Pinned
Backnodecode-ai
ThomSharkclaude-code: a request the CLI wrote fresh that fails is forgotten too, so the next round asks the CLI anew (#124)3101ba9· 11 Nov13 commits
test2 filescell.lisp12.9 KBcli.lisp23.1 KBrelay.lisp8.1 KBwire.lisp9.1 KB

nodecode-claude-code

A Nodecode cell that runs Claude models through your own logged-in Claude Code CLI. Pick claude-code/<model> in /models, and each model round goes out with the login claude already has.

Nodecode keeps the agent. Its turn loop, tools, context engine, retries and usage record work the same as on any other provider. The CLI only writes the request:

  1. Nodecode builds the round's Messages request, the same way it does for Anthropic.
  2. The cell starts claude -p in stream-json mode with its own tools off. It hands the CLI the round's system prompt, history and tools, and points ANTHROPIC_BASE_URL at a loopback relay only that run knows.
  3. The CLI writes the request it would make, with its own headers. The relay keeps it and the CLI is stopped, so the CLI itself never sends anything to Anthropic.
  4. Nodecode sends those exact bytes to api.anthropic.com and reads the stream with its own Anthropic parser. Tool calls come back under Nodecode's tool names and run in Nodecode, never in the CLI.

It follows NousResearch's hermes-plugin-claude-subscription-directsdk.

Before you use it

  • Anthropic's terms. The Claude Agent SDK documentation says third-party products may not offer claude.ai login or plan rate limits without Anthropic's approval. This cell is for running your own CLI on your own machine. Read the current terms yourself before relying on it.
  • Billing. Whether a round draws from your plan or from extra usage is decided by Anthropic's service. Turn off extra usage in your account if you don't want overage charges. Nodecode prices a claude-code round at Anthropic's API list price for its model: the Dashboard's cost for it is what the round would have cost on the API, not what your plan charged.
  • Models. /models lists what your login may call: Anthropic's own model listing, asked with the headers the CLI sends, so a model is offered the day Anthropic ships it. No request goes out to list them and no usage is spent. Models with windows over 200K run on their 1M route. On some plans a 1M route, and Fable, draw from usage credits.

Install

Linux, macOS and Windows.

Install Claude Code, run claude once and /login. Then run nodecode add nc://claude-code, or copy this folder into ~/.nodecode/cells/nodecode-claude-code/ and restart Nodecode (or run (restart-cells)). When no claude is on PATH, a notice says so.

On Windows a bare command is looked for as claude.exe, then claude.cmd: the native installer's binary first (it lands in %USERPROFILE%\.local\bin; add that folder to your PATH when the installer says it is not on it), then npm's shim. command may also name the file itself.

Configure

This is optional. The section is on unless it says "enabled": false:

{
  "claude-code": {
    "command": "claude",
    "models": ["claude-haiku-4-5"],
    "timeout_seconds": 120,
    "reuse_seconds": 600
  }
}

See config.example.jsonc.

What it costs in time

A round the CLI writes starts a fresh claude process: about 0.2 s on Linux, 0.8 s for claude.exe on Windows. The CLI then replays the session's history, about 2 ms for each earlier user turn. The CLI writes the request's headers, system blocks and tools; the messages are the round's own. So a later round of the same session whose system text, tools, model, effort, output ceiling, thinking, folder and first user message are unchanged, and whose history carries no new kind of block, sends the request the CLI last wrote again around its own messages and starts no CLI at all. That lasts reuse_seconds (600 by default; 0 starts the CLI every round). A reused request that fails is forgotten, and one the API refuses for its login (401, 403) is written afresh and sent once more. The per-request context the CLI adds to the newest turn (the date, the account's email, an environment note) is not sent: the next round would replay that turn without it, and every thinking block signed behind it would then fail the API's prefix check and be dropped.

Test

From a Nodecode checkout's src/:

sbcl --non-interactive --eval '(require :asdf)' \
  --eval '(push (truename ".") asdf:*central-registry*)' \
  --eval '(push #p"/path/to/cells/nodecode-claude-code/" asdf:*central-registry*)' \
  --eval '(asdf:test-system :nodecode-claude-code)'

The tests never start the real CLI and never reach Anthropic. A whole round runs against test/fake-claude.py, a stand-in that speaks the CLI's stream-json and needs python3.

MIT licensed.

Add nc://claude-code

  1. 1

    Install Nodecode

    Once per machine.

    $ curl -fsSL https://nodecode.ai/install.sh | sh
  2. 2

    Add the cell

    Pinned at 3101ba9.

    $ nodecode add nc://claude-code

    Or tell the agent add the claude code cell.

  3. 3

    Log in to Claude Code

    Log in with claude once, then pick a claude-code/ model in /models.