# Building an AI REPL with QuickJS

DevFeed: [Building an AI REPL with QuickJS](<https://devfeed.tech/articles/building-an-ai-repl-with-quickjs-28087.md>)

Original publisher: [Read original article](<https://jlongster.com/building-an-ai-repl-with-quickjs>)

Author: James Long

Published: 2025-11-18T12:00:00Z

Content type: opinion

Language: en

Sources: [James Long](<https://devfeed.tech/sources/james-long.md>)

Topics: [Artificial Intelligence](<https://devfeed.tech/topics/ai.md>), [wasm](<https://devfeed.tech/topics/wasm.md>), [WebAssembly](<https://devfeed.tech/topics/web-assembly.md>), [anthropic](<https://devfeed.tech/topics/anthropic.md>), [Claude Code](<https://devfeed.tech/topics/claude-code.md>), [User experience (UX)](<https://devfeed.tech/topics/ux.md>), [C](<https://devfeed.tech/topics/c.md>), [debug](<https://devfeed.tech/topics/debug.md>), [Error Handling](<https://devfeed.tech/topics/error-handling.md>)

Tags: [ai](<https://devfeed.tech/tags/ai.md>), [anthropic](<https://devfeed.tech/tags/anthropic.md>), [bytecode](<https://devfeed.tech/tags/bytecode.md>), [c](<https://devfeed.tech/tags/c.md>), [claude-code](<https://devfeed.tech/tags/claude-code.md>), [debugger](<https://devfeed.tech/tags/debugger.md>), [error-handling](<https://devfeed.tech/tags/error-handling.md>), [github](<https://devfeed.tech/tags/github.md>), [ux](<https://devfeed.tech/tags/ux.md>), [webassembly](<https://devfeed.tech/tags/webassembly.md>)

## AI overview

The article describes a three-hour experiment building an AI-integrated REPL with a custom WebAssembly build of QuickJS. The system evaluated JavaScript locally, exposed function bytecode and execution controls, and sent failed evaluations to Anthropic's Sonnet 4.5. The author concludes that the approach was not very useful for simple scripts but sees potential in sharing an executing environment with AI and debugger hooks.

## Source excerpt

Yesterday I did a livestream where I built a usable REPL with AI integration. Mostly from scratch, all in 3 hours. It uses a custom WASM build of QuickJS for evaluation. If the evaluation fails, it sends the text to Anthropic to speak to Sonnet 4.5. The idea was to meld a live evaluation environment together with AI. By using QuickJS as an evaluator, we get more than just a sandbox: we are able to inspect bytecode of functions, we could pause execution as needed, etc. I thought we might discover use cases that would be difficult to do by sending JS to eval off to a remote sandbox (or a separate node instance). It's also a UX experiment: you can either write code or talk to AI. In the end, it didn't prove to be super useful. The cases where I want to provide deep introspection at runtime to AI are where I'm already working with a very complex codebase, not writing simple scripts. For the UX, I generally want to write code in a dedicated editor and send it off to be evaluated. I still think there's merit in the idea of sharing an executing environment with AI with the debugger hooks enabled; I'm researching companies working on this. Let me know if you know of any. Still, it was fun to give AI the ability to get the bytecode for a function and describe what the function does at a very low-level. I asked to write a function that sums the numbers in an array, and then asked it to get the bytecode and describe it: Some notable things that happened during this: QuickJS doesn't come with a WASM build by default. I told Claude Code to compile it to WebAssembly, and it got Emscripten all setup and successfully built it to WASM Sonnet 4.5 was able to very easily write a bunch of C code to provide new APIs in QuickJS Changing how error handling works, another example of how nice it was to get AI to work with the C code I intended to eventually dig into QuickJS and change some fundamental features but decided to pause this experiment Adding tools is really fun. Here I added a t