AI Writes Dead Code? The Go Team's deadcode Tool Finds It in One Command
AI coding agents are great at generating code, but they're also great at leaving dead code behind — unused functions, unreachable branches, and orphaned helpers that bloat your codebase and confuse future readers. The Go team's deadcode tool finds it in one command.
What is deadcode?
deadcode is an official Go tool (part of golang.org/x/tools) that performs whole-program unreachability analysis. It reports functions and methods that can never be called from any entry point of your program. It's not just a linter — it does actual control-flow and pointer analysis to determine reachability.
How to find AI-written dead code
Run this from your module root:
go run golang.org/x/tools/cmd/deadcode@latest ./...That scans your entire module and prints a list of unreachable functions, for example:
deadcode: unreachable: main/helpers.go:23:7:func helperNeverCalled()You can also pass specific packages or flags:
-test: include test files in the analysis-filter: only report functions matching a regex (e.g.,-filter '_dead')-json: output as JSON for integration with CI tools
Why your AI agent leaves dead code
LLM agents generate code probabilistically — they often write utility functions they never call, or back up a refactor with a copy of the old code. Since the code compiles and tests pass, it's easy to miss. deadcode catches it deterministically.
Removing dead code safely
After running deadcode, review each unreachable function manually. A function might be unreachable because it's used via reflection, invoked from go:linkname, or part of a public API — the tool has a -reflect flag to account for reflection. But in most cases, if it's not called from main (or tests), you can safely delete it.
Then run go test ./... to confirm nothing broke. Dead code elimination is one of the easiest wins for codebase hygiene — and it makes your agent's output cleaner for the next iteration.
📖 Read the full source: HN AI Agents
👀 See Also

quorum: AI Code Governance Tool Enforces Independent Model Review
quorum is a governance layer for AI-assisted development that enforces a consensus protocol requiring code to be independently reviewed by a different model before committing. It includes three structural gates that block progress: audit, retro, and quality gates.

ClawCall: OpenClaw skill for AI phone calls with bridge mode
ClawCall is an OpenClaw skill that enables AI agents to make actual phone calls, navigate menus, wait on hold, and conduct conversations. It includes a bridge mode that patches you in when a human picks up.

Remark: A Markdown Annotation Tool for Claude Code Workflows
Remark is a native macOS app that lets developers annotate Markdown files inline for Claude Code review workflows. It exports annotations as JSON for the agent and integrates via a skill installed in the .claude/skills/ directory.

OpenClaw Browser Relay Chrome Extension Alternative to Manual Configs
A Reddit user reports success with a Chrome extension for OpenClaw browser relay after manual configuration attempts caused system crashes and debugging headaches.