guess

guess

ClaudeCode - Agentic AI for Elixir Applications

Hi! I’ve been building ClaudeCode, an SDK that lets you embed Claude as an agent in your Elixir apps - not just a chatbot, but an AI that can take actions.

The Problem

Most AI integrations are text-in/text-out. Building anything useful means parsing responses, manually wiring tool calls, handling conversation state, and mocking everything by hand for tests.

The Solution: Hermes + ClaudeCode

ClaudeCode wraps the claude cli, giving Claude full agentic capabilities. Combined with hermes_mcp v0.14.1 — Documentation , Claude can call your Elixir functions directly:

  # Define a tool
  defmodule MyApp.Tools.RefundOrder do
    use Hermes.Server.Component, type: :tool

    schema do
      field :order_id, :string, required: true
    end

    def execute(%{order_id: id}, frame) do
      {:ok, refund} = MyApp.Orders.refund(id)
      {:reply, Response.json(Response.tool(), refund), frame}
    end
  end

  # Create an MCP server
  defmodule MyApp.SupportTools do
    use Hermes.Server, name: "myapp", version: "1.0.0", capabilities: [:tools]

    component MyApp.Tools.RefundOrder
    component MyApp.Tools.OrderLookup
  end

  # Start a session
  {:ok, session} = ClaudeCode.start_link(mcp_servers: %{"myapp" => MyApp.SupportTools})

  # Ask it to do something
  session
  |> ClaudeCode.stream("Customer jane@example.com wants a refund for her last order")
  |> ClaudeCode.Stream.tap(&IO.inspect/1)
  |> ClaudeCode.Stream.final_text()

Claude will call OrderLookup, find Jane’s order, call RefundOrder, and explain what happened. No decision trees. No hardcoded workflows.

Testing Without API Calls

  test "support agent processes refunds" do
    ClaudeCode.Test.stub(ClaudeCode, fn _query, _opts ->
      [
        ClaudeCode.Test.tool_use("OrderLookup", %{email: "jane@example.com"}),
        ClaudeCode.Test.tool_result(%{id: "ORD-123", total: 99.99}]),
        ClaudeCode.Test.text("Processing refund for order ORD-123..."),
        ClaudeCode.Test.tool_use("RefundOrder", %{order_id: "ORD-123", reason: "request"}),
        ClaudeCode.Test.tool_result(%{status: "processed"}),
        ClaudeCode.Test.text("Done! Refunded $99.99.")
      ]
    end)

    {:ok, session} = ClaudeCode.start_link()
    result = session |> ClaudeCode.stream("Refund Jane") |> ClaudeCode.Stream.final_text()

    assert result =~ "Refunded $99.99"
  end

Millisecond tests. No API calls. Full async: true support.

Also Included

  • OTP Supervision - Sessions restart on failure
  • Native Streaming - Elixir Streams, LiveView-ready
  • Multi-turn Memory - Context retained across queries
  • Concurrent Agents - Run multiple sessions with the actor model

Links

https://github.com/guess/claude_code

Early days - I’d love to hear what agents you’d build, or what’s missing that would make this useful for your projects.

Where Next?

Popular in Announcing Top

bryanjos
Hi, I wanted share a small library we at Revelry Labs made for rendering react components from the server side. There are instructions fo...
New
mbuhot
Leverage Open Api 3.0 (Swagger) to document, test, validate and explore your Plug and Phoenix APIs. Generate and serve a JSON Open API ...
New
tmbb
I’ve been working on two packages (not on hex.pm yet) to build admin interfaces for phoenix apps: bureaucrat - which contains a bunch ...
New
mathieuprog
Hello :waving_hand: Allow me to introduce you to Tz, an alternative time zone database support to Tzdata. Why another library? First a...
New
oltarasenko
Dear Elixir community, After a year of development, bug fixes, and improvements, we are proudly ready to share the release of Crawly 0.1...
New
wojtekmach
Hey everyone! Req is an HTTP client for Elixir that I’ve been working on for quite some time. There is already a lot of HTTP clients out...
New
bluzky
You may know https://ui.shadcn.com/, a UI component library for React. I really love it’s design style and components. I’ve built some co...
384 14553 119
New

Other popular topics Top

joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New

We're in Beta

About us Mission Statement