- Go 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .forgejo/workflows | ||
| .github/workflows | ||
| claudeacp | ||
| claudeagent | ||
| cmd/claudeacp | ||
| .gitignore | ||
| .golangci.yml | ||
| CHANGELOG.md | ||
| go.mod | ||
| go.sum | ||
| LICENSE | ||
| README.md | ||
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:
claudeacptakes claude's options and passes them to everyclaudeit 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 isclaudeacp, where upstream's isclaude-acp; the packages are the same. - CI runs on this forge, on Linux:
.forgejo/workflows/ci.ymlstands 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.claudeacpis one Go binary. - Your claude. It runs the
claudeon yourPATH(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 withclaude --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-controland--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),--helpand--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 mcpor--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--settingsvalue that starts with-.claudeacp -versionis 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 (
NotebookEditwith the settingsBash Read Edit Write Glob Grep Skill WebFetch WebSearch Agent TodoWrite Monitor TaskStop ToolSearch), and so is a rule's own ask: withask: ["Bash(echo *)"], claude says "denied … don't ask mode" wheredefaultwould 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
Bashinallow,echo x > ~/proberan and wrote the file: the rule matched the whole tool, and where a redirect writes is not somethingBashchecks. Without the rule the same call is denied, and so it is with onlyBash(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, notBash. - An allow rule does not reach what claude protects:
Writeto.claude/is denied withWriteinallow, whereacceptEditsanddefaultask. (A write under<worktree>/.git/in a linked worktree, where.gitis a file, fails with the file system'sENOTDIR: not a permission's denial.) - A deny rule wins over an allow rule: with
Bashallowed andBash(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". AskUserQuestionis not available to a city's agents ondontAsk, for two reasons that add.claudeacphas 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, sodontAskdenies 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 inallowbrings the form back was not tried.- Not every tool asks.
EnterPlanModeran in all three modes without a request. The session is then in plan mode, andExitPlanModedoes reach the client, with the choices Auto, accept edits and ask before edits: none of them isdontAsk, so a client that picks one has left the mode. The mode list the agent offers (session/set_mode, the Mode config option) has nodontAskeither, 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 ofExitPlanMode'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.
claudeacpfollows 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, andclaudeacp/NOTICEcarries the licence. - Anthropic's Agent SDKs (Python, MIT; TypeScript) drive
claudeover the same stream-JSON protocol.claudeagentis a Go client for that protocol;claudeagent/sessionsis ported from the Python SDK's session helpers (claudeagent/NOTICE). Nothing comes from the TypeScript SDK or from theclaudebinary. - The protocol is undocumented. The package parses leniently (unknown messages arrive as
Unknown, raw JSON is kept), detects features from whatclaudesays it supports, and pins noclaudeversion. A change inclaudecan 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
claudequeues them, or steer the running turn (_session/steering); cancel. - Every permission
claudeasks 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_callandtool_call_update: a call startspendingas the model writes it, its input arriving a field at a time;in_progressis sent when its tool starts to run, not while the model writes the input, and not while the user is asked to allow it; thencompletedorfailed. The moment is read from claude'sPreToolUsehook (a call claude doesn't ask about runs once that hook has run, andclaudeacptells the client after 100 ms with no permission request or denial) and from the user's allowing a request;tool_progressalso 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 frompendingtofailedand is neverin_progress; one cancelled while it runs goes fromin_progresstofailed. A server tool's call (server_tool_use), which claude runs no hook for, stayspendinguntil 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--modelor_meta.claudeCode.options.modelnames (an alias such asopusis 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 andopusas 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 untilConfig.TaskToolssetsCLAUDE_CODE_ENABLE_TODO_TOOLS=1for it; a caller or a session that sets that variable itself, to0for one, has its word). What claude sends besides the model's requests:Config.NoNonessentialTrafficsets the variables that turn off its usage metrics, error reports, feedback, surveys, update checks and feature-flag fetching (CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFICand the restquietVarslists inoptions.go), andConfig.ExportTelemetryturns 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 toapi.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:
- the Claude Agent SDK for Python, MIT, Copyright (c) 2025 Anthropic, PBC (
claudeagent/NOTICE); - claude-agent-acp, Apache-2.0, Copyright 2025 Zed Industries, Inc. and contributors (
claudeacp/NOTICE).
Claude and Claude Code are trademarks of Anthropic, PBC. Using this software is using Claude Code, under the terms that cover your Anthropic account.