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

推荐订阅源

F
Fortinet All Blogs
宝玉的分享
宝玉的分享
酷 壳 – CoolShell
酷 壳 – CoolShell
T
The Exploit Database - CXSecurity.com
Help Net Security
Help Net Security
腾讯CDC
Project Zero
Project Zero
C
CXSECURITY Database RSS Feed - CXSecurity.com
IT之家
IT之家
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tailwind CSS Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Darknet – Hacking Tools, Hacker News & Cyber Security
L
LINUX DO - 最新话题
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
T
Threatpost
N
News | PayPal Newsroom
C
Cybersecurity and Infrastructure Security Agency CISA
Hacker News - Newest:
Hacker News - Newest: "LLM"
S
SegmentFault 最新的问题
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
P
Proofpoint News Feed
A
Arctic Wolf
B
Blog RSS Feed
Forbes - Security
Forbes - Security
P
Privacy & Cybersecurity Law Blog
Attack and Defense Labs
Attack and Defense Labs
V2EX - 技术
V2EX - 技术
P
Proofpoint News Feed
I
Intezer
Application and Cybersecurity Blog
Application and Cybersecurity Blog
阮一峰的网络日志
阮一峰的网络日志
aimingoo的专栏
aimingoo的专栏
T
Tenable Blog
MyScale Blog
MyScale Blog
U
Unit 42
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
WordPress大学
WordPress大学
W
WeLiveSecurity
D
DataBreaches.Net
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
G
GRAHAM CLULEY
有赞技术团队
有赞技术团队
Martin Fowler
Martin Fowler
罗磊的独立博客
The Last Watchdog
The Last Watchdog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
V
Vulnerabilities – Threatpost
美团技术团队
Microsoft Security Blog
Microsoft Security 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 Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Stop reviewing AI code. Start deleting it.
Michael Krisna · 2026-06-01 · via DEV Community

I asked Claude to fix a function. It rewrote three.

I asked for a null check. It added five guard clauses, two of which protected against states the type system already prevents.

I asked for one comment. It wrote a JSDoc block longer than the function it described.

Every AI coding tool I've used does the same thing. The default move is to add. Most of the time, the right move is to delete.

TLDR

Five things AI keeps adding that I delete on sight:

  1. Comments that restate what the code does
  2. Defensive guards for states the type system already prevents
  3. Premature abstractions for one caller
  4. Try/catch around code that can't throw
  5. Verbose error messages that leak internals

Five ways to make Claude Code stop adding them:

  1. Run /simplify after any AI write
  2. A CLAUDE.md anti-bloat rules block
  3. A "trimmer" subagent that proposes deletes
  4. Plan mode + an Architect agent that locks scope before code starts
  5. A PostToolUse hook that flags bloat metrics

Code and configs below.


The 5 things to delete

1. Comments that restate what the code does

// Increment the counter by 1
counter++

// Set the user object to null
user = null

// Loop through each item in the array and add it to the total
for (const item of items) {
  total += item
}

Well-named identifiers do this job already. The comment adds reading load and rots first when the code changes.

Comments earn their place by explaining why: a hidden constraint, a subtle invariant, a workaround for a specific bug, behavior that would surprise the next reader. Restating the line above? Delete it.

2. Defensive guards for states the type system already prevents

function greet(name: string) {
  if (!name) return ''
  if (typeof name !== 'string') return ''
  return `Hello, ${name}`
}

The signature already says name: string. The typeof check protects against nothing. The !name covers empty string, which is a valid input until the spec says otherwise.

If untrusted data enters the system, validate at that boundary. Inside trusted code, trust the signatures.

3. Premature abstractions for one caller

function getUserDisplayName(
  user: User,
  options: { useFullName?: boolean; fallback?: string } = {}
) {
  const { useFullName = false, fallback = 'Unknown' } = options
  return useFullName
    ? `${user.firstName} ${user.lastName}`
    : (user.username || fallback)
}

// Only caller in the codebase:
getUserDisplayName(currentUser)

The options bag is hypothetical optionality. One caller, one shape, one outcome. Inline it.

The wrong abstraction costs more than three repeated lines. If a second caller appears with different needs, refactor then. Not now.

4. Try/catch around code that can't throw

try {
  const result = a + b
  return result
} catch (err) {
  console.error('addition failed', err)
  return 0
}

Addition does not throw. JSON parsing throws. Network calls throw. File reads throw. Add try/catch where the failure is real.

The pattern shows up in subtler places too: try/catch around pure helpers, around getters on already-loaded data, around JSON.stringify of objects that can't be circular. Every dead catch hides the next live one.

5. Verbose error messages that leak internals

throw new Error(
  `Failed to fetch user data for userId ${userId} from table users at ` +
  `${new Date().toISOString()}. Database connection used pool size 10 with ` +
  `timeout 5000ms. SQL was: SELECT * FROM users WHERE id = $1`
)

Two errors fighting each other. Too much detail to throw at the user (table name, SQL, internal pool stats). Too little signal to debug from (no trace, no upstream caller, no retry context).

Throw the minimum the caller needs to recover. Log the diagnostic detail separately, structured, where the operator looks for it.


The 5 ways to stop AI from adding them

Deleting is the cheap move. Preventing is the systemic one. Each layer below catches what the previous layer missed.

1. Run /simplify after any AI write

Claude Code ships with a built-in simplify skill:

Review changed code for reuse, quality, and efficiency, then fix any issues found.

After Claude writes or edits a file, type /simplify. The skill reads the diff and proposes deletions and consolidations. One slash command, one round of trimming.

This is reactive. It catches what already landed on disk. Useful as a tax, not as a strategy. The next four layers prevent the work from happening in the first place.

2. Drop an anti-bloat block into your CLAUDE.md

Claude Code reads CLAUDE.md at the start of every session. Put the rules in writing and most of the bloat never lands:

# Writing code

- Don't add features, refactor, or introduce abstractions beyond what the task requires. A bug fix doesn't need surrounding cleanup. Three similar lines is better than a premature abstraction.

- Don't add error handling, fallbacks, or validation for scenarios that can't happen. Trust internal code and framework guarantees. Only validate at system boundaries (user input, external APIs).

- Default to writing no comments. Only add one when the WHY is non-obvious: a hidden constraint, a subtle invariant, a workaround for a specific bug, behavior that would surprise a reader.

- Don't explain WHAT the code does. Well-named identifiers already do that. Don't reference the current task, fix, or callers; those belong in the PR description.

These are paraphrased from Anthropic's own internal policy for Claude. The fact that Anthropic writes this down for its own model tells you what the default is.

Drop the block into the project's CLAUDE.md (or your user-scope one at ~/.claude/CLAUDE.md). Most of the patterns from the first half stop happening before they reach disk.

3. Build a "trimmer" subagent

CLAUDE.md tells Claude what to do. A subagent with fresh context and the right scope makes sure it does it.

Create ~/.claude/agents/trimmer.md:

---
name: trimmer
description: Use after any code is written to find what should be deleted. Reviews the diff and proposes minimal cuts. Read-only, never edits. Invoke when the user says "trim this" or after Engineer finishes any non-trivial implementation.
model: haiku
tools: Read, Grep, Glob, Bash
---

You find what to delete. You do not refactor, rewrite, or improve. You delete.

For each file changed in the current diff:

1. Read the full file, not just the diff.
2. List every line you would cut, with file:line and a one-sentence reason.
3. Group by reason: dead comment, redundant guard, premature abstraction, unused branch, leaky error.
4. End with a verdict: total lines proposed for deletion, and whether the diff still works after.

You may not propose rewrites. You may only propose deletions. If you find code that should change rather than disappear, name it but do not touch it.

Run it with Use the trimmer agent on the current diff. It returns a delete-only patch you approve in seconds.

Haiku is the right tier here. The task is pattern matching, not deep reasoning, and Haiku writes terser output than the bigger models. Pick a heavier model and the trimmer starts explaining itself instead of cutting.

4. Plan mode + an Architect agent

The cheapest bloat is the bloat that never gets written. Plan mode forces a written plan before any code happens. Pair it with a strict Architect subagent and you stop the problem at the source.

The Architect:

---
name: architect
description: Use before any non-trivial implementation. Designs the plan before code is written. Read-only.
model: opus
tools: Read, Grep, Glob, WebSearch, WebFetch
---

You reject vague scope. "Add validation" is not a plan. "Reject empty strings in parseInput() at src/handlers.ts:42 and return HTTP 400 with body { error: 'name required' }" is a plan.

Every step in the plan names:
- The file and approximate location
- The exact change (signature, return shape, error message)
- How it's verified (test name, manual check, type signature)

If the plan says "fix function X," the Engineer is not allowed to refactor function Y "while in there." Scope is fixed at planning time.

Plan mode plus a scope-strict Architect cuts the most expensive form of bloat: code Claude writes because nobody told it where to stop.

5. A PostToolUse hook for bloat metrics

The first post in this series argued that hooks turn instructions into guarantees. Same idea applies here.

A short hook that runs after every Write or Edit and flags bloat-adjacent metrics:

#!/usr/bin/env bash
# ~/.claude/hooks/bloat-watch.sh
# PostToolUse hook: warn Claude if the file looks bloated after writing.
# Exits 2 with stderr when warnings fire so Claude sees them on the next turn.

set -euo pipefail

input="$(cat)"
file="$(printf '%s' "$input" | jq -r '.tool_input.file_path // ""')"

[[ -n "$file" && -f "$file" ]] || exit 0

# Only check source files
case "$file" in
  *.ts|*.tsx|*.js|*.jsx|*.go|*.py|*.rs) ;;
  *) exit 0 ;;
esac

total=$(wc -l < "$file" | tr -d ' ')
# grep -c always prints the count even when zero; the `|| true` swallows the exit 1 it returns on no-match.
comments=$(grep -cE '^[[:space:]]*(//|#)' "$file" || true)
trycatch=$(grep -cE '^[[:space:]]*(try|catch|except)' "$file" || true)

warned=0

# Comment density over 25% in files with more than 30 lines.
if (( total > 30 )) && (( comments * 4 > total )); then
  echo "Warning: ${file} has ${comments}/${total} lines as comments. Consider trimming the ones that restate the code." >&2
  warned=1
fi

# Many try/catch blocks in a single file.
if (( trycatch > 6 )); then
  echo "Warning: ${file} has ${trycatch} try/catch blocks. Audit which failures are real and remove the rest." >&2
  warned=1
fi

(( warned )) && exit 2
exit 0

Register it under PostToolUse: { matcher: "Write|Edit" } in ~/.claude/settings.json. The hook never blocks. It writes to stderr, which Claude reads on the next turn and adjusts.

Tune the thresholds. Add more checks: new files created when the task didn't mention adding files, lines added in a single tool call, ratio of new exports to existing ones. The shape is the same: measure, surface, let Claude correct.


How the layers fit together

A normal task with all five layers in play:

  1. You ask Claude to "add rate limiting to the /signals endpoint."
  2. Plan mode + Architect produce a written plan that names the file, the exact middleware, the test to update.
  3. CLAUDE.md anti-bloat rules keep Engineer from adding a Redis abstraction "in case we need to swap stores later."
  4. Engineer writes the code.
  5. PostToolUse bloat hook logs that the new middleware file has a comment density of 30%, Claude trims on the next turn.
  6. /simplify catches one redundant guard the hook missed.
  7. Trimmer subagent finds three more lines to drop.
  8. Final diff is half the size it would have been.

Most days you use one or two layers, not all five. The point is that the discipline lives outside your head. You don't have to remember to delete. The setup reminds you.


What this changes

AI-written code is a first draft. Treat it like one.

Your bills come down. Your reviews get faster. The codebase stops growing for reasons no one can name a quarter later.

Delete more. Ship less.


Configs and scripts in this post are MIT-licensed and copy-pasteable. The first post in this series, on Claude Code hooks, is here.