anthropic4s
GitHub

Docs With Claude Code

Build with Claude Code

anthropic4s 1.0.0 shipped in November 2026, after today's models were trained. Ask one to write an agent with it, and it reaches for the official Java SDK's builders or methods that do not exist. The anthropic4s plugin for Claude Code gives it the real API, and a way to take an agent from an empty folder to a tested project.

You will learn

  • How to install the plugin
  • What each part of it does
  • How to build an agent end to end with /anthropic4s:new-agent
  • Why its examples can be trusted, and what it measured

Install it#

The plugin's repository is also its marketplace. In Claude Code:

Claude Code
/plugin marketplace add zakariahere/anthropic4s-plugin
/plugin install anthropic4s@anthropic4s-plugin

From a shell, the same two steps are claude plugin marketplace add and claude plugin install. The source is on GitHub, under Apache 2.0.

What is inside#

PartWhat it does
Skill anthropic4s Loads whenever Scala code talks to Claude. It holds the rules a model gets wrong from memory, such as one client as a Resource, streaming above about 21k output tokens, no temperature, and code that depends on Messages[IO] so it can be tested. It also has short references for each topic in these docs.
Skill new-agent The end-to-end path below, started with /anthropic4s:new-agent <what it should do>.
Agent anthropic4s-reviewer A read-only review of anthropic4s code: client lifecycle, hand-rolled tool loops, ungated side effects, secrets in tool errors, blocking inside IO, and testability. Each finding comes with a file:line and a fix.
Hooks After each edit, a warning (never a block) for an API key literal, sampling parameters, a model id that has a constant, unsafeRunSync, prompt text in traces, or a large non-streaming request. At session start, a note when the build depends on anthropic4s.
Evals Six claude plugin eval cases, each run with and without the plugin: a first program, a support agent with a refund gate, a long streamed report, Play with structured output, a review of planted bugs, and a check that the skill stays out of Python work.

An agent, end to end#

/anthropic4s:new-agent a support agent that looks up orders and refunds them with approval runs these phases in order and stops at each checkpoint:

  1. Pin it down. It asks what one run does, which tools change anything, and where the agent runs (a command-line program, or inside Play).
  2. Scaffold. It copies a template sbt project and runs its tests before writing any agent code, to prove the toolchain works.
  3. Tools first. It writes argument and result case classes with @description, each tool behind a small trait so tests can use a fake.
  4. The agent. It writes a system prompt, a withBeforeTool gate on every tool with side effects, an iteration limit, and a full RunStop match.
  5. Tests before tokens. It writes ScriptedModel tests for the happy path, a failing tool, a denied gate and a refusal, until sbt test passes.
  6. A real run, only when you agree, since it needs ANTHROPIC_API_KEY and spends tokens. Then a pass by the reviewer agent.

The tests it writes follow the testkit, with no network and no API key:

README.md · Testing your agents
for {
  model  <- ScriptedModel.of[IO](Replies.toolUse("get_weather", Json.obj("city" -> "Ghent".asJson)), Replies.text("Rainy."))
  result <- model.toolRunner(List(weather)).run(request)
  sent   <- model.requests            // inspect what your code sent
} yield assertEquals(result.text, "Rainy.")

Why the examples are right#

Every Scala snippet in the plugin is cut from a small sbt project in its repository. That project depends on the published anthropic4s from Maven Central, compiles with warnings as errors, and runs testkit tests in CI. A script fails the build when a snippet in the skill no longer matches its source, and the scaffold template is a tested project too. When anthropic4s releases a new version, anything that stops compiling breaks the plugin's CI first.

What it measured#

In a first smoke run of the hello-world eval (one run per arm), Claude passed all 5 checks with the plugin and 0 of 4 without it. The skill-loaded check applies only to the run with the plugin. Without the plugin, Claude's code did not use the library's real API. One case, run once, is a smoke test rather than a benchmark. The full suite is in the repository for anyone who wants to run it.

Recap

  • Install it with /plugin marketplace add zakariahere/anthropic4s-plugin, then /plugin install anthropic4s@anthropic4s-plugin.
  • The skill teaches the real API, and /anthropic4s:new-agent builds an agent with its tests before it spends any tokens.
  • Its examples compile against the published library, and its evals measure the difference against no plugin.

Every snippet on this page is copied, character for character, from the anthropic4s repository: its README, docs/play.md or examples/, which compiles with the build.