Dualism is a prototype LLM-assisted code editor modelled after notebooks, designed to facilitate iterating on generated code by editing the prompt and regenerating.
When generating code with ChatGPT and Claude, I often iterate on the same code multiple times before copying it into my actual source code. The chat interface here is kind of clunky, I end up repeatedly typing things like “that’s good but now make it handle this edge case”.
Conversely, when generating code in Copilot, Cursor, and Colab, I end up using comments as prompts, and I find I’m not too attached to the code it generates. When I need to change the generated code, I’d rather just adjust the prompt and regenerate. But that workflow is difficult in these code editors, which don’t save the prompt or the delimit the generated code.
With Dualism, you can go back and iterate on the prompt, regenerating the code response until you get it just right.
Dualism also does away with the chat conceit. No more asking ChatGPT to “please generate code to […]”. It also provides an export view, which concatenates all the cells and formats your prompts as code comments.
You can also edit the generated code and regenerate its prose description. (Hence, “dualism”.) This is for those cases where it’s easier to reach in and make a small edit directly to the code, and ensures the prompt and code always stay in sync.
Finally, you can switch languages even after the code has been generated, in which case the code is regenerated in the new language. This is particularly useful for shell scripts which have crossed the complexity threshold to justify writing them in Python.
This is a working prototype, but it really is a prototype: its purpose is to explore different interaction models for LLM-assisted programming.
Enough yapping, go play with Dualism!
This is just a prototype. I find it’s good enough to write shell scripts (which was my original motivation), but it has many limitations and room for improvement:
If you’re interested in tinkering, check out Dualism on GitHub!
Dualism uses Claude Sonnet to generate code. The prompts took some tweaking but pretty reliably do what I want. I have some cleanup functions that remove extraneous code (exports, markdown backticks) that it sometimes generates.
The rest is pretty standard frontend web code, written in TypeScript with Next.js and Panda CSS, hosted on Render. The code editor is CodeMirror using the UIW React wrapper.
I’m Noah Tye. I love programming tools and I’m frustrated that the chatbot paradigm is so common for LLMs.
You can find me on Twitter or read more on my website!