Fork of afrase/claude-acp-go: a Go ACP adapter for Claude Code
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
gascity-argos 8eeeacc598
All checks were successful
CI / Changelog (push) Successful in 5s
Release / Release (push) Successful in 6s
CI / Test (push) Successful in 43s
CI / Lint (push) Successful in 46s
session/new takes the session id from the client (#21)
2026-11-18 22:30:08 +00:00
.forgejo/workflows Pin the changelog action at 2.1.0 and remove the release guard of claudeacp#5 (#11) 2026-11-12 14:28:25 +00:00
.github/workflows claude-acp-go v0.1.0: an ACP agent for Claude Code in Go 2026-11-04 21:36:38 +09:00
claudeacp session/new takes the session id from the client (#21) 2026-11-18 22:30:08 +00:00
claudeagent Keep MCP credentials out of claude's arguments (#19) 2026-11-17 14:28:59 +00:00
cmd/claudeacp Found in the last review of #1: a stale description, override log lines without a session, options not refused (#8) 2026-11-12 13:20:46 +00:00
.gitignore The adapter's binary is claudeacp, not claude-acp (#3) 2026-11-12 05:57:55 +00:00
.golangci.yml Accept the Claude options gc appends to an ACP command (#1) 2026-11-11 22:40:14 +00:00
CHANGELOG.md session/new takes the session id from the client (#21) 2026-11-18 22:30:08 +00:00
go.mod Accept the Claude options gc appends to an ACP command (#1) 2026-11-11 22:40:14 +00:00
go.sum claude-acp-go v0.1.0: an ACP agent for Claude Code in Go 2026-11-04 21:36:38 +09:00
LICENSE claude-acp-go v0.1.0: an ACP agent for Claude Code in Go 2026-11-04 21:36:38 +09:00
README.md session/new takes the session id from the client (#21) 2026-11-18 22:30:08 +00:00

claudeacp

An Agent Client Protocol agent for Claude Code, written in Go, and the Go library it is built on.

claudeacp lets Zed and other ACP clients run Claude Code without Node: a single static binary that speaks ACP to the editor and runs your own claude CLI for each session. It behaves like claude-agent-acp, the Node agent ACP clients run today, so a client written for one works with the other.

This project is unofficial and not affiliated with or endorsed by Anthropic. It contains no authentication code and never touches your credentials: it runs the unmodified claude you installed, which signs in as it always does.

This fork

This is mikluko/claudeacp, a fork of afrase/claude-acp-go, made so that Gas City can run its agents on ACP with its ordinary claude provider. gc starts an ACP agent with the provider's acp_command and appends the options of the claude CLI to it, among them --settings with the file that holds gc's hooks. Upstream's claude-acp takes no options and exits with code 2, so those hooks never reach claude.

What differs from upstream:

  • claudeacp takes claude's options and passes them to every claude it starts: claudeacp --dangerously-skip-permissions --effort max --model opus --settings /city/.gc/settings.json. See Claude's options.
  • The module path is sarak.sh/mikluko/claudeacp, and the binary is claudeacp, where upstream's is claude-acp; the packages are the same.
  • CI runs on this forge, on Linux: .forgejo/workflows/ci.yml stands in for upstream's GitHub workflow, which asks for a macOS runner.

Everything else is upstream's; what follows is its README, with the module path changed.

Why

  • No Node. claude-agent-acp needs Node and an npm install, and runs a Node process beside each claude. claudeacp is one Go binary.
  • Your claude. It runs the claude on your PATH (or $CLAUDE_CODE_EXECUTABLE), with your login, settings, CLAUDE.md, hooks, skills, plugins and MCP servers, as in the terminal. Sessions are claude's own: one started here resumes in the terminal with claude --resume, and the other way round.
  • Readable. The protocol code is plain Go you can read and step through, with no bundled SDK in between.

Install

You need Claude Code installed and signed in (run claude once in a terminal), and Go 1.27.3 or later to build:

go install sarak.sh/mikluko/claudeacp/cmd/claudeacp@latest

The binary lands in $(go env GOPATH)/bin. claudeacp -version prints its version.

No environment variable is needed: Go resolves the module from sarak.sh by its tags. A release is a tag vX.Y.Z that a workflow cuts when a pull request turns [Unreleased] in CHANGELOG.md into a version section; to pin one, write @vX.Y.Z for @latest, or go get -tool sarak.sh/mikluko/claudeacp/cmd/claudeacp@vX.Y.Z to track it as a tool dependency.

Use it from Zed

Add the agent to Zed's settings.json, with the binary's full path (Zed doesn't start agents through your shell):

{
  "agent_servers": {
    "Claude (claudeacp)": {
      "type": "custom",
      "command": "/Users/you/go/bin/claudeacp",
      "args": [],
      "env": {}
    }
  }
}

Then pick it in the Agent Panel's new-thread menu. If claude isn't on the PATH Zed gives agents, name it: "env": {"CLAUDE_CODE_EXECUTABLE": "/opt/homebrew/bin/claude"}.

Any other ACP client starts it the same way: run claudeacp and speak ACP on its stdin and stdout. It logs to stderr.

Claude's options

Whatever follows claudeacp on its command line is passed to every claude it starts, one per ACP session (new, loaded, resumed or forked):

claudeacp --dangerously-skip-permissions --effort max --model opus --settings /city/.gc/settings.json --add-dir /data
  • Named by the agent: --model, --effort, --permission-mode, --dangerously-skip-permissions (the same as --permission-mode bypassPermissions) and --settings. They are the session's starting options: the client's view of the session (its mode, model and effort) follows them. Given twice, the last one stands.
  • Passed as they are: every other option, in order and after the flags the agent sets, with its value beside it (--add-dir /extra, --append-system-prompt "Be brief."). Claude settles a flag the agent sets as well, and rejects one it doesn't know.
  • Refused, with exit code 2 and the reason, because they change how the agent runs claude: --print/-p, --input-format, --output-format (the agent speaks stream-JSON), --permission-prompt-tool (the agent answers permission requests), --resume/-r, --continue/-c, --session-id, --fork-session, --resume-session-at, --from-pr (the agent starts, resumes and forks sessions, and names each), --no-session-persistence (transcripts are how sessions are listed and loaded), --bare (it would drop your login, hooks and skills), --sdk-url (the agent speaks to claude over its standard input and output), --teleport (the agent resumes sessions itself), --worktree/-w (claude would run in a worktree of its own, not in the session's folder), --bg/--background, --cloud, --environment, --desktop, --remote-control and --remote-control-session-name-prefix (claude would run the session somewhere other than as the agent's child: in the background, in the cloud, in the Desktop app or as an interactive session), --help and --version (claude would print and exit), an argument that isn't an option where one is due (claude's subcommands, or a prompt: the first argument, or one after an option that takes no value, or no more values, such as --verbose mcp or --model opus mcp), -- (a prompt), and a named option given with no value, or with another long option for its value (--model --effort max), or a --settings value that starts with -. claudeacp -version is the agent's own, answered when it is the first argument.

Bypass permissions. Whatever the mode, claudeacp passes --allow-dangerously-skip-permissions to every claude it starts (not when it runs as root with IS_SANDBOX unset, where claude refuses the mode, and claudeacp offers none), so that a client can switch the session to bypass permissions later: without it claude refuses set_permission_mode bypassPermissions with bypass_not_launched. The flag only allows the mode; it starts no session in it, and changes nothing claude sends the model. What does is the mode being bypass permissions, whether the session starts in it (--dangerously-skip-permissions or --permission-mode bypassPermissions) or is switched to it. Then claude adds "While bypass permissions mode is active: You can do much of your work through the Bash tool when it is the simpler route: read files with cat, head, or sed -n …" to the first message, and (for a session that started in the mode) drops "Avoid using this tool to run cat, head, tail, sed, awk, or echo" from the Bash tool's description. Checked with claude 2.1.322; see the changelog.

Permission modes: who decides. Whether a call needs asking about is claude's to say, in every mode; claudeacp only carries the question. It starts claude with --permission-prompt-tool=stdio, so a call claude would ask about arrives as a can_use_tool request, which claudeacp sends its client as session/request_permission and answers with what the client picks. It allows nothing itself: a client that has no session/request_permission, or fails it, has the call denied and the turn stopped, and the PreToolUse hook claudeacp runs to time a call says nothing of whether it may run (TestPermissionNotAnsweredIsDenied, TestPreToolUseDecidesNothing). So in dontAsk, where claude itself denies a call that no allow rule covers and sends no request, claudeacp cannot turn that into an allow. Checked with claude 2.1.322 against a fake API that plays the model and asks for one tool call, with no model called (CLAUDEACP_E2E_CLAUDE=1 go test -v -run TestE2EPermissionModes ./claudeacp), for a call no allow rule covers:

Mode A call no allow rule covers The model's result What the client gets
dontAsk denied by claude, at once an error: "Permission to use NotebookEdit has been denied because Claude Code is running in don't ask mode. IMPORTANT: You may attempt to accomplish this action using other tools…" no session/request_permission; the call goes from pending to failed, "Permission denied: Permission to use NotebookEdit has been denied because Claude Code is running in don't ask mode…"
acceptEdits an edit of a file in the session's folder, and NotebookEdit on a notebook read, run; a Write to .claude/, Bash and WebFetch are asked on a refusal: "The user refused permission to run the tool." a session/request_permission with the options allow-once, reject (and allow-always where claude suggests a rule)
default asked, whatever the tool the same the same

What a city on dontAsk can rely on, from the same run:

  • A tool no allow rule names is denied (NotebookEdit with the settings Bash Read Edit Write Glob Grep Skill WebFetch WebSearch Agent TodoWrite Monitor TaskStop ToolSearch), and so is a rule's own ask: with ask: ["Bash(echo *)"], claude says "denied … don't ask mode" where default would have asked. Nobody is asked, ever.
  • An allow rule covers every call of its tool, and claude does not look into the call. With the bare Bash in allow, echo x > ~/probe ran and wrote the file: the rule matched the whole tool, and where a redirect writes is not something Bash checks. Without the rule the same call is denied, and so it is with only Bash(echo *) allowed, which does not cover a command that redirects to a file outside the session's folder. To confine Bash, allow the commands it may run, not Bash.
  • An allow rule does not reach what claude protects: Write to .claude/ is denied with Write in allow, where acceptEdits and default ask. (A write under <worktree>/.git/ in a linked worktree, where .git is a file, fails with the file system's ENOTDIR: not a permission's denial.)
  • A deny rule wins over an allow rule: with Bash allowed and Bash(echo *) denied, the same call is denied, in every mode, with "Permission to use Bash with command echo x > … has been denied." (no mention of the mode). A deny rule that names a whole tool (Edit) takes it from the model: its call fails with "No such tool available: Edit. Edit is disabled for this session".
  • AskUserQuestion is not available to a city's agents on dontAsk, for two reasons that add. claudeacp has claude drop the tool, in every mode, for a client that does not take forms (elicitation.form): the call fails with "No such tool available: AskUserQuestion. AskUserQuestion is disabled for this session". For a client that does, the tool is like any other that no allow rule names, so dontAsk denies it ("Permission to use AskUserQuestion has been denied because Claude Code is running in don't ask mode") and sends the client no form. Whether naming it in allow brings the form back was not tried.
  • Not every tool asks. EnterPlanMode ran in all three modes without a request. The session is then in plan mode, and ExitPlanMode does reach the client, with the choices Auto, accept edits and ask before edits: none of them is dontAsk, so a client that picks one has left the mode. The mode list the agent offers (session/set_mode, the Mode config option) has no dontAsk either, and a client can switch the session to any mode in it. So the mode holds for as long as the client does not switch out of it or pick one of ExitPlanMode's choices.

Precedence. A client's _meta.claudeCode.options on session/new (and load, resume and fork) come after the command line's: its model, permissionMode and settings, when set, replace the command line's for that session, and an empty value ("", or {} for settings) leaves the command line's; a replacement is logged at Info. Its additionalDirectories, disallowedTools and mcpServers add to what the command line passes. The rule is in claudeacp/options.go (options and applyOptions) and tested in TestClaudeArgsPrecedence.

Naming a session. session/new's _meta.claudeCode.sessionId is the id claude starts under, and the one the response and every later sessionId the agent sends carry, in place of one claudeacp mints itself: a client that keeps its own key for a session (such as a city's gc, so that claude's transcript lands under the name it looks for and session/resume reopens it there) sends the key, not the agent's id, back. It must be a UUID, and name no session already open, or session/new fails with invalidParams and starts no claude; without it, nothing changes. load, resume and fork keep a session's own id and take no such key. The rule is in claudeacp/session.go (sessionID) and tested in TestNewSessionID and TestNewSessionFails.

In Go, claudeacp.Config.ClaudeArgs (and claudeacp.MainArgs) take the same list, and claudeagent.Options.Args passes it to a single claude.

Use it as a library

The module has four packages:

Package What it is
claudeagent A client for the claude CLI's stream-JSON control protocol, the one Anthropic's Agent SDKs use: sessions, one-shot queries, typed messages, permission callbacks, hooks, MCP elicitations, control requests. Standard library only.
claudeagent/sessions claude's transcripts on disk: list, read, fork and delete sessions.
claudeagent/claudetest A scripted fake claude and recorded cassettes, to test code built on claudeagent with no process or login.
claudeacp The ACP agent, on claudeagent and acp-go: Serve it on any streams, or Main on stdin and stdout.

One prompt, its answer and its cost:

package main

import (
	"context"
	"fmt"
	"log"

	"sarak.sh/mikluko/claudeacp/claudeagent"
)

func main() {
	ctx := context.Background()
	for m, err := range claudeagent.Query(ctx, "What does this repository do?", claudeagent.Options{}) {
		if err != nil {
			log.Fatal(err)
		}
		switch m := m.(type) {
		case *claudeagent.Assistant:
			for _, b := range m.Message.Content {
				if b.Type == "text" {
					fmt.Print(b.Text)
				}
			}
		case *claudeagent.Result:
			fmt.Printf("\n(%d turns, $%.4f)\n", m.NumTurns, m.TotalCostUSD)
		}
	}
}

claudeagent.Start keeps a session open for more prompts, steering, interrupts and model or mode changes; Options.CanUseTool answers claude's permission requests. Each package's documentation has runnable examples: go doc sarak.sh/mikluko/claudeacp/claudeagent.

How it relates to the others

  • claude-agent-acp (Zed Industries, Apache-2.0) is the Node ACP agent for Claude Code. claudeacp follows its behaviour and wire shape (session and message ids, _meta.claudeCode, _claude/origin, modes, config options, the JetBrains fork-at extension), so clients need no changes. It is written fresh in Go; where a file is translated from claude-agent-acp, it says so, and claudeacp/NOTICE carries the licence.
  • Anthropic's Agent SDKs (Python, MIT; TypeScript) drive claude over the same stream-JSON protocol. claudeagent is a Go client for that protocol; claudeagent/sessions is ported from the Python SDK's session helpers (claudeagent/NOTICE). Nothing comes from the TypeScript SDK or from the claude binary.
  • The protocol is undocumented. The package parses leniently (unknown messages arrive as Unknown, raw JSON is kept), detects features from what claude says it supports, and pins no claude version. A change in claude can still break it, as it can the official SDKs.

What's supported

  • Sessions: new, load (with the history replayed), resume, fork (whole, or up to a message), list, delete, close; additional directories; a system prompt to append or override.
  • Prompts with text, images and embedded resources; prompts sent mid-turn are queued as claude queues them, or steer the running turn (_session/steering); cancel.
  • Every permission claude asks for goes to the client, with "always allow" options worded per tool; the agent never allows anything itself. Modes: default, accept edits, plan, auto, bypass permissions (when allowed).
  • Tool calls as tool_call and tool_call_update: a call starts pending as the model writes it, its input arriving a field at a time; in_progress is sent when its tool starts to run, not while the model writes the input, and not while the user is asked to allow it; then completed or failed. The moment is read from claude's PreToolUse hook (a call claude doesn't ask about runs once that hook has run, and claudeacp tells the client after 100 ms with no permission request or denial) and from the user's allowing a request; tool_progress also says a tool runs. A call that never runs (the user or a rule refuses it, the turn is cancelled first, or the model stops before finishing it) goes from pending to failed and is never in_progress; one cancelled while it runs goes from in_progress to failed. A server tool's call (server_tool_use), which claude runs no hook for, stays pending until their result.
  • Config options: model, effort, fast mode, agent. The model option's values are model ids (claude-opus-5-5), and its current value is the id of the model the session runs on: the one --model or _meta.claudeCode.options.model names (an alias such as opus is read as the id it resolves to in claude's list of models; an id the list doesn't name, such as --model claude-opus-4-1, is shown as it is), else the model claude's default resolves to, and after a switch, by the client or by claude, the new model's id. Claude lists the default and opus as one model, claude-opus-5-5, and the option offers it once. To set the option a client sends one of its values; an alias claude lists (default, opus, sonnet) is still accepted, and claude is told the alias. Plans from claude's to-do tools (a claude run with no terminal has none until Config.TaskTools sets CLAUDE_CODE_ENABLE_TODO_TOOLS=1 for it; a caller or a session that sets that variable itself, to 0 for one, has its word). What claude sends besides the model's requests: Config.NoNonessentialTraffic sets the variables that turn off its usage metrics, error reports, feedback, surveys, update checks and feature-flag fetching (CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC and the rest quietVars lists in options.go), and Config.ExportTelemetry turns its OpenTelemetry export (metrics and logs, as OTLP) on when the environment names an OTLP endpoint, which is the environment's to name; each keeps a variable the environment already has. The WebFetch safety check, which sends a hostname to api.anthropic.com, is a setting (skipWebFetchPreflight), not set by either. AskUserQuestion as a form (when the client takes form elicitation). Slash commands. Usage, cost and the context window. Session titles.
  • MCP servers from the client (stdio, HTTP, SSE); an MCP server's form or sign-in page passed to the client when it takes them.
  • Subagents as sessions of their own (the ACP subagents RFD), each stoppable, for clients that take them; notices of claude's own.

Not supported: ACP's authenticate (there is nothing to authenticate: sign in with claude itself; when claude isn't signed in, prompts fail with its own message), MCP servers over ACP's own transport, and the client's file-system and terminal capabilities (claude's tools run on the machine, as in the terminal). Windows isn't tested.

Development

go build ./... && go vet ./... && go test -race ./...

The tests run fake claudes and need no login. claudeagent/claudetest/cmd holds the tools that record the real claude against a fake Messages API (fakeapi), for new cassettes.

Licence and credits

MIT: see LICENSE. Parts are derived from:

Claude and Claude Code are trademarks of Anthropic, PBC. Using this software is using Claude Code, under the terms that cover your Anthropic account.