Agentic Toolchain

This section covers how to install and configure the agentic toolchain for Clojure development.

We are going to focus on using open source tools and open weight models for this manual. Open Source based tool chains offer a lot of attractive charactists. You have a lot of control

In order to do so, we are going to use OpenCode, or PI Agent.

You are welcome to pick and choose any of these tools. This manual will focus on using PI Agent with the Clojure MCP server.

Install OpenCode

Opencode is a complete coding editor designed to complete with Claude Code or Codex.

OpenCode has both an Native UI and TUI version.

brew install anomalyco/tap/opencode

Open Code Configuration

OpenCode configured via a opencode.json file in your projects root folder of the project. You can also define a global configuration file.

A common development pattern with OpenCode is to configure a custom System Prompt with the standard editing tools. In the below configuration, we are using the standard editing tools with the clojure-lsp tool for validating edits.

{
  "$schema": "https://opencode.ai/config.json",
  "autoupdate": true,
  "model": "anthropic/claude-sonnet-4-5",
  "agent": {
    "clojure_build": {
      "mode": "primary",
      "model": "anthropic/claude-sonnet-4-5",
      "prompt": "{file:./clojure_build.md}",
      "tools": {
        "write": true,
        "edit": true,
        "read": true,
        "bash": true
      }
    }
  },
  "mcp": {},
  "lsp": {
    "clojure-lsp": {
      "command": ["/opt/homebrew/bin/clojure-lsp"],
      "extensions": [".clj", ".cljs", ".cljc", ".edn", ".bb"],
      "env": {
        "CLOJURE_LSP_LOG_LEVEL": "info"
      },
      "initialization": {
        "initializationOptions": {
          "project-root-uri-as-project-root?": true,
          "text-document-sync-kind": 2
        }
      }
    }
  }
}

Install PI Agent

PI Agent is a TypeScript based coding agent that is designed for simplicity. PI Agent is only an TUI.

npm install -g @mariozechner/pi-coding-agent

PI Agent Configuration

Install Clojure MCP

Clojure MCP is an advance MCP server for working with Clojure. It includes toosl for running Clojure Code via the REPL, and advance tools for editing Clojure code.

clojure -Ttools install-latest :lib io.github.bhauman/clojure-mcp :as mcp

Install Clojure MCP Light

Clojure MCP Light is a command line tool for evaluating Clojure code.

bbin install https://github.com/bhauman/clojure-mcp-light.git --tag v0.2.1
bbin install https://github.com/bhauman/clojure-mcp-light.git --tag v0.2.1 --as clj-nrepl-eval --main-opts '["-m" "clojure-mcp-light.nrepl-eval"]'
bbin install https://github.com/bhauman/clojure-mcp-light.git --tag v0.2.1 --as clj-paren-repair --main-opts '["-m" "clojure-mcp-light.paren-repair"]'