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

Hipocampus: A Persistent Memory System for AI Agents Using Compaction Trees
Hipocampus addresses the problem of AI agents forgetting context between sessions by implementing a compaction tree that compresses conversation history through five levels: raw → daily → weekly → monthly → root, with a topic index called ROOT.md.

Blindspot MCP: An External Brain for AI Coding Agents
Blindspot MCP is a tool that indexes full codebases using tree-sitter and SQLite to help AI coding agents understand symbols, dependencies, and relationships across files, preventing changes that break code outside their immediate context.

Publicly Hosted MCP Servers for Health, Academic, and Government Data
A developer has built and publicly hosts 14 MCP servers providing access to CDC datasets, clinical trials, FDA data, academic publications, congressional information, weather data, and other utilities. These servers require no setup, API keys, or local installation.

Claude Code Routines: Schedule Agent Tasks Like Cron with Reasoning
Claude Code Routines let you run agent tasks on a schedule without keeping a session open. A Reddit user shares real examples: nightly commit review, weekly dependency check, daily error log analysis — with AI reasoning instead of raw script output.