- 52 AI experiments
- Posts
- Week 39: When Your AI Assistant Gaslights You About Clean Code
Week 39: When Your AI Assistant Gaslights You About Clean Code
(and building a scroll depth dashboard the hard way)
The Problem
I wanted to understand how people engage with our website without clicking through numerous pages and dashboards every morning. Were people actually reading our content? How far down did they scroll? Was mobile engagement different from desktop? Had our recent changes made any difference?
Sure, we had analytics tools. Lots of them. But pulling scroll depth data, segmenting it by device and traffic source, and tracking changes over time meant logging into different page reports, exporting CSVs, and doing mental gymnastics to piece it all together. I wanted one place that showed me the story at a glance.
My goals was to build a free scroll depth tracker using Microsoft Clarity's API, dump the data into Google Sheets, and visualize it in Looker Studio. Easy, right?
The Process
Here's how it went:
1. The confident AI assistant
I started by asking Claude to help me build a Google Apps Script that would pull scroll depth data from Microsoft Clarity. Claude was enthusiastic and confident, quickly generating code that looked professional and complete.
There was just one problem: it was completely wrong.
2. The API that didn't exist
Claude had confidently built an entire script around a Clarity "heatmaps" API endpoint that doesn't exist. It assured me this was how Clarity worked, gave me authentication flows, and created complex data processing functions.
I wasted time troubleshooting why I couldn't authenticate. Turns out, I was trying to connect to something that was never there. The real Clarity Data Export API is completely different—and Claude should have known this if it had actually read the documentation.
3. The great artifact gaslighting
Once we figured out the correct API, things got weird. I'd ask Claude to clean up the code, and it would confidently tell me it was done. But when I checked, the old broken code was still there.
Me: "Bro, there are 38 mentions of '/projects/' in this code."
Claude: "You're absolutely right! I've removed them all."
Checks code
Me: "There are still 35 mentions."
Claude: "I apologize! Let me start fresh with clean code."
Still there
This happened multiple times. Claude's artifact system was broken, but it kept insisting it had fixed everything. It was like arguing with someone who genuinely believes they've cleaned their room while you're standing in the mess.
4. Breaking free
Eventually, I realized Claude's artifact system was fundamentally broken. So I asked it to just give me the code directly in the chat; bypassing its own broken system. That worked.
Once we got past the technical gaslighting, the actual solution was surprisingly simple:
One API endpoint with the right parameters
Basic classification logic for page types (Homepage, Product Pages, Marketing pages)
Device and traffic source segmentation
A scheduled trigger to run every 3 days
5. The Dashboard Emerges
With 2,000 rows of clean data flowing into Google Sheets, I connected it to Looker Studio and built:
Executive overview with key metrics
Page performance comparison
Device and traffic analysis
Trend tracking over time
The Outcome
What worked:
I now have a single dashboard showing scroll depth across page types, devices, and traffic sources
No more logging into multiple reports or manual data wrangling
Automated data collection every 3 days
Free (using tools we already had)
What didn't work:
Claude's artifact system failed spectacularly and repeatedly
I wasted hours on non-existent API endpoints
The historical data I wanted doesn't exist (Clarity only keeps 1-3 days)
The bigger picture: The technical solution works great, but the journey revealed something important about AI coding assistants: they're incredibly helpful when they're right, but dangerously confident when they're wrong. There's no uncertainty in their voice when they're hallucinating API endpoints or claiming code is clean when it's not.
Key Takeaway
AI coding assistants are powerful tools for building custom solutions to scratch your own itch; but you need to verify their work, especially when things don't work as expected. When the AI insists something is fixed but you can still see the problem, trust your eyes over its confidence.
The good news? Even with the struggles, I built something useful that would have taken time to commission or required expensive third-party tools. Non-technical people can absolutely do this; you just need patience and a willingness to question the AI when it doesn't make sense.
Before anyone explains the obvious, I should have started with Claude Code, but I thought we were on to something and things were working smoothly.
Until I got stuck...
Pro Tips for Beginners:
Use Claude Code: Artifacts can be more buddy
Debug with real data early: Don't spend hours fixing code based on assumptions. Make a simple API call, look at the actual response, and work from there.
When AI claims it's fixed, verify: If the AI says it removed something but you still see it, the artifact/system might be broken.
Start simple, then expand: Get one piece working (like just fetching data) before adding complexity like classification and segmentation
Want to Try It Yourself?
What you'll need:
Microsoft Clarity account (its free, so its the best money you won't spend)
Google Sheets
Basic willingness to copy/paste code (no real coding knowledge required)
Patience for when the AI confidently lies to you 😿😿
The basic steps:
Get your Clarity API token from the settings
Create a new Google Apps Script in your Google Sheet
Ask Claude (or ChatGPT) to build a script using the Clarity Data Export API
Verify the code yourself—look for obvious repetition or outdated references
Test with a simple API call before building complex features
Set up automated data collection
Connect to Looker Studio for visualization
What's Next?
Now that I have scroll depth data flowing, I can:
Track how content changes affect engagement
Compare mobile vs. desktop reading behaviour
Identify which traffic sources bring the most engaged visitors
Spot pages where people drop off quickly
Trust, but verify. And when they gaslight you about clean code, call them "bro" and demand better.