joey castillo's personal website

Claude31

Claude31 is a small agentic coding harness for Windows 3.11. It contains an editor with syntax highlighting, a project tree and an agent that reads, writes, builds and runs C programs on your machine, talking to Anthropic’s Claude over TLS.

It is a 16-bit Windows program that runs both in x86 virtual machines and on actual x86 hardware. Here’s a demo:

This 1.44 MB floppy disk image holds the complete Claude31 source, but no executable; INSTALL.BAT builds it using the open source OpenWatcom toolchain (once you have installed it as described below).

Claude31 is free software released under the GNU GPL version 2.

Requirements

Software

Virtual Machine

Create an 86Box VM with the following settings:

  • [1993] Socket 4, [i430LX] Intel Premiere/PCI, 32 MB RAM
  • CPU: Intel Pentium OverDrive, 133 MHz, no Softfloat FPU
  • Display: [ISA] Tseng Labs ET4000AX
  • Input: PS/2 Keyboard, PS/2 Mouse
  • Sound (optional): [ISA] Sound Blaster v1.0
  • Network: [ISA] Novell NE2000, SLiRP mode
  • Serial Port: COM1 on named pipe (if you want Claude31’s logs)
  • Storage Controllers: skip
  • Hard Disk: [Generic] RAM Disk, 504 MB (CHS: 1024, 16, 63), IDE
  • Floppy drive: 1x 3.5" 1.44M
  • CD-ROM Drive: ATAPI bus, 0:1 channel, 8x speed, 86Box 86B_CD 3.50

Bare Metal Hardware

Claude31 has been tested on the Asus Eee PC 4G Surf. It may run on other machines, but no promises. You will need to use the dd utility to create an MS-DOS boot disk on a USB stick, boot to that, and install MS-DOS 6.22. If the Eee previously ran Linux, you may also need to run FDISK /MBR to make the SSD bootable. Once MS-DOS 6.22 is installed, you can install Windows.

Note that the Eee PC’s BIOS treats any thumb drive you booted from as a floppy disk drive (A:), and any other disk attached at boot as an extra hard drive (D:). The SSD is your C: drive.

If using the Asus Eee PC, you will also need to download this driver to use the Ethernet adapter. When running Windows setup, tell Windows that you have an unlisted network card, and point it to this driver.

Install

  1. Install OpenWatcom. When you do, run a “Selective installation”, and under “Target operating systems” ensure both Windows 3.x and DOS targets are checked. Leave all other options at defaults.
  2. Put this disk in A: (or D:) and, in File Manager, select the drive.
  3. Double-click INSTALL.BAT. INSTALL copies everything to C:\CLAUDE31, builds CLAUDE31.EXE from source, and installs it. The build takes a few minutes emulated; it is much faster on the Eee’s Celeron-M.
  4. Run C:\CLAUDE31\CLAUDE31.EXE. On the first run it asks for your API key and COM port where it can dump its logs (the Eee PC has no COM port). Both settings go into C:\CLAUDE31\HARNESS.INI and can be changed later via File > Setup.

How to Use

  • File > New Project... — type a full path, like C:\PROJECTS\HELLO, and press OK. The folder is created, along with some project structure and a MAKEFILE that builds SRC\HELLO.C to BUILD\HELLO.EXE.
  • File > Open Project... — open the PROJECT.C31 file in any Claude31 project folder to open that project.

Enter a task in the bottom box and press Enter; for example:

Write a program that shows the time in a window. Build and run.

The log shows your prompts and the agent’s replies and tool use. Hitting the Escape key while in the task box stops a task. The agent can read, write, edit, list, delete and rename files in the project, run wmake or the compiler, and run a program. NOTE: It cannot see the screen, or for that matter anything the program prints! If your program crashes, or something looks weird, say so in the chat.

Each project keeps its ongoing conversation in a file, TRANS.TXT in the C31WORK directory. Claude > New transcript clears it. The transcript is how the agent knows what came before; you should clear it in between unrelated tasks.

If a file named AGENTS.TXT exists at the project root, its contents are handed to the agent at every turn, appended to the system prompt. This is useful for code conventions, specific hazards or guidelines, and project-specific quirks. Keep it short and sweet: a page of house rules, not an instruction manual. Hard cap at 4 KB; if the file is larger than that, the harness ignores it altogether, with a note in the log.

The editor saves files as UTF-8, which means you can write any language in your comments. Stick to ASCII though in any string literals; Windows 3.11 was unaware of UTF-8, so anything past the ~ symbol is likely to render as goofy. The diskette’s copy of GNU Unifont includes coverage for the Latin-1 range, punctuation, arrows, symbols and box drawing characters; anything else shows as a small tofu box. You can install a fuller version of Unifont with support for the full basic multilingual plane, plus Plane 1 — emoji! — via a supplementary diskette.

Having Claude31 Change Itself

The full source for Claude31 is installed in C:\CLAUDE31\SRC. Go to File > Open Project, open C:\CLAUDE31\PROJECT.C31 and ask for the change; the agent edits the source and builds two copies of the program: BUILD\CLAUDE31.EXE (which you can INSTALL over the existing CLAUDE31.EXE) and BUILD\C31_DEV.EXE (which the harness can run to preview changes). C31_DEV.EXE will open with no API key and the Setup dialog showing, since it will have no HARNESS.INI file available to it. This is expected. If you want to work with a project using your newly changed program:

  1. Quit Claude31.
  2. Open C:\CLAUDE31 in File Manager.
  3. Double-click INSTALL.BAT to install the new build. The old executable will be backed up to CLAUDE31.BAK, in case you need to restore it.

Be liberal with the use of the Claude > New transcript action; the whole transcript is sent with each conversation turn, so when a task is done, clear it out so that the next task starts clean. A long transcript with cruft from a previous task makes the agent worse at the next one.

Settings (HARNESS.INI)

api

  • key - your API key
  • model - default claude-sonnet-5
  • max_tokens - default 16000
  • effort - choose from low, medium, high, xhigh, max

net

  • timeout - seconds before giving up, default 60
  • keepalive - set to 1, this keeps the TLS session open between turns

agent

  • max_turns per task (default 12, increase as needed)
  • run_timeout for when you @@RUN the program (default 10 s)

compile

  • watcom - path to the dev tools, default: C:\WATCOM
  • timeout - seconds to let a build run (default 180 s)

log

  • com - Set to mirror the log to a serial port, blank to disable
  • baud - baud for the serial port
  • file - when set to 1, also writes LOG.TXT beside the program
  • diag - set to 1 to dump diagnostics to the chat as well as LOG.TXT

project

  • dir - the default project to open at start, set whenever you open a project

font

  • unifont - path to UNIFONT.U16 for more Unicode coverage; default is fine

Security

Windows 3.11 did not ship with TLS. In fact, it didn’t even ship with TCP/IP! As such, it’s kind of a hack to get a Win16 app like this to talk to a modern API. But with Claude’s help, we got there:

  • I’ve updated the wolfSSL Win16 port from dialup.net to do server certificate validation.
  • Claude31 gathers entropy from keystrokes, mouse movements and other sources to ensure proper random number generation for session keys.
  • The ROOTS.PEM file contains root certificates that can vouch for api.anthropic.com.

Is this bulletproof? Oh my god no. It also requires having a computer powerful enough to do the encryption math before the connection times out, which means you’re never going to run this on an 80486. But a Pentium seems to cut it in emulation. And it’s downright trivial for a modern (read: 2007-era) Celeron M like the one in the Eee PC.

Your API key is still, of course, stored in plain text in HARNESS.INI, and you’re connecting an operating system that predates SSL to the Star Wars cantina that is The Internet, so, yeah. Point is, use an API key created just for this experiment, turn off auto-reload, and delete it when you’re done.

Source and License

  • Claude31: GNU General Public License, version 2
  • WOLFSSL2.DLL: fork of wolfSSL 5.5.4, GNU General Public License, version 2. Source available here; upstream code here
  • UNIFONT.U16: GNU Unifont 17.0.05, SIL Open Font License version 1.1. Source available at unifoundry.com