Welcome to issue 23 of the Sheets Insiders membership program.
You can see the full archives here.
Vibe Coding with Apps Script π
In the past month, the term “vibe coding” has gained popularity in tech circles.
βIt was coined by one of the founding team members of OpenAI and refers to AI-dependent programming. I.e. you rely entirely on the AI tool to generate your code.
I thought I’d give it a try for a recent Apps Script project I’m helping someone with.
Person A has a Google Sheet with a lot of background cell colors. He wanted a script that counted the background colors (e.g. 100 cells were red, 250 were green, etc.).
It’s a simple automation and an ideal test case for an AI tool to write the Apps Script.
I’m using ChatGPT o3-mini-high, which is tailored to math and coding tasks, but you can try vibe coding with any LLM model.
The idea is to describe in words (or with your voice) what you want to build and delegate ALL the coding to the AI tool.
Let’s see what happened…
I started with this prompt.
Prompt 1
let’s code together. I want to write an apps script project that counts how many cells I have in Sheet1
The model reasoned for 18 seconds before giving me two different Apps Script functions, because of the ambiguity in my prompt question.
It’s worth pausing here and just taking stock.
ChatGPT took 18 seconds to write not one, but two, Apps Script solutions for me. And although this was a very simple problem, it would have taken me 10 – 15 minutes to figure out all the syntax myself.
I then simply copied and pasted the code from ChatGPT directly into my Apps Script editor and ran it.
Continuing, I asked it to now identify the background cell colors for me.
Prompt 2
now i want to make a list of any background cell colors that are in the sheet
It reasoned for 21 seconds then created a function to list the hex codes of any colors in my Sheet. Again, I copied the code to the editor and ran it without any changes.
The output in the script Logger window was:
Unique background colors in Sheet1: #00ff00, #0000ff, #00ffff, #ffff00, #ff0000
Since these hex values are hard for us humans to interpret, I asked it to add names to them.
Prompt 3
can you add names to these hex values in the output?
It wrote a helper function to assign names to the common colors. My output was now:
Unique background colors in Sheet1 with names: [{“hex”:”#00ff00″,”name”:”Lime”},{“hex”:”#0000ff”,”name”:”Blue”},{“hex”:”#00ffff”,”name”:”Cyan”},{“hex”:”#ffff00″,”name”:”Yellow”},{“hex”:”#ff0000″,”name”:”Red”}]
So I asked it to add counts to each of these colors.
Prompt 4
can you add a count of how many cells have each color and the output should be a small table format like this:
color name | count
It reasoned for 24 seconds to update the code. I pasted it into the editor, ran it and got the following output in my Apps Script executions window:
I carried on with a few more prompts to add a total count, add a custom menu to my Sheet and even send me an email with these results:
Here’s what it looks like in action:
Impressive. Fun. Easy.
Thoughts on vibe coding
Let me zoom out and share some closing thoughts:
- This problem β counting colors in a Sheet β was an ideal task to be automated with code. Simple but tedious to do manually.
β - Creating this project without any AI help (like we used to do!) would have probably taken me 1 – 2 hours. With ChatGPT, it took under 30 minutes, and I was also able to multitask and work on other things whilst the model was churning away.
β - This style of coding was way easier and more relaxed than writing it myself. I had to think of the idea, but not stress over the intricacies of the code syntax.
β - I know how to write Apps Script, so I can broadly understand the code. So I can eyeball it and check it, which is definitely helpful. But since I didn’t have to make any changes to the code myself, it didn’t make a difference in this case.
To summarize, I think the LLMs are now good enough, with direction, to write these sorts of small automations in Apps Script. This really changes the game and opens up possibilities to non-coders to automate tedious manual tasks.
Some pointers:
- Be specific with your prompts.
β - Build in steps, rather than try to cram everything into the first prompt.
β - Ask for revisions or corrections if the generated code doesn’t give you expected answers.
β - Copy-paste any error messages into the LLM and ask it to fix the code.
β - Start small. Test frequently. Check your results. Ultimately, these AI chatbots are just tools. The buck stops with you.
I really encourage you to give it a shot.
Happy Vibe Coding! π
Template
Here’s the color coding Google Sheet template:
βSheets Insiders 23: Vibe Coding Color Counterβ
Go to the menu Extensions > Apps Script to see the code.
You will need to grant permission to the script to run the first time.
And, if you’re interested, here’s the chat history:
βChatGPT Vibe coding prompt session
And finally, here’s another commentary on vibe coding, including its limitations.