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

Codebook Lossless LLM Compression: 10-25% RAM Reduction with Bitwise Packing
A developer's proof-of-concept code demonstrates lossless LLM compression by packing fp16 weights into blocks, achieving 10-25% RAM reduction with a trade-off of approximately halved inference speed. The approach identifies that most models only use 12-13 bits of unique values despite fp16's 16-bit representation.

Rudel: Open-source analytics for Claude Code sessions
Rudel is an open-source analytics tool that analyzes Claude Code sessions, providing insights from 1,573 real sessions with 15M+ tokens and 270K+ interactions. It reveals patterns like 4% skills usage, 26% abandonment rates, and error cascade patterns.

Claude Code v2.1.76 System Prompt Updates: Security Monitor Refinements and New Hook Event
Claude Code v2.1.76 includes updates to system prompts with 43 new tokens, featuring refinements to the security monitor for autonomous agents and the addition of a PostCompact hook event. Changes include clarified sensitive data detection, expanded code deserialization examples, and improved formatting for irreversible local destruction guidance.

cowork-session-sync v1.0.0 provides session continuity for Claude Cowork
cowork-session-sync v1.0.0 is a tool that maintains session continuity for Claude Cowork by archiving raw transcripts, distilling them to Markdown, and enabling one-phrase bootstrap with 'catchup-bunny' to restore full context.