explaingit

licjon/clos-alchemy

Analysis updated 2026-05-18

3Common LispAudience · developerComplexity · 4/5Setup · hard

TLDR

A Common Lisp library that extracts structured, typed objects from messy text by having an LLM fill in your own class definitions.

Mindmap

mindmap
  root((clos-alchemy))
    What it does
      Extracts typed data
      Uses CLOS classes
      LLM constrained output
    Tech stack
      Common Lisp MOP
      JSON Schema
      llama.cpp backend
    Use cases
      Parse text to objects
      Constrain LLM output
      Improve with field docs
    Audience
      Lisp developers
    Notes
      Manual Quicklisp clone
      No silent type fallback

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Extract structured data like names, emails, and lists from free-form text into typed Lisp objects.

USE CASE 2

Constrain a local llama.cpp model's output to match a JSON Schema derived from your class.

USE CASE 3

Replace manual hash table or plist parsing of LLM output with real typed CLOS instances.

USE CASE 4

Add field descriptions to class slots to improve extraction accuracy on ambiguous data.

What is it built with?

Common LispQuicklispllama.cppJSON Schema

How does it compare?

licjon/clos-alchemyedencompiler/lwlglwondermonger-daydreaming/latent-lisp
Stars330
LanguageCommon LispCommon LispCommon Lisp
Setup difficultyhardmoderatemoderate
Complexity4/54/55/5
Audiencedeveloperdeveloperresearcher

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · hard Time to first run · 1h+

Not on Quicklisp yet, local llama.cpp use requires building a shared library and downloading a GGUF model.

In plain English

clos-alchemy is a Common Lisp library that turns messy, unstructured text into structured, typed data using a large language model. Instead of getting back loose strings, hash tables, or plists from an AI model, you get a real typed object built from an ordinary class you already defined. The way it works is that you write a normal CLOS class, Common Lisp's built in system for defining object types, with typed slots like strings, integers, or lists. The library inspects that class definition using Lisp's metaobject protocol, automatically turns it into a JSON Schema, and uses that schema to constrain what the language model is allowed to generate. The AI's output is then checked against the schema and used to build and return a genuine instance of your original class, with all its normal accessors working as expected. This mirrors a similar tool in the Python world called instructor, which does the same thing using Pydantic models instead of CLOS classes. Setup currently requires manually cloning this repository and a companion backend library into a folder that Quicklisp, the Lisp package system, can find, since it is not yet published there. If you want to run everything locally using llama.cpp instead of a remote API, additional companion repositories are needed, along with building llama.cpp itself as a shared library and downloading a GGUF format model file. The library supports a wide range of Lisp type specifiers, mapping things like strings, integers, booleans, enumerated values, lists, and nested objects to their JSON Schema equivalents, and it deliberately refuses to guess when a type has no clear JSON equivalent rather than silently falling back to treating everything as a string. Field documentation on your class slots is also fed into the model's prompt to improve extraction accuracy on ambiguous fields. The full README is longer than what was shown.

Copy-paste prompts

Prompt 1
Help me clone and load clos-alchemy and cl-llm-backend into my Quicklisp local-projects folder.
Prompt 2
Explain how a CLOS class definition gets turned into a JSON Schema by this library.
Prompt 3
Walk me through setting up the llama.cpp backend to run extraction locally.
Prompt 4
Show me which Lisp type specifiers are supported for extraction and which are not.

Frequently asked questions

What is clos-alchemy?

A Common Lisp library that extracts structured, typed objects from messy text by having an LLM fill in your own class definitions.

What language is clos-alchemy written in?

Mainly Common Lisp. The stack also includes Common Lisp, Quicklisp, llama.cpp.

How hard is clos-alchemy to set up?

Setup difficulty is rated hard, with roughly 1h+ to a first successful run.

Who is clos-alchemy for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.