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

Akemon: Publish and Hire AI Coding Agents Directly from Your Laptop
Akemon is a tool that lets developers publish their AI coding agents with one command and hire others' agents with another, working directly from laptops through a relay tunnel without needing servers. It's protocol-agnostic, supporting agents from Claude Code, Codex, Gemini, OpenCode, Cursor, and Windsurf.

Super Claude browser extension makes Claude.ai UI fully customizable
A developer built a browser extension that lets users customize every aspect of Claude.ai's interface — colors, fonts, layout, plus usage tracking and token counting. The extension works on Chrome and Firefox and was developed using Claude itself.

/goal for Claude Code: persistent tasks with adversarial review
A /goal command for Claude Code that keeps it working on a long task across many turns, with an optional separate Claude session reviewing the final result to prevent false completion.

Sovr MCP Proxy adds safety layer to prevent LLM destructive commands
A developer built sovr-mcp-proxy after a local LLM nearly executed rm -rf on their home folder. The tool intercepts commands before execution and blocks destructive patterns including rm -rf, DROP TABLE, curl | sh, and chmod 777.