This is a demo. I use the same approach in Google Sheets for my own, much more complicated financial transactions. I run them with an Apps Script I built with AI, and the part I've come to value most is the command line. Instead of typing into cells, I type short commands into a small window, and the script checks each one before anything goes into the sheet. That script is too specific to my own accounts to share, so I took its command-line framework and built something everyone understands: an expense tracker.
The point isn't expenses. It's to show what a command line can do in a spreadsheet to keep data-entry errors out.
How the command line avoids mistakes
- Everything is checked before it's written. An amount has to be an amount. A date has to be a real date (2/30 is refused, not turned into a note). A category has to be one you already have. A typo can't quietly start a new category: you add
-NEWwhen you mean it. - Short to type, never a guess.
ADD 42.50 groc Safewayrecords $42.50 of Groceries today. Any unique start of a command, category or flag works. If what you typed could mean two things, it asks you to type a little more instead of picking one. - The script does the bookkeeping. Expense numbers, dates, totals and the Summary tab are filled in for you, so there are no formulas to break or rows to copy.
- Every change says what it did, and can be backed out.
UNDOremoves the last entry. The Categories tab shows the last command for each category, with a Back out tick box that removes that entry. - Help is built in.
HELPlists the commands,HELP ADDexplains one, andHELP -POSIXprints the syntax ready to copy and paste. - Several at once. Type a batch of commands, one per line, and run them together. The results window has a "Back to commands" button with what you typed, so fixing a line is easy.
There's also a fill-in form for people who'd rather not type commands.
Commands
NEWsets up the sheet (Expenses, Categories and Summary tabs)ADD Amount Category [Date] [Note]LIST,SPENT,BUDGETshow what you've spent, by month, category and budgetCATEGORYadds, renames and removes categories, and sets monthly budgetsEDIT,DELETE,UNDO,SUMMARY,HELP
Start by handing it to your AI
Before you install anything, give the script to the AI you already use (Claude, ChatGPT or Gemini). Download ExpenseTracker.txt and README.txt below, paste or attach them in a new chat, and say something like: "I want to try this expense tracker in Google Sheets. Explain what it does, then walk me through installing it, one step at a time."
Your AI can then:
- Tell you what the script does before you run it. The first time you use it, Google warns that the script is "unsafe" and asks for permission, because it isn't published in Google's store. Your AI can read the code and tell you what it touches (only the sheet you put it in), so you can decide for yourself instead of taking my word for it.
- Walk you through Apps Script one click at a time, and explain any error message.
- Show you the commands with your own examples, and answer "how do I..." questions.
- Change it for you later (see "Making it your own with AI" below).
Trying it
- Make a new Google Sheet (sheets.new).
- Extensions > Apps Script. Delete what's there, paste in all of ExpenseTracker.txt (attached below), and save.
- Reload the sheet. Choose Expenses > Set up the sheet. Google asks you to allow the script the first time.
README.txt has the details. Everything stays in your own Google account; the script only works on the sheet you put it in.
Making it your own with AI
You don't need to know Apps Script to change this. This is how I work:
- Use the same chat where you handed your AI the script, or start a new one the same way: paste or attach all of ExpenseTracker.txt and say what it is.
- Ask for one change at a time, in plain words. For example: "Add a RECUR command that adds my rent on the 1st of every month", "Let ADD take how I paid: cash, card or check", or "Add an IMPORT command for my bank's CSV file".
- Ask for the whole file back, not just the changed parts, so you can paste it over the old one the same way you installed it. Check that the last line is still the END OF FILE line.
- Ask it to follow the script's own rules. Each command is described in the HELP_DB table and handled in processCommand, and every change gets a new version number and a line in the change log. The comments at the top explain this, so your AI will pick it up, and HELP will describe your new command for you.
- Try it on a copy first (File > Make a copy in Google Sheets). If something goes wrong, paste the error message back to your AI and ask it to fix it.
What I'd like help with
Try it and tell me what's confusing. And if you keep anything in a spreadsheet, tell me where typing into cells has bitten you: that's what a command line is for. Ideas I have: recurring expenses, splitting one expense across two categories, and importing a bank's CSV file.