Claude Code Builds Complete 64-Bit OS from Scratch in One Session
Share this article
In a remarkable display of AI-assisted development, a programmer has successfully built a complete 64-bit operating system from scratch in a single session while sick in bed. The resulting "Simplicity OS" features a working Forth interpreter and demonstrates the potential of AI tools like Claude Code to handle complex system programming tasks.
The Vision: Simplicity OS
The project began with a simple yet ambitious concept: creating an operating system where everything is a Forth word. As the developer explained, "The entire OS would be like Lego blocks: simple, composable words that directly control hardware. Want to know your screen resolution? SCREEN returns all parameters to the stack. Want to change brightness? SCREEN-SET takes parameters from the stack and applies them."
This approach represents a radical departure from traditional OS design, offering pure, simple, and direct hardware control through a minimalist programming language.
The Technical Journey
What makes this achievement particularly noteworthy is the transparency of the entire development process. The developer documented every prompt, every response, every challenge, and every breakthrough in a comprehensive narrative file.
Stage 0: Protected Mode (30 minutes)
The initial phase focused on creating a boot sector that could load and transition from 16-bit real mode to 32-bit protected mode. The first "hello world" moment came when the system successfully displayed:
Simplicity OS v0.1 - Protected mode
5 35
Stage 1: Forth Interpreter (45 minutes)
With the basic bootstrapping complete, the team built a real Forth interpreter featuring the critical NEXT inner loop. This breakthrough allowed actual Forth code to execute:
2 3 + . → prints "5"
5 7 * . → prints "35"
The 64-bit Wall (1 hour)
The project hit a significant roadblock when attempting to transition to 64-bit long mode. Multiple attempts with different page table locations (0x1000, 0x10000, 0x70000, 0x9000) all resulted in system crashes, with the machine triple-faulting and rebooting.
The Breakthrough (30 minutes)
The solution came from an unexpected approach. As the developer noted, "The issue: you can't use a 64-bit GDT while executing 32-bit code." The solution required a two-GDT approach:
- Use 32-bit GDT during setup
- Enable long mode while in 32-bit code
- Load a NEW 64-bit GDT after long mode is active
- Far jump to 64-bit code segment
The successful transition was marked by debug markers: "PCAE" in red and "L64" in yellow, confirming that 64-bit code was executing.
Technical Highlights
The Forth Interpreter
At the heart of Simplicity OS is a sophisticated Forth interpreter with the elegant NEXT loop:
NEXT:
lodsq ; Load next word address (64-bit)
jmp rax ; Execute it
This minimalist implementation enables the system to execute Forth code efficiently while maintaining the language's characteristic simplicity and power.
Complete Forth System
The OS includes a comprehensive Forth environment with:
- 15 built-in words + unlimited user-defined words
- Colon definitions with nesting capabilities
- Variables with allocated storage
- Comments and strings support
- Introspection capabilities (words, see, forget)
- Dictionary with linked list structure
The system demonstrates remarkable composability, allowing users to define complex operations from simple primitives:
> : square dup * ;
> : square4 square square ;
> 2 square4 .
256 ok
Why Forth?
Forth proves to be an ideal choice for system programming due to its:
- Minimal implementation requirements
- Self-hosting and extensible nature
- Direct hardware access capabilities
- Interactive development environment (REPL)
- Compositional architecture
As the developer explains, "The entire OS will be Forth words. Want to read from disk? DISK-READ. Want to set screen brightness? SCREEN-SET. Everything follows the same pattern."
The AI's Role
This project exemplifies a new paradigm in human-AI collaboration. While the developer provided vision and direction, Claude Code handled the heavy lifting:
- Wrote all assembly code
- Debugged boot issues
- Managed build systems (Make, NASM, QEMU)
- Handled git commits
- Found the 64-bit solution after multiple failures
- Created comprehensive documentation
The developer emphasizes that "This isn't about me being clever. I gave vision and direction. Claude did the heavy lifting."
Current Status and Future Directions
Simplicity OS has reached a complete foundational state with:
- PS/2 keyboard driver with shift support
- Interactive REPL
- Colon definitions with nesting
- Variables
- Comments and strings
- Introspection capabilities
Future additions planned include:
- Disk I/O for persistence
- More hardware drivers following the DEVICE-* convention
- Graphics mode
- Network stack
All code is public domain, and the complete development narrative is transparently documented.
Implications for AI-Assisted Development
This project demonstrates several key insights about AI-assisted system programming:
- Transparency Matters: The complete development narrative, including failures and debugging, provides an authentic look at the development process.
- AI as Amplifier: Claude Code handled the complex assembly and system-level tasks while the human maintained architectural oversight.
- Reproducibility: The tools are available, the AI is accessible, and the results are reproducible.
As the developer states, "The point: Show what's possible. No gatekeeping. No mystery. Just: 'Here's what we did, here's how we did it, go build something.'"
For developers interested in exploring this further, the project is available on GitHub with complete instructions for cloning and running the OS. The transparent documentation provides an unprecedented look at how AI can collaborate with humans on complex system programming tasks.
This experiment represents more than just a technical achievement—it's a glimpse into the future of software development, where human creativity and AI capability combine to push the boundaries of what's possible.