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

推荐订阅源

V
Vulnerabilities – Threatpost
AI
AI
D
Darknet – Hacking Tools, Hacker News & Cyber Security
L
LINUX DO - 热门话题
G
GRAHAM CLULEY
Cisco Talos Blog
Cisco Talos Blog
T
Tenable Blog
L
Lohrmann on Cybersecurity
Know Your Adversary
Know Your Adversary
A
Arctic Wolf
T
Threatpost
AWS News Blog
AWS News Blog
S
Securelist
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
J
Java Code Geeks
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
The GitHub Blog
The GitHub Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
C
Cisco Blogs
F
Full Disclosure
Jina AI
Jina AI
Engineering at Meta
Engineering at Meta
I
InfoQ
C
CXSECURITY Database RSS Feed - CXSecurity.com
I
Intezer
C
CERT Recently Published Vulnerability Notes
Last Week in AI
Last Week in AI
P
Privacy International News Feed
Scott Helme
Scott Helme
WordPress大学
WordPress大学
Simon Willison's Weblog
Simon Willison's Weblog
D
Docker
T
Threat Research - Cisco Blogs
P
Proofpoint News Feed
C
Cyber Attacks, Cyber Crime and Cyber Security
Y
Y Combinator Blog
T
Tor Project blog
V
Visual Studio Blog
Spread Privacy
Spread Privacy
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Google DeepMind News
Google DeepMind News
B
Blog RSS Feed
Google Online Security Blog
Google Online Security Blog
C
Check Point Blog
爱范儿
爱范儿
N
News and Events Feed by Topic
博客园 - 【当耐特】
TaoSecurity Blog
TaoSecurity Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main

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 Claude Code from Lobotomizing Itself Mid-Task
Ian L. Pater · 2026-05-19 · via DEV Community

Claude Code has a feature called auto-compact that quietly destroys your session quality.

The Problem

I was three hours into a multi-file refactoring session, had just finished explaining which modules needed interface changes and which were already done. Auto-compact fired at 80% context. When Claude came back, it had no idea which files had been edited and which still needed changes. It suggested modifying a file I'd finished an hour earlier and forgot a constraint I'd repeated twice. I had to re-explain the entire task from scratch.

The community calls this "lobotomization" and it's accurate. Post-compaction Claude loses track of what repo you're in, forgets constraints you set, drops skills you invoked. The quality drop is immediate and obvious.

A note on terminology: throughout this post I reference /flush, /project, and other slash commands. These are custom Claude Code skills I built (stored as markdown files in ~/.claude/commands/), not built-in features. /project loads a project's saved state (CLAUDE.md with Working/Blocked/Next, domain topic files, recent daily logs) so Claude knows what happened last session. /flush captures the current session state to multiple places (daily log, project state, MEMORY.md, topic files) so the next session can pick up where this one left off. Think of /project as "load game" and /flush as "save game." The skill files are simple markdown prompts that Claude follows as instructions.

The Technical Reality

Community analysis of Claude Code's minified source found a hardcoded buffer that triggers compaction. The exact value has changed across versions (it was ~13k in early 2026, reportedly ~33k in later builds), but the mechanism is the same:

var jbA = 13000;

function lwB() {
    let T = UhT();      // Available input (context - max_output_tokens)
    let R = T - jbA;    // Subtract 13k buffer
    return R;           // This is where auto-compact triggers
}

Enter fullscreen mode Exit fullscreen mode

Buffer Reserved = max output tokens + safety buffer.

Output Token Setting Buffer Reserved Usable Context
64k (max) 77k (38.5%) 123k
32k (default) 45k (22.5%) 155k
Auto-compact off None 200k

With default settings, you're losing 22.5% of your context window to a safety buffer you may never need.

These numbers reflect the ~13k buffer from early 2026 builds. If the buffer has increased in your version, the usable context will be lower. The principle holds regardless: auto-compact reserves a meaningful chunk of your context window.

Why This Matters

Research on iterative context rewriting (arXiv 2510.04618) calls it "context collapse": when LLMs rewrite their own context iteratively, accuracy drops. Claude Code's auto-compact does exactly this.

Compaction is lossy compression. You're asking an LLM to decide what's "important" and discard the rest. For the kind of work I do (multi-file refactors, constraint-heavy debugging sessions, anything where I've spent twenty minutes explaining what not to touch), that's a bad tradeoff.

The Fix

Add one line to ~/.claude.json:

{
  "autoCompactEnabled": false
}

Enter fullscreen mode Exit fullscreen mode

Or run /config in an active session and toggle "Auto-compact enabled" off.

The New Workflow

With auto-compact disabled, you get the full 200k context window with no buffer held in reserve. No surprise compaction mid-task. The session stays coherent until you decide otherwise.

When I do need to reclaim context, I use /compact with explicit instructions: /compact "focus on the authentication refactor, discard the earlier debugging". This way I control what survives instead of letting Claude guess. More often, though, the better move is /export to save the conversation, then start a fresh session and have Claude read it back in. Fresh context, curated history, no lossy summarization.

I also dropped my flush threshold from 75% to 60%. When context hits 60%, Claude prompts me to run /flush before continuing. This captures the session state while there's still room to maneuver.

The Tradeoff

Disabling auto-compact means sessions will hit the context limit. You'll need to manually compact, export and restart, or finish the task before running out. I'd rather use that 45k toward skills, rules, and context I deliberately set up than reserve it for an automatic summarization that makes Claude worse.

Anthropic's own guidance has moved toward recommending auto-compact stay enabled, and for simple single-task sessions that's reasonable. For constraint-heavy work where I've built up significant context (multi-file refactors, debugging with specific rules about what not to touch), the automatic summarization loses too much.

Claude Code now supports 1M token context windows on some plans, which reduces the urgency of this problem. But context hygiene still matters at any window size. A 1M window fills up the same way a 200k window does, just slower. Knowing when to flush deliberately versus letting auto-compaction guess is a workflow discipline, not a context size question.

Session Management (Beyond Compaction)

The Context % Statusline

I have a custom statusline script that shows [XX%] at every prompt so I always know how much context is left. The script reads context_window.used_percentage from Claude Code's JSON input and renders it inline:

# ~/.claude/statusline-command.sh
PERCENT=$(echo "$input" | jq -r '.context_window.used_percentage // 0' | cut -d. -f1)
printf "\033[01;32m%s@%s\033[00m:\033[01;34m%s\033[00m [%s%%]" "$user" "$host" "$cwd" "$PERCENT"

Enter fullscreen mode Exit fullscreen mode

The Emergency Rescue

When you hit >90% and can't even run /flush (the output won't fit), the workaround is a second terminal:

# In the dying session:
"Write a summary of everything we've done to ~/session-dump.txt"

# In the fresh session:
"Read ~/session-dump.txt and run /flush for those projects"

Enter fullscreen mode Exit fullscreen mode

The dying session has enough context left to write a file. The fresh session has enough context to process it. One session as the brain, the other as the hands.

Thresholds

Context % Action
<60% Work normally
60% Claude suggests /flush
85% Claude auto-runs /flush (non-interactive)
>90% Emergency: dump to file, rescue from new session
100% Session dead. Hope you flushed.

The Session Lifecycle

Session Start: /project

Every session starts with /project <name>, which fuzzy-matches against a project index, reads the project's CLAUDE.md (including the State section with Working/Blocked/Next), pulls in domain-specific topic files, and checks recent daily logs for open threads. After that, Claude knows what I was doing last session, what's blocked, and what's next. I've wasted enough time re-explaining context to treat this as non-optional.

During the Session

MEMORY.md is always available (auto-loaded). Topic files get pulled when the task crosses domains. Context files from llm-context/ are loaded as needed.

Session End: /flush

Think of /flush as a save game hotkey. You just scraped through a gnarly debugging session, you're at 65% context, and the next task is going to be heavy. /flush captures session state to three or four places: daily log, project state (Working/Blocked/Next), MEMORY.md for new lessons, and optionally a domain topic file if something specialized came up. All append-only, new entries prepended, old entries never dropped.

I learned the hard way that skipping /flush before switching tasks means the next session starts cold. Claude picks up CLAUDE.md and has no idea what happened in the gap.

I watched this exact failure mode play out over three months on a cron health system, where each cold-start session ratified a broken fix (see: The LLM Kept Saying ‘Fixed.’).

After /flush: Why /clear Beats /compact

After flushing, I use /clear instead of /compact. Compaction spends tokens on a lossy summary. /clear costs zero tokens and gives a clean 200k window. The memory system means nothing is lost: /flush already persisted everything worth keeping, and /project reloads it.

/compact still has a use case mid-session (at ~70% context, same task, don't want to reload everything). For session boundaries, /clear is strictly better.

Daily Cron

Drift check confirms indexes match filesystem reality. Heartbeat alerts for overdue P1 tasks get written to the daily log automatically.

Data Flow Summary

/project (read) → work → /flush (write) → /clear → /project (read) → ...

Enter fullscreen mode Exit fullscreen mode

Each session starts where the last one left off, without carrying the previous session's token baggage.

Hooks as Workflow Enforcement

Claude Code's settings.json supports lifecycle hooks: PreToolUse, PostToolUse, and PermissionRequest. These fire on every tool call, and the output gets injected into the conversation as a system reminder. Most people use them for security (blocking dangerous commands). But they're also the best way to enforce workflow patterns that instructions alone can't guarantee.

Example: Forcing a Plan Template

I have a plan template at ~/llm-context/plan-template.md with pre-flight checklists, agent routing guidance, TDD decisions per step, and a verification matrix. CLAUDE.md says "use this template for any plan with 3+ steps." Claude follows this instruction maybe 70% of the time. When it doesn't, the plan is worse: missing verification steps, no fail-fast conditions, no agent routing.

The fix is a PostToolUse hook on EnterPlanMode. When Claude enters plan mode, a 5-line shell script fires and injects the entire plan template into the conversation as a system reminder. Claude can't miss it because the template is literally in the conversation at the moment planning starts.

The hook script:

#!/bin/bash
TEMPLATE="$HOME/llm-context/plan-template.md"
if [[ -f "$TEMPLATE" ]]; then
  echo "MANDATORY: Use the following plan template. Follow its structure exactly."
  echo ""
  cat "$TEMPLATE"
fi

Enter fullscreen mode Exit fullscreen mode

The settings.json entry:

{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "EnterPlanMode",
        "hooks": [{
          "type": "command",
          "command": "/path/to/plan-mode-template.sh",
          "timeout": 5
        }]
      }
    ]
  }
}

Enter fullscreen mode Exit fullscreen mode

Why This Works Better Than Instructions

A PostToolUse hook injects the template into the conversation at the moment it's needed. Claude can't miss what's already on screen. CLAUDE.md instructions compete for attention with everything else in the system prompt, and compliance hovers around 70%. The hook makes it 100%.

Any time you catch yourself thinking "Claude keeps forgetting to do X before Y," that's a hook. I have a PostToolUse on WebFetch that injects prompt injection warnings after fetching external content (caught a real issue once when a scraped page had instructions embedded in it). I have a PreToolUse on Bash that adds safety checks before shell commands in my infrastructure directories. A PostToolUse on Write/Edit that reminds Claude to lint after file modifications.

What Belongs Here vs Memory Architecture

The session management side is the easy part. How the memory files are structured, what goes in MEMORY.md vs topic files vs project state, is the part most people get wrong. That's a separate post.

Related: LLM Benchmark Rankings 2026 | LLM Routing Playbook | API Quota Dashboard