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

kelvinst
Hey everyone! Well, we made this lib a while ago and now we decided to finally go out and public with it! It’s a tool for creating and m...
New
treble37
Just looking for a little feedback on a tiny helper library I built - Sometimes I find the need to convert maps with atom keys to maps w...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 30338 241
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
fuelen
Hey folks! Want to present a toolkit for writing command-line user interfaces. It provides a convenient interface for colorizing text...
New
woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
restlessronin
The repo is at GitHub - cyberchitta/openai_ex: Community maintained Elixir library for OpenAI API · GitHub. Docs are at OpenaiEx User Gu...
152 10719 134
New

Other popular topics Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
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
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement