← Back to Blog

Building a Bare-Metal OS in Rust with AI — From Boot to Claude in 48 Hours

Matt Gates · April 1, 2026 · 10 min read

It started with a question that sounded ridiculous: What if Claude didn't need an operating system at all?

Not a container. Not a VM. Not a stripped-down Linux install. What if we wrote the operating system ourselves, from scratch, in Rust -- and the only thing it did was run AI coding agents on raw hardware?

48 hours later, we had a bare-metal OS that boots via UEFI, brings up networking, completes a TLS 1.3 handshake, and streams Claude's responses token-by-token directly to a framebuffer terminal. No Linux kernel. No POSIX. No JavaScript runtime. 237,000 lines of Rust across 38 crates.

The Spark

I run a repair shop. I've been using Claude as a coding partner for months -- multiple instances, multiple projects, always fighting for terminal space. One night I was staring at htop watching four Claude Code sessions share an i9-11900K through seven layers of abstraction: Linux kernel, systemd, Docker, Node.js, Electron, VS Code, the extension host...

The CPU was doing more context-switching than actual work. And I thought: what if the agents just talked to the hardware directly?

I knew Rust. I'd read Philipp Oppermann's blog_os tutorials. I had a QEMU setup ready. And I had Claude as a copilot. So I started typing.

Hour 0-6: Boot to Blinking Cursor

The first milestone was simple: get pixels on screen and a cursor blinking. We used the bootloader crate (v0.11) for UEFI boot, which hands us a GOP framebuffer and a memory map. From there:

The first character appeared on screen at hour 3. By hour 6, we had a working terminal with ANSI escape sequence support via the vte crate. You could type, see your text, and scroll.

// The moment it all started working -- kernel entry point
fn kernel_main(boot_info: &BootInfo) -> ! {
    // Init hardware: GDT, IDT, heap, interrupts
    init_hardware(boot_info);

    // Bring up the framebuffer terminal
    let fb = boot_info.framebuffer.as_ref().unwrap();
    init_terminal(fb.info(), fb.buffer_mut());

    serial_println!("ClaudioOS v0.1 -- we have pixels");

    // Start the async executor -- everything from here is futures
    executor::run(main_task());
}

Hour 6-18: Networking from Nothing

This is where most hobby OS projects stall. Networking means PCI bus enumeration, a NIC driver, a TCP/IP stack, DHCP, DNS. Each one is a project unto itself.

We went with VirtIO-net for QEMU (the legacy 0.9.5 spec -- simpler, well-documented) and smoltcp for the TCP/IP stack. The key insight: smoltcp is already no_std. It's designed for embedded. It just works if you feed it packets.

The VirtIO driver took the longest. You're doing MMIO with virtqueues, managing descriptor rings, handling interrupts. But once that first DHCP ACK came back with an IP address, everything accelerated. DNS resolution, TCP connections, HTTP requests -- smoltcp handled the protocol, we just had to shuffle packets between it and the NIC.

Hour 18-30: The TLS Wall

Here's where people told us it was impossible.

"You can't do TLS on bare metal without a full crypto library. Use Linux."

We used embedded-tls -- a no_std TLS 1.3 implementation designed for microcontrollers. It supports AES-128-GCM-SHA256, which is all we need for the Anthropic API. But there was a catch: it needs AES-NI instructions, which means the CPU needs to be in the right mode.

We spent four hours debugging a General Protection Fault that turned out to be SSE/AVX not being enabled. The fix was three instructions:

// Enable SSE, SSE2, and AVX via control registers
unsafe {
    // CR0: clear EM (bit 2), set MP (bit 1)
    let mut cr0 = read_cr0();
    cr0 &= !(1 << 2);  // clear EM
    cr0 |= 1 << 1;     // set MP
    write_cr0(cr0);

    // CR4: set OSFXSR (bit 9) + OSXSAVE (bit 18)
    let mut cr4 = read_cr4();
    cr4 |= (1 << 9) | (1 << 18);
    write_cr4(cr4);

    // XCR0: enable SSE (bit 1) + AVX (bit 2)
    write_xcr0(0b111);
}

After that, TLS handshakes worked on the first try. The QEMU flag -cpu Haswell gives us AES-NI, and embedded-tls handled the rest. First successful HTTPS request to api.anthropic.com at hour 24.

Hour 30-42: Claude Speaks from Bare Metal

With HTTPS working, the API client was surprisingly straightforward. The Anthropic Messages API is clean: POST JSON, get back SSE events. We wrote a raw HTTP/1.1 client -- no reqwest, no hyper, just formatted bytes over a TLS stream.

// Sending a message to Claude from bare metal
let request = format!(
    "POST /v1/messages HTTP/1.1\r\n\
     Host: api.anthropic.com\r\n\
     Content-Type: application/json\r\n\
     X-API-Key: {api_key}\r\n\
     Anthropic-Version: 2023-06-01\r\n\
     Content-Length: {len}\r\n\r\n\
     {body}"
);
tls_stream.write_all(request.as_bytes()).await?;

// Parse SSE stream token by token
while let Some(event) = sse_reader.next_event().await {
    match event.event_type {
        "content_block_delta" => {
            let text = event.data.extract_delta_text();
            terminal.write_str(&text);  // Directly to framebuffer
        }
        "message_stop" => break,
        _ => {}
    }
}

The moment Claude's first response streamed across the bare-metal terminal, character by character, with no operating system between the network card and the screen -- that was the moment we knew this project was real.

Hour 42-48: Multi-Agent Dashboard

The whole point was to run multiple agents. We built a split-pane terminal manager (think tmux, but native to the framebuffer) with Ctrl+B prefix shortcuts. Each pane is an independent viewport with its own scroll buffer, cursor state, and ANSI parser.

Each agent session is an async task on our interrupt-driven executor. When a NIC interrupt fires, it wakes the right future. When the agent is idle, the CPU executes hlt. No polling. No wasted cycles.

The "Impossible" Moments

Every few hours, we hit something that seemed like a wall. Every time, we got through it:

The lesson: In 2026, "impossible" usually means "nobody tried it in Rust yet." The no_std ecosystem is better than people think. Most things work if you're willing to fork a crate and strip out the std dependency.

By the Numbers

What We Learned About Building an OS in 2026

Rust makes OS development tractable for small teams. The borrow checker catches the bugs that would be use-after-free in C. The type system enforces invariants that would be comments in any other language. And the no_std ecosystem means you're not writing everything from scratch.

AI as a copilot changes the calculus. Claude helped us write driver code, debug register-level issues, and navigate unfamiliar specs. The feedback loop -- write code, hit a hardware fault, ask Claude, fix it, repeat -- was measured in minutes, not days.

The abstraction layers we take for granted are expensive. When you remove Linux, systemd, Docker, Node.js, and Electron, a modern CPU spends its cycles on actual work. Our agent sessions use a fraction of the resources because there's nothing between the async executor and the interrupt controller.

ClaudioOS isn't a toy. It boots on real hardware -- an i9-11900K, a Supermicro 4028GR-TRT, an HP Victus laptop. It runs Claude agents that can read files, write code, execute Python, compile Rust, and browse the web. All from bare metal.

The code is open source. Go build something impossible.

Matt Gates is the creator of ClaudioOS and owner of Ridge Cell Repair LLC. He builds systems in Rust and believes every "impossible" is just an untested hypothesis.

← Back to Blog · ClaudioOS Home · GitHub