Vibe learning rust by building an app (spoiler I didn't)
Introduction
I have decided to write a simple .venv cleaning tool to use in the labs. I decided to use rust (as every new python tool is written in rust as it’s blazingly fast (tm) ). I don’t know rust, but I’m hoping Claude sonnet 4 does. I will be vibe coding this app using the techniques I discovered when writing my Apps’ere tool.
Setup
I already rust installed on my mac using rustup and I will again be using the zed editor. In the last demo I used copilot as my AI, this time I am going to sign up for the free trial of Claude Sonnet 4 that comes with Zed to give this a try.
.rules file
To start with I have been doing some RTFM and discovered the zed rules file which allows us to communicate set criterial with the agent. I have written the initial basic .rules file (note the typos again!)
You are to use rust as the programming language.
You can use any libraries that are required and these can be installed via cargo
All code should have full comments and explainations and use the rust styleguide
This app is designed to work in three modes
1. cli with command lines
2. tui with simple interface
3. gui which will use Qt6 rust bindingsDesign Document
Most articles on vibe coding recommend writing a Product Requirments Documet PRD I have written a very simple one to get started.
PRD click to expand
Venv cleaner
cli mode
Is an 3 mode application to help manage and clean up .venv folders on mac and linux.
The fist mode is cli, this allows the user to run the tool venv_cleaner [dir] with the following command lines
-r recurse and search from the current directory -f force always delete
The tool will search for a .venv in the current folder or one passed and prompt the user if found if it should be deleted. If yes then the .venv folder will be removed. If the -r or -f flags are used
-q query
will recurse the directory passed or current directory and print out the path / and size of the .venv folder. The size should be reported in either Mb or Gb depending upon the size.
tui
This will use the rust tui library to give a console based application. this is activated using the –tui flag.
It will open the current folder and present a view of each .venv folders found by recursing.
It will display in a list the following information
location size in bytes last used data created date
There should be the ability to open a new folder , delete the selected .venv in the list as well as order by date of creation
Gui
This will as the same functionality as the tui version but use a Qt6 based GUI rather than a tui.
Getting Started
With all this in place I sent the agent a message, including the .rules and Design.md
Write the initial project files and folders for the venv cleaner app. Start with the cli mode described.As I had zed in “write” mode it went off and wrote a file of stuff for me.
First a Cargo.toml file with all the elements required. Then a src folder with a number of rust files. This took a while so I got a coffee!
It generate 7 files including README.md and a License file. It then asked if it could compile and run the tool to check it. It had written a load of unit tests as well.
Compilation actually failed so it went back and fixed it. Finally it compiles with a few warning.
It then asked permission to run the tests. Which worked after the fixes.
Slow down!
The agent then went a bit mental writing all sorts of scripts to build the tools and also to install and setup rust none of which were required. It has only written the basic command line tool which seems to work well.
In the overall build setup there are executables for each of the TUI / GUI mode but none of the TUI / GUI mode stuff actually works.
This initial setup has created a 45k/200k context and used up 28/50 of my prompt usage (I was on about 12 when I started so not too bad).
I’ve not actually looked at any of the code generated or how the project actually works yet!
TUI mode
I prompted the agent to develop the tui mode for me an let it work whilst I got breakfast (it is 6.30 am). This took about 20 minutes so managed to do the washing up too!
At some stage the Agent asked me to turn on Burn Mode this seems to eat up the free usage I have (44/50) I switched to the pro trial for 14 days to give it a go.
You can see some of zed in action here
Some upgrades.
The basic TUI system was working well but I wanted to make a few updates after using it. The main one was to get it to add feedback to the user and show the tui when scanning the directories. This worked well.
GUI Mode
Next I wanted to add a gui mode, however after a little bit of reading I decided not to use the Qt rust bindings as it seems a little over complicated for what I needed. There are a number of gui libraries for rust, in the end I decided to use egui as it seemed the simplest one. First thing I did was to update the .rules file.
3. gui which will use egui rust bindings
I have quite a large context window now (144k/200k) so this may cause some issues. but I added the prompt
Now write a full gui version of the tool using egui. Try to immitate the tui version.I started off the process and made more coffee! It took a while and had a few initial compilation errors but now I have a full gui!
App working
Analysis
The full source code is on Github
The agent has developed 13 rust files, split into a folder structure as follows
ls src/
cli core gui main.rs tui
It further developed a Cargo.toml build file as well as a build script all of which work and I have re-built the tool under linux (needed to install a few extra system libraries first).
My final context window is 185K / 200K and I have used up approx 50 prompts from my allowance (i didn’t make notes of this to start) this is approx $2.50 if I have understood the billing correctly.
Timeline of development
Monday Night
- Monday night, had an idea that I needed a tool to make cleaning .venvs easier for the students.
- Decided to vibe code in rust tomorrow ( I also dream designed some of it!)
Tuesday Morning
I started writing this post whilst the AI was doing stuff, and finished it off after lunch.
- 6 am started to design the .rules file and PDB
- 7 am initial code written by AI had breakfast
- 8 am commit first version (08:13) did school run and thought about next steps
- 9 am got cli working and tested added a few features
- 10 am started the TUI version committed about 10.30 (had coffee)
- 11 am did research about gui options and made gui version
- 11.30 got it working on linux which required lib installs and coffee
- 12.30 finished gui version deployed to linux and my AppsEre app
That’s it for the day, I made a sandwich whilst the gui version was building, guess it’s time for the pub now :-)
Final Thoughts
Yet again I have written a fully working program with no knowledge of the code or how it works. Am I scared? Not sure yet. My next step is top analyze both code bases and see what I have produces.
I’m really happy with the cli and TUI versions and I must say the Agent has design the layout and key bindings well. It has added extra features I did not specify (for example –dry-run and –force)
I needed to add some extra features for the TUI such as prompts to show the tool in action when scanning large folders etc.
The gui is not quite as nice but does work. I will keep it for now but may in future see how I can use Qt / QML in rust (once I have learnt how to program in rust).
You can see the full agent dialog here
I will be using both the tools I have developed, I may even have to incorporate this into my teaching.
BTW I have yet to learn rust!