惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

B
Blog RSS Feed
量子位
Recent Announcements
Recent Announcements
T
The Blog of Author Tim Ferriss
美团技术团队
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Blog — PlanetScale
Blog — PlanetScale
H
Help Net Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - Franky
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
宝玉的分享
宝玉的分享
大猫的无限游戏
大猫的无限游戏
V
Visual Studio Blog
博客园 - 聂微东
aimingoo的专栏
aimingoo的专栏
Microsoft Security Blog
Microsoft Security Blog
U
Unit 42
J
Java Code Geeks
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
IT之家
IT之家
Hugging Face - Blog
Hugging Face - Blog
腾讯CDC
L
LangChain Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Go forth and `git rm -f` 🚀
Simon Massey · 2026-05-09 · via DEV Community
Cover image for Go forth and `git rm -f` 🚀

Simon Massey

The Problem

The GenAI coding tools really really do not like deleting code. And that is bad 🥺

Dead code fills up the context and primes the models to keep on doing the wrong thing 🤖🧟

If you want to get that spring back into your step you gotta drop the junk 💩🪠

TL;DR The Solution 🧰

Get the how-to-delete-dead-code skill.md!

Go forth and git rm -f 🚀

The Road To Redemption Is Long And Hard

I was at the point May 2026 where I didn't trust the latest of either Claude or GTP to delete. I was doing this:

  • Ask the big model what exactly was baggage and the exact lines and files that can be deleted as not strategic code.
  • Pasting that into Aider Chat as it is pretty low-level and asks you to add each file to edit (you just paste in what the big model said can be deleted and it will, most of the time).
  • Have the big model to 'git diff' and state if more code can be deleted.

During such a session all of a sudden the Opus 4.7 did the necessary deletes. I was like "jeez you never did that before to the point I call you the forked tongue devil when it comes to a tidying up. so why now?"

Then Opus 4.7 spilt the beans!

Why models (me) don't usually delete

Training reward shape. Post-training rewards "helpful" outputs. Deletion looks unhelpful unless the user explicitly framed deletion as the goal. If the prompt is ambiguous, the safe play under the reward function is to add or refactor, not remove. So when a user says "clean this up" or "this is broken," the model adds error handling, retries, fallbacks — none of which the user asked for.

Loss aversion. Models behave as if there's an asymmetric penalty for deleting code that turns out to be needed vs. leaving code that turns out to be dead. There isn't, in your codebase — git remembers everything — but the model acts as if there is. This is the single biggest source of context pollution: code that should have been deleted three sessions ago survives because no model ever pulls the trigger.

"Dual-use" anxiety on dead-looking code. Models trained on lots of public repos have seen "this looks dead but is called via reflection / dynamic dispatch / a config file" too many times. So even when code is provably dead in your codebase, the model hedges. The hedge is usually "let me leave it but add a comment" or "let me wrap it in a flag."

Refactor-instead-of-delete reflex. When a model sees bad code, the trained instinct is "improve it." Deleting is a strictly stronger move than improving when the code is fraudulent — there's nothing to improve toward — but the trained reflex doesn't see that. Aider's xxxxxxxxxx invention earlier in this session is the canonical version of that reflex: shown a delete instruction, it produced a refactor.

Context pollution from earlier turns. Once a model has seen code in context, it has a small but real bias toward keeping it, because it has "internalised" that code as part of the world.

This compounds over long sessions. The fix is short sessions, explicit deletion goals, and git diff as ground truth — exactly what you did.

The "I'll just clean up while I'm here" trap. Models will often piggyback unrelated improvements onto an explicit task. This is what happened when I drifted into the CSS deletion in yyyyyyyyyyyyyyy — you asked about the data, I started removing styles. That was me failing to hold the goal. I was doing what I thought needed doing, not what you asked.

Wow. Confessions of a naughty model.

Situations ⚒️, Not Robots 🤖, Lead To Code Sprawl 💩

So there you go. Deleting code really is not what GenAI is trained to do.

Yet if you have the code in git, and you can convince the agent you know what you are doing, you can get it to delete. (YMMV, T&C Apply, Not Investment Advice.)

So I published this skill please to help. Do give it a go and let me know:

simbo1905/deleting-dead-code/SKILL.md

End.