Skip to main content

Overview

ClaudeCodeAgent integrates the Claude Code CLI with the Definable framework. Claude Code is an agent with its own LLM loop, file operations, and code execution. ClaudeCodeAgent communicates with the CLI via subprocess + JSONL protocol and layers Definable features on top: memory, knowledge/RAG, custom tools, guardrails, middleware, tracing, and structured output. No external SDK dependency — the transport layer is built-in.

Quick Start

Requires Claude Code CLI installed: npm install -g @anthropic-ai/claude-code

Prerequisites

  1. Install the Claude Code CLI: npm install -g @anthropic-ai/claude-code
  2. Authenticate: claude auth
  3. Install Definable: pip install definable

Configuration

Claude Code Settings

Definable Features

All standard Definable features work with ClaudeCodeAgent:

Custom Tools

Define tools with the @tool decorator. They’re automatically registered as MCP tools and called by Claude Code when needed:

Guardrails

Tool Guardrails

Tool guardrails intercept Claude Code’s tool calls via the control protocol. When the CLI requests permission to use a tool, your guardrails can allow or deny:

Input/Output Guardrails

Input guardrails run before the CLI is called. Output guardrails run after:

Multi-Turn Sessions

Use session_id to continue conversations:
For automatic session continuation, set continue_conversation=True:

RunOutput

ClaudeCodeAgent.arun() returns the same RunOutput type as Agent.arun():

Architecture