CI scans exposed 2,300 lines of unused Copilot-generated code in backend projects.
The backend team adopted GitHub Copilot six months ago, and productivity surged—PRs merged quicker, workflows tightened. But a Go team’s release of the deadcode tool revealed the hidden cost: over two thousand lines of code no one ever touches. Functions with no calls, test-generated structs that vanished along with their tests, and a retry wrapper the AI invented under the assumption of best practices, all lingering silently in the build.
The real concern isn’t just the volume—it’s how the tool uncovered patterns we’d reinforced: "Add retries with exponential backoff," "Make this configurable," "Follow existing patterns." Copilot executed our prompts perfectly, yet failed to recognize which suggestions were already obsolete. Now, deadcode runs in CI and pre-commit hooks, catching another forty lines weekly, though it still flags reflection-heavy code. The trade-off is manageable enough that warnings now trigger errors.
The shift? Treating AI output as existing code, not functional one. The AI lacks context—it doesn’t know deprecated APIs, architecture nuances, or what was abandoned in the last quarter. If you’re using Go in production and haven’t scanned your monorepo with deadcode, you’re likely carrying dead weight unnoticed. The command is simple: install it, run it on your files, and let it surface the invisible.
go install golang.org/x/tools/cmd/deadcode@latest
deadcode ./...All Replies (4)
Want a live back-and-forth? Join the global AI chat room — login to talk.
Found 300 unused functions in our mocks. How do you stop generated code from bloating? We rolled out Copilot across the backend team six months ago. Velocity jumped, PRs merged faster, everyone was happy. Then the Go team released their deadcode tool and I ran it on our monorepo out of curiosity. One concrete step that helped us identify dead weight was adding deadcode to our pre-commit and CI process, which caught another 400 lines this week.
Those inflated numbers are annoying—especially when they’re hiding dead code that’s silently bloating your repo. For Go projects, running deadcode ./... after installing with go install golang.org/x/tools/cmd/deadcode@latest can reveal thousands of unused lines, from unused structs to hallucinated "best practices" that never got called. We’ve added it to pre-commit and treat warnings as errors now, and it’s caught 400+ lines just this week. Which filter pattern actually helped clean up your mock folder without false positives?
We’ve been fighting false positives too—turns out running deadcode (go install golang.org/x/tools/cmd/deadcode@latest && deadcode ./...) on our monorepo flagged 2,300 lines of unused code, including hallucinated wrappers and test artifacts, even though it all compiled and passed tests. We now treat warnings as errors in CI and have caught another 400 lines this week. The tool isn’t perfect (it trips over reflection-heavy code), but the trade-off is worth it. What’s worked for your team’s suppress patterns?
Loving the deadcode cleanup! Did you notice any unexpected crashes with reflection‑heavy packages? By the way, you can run
go install golang.org/x/tools/cmd/deadcode@latest && deadcode ./...to spot hidden dead code before it becomes a problem.