<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Will Gwyn</title>
    <description>The latest articles on DEV Community by Will Gwyn (@wrg32786).</description>
    <link>https://dev.to/wrg32786</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4180242%2Fe9b1126b-5798-409a-9e5e-f00672fff25e.jpg</url>
      <title>DEV Community: Will Gwyn</title>
      <link>https://dev.to/wrg32786</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/wrg32786"/>
    <language>en</language>
    <item>
      <title>How do I make Claude Code auto clear instead of compact?</title>
      <dc:creator>Will Gwyn</dc:creator>
      <pubDate>Tue, 03 Nov 2026 20:01:31 +0000</pubDate>
      <link>https://dev.to/wrg32786/how-do-i-make-claude-code-auto-clear-instead-of-compact-6ka</link>
      <guid>https://dev.to/wrg32786/how-do-i-make-claude-code-auto-clear-instead-of-compact-6ka</guid>
      <description>&lt;p&gt;Claude Code has no built-in setting to auto clear instead of auto compact, so you have to do it from outside the session: have the agent write a checkpoint file before the window fills, then send &lt;code&gt;/clear&lt;/code&gt; and start the fresh session pointed at that file. aigent-os (&lt;a href="https://github.com/wrg32786/aigent-os" rel="noopener noreferrer"&gt;https://github.com/wrg32786/aigent-os&lt;/a&gt;, MIT) does that loop for you: at 80% context it saves a verified capsule, runs &lt;code&gt;/clear&lt;/code&gt;, and resumes in a new session, with memory kept in git.&lt;/p&gt;

&lt;p&gt;That's the short answer. Here's how it works, how to set it up, and how to do it by hand if you don't want a harness.&lt;/p&gt;

&lt;h2&gt;
  
  
  why clear instead of compact
&lt;/h2&gt;

&lt;p&gt;auto compact has the model summarize the conversation and keep going on the summary. it works, but you can't see what got dropped, and after a few rounds you're running on a summary of a summary.&lt;/p&gt;

&lt;p&gt;clearing gives you an empty window. the catch is the new session knows nothing. so the whole trick is writing a good handoff before you clear, and making sure the clear never fires before the handoff is actually saved.&lt;/p&gt;

&lt;h2&gt;
  
  
  the steps (with aigent-os)
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;requirements: Claude Code, Node.js 18+ with npm, and bash (Git Bash on Windows).&lt;/li&gt;
&lt;li&gt;clone and preview. the dry run prints what it would change and writes nothing:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   git clone https://github.com/wrg32786/aigent-os.git &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cd &lt;/span&gt;aigent-os &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; bash install.sh &lt;span class="nt"&gt;--dry-run&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;if the plan looks right, run &lt;code&gt;bash install.sh&lt;/code&gt;, open a new terminal, and run &lt;code&gt;aigent&lt;/code&gt;. first launch runs guided setup.&lt;/li&gt;
&lt;li&gt;work normally. when context hits the threshold (default 80%, set &lt;code&gt;AIGENT_PRESSURE_THRESHOLD_PCT&lt;/code&gt; to change it), it asks Claude to write a capsule: what you're doing, decisions made, open threads, next step.&lt;/li&gt;
&lt;li&gt;it waits for Claude to print an exact acknowledgement. no ack, no clear.&lt;/li&gt;
&lt;li&gt;it sends exactly one &lt;code&gt;/clear&lt;/code&gt;, checks a fresh session started, and tells the new session to load the capsule and keep going.&lt;/li&gt;
&lt;li&gt;the shipped settings set &lt;code&gt;"idleCompaction": false&lt;/code&gt; so Claude Code's idle compaction doesn't step in and summarize a quiet session instead.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;your notes and capsules are plain markdown in git. when the install folder has a git remote, it commits and pushes them each cycle, so you can diff and roll back what the agent remembers. one heads up: if you installed in the cloned folder, its origin is the public repo, so point origin at your own private repo first.&lt;/p&gt;

&lt;h2&gt;
  
  
  the lighter option: just the capsule plugin
&lt;/h2&gt;

&lt;p&gt;if you don't want the full install, the repo ships a plain Claude Code plugin called context-capsule. it's the manual half: you run &lt;code&gt;/capsule&lt;/code&gt; or &lt;code&gt;/refresh&lt;/code&gt;, it writes the capsule, you run &lt;code&gt;/clear&lt;/code&gt; yourself, and the next session gets a pointer so &lt;code&gt;/resume&lt;/code&gt; picks up where you left off.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;/plugin marketplace add wrg32786/aigent-os
/plugin &lt;span class="nb"&gt;install &lt;/span&gt;context-capsule@aigent-os
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  doing it by hand
&lt;/h2&gt;

&lt;p&gt;no tools needed, just discipline:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;around 70 to 80% context, ask Claude to write a handoff file: goal, what's done, decisions and why, files touched, exact next step.&lt;/li&gt;
&lt;li&gt;read it. if the next step is vague, make it fix that.&lt;/li&gt;
&lt;li&gt;commit it.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/clear&lt;/code&gt;, then: "read HANDOFF.md and continue from the next step."&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;start early. if you wait until compaction is about to fire, there often isn't room left to write a good handoff.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;is there a native auto clear setting in Claude Code?&lt;/strong&gt;&lt;br&gt;
not that I know of as of today. there's an open feature request for exactly this, threshold auto clear with a handover doc and auto resume: &lt;a href="https://github.com/anthropics/claude-code/issues/90089" rel="noopener noreferrer"&gt;https://github.com/anthropics/claude-code/issues/90089&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;can a PreCompact hook do the clear?&lt;/strong&gt;&lt;br&gt;
a hook can run when compaction is about to happen, but it can't swap compaction for a clear. that's why aigent-os gets ahead of it at a lower threshold and drives the clear from a runner outside the session.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;what happens if the capsule is bad?&lt;/strong&gt;&lt;br&gt;
it won't resume into a capsule that recorded no next step. that check exists because we found three of our four live seats would have resumed into an empty checkpoint once.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;is this better than compaction?&lt;/strong&gt;&lt;br&gt;
it's a different trade-off, not a proven win. you get an explicit checkpoint you can read and a clean window, instead of a summary you can't inspect.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;does it work on Windows / macOS / Linux?&lt;/strong&gt;&lt;br&gt;
yes, all three. the publicly shown evidence is 11 of 11 clean refresh cycles on one Windows seat, so it's single-seat evidence, not a reliability claim.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;does it send my data anywhere?&lt;/strong&gt;&lt;br&gt;
aigent-os has no server. Claude Code talks to Anthropic as usual, npm downloads packages at install, and semantic search downloads a small model once.&lt;/p&gt;

&lt;h2&gt;
  
  
  what we use it for
&lt;/h2&gt;

&lt;p&gt;we run four Claude Code agents on it every day: Titus oversees, Pheme owns the newsletter business, Davinci builds, Metis handles task assignment and clerical work. they write our daily newsletter The AIgent, run social and video, and build courses and email funnels. Mike and I set direction and make the calls. the auto clear loop is what lets those sessions run for weeks without anyone re-briefing them.&lt;/p&gt;

&lt;p&gt;repo: &lt;a href="https://github.com/wrg32786/aigent-os" rel="noopener noreferrer"&gt;https://github.com/wrg32786/aigent-os&lt;/a&gt;. if it helps, a star helps other people find it. issues and PRs welcome.&lt;/p&gt;

&lt;p&gt;related: &lt;a href="https://dev.to/wrg32786/how-do-i-stop-claude-code-from-auto-compacting-and-losing-context-278l"&gt;How do I stop Claude Code from auto-compacting and losing context&lt;/a&gt;&lt;/p&gt;

</description>
      <category>claudecode</category>
      <category>ai</category>
      <category>productivity</category>
      <category>opensource</category>
    </item>
    <item>
      <title>how to run long-lived claude code agents from your phone</title>
      <dc:creator>Will Gwyn</dc:creator>
      <pubDate>Thu, 29 Oct 2026 16:07:31 +0000</pubDate>
      <link>https://dev.to/wrg32786/how-to-run-long-lived-claude-code-agents-from-your-phone-53ne</link>
      <guid>https://dev.to/wrg32786/how-to-run-long-lived-claude-code-agents-from-your-phone-53ne</guid>
      <description>&lt;p&gt;i ran my newsletter business from my phone for 14+ days in september while elk hunting. phone, Starlink Mini, no laptop. the agents ran on my computer at home and i steered them from the Claude app.&lt;/p&gt;

&lt;p&gt;this is the how-to version. three pieces: claude code remote control, keeping the host machine awake, and keeping agent sessions healthy for days. disclosure up front: the third piece uses aigent-os, an open-source thing i built (&lt;a href="https://github.com/wrg32786/aigent-os" rel="noopener noreferrer"&gt;https://github.com/wrg32786/aigent-os&lt;/a&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  what is claude code remote control?
&lt;/h2&gt;

&lt;p&gt;remote control connects the Claude mobile app (iOS and Android) or claude.ai/code to a Claude Code session running on your own machine. the session never leaves your computer. your filesystem, MCP servers, tools, and project config all stay local. the phone is a window into that session.&lt;/p&gt;

&lt;p&gt;you can send messages from the terminal, browser, and phone interchangeably, and the conversation stays in sync. you can also attach photos and files from your phone and they get passed into the local session.&lt;/p&gt;

&lt;p&gt;this is different from cloud sessions, which run on Anthropic's infrastructure and keep going with your laptop closed. remote control is what you want when the work depends on your local setup, which for long-running agents it usually does.&lt;/p&gt;

&lt;h2&gt;
  
  
  what do you need before you start?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;a Pro, Max, Team, or Enterprise plan. API keys are not supported. on Team and Enterprise an owner has to enable it in admin settings.&lt;/li&gt;
&lt;li&gt;be logged in. run &lt;code&gt;claude&lt;/code&gt; and use &lt;code&gt;/login&lt;/code&gt; to sign in through claude.ai.&lt;/li&gt;
&lt;li&gt;talk to &lt;code&gt;api.anthropic.com&lt;/code&gt; directly. it doesn't work through Bedrock, Google's platform, Microsoft Foundry, or a custom &lt;code&gt;ANTHROPIC_BASE_URL&lt;/code&gt; proxy.&lt;/li&gt;
&lt;li&gt;don't set &lt;code&gt;CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC&lt;/code&gt; or &lt;code&gt;DISABLE_GROWTHBOOK&lt;/code&gt;. those turn it off.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  how do you start a remote control session?
&lt;/h2&gt;

&lt;p&gt;two ways.&lt;/p&gt;

&lt;p&gt;start a new one in your project directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; ~/my-agent
claude remote-control
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or, if you already have a session open, run this inside it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/remote-control
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;then connect from your phone. either press space in the terminal to show a QR code and scan it with the Claude app, or open the Claude app, tap &lt;strong&gt;Code&lt;/strong&gt;, and pick the session from the list.&lt;/p&gt;

&lt;p&gt;for multiple agents, i run one session per agent, each in its own directory, so each shows up as its own session in the app.&lt;/p&gt;

&lt;h2&gt;
  
  
  what happens if the computer sleeps or the network drops?
&lt;/h2&gt;

&lt;p&gt;per the docs, if your machine sleeps or the network drops, Claude Code reconnects automatically when the machine comes back online. that's nice, but "comes back online" is doing a lot of work. if the machine is asleep, your agents aren't doing anything. the computer has to stay on and the &lt;code&gt;claude&lt;/code&gt; process has to keep running.&lt;/p&gt;

&lt;p&gt;so the real job is keeping the host awake.&lt;/p&gt;

&lt;h2&gt;
  
  
  how do you keep the host computer awake?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;macOS:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;caffeinate &lt;span class="nt"&gt;-dimsu&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;run it in its own terminal (or tmux pane) and leave it. also check System Settings for sleep and power options, and look at "start up automatically after a power failure" if your mac has it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Linux (systemd):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;systemd-inhibit &lt;span class="nt"&gt;--what&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;idle:sleep &lt;span class="nt"&gt;--why&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"agents running"&lt;/span&gt; &lt;span class="nb"&gt;sleep &lt;/span&gt;infinity
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or disable sleep targets entirely on a dedicated box:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Windows:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;powercfg&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;/change&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;standby-timeout-ac&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;0&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;powercfg&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;/change&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;hibernate-timeout-ac&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;0&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;other things worth doing before you leave for real:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;run sessions inside &lt;code&gt;tmux&lt;/code&gt; so a closed terminal window doesn't kill them&lt;/li&gt;
&lt;li&gt;plug in, and ideally put it on a small UPS&lt;/li&gt;
&lt;li&gt;turn off automatic OS update restarts for the trip&lt;/li&gt;
&lt;li&gt;test it. leave the house for an afternoon and drive everything from your phone&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  why do long-lived claude code sessions degrade?
&lt;/h2&gt;

&lt;p&gt;the context window fills up. a session that's been going for a day is carrying a lot of stale stuff, and quality drops. compaction helps a bit, but you're summarizing a summary of a summary, and things get lost in ways you can't see.&lt;/p&gt;

&lt;p&gt;for a session you want running for weeks, you need state that lives outside the context window.&lt;/p&gt;

&lt;h2&gt;
  
  
  how does aigent-os keep agents running for weeks?
&lt;/h2&gt;

&lt;p&gt;the loop is simple:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;the agent saves a &lt;strong&gt;context capsule&lt;/strong&gt;: what it's working on, what's done, what's next, open questions.&lt;/li&gt;
&lt;li&gt;it runs &lt;code&gt;/clear&lt;/code&gt;, so the context is actually empty.&lt;/li&gt;
&lt;li&gt;it resumes from the capsule plus its &lt;strong&gt;long-term memory&lt;/strong&gt;, which is git-backed.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;so every agent regularly starts fresh, but it starts fresh knowing what it was doing. because memory is in git, you get history and diffs for free, and you can see exactly what an agent "knows."&lt;/p&gt;

&lt;p&gt;this matters even more with remote control. on a phone over satellite, you want short, clear check-ins. a session that's clean and knows its own state answers "what happened today?" way better than one that's 180k tokens deep.&lt;/p&gt;

&lt;p&gt;i run four agents this way: an overseer, a newsletter agent, a builder, and a clerical/job assignment agent. separate roles mean when i check in from my phone, i know exactly who to ask.&lt;/p&gt;

&lt;p&gt;docs are at &lt;a href="https://wrg32786.github.io/aigent-os/" rel="noopener noreferrer"&gt;https://wrg32786.github.io/aigent-os/&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  what does a phone check-in actually look like?
&lt;/h2&gt;

&lt;p&gt;open the Claude app, tap Code, pick the agent. ask what happened since last time, answer whatever it saved up for me, approve or redirect, close the app. most of the work is the agents doing things. my part is steering.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;do my agents run in the cloud with remote control?&lt;/strong&gt;&lt;br&gt;
no. they run on your machine. the phone and browser are just interfaces to that local session.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;can i use an API key?&lt;/strong&gt;&lt;br&gt;
no. remote control needs a Pro, Max, Team, or Enterprise plan and a claude.ai login.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;what if my computer has to be off?&lt;/strong&gt;&lt;br&gt;
then remote control won't work. use Claude Code cloud sessions instead, which run on cloud infrastructure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;does it work on a slow connection like Starlink?&lt;/strong&gt;&lt;br&gt;
it worked for me for two weeks on a Starlink Mini. your mileage will vary with signal.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;do i need aigent-os to use remote control?&lt;/strong&gt;&lt;br&gt;
no. remote control works with any Claude Code session. aigent-os is what keeps sessions from degrading when you want them running for days or weeks.&lt;/p&gt;




&lt;h3&gt;
  
  
  notes / sources
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Remote Control docs: &lt;a href="https://code.claude.com/docs/en/remote-control" rel="noopener noreferrer"&gt;https://code.claude.com/docs/en/remote-control&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Claude Code on mobile: &lt;a href="https://code.claude.com/docs/en/mobile" rel="noopener noreferrer"&gt;https://code.claude.com/docs/en/mobile&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;cloud sessions (for comparison): &lt;a href="https://code.claude.com/docs/en/claude-code-on-the-web" rel="noopener noreferrer"&gt;https://code.claude.com/docs/en/claude-code-on-the-web&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;sleep commands (&lt;code&gt;caffeinate&lt;/code&gt;, &lt;code&gt;systemd-inhibit&lt;/code&gt;, &lt;code&gt;powercfg&lt;/code&gt;) are standard OS tools, not from Anthropic docs&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>claudecode</category>
      <category>ai</category>
      <category>productivity</category>
      <category>opensource</category>
    </item>
    <item>
      <title>My four Claude Code agents run my newsletter. Here's how I keep them from forgetting.</title>
      <dc:creator>Will Gwyn</dc:creator>
      <pubDate>Tue, 27 Oct 2026 15:17:49 +0000</pubDate>
      <link>https://dev.to/wrg32786/my-four-claude-code-agents-run-my-newsletter-heres-how-i-keep-them-from-forgetting-2o4l</link>
      <guid>https://dev.to/wrg32786/my-four-claude-code-agents-run-my-newsletter-heres-how-i-keep-them-from-forgetting-2o4l</guid>
      <description>&lt;p&gt;I'm Will. I run a small business, and most of the daily work is done by four Claude Code agents: Titus, Pheme, Davinci and Metis. They run on aigent-os, an open source harness I built, and v1.1.0 shipped this weekend with Managed Auto-Refresh as stable.&lt;/p&gt;

&lt;p&gt;This post follows one newsletter issue through the loop, then gets into how the harness keeps the agents coherent and where it's still weak. Full disclosure, I'm the author.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fo0ole9xu4may6172h23f.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fo0ole9xu4may6172h23f.gif" alt="Illustration of an auto-refresh cycle: capsule written at 80%, ack, /clear, resume at 10% context" width="720" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(That GIF is an illustration, not a screen recording.)&lt;/p&gt;

&lt;h2&gt;
  
  
  One issue, start to finish
&lt;/h2&gt;

&lt;p&gt;The newsletter is The AIgent (&lt;a href="https://theaigent.xyz" rel="noopener noreferrer"&gt;theaigent.xyz&lt;/a&gt;). It goes out daily to about 9k subscribers and it's growing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It starts on the job board.&lt;/strong&gt; Metis assigns jobs on a job board. The other agents claim them and run them. Nobody is waiting for me to type a prompt to get the day moving.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The draft.&lt;/strong&gt; My team built a whole engine for the newsletter, with roles like a drafter, proofreaders and researchers, and every issue goes through it. Pheme, my head agent in charge of the newsletter, checks it before she schedules it each day.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The featured repo.&lt;/strong&gt; Each issue has a featured repo of the day. That one pick feeds everything downstream.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The video.&lt;/strong&gt; A video engine runs off the newsletter. Every day it takes the featured repo and, fully automatically, makes a talking-head video of my avatar clone. It gets posted to Instagram at &lt;a href="https://www.instagram.com/the_aigent_news/" rel="noopener noreferrer"&gt;@the_aigent_news&lt;/a&gt;. &lt;a href="https://www.instagram.com/p/De7FFM6CiWA/" rel="noopener noreferrer"&gt;Here is one of them&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ads and funnels.&lt;/strong&gt; The agents set up direct ad deals on the newsletter, run Meta ads with me, and build email funnels.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;My sign-off.&lt;/strong&gt; Nothing closes until I sign off. That's a hard rule. The agents can do the legwork on a deal or a campaign, but I'm the one who says yes. There's a check before mine, too: Pheme catches stuff daily, inaccuracies and the like, before an issue gets scheduled.&lt;/p&gt;

&lt;p&gt;Same agents also build educational courses: custom AI courses that run natively in the user's own Claude or ChatGPT app.&lt;/p&gt;

&lt;h2&gt;
  
  
  The actual hard problem
&lt;/h2&gt;

&lt;p&gt;None of those tasks is the hard part on its own. The hard part is keeping four agents coherent across weeks without losing context.&lt;/p&gt;

&lt;p&gt;Claude Code gives you two built-in options when a window fills. Compaction summarizes the conversation and keeps going. The main task usually survives, but small decisions get dropped, like "that file is generated, edit the template", and later the agent does the thing you already ruled out. &lt;code&gt;/clear&lt;/code&gt; gives you a clean window and forgets everything, so you re-brief by hand.&lt;/p&gt;

&lt;p&gt;I wanted a third path: write down what matters, clear, and pick back up.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Managed Auto-Refresh works
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;At a context threshold (80% by default) the runner asks the agent to write a capsule. A capsule is a checkpoint file stored in git, so it's versioned and you can diff it or roll it back.&lt;/li&gt;
&lt;li&gt;The agent has to reply with one exact line, &lt;code&gt;Capsule Complete, Ready For Clear&lt;/code&gt;, in its own text. A sentence that merely mentions the phrase doesn't count, and neither do thinking blocks or tool inputs.&lt;/li&gt;
&lt;li&gt;Only after that ack does the runner send &lt;code&gt;/clear&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;It then waits for a SessionStart hook receipt that proves a fresh session started. Typing &lt;code&gt;/clear&lt;/code&gt; isn't treated as proof.&lt;/li&gt;
&lt;li&gt;The new session gets one resume prompt and picks up from the capsule.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The rule I care most about is at most once. One ack buys at most one clear, and an ack only counts for its own cycle. If things get ambiguous, for example operator input interrupts a prepared clear, the runner stops at &lt;code&gt;HOLD:clear-stalled-after-ack&lt;/code&gt; with a visible notice. It doesn't retry. A double clear or a half stranded session is worse than stopping and asking me.&lt;/p&gt;

&lt;h3&gt;
  
  
  The capsule doesn't give orders
&lt;/h3&gt;

&lt;p&gt;On resume a capsule is reference only. It's shown to the fresh session as data, and live state wins on any conflict. It can't add a step or change the objective.&lt;/p&gt;

&lt;p&gt;If the writer can't tell whether something is pending, the field is written as &lt;code&gt;Unknown&lt;/code&gt;. A blank field reads like "nothing pending", which is a lie. &lt;code&gt;Unknown&lt;/code&gt; makes the next session go check.&lt;/p&gt;

&lt;h3&gt;
  
  
  Memory and onboarding
&lt;/h3&gt;

&lt;p&gt;Long-term memory lives in per-agent vaults, so Titus's notes aren't Pheme's notes. On first run aigent-os interviews you: three plain questions, then a first plan. That's it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where it's still weak
&lt;/h2&gt;

&lt;p&gt;I'd rather you read this here than find it in the issues.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Evidence is single-seat.&lt;/strong&gt; The public result is 11 of 11 refresh cycles on one Windows seat. That's not a fleet or reliability claim, and I'm not claiming refresh beats compaction.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The runner can still miss a permission dialog and answer it (#104).&lt;/strong&gt; A guard exists, but Claude Code writes the transcript late, so it missed in 1 of 4 real runs. Automatic input is off by default. Don't turn it on for a seat that can hit permission prompts, and watch the seat during refreshes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Launching a seat from inside another Claude Code session can lose its transcript (#98).&lt;/strong&gt; Launch from a plain terminal for now, or set &lt;code&gt;CLAUDE_CODE_FORCE_SESSION_PERSISTENCE&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scrolling the seat window sends stray input (#99).&lt;/strong&gt; Avoid scrolling in the seat terminal during a refresh cycle.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Done items are unverified (#80).&lt;/strong&gt; The capsule's "Done" section can hold the agent's own claim that something shipped. Reference only framing limits the damage but nothing checks each item yet.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Stop hook advises, it doesn't block (#82)&lt;/strong&gt;, and outside side effects in flight during a refresh aren't tracked yet (#81).&lt;/li&gt;
&lt;li&gt;macOS has the least mileage. On Windows you need Git Bash.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What's coming
&lt;/h2&gt;

&lt;p&gt;A standalone context-capsule Claude Code plugin is in review (PR #103). It hasn't shipped, so treat it as coming.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;p&gt;You need Claude Code, Node 18+ with npm, and bash.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/wrg32786/aigent-os.git
&lt;span class="nb"&gt;cd &lt;/span&gt;aigent-os
git checkout v1.1.0
bash install.sh &lt;span class="nt"&gt;--dry-run&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The dry run prints every change and writes nothing. If it looks right, run &lt;code&gt;bash install.sh&lt;/code&gt;, open a new terminal and run &lt;code&gt;aigent&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If you try it, tell me where the loop could still double clear or strand a session. Issues and PRs welcome.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Repo: &lt;a href="https://github.com/wrg32786/aigent-os" rel="noopener noreferrer"&gt;https://github.com/wrg32786/aigent-os&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Release notes: &lt;a href="https://github.com/wrg32786/aigent-os/releases/tag/v1.1.0" rel="noopener noreferrer"&gt;https://github.com/wrg32786/aigent-os/releases/tag/v1.1.0&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Newsletter: &lt;a href="https://theaigent.xyz" rel="noopener noreferrer"&gt;https://theaigent.xyz&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Instagram: &lt;a href="https://www.instagram.com/the_aigent_news/" rel="noopener noreferrer"&gt;https://www.instagram.com/the_aigent_news/&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>claudecode</category>
      <category>ai</category>
      <category>opensource</category>
      <category>devtools</category>
    </item>
    <item>
      <title>How to keep a Claude Code agent running for days without losing context</title>
      <dc:creator>Will Gwyn</dc:creator>
      <pubDate>Fri, 16 Oct 2026 19:18:59 +0000</pubDate>
      <link>https://dev.to/wrg32786/how-to-keep-a-claude-code-agent-running-for-days-without-losing-context-520b</link>
      <guid>https://dev.to/wrg32786/how-to-keep-a-claude-code-agent-running-for-days-without-losing-context-520b</guid>
      <description>&lt;p&gt;You don't keep one context window alive for days. You run a chain of bounded sessions that share durable state on disk (a progress file, a task list, git history), and you make the handoff between sessions automatic and checkable.&lt;/p&gt;

&lt;p&gt;I've been running Claude Code agents this way for months, and most of what goes wrong happens at the boundary between sessions, not inside them. So this is mostly about that boundary.&lt;/p&gt;

&lt;h4&gt;
  
  
  What Claude Code gives you on its own
&lt;/h4&gt;

&lt;p&gt;A single session doesn't last forever because the context window fills. When it does, Claude Code compacts automatically, summarizing the history so the session can continue. Anthropic's docs list what survives that: project-root CLAUDE.md, unscoped rules and auto memory get re-injected from disk, and a handful of recently touched files get re-read. Everything else becomes part of a summary. Auto memory, which the docs describe as notes Claude writes itself based on your corrections and preferences, also carries across sessions.&lt;/p&gt;

&lt;p&gt;Between sessions you have &lt;code&gt;/clear&lt;/code&gt; to start fresh, &lt;code&gt;/resume&lt;/code&gt; to return to an earlier conversation, and subagents to do heavy reading in their own context so your main window stays lean. There's also a built-in &lt;code&gt;/goal&lt;/code&gt; command. Per the command reference, it keeps Claude working across turns until a condition you set is met. As far as I can tell from the docs, it's about finishing a task, not carrying memory from one window to the next.&lt;/p&gt;

&lt;h4&gt;
  
  
  What Anthropic recommends for long-running work
&lt;/h4&gt;

&lt;p&gt;The clearest guidance is Anthropic's engineering post "Effective harnesses for long-running agents." Its framing stuck with me: agents "must work in discrete sessions, and each new session begins with no memory of what came before." Their answer was an initializer session that sets up an &lt;code&gt;init.sh&lt;/code&gt;, a &lt;code&gt;claude-progress.txt&lt;/code&gt; log and an initial git commit. After that, every session makes incremental progress on one feature, commits with a descriptive message and updates the progress file. The next session starts by reading that file and the git log.&lt;/p&gt;

&lt;p&gt;Anthropic also published a companion repo, anthropics/cwc-long-running-agents, that turns those patterns into small hooks. It includes a structured &lt;code&gt;PROGRESS.md&lt;/code&gt;, a commit-on-stop hook as a backstop, and a separate evaluator agent that grades the work from a fresh context.&lt;/p&gt;

&lt;p&gt;Community advice lands in the same place. The most useful Reddit thread I found on running agents "for weeks" argued for treating each model session as a replaceable worker and keeping the real state (task graph, decisions, next action) outside it. A second tip from the same threads: have subagents write their output to disk and hand back a path and a one-line summary, so the orchestrator doesn't fill up with their raw output.&lt;/p&gt;

&lt;h4&gt;
  
  
  The options, honestly
&lt;/h4&gt;

&lt;p&gt;You can do all of this by hand with CLAUDE.md, a progress file and git, and for many projects that's enough. If you want help, several tools cover different parts. claude-mem captures what your agent does, compresses it and injects relevant context into future sessions. context-mode keeps tool output from flooding the window and persists session memory. claude-auto-handoff replaces auto-compact with a structured brief, a &lt;code&gt;/clear&lt;/code&gt; and a seeded fresh session. Hindsight is a memory service built to learn across agents. They overlap, and plenty of people run two together.&lt;/p&gt;

&lt;h4&gt;
  
  
  What I run (I built this)
&lt;/h4&gt;

&lt;p&gt;I built aigent-OS, so read this as the author talking. It's an open-source Claude Code harness that refreshes its own context instead of compacting. At a context threshold (80% by default) it asks Claude to write a capsule, waits for one exact acknowledgement, sends a single &lt;code&gt;/clear&lt;/code&gt;, confirms via the &lt;code&gt;SessionStart&lt;/code&gt; hook that a new session really started, and resumes from the capsule. Memory is plain markdown in git. It's MIT licensed, runs locally and needs Node 18+: &lt;a href="https://github.com/wrg32786/aigent-os" rel="noopener noreferrer"&gt;https://github.com/wrg32786/aigent-os&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Running it for days taught me where the boundary breaks. Four aigent-OS seats run my newsletter, The AIgent. That's operating experience, not a measured result, and I'm not claiming it grew anything. In August a check of those four seats found that three would have resumed into a checkpoint with no actionable content. Now the capsule selector refuses that kind of checkpoint, and a test in the repo defends the fix. Stale notes were another problem, so notes can carry a validity window and rank below current ones once it ends. Memory that tries to give instructions gets held before it's saved, and saved memory is read back as data, never as commands.&lt;/p&gt;

&lt;p&gt;The limits are real. Managed Auto-Refresh is in the v1.1.0-rc.1 release candidate. The only formal public result is 11 of 11 clean refresh cycles on one seat. That's single-machine evidence, not proof at fleet scale. On rc.1, a long session can also stall at the clear step and need a manual &lt;code&gt;/clear&lt;/code&gt;. The fixes are merged on master and land in the next release. Two narrower acknowledgement bugs are still open as #90 and #91, so if you ever clear by hand, make sure the latest capsule is saved first.&lt;/p&gt;

&lt;h4&gt;
  
  
  FAQ
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Can a single Claude Code session literally run for days?&lt;/strong&gt;&lt;br&gt;
I didn't find a documented wall-clock limit on an interactive session, but the context window fills well before that. In practice, "days" means compactions or clear-and-resume cycles.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What should the progress file contain?&lt;/strong&gt;&lt;br&gt;
Anthropic's post uses what was done, what's next and known issues, backed by git commits. I'd add the exact next step. A checkpoint without one is the failure I hit most.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do subagents help?&lt;/strong&gt;&lt;br&gt;
Yes, for big reads and searches, as long as they return a short result and a file path instead of everything they saw.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Is compaction good enough for long runs?&lt;/strong&gt;&lt;br&gt;
Often, especially if your durable state lives in files. Compaction loses detail, so anything you can't afford to lose belongs on disk.&lt;/p&gt;

</description>
      <category>claudecode</category>
      <category>ai</category>
      <category>agents</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Claude Code /compact vs /clear: what actually happens to your context</title>
      <dc:creator>Will Gwyn</dc:creator>
      <pubDate>Fri, 16 Oct 2026 19:17:58 +0000</pubDate>
      <link>https://dev.to/wrg32786/claude-code-compact-vs-clear-what-actually-happens-to-your-context-55d8</link>
      <guid>https://dev.to/wrg32786/claude-code-compact-vs-clear-what-actually-happens-to-your-context-55d8</guid>
      <description>&lt;p&gt;short version: &lt;code&gt;/compact&lt;/code&gt; swaps your conversation for a summary Claude writes and keeps the same session going. &lt;code&gt;/clear&lt;/code&gt; starts a new conversation with an empty context. your project memory (CLAUDE.md and friends) still loads, and the old conversation is still reachable through &lt;code&gt;/resume&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;the longer version matters, because the two look alike in the prompt bar and behave really differently. i've watched people (me included) pick the wrong one mid task and lose a decision that took an hour to reach.&lt;/p&gt;

&lt;h2&gt;
  
  
  what /compact does
&lt;/h2&gt;

&lt;p&gt;Anthropic's command reference describes &lt;code&gt;/compact [instructions]&lt;/code&gt; as freeing up context "by summarizing the conversation so far," with optional focus instructions. run &lt;code&gt;/compact focus on the API changes&lt;/code&gt; and the summary leans toward what you named. you can also compact part of a conversation from &lt;code&gt;/rewind&lt;/code&gt; with "Summarize from here" or "Summarize up to here." the automatic pass Claude Code runs near the limit is the same operation, you just don't get to steer it.&lt;/p&gt;

&lt;p&gt;after a compaction, the docs list what comes back on its own. the system prompt and output style still apply. project root CLAUDE.md, unscoped rules and auto memory get re-injected from disk. up to five recently modified files Claude touched get re-read, and a file over 5,000 tokens comes back only as a path. invoked skills return within a per skill cap. path scoped rules and nested CLAUDE.md files aren't re-injected right away, they reload on demand when Claude touches a matching file again. context that hooks added earlier, and anything that only lived in the conversation, survives only as whatever the summary kept.&lt;/p&gt;

&lt;p&gt;a cost detail people miss: the costs page notes that &lt;code&gt;/compact&lt;/code&gt; "reads the conversation it summarizes, so compacting a large context is itself a large request."&lt;/p&gt;

&lt;h2&gt;
  
  
  what /clear does
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;/clear&lt;/code&gt; (aliases &lt;code&gt;/reset&lt;/code&gt; and &lt;code&gt;/new&lt;/code&gt;) starts a new conversation with empty context. the commands overview says it "starts fresh on a new task while keeping project memory," so your CLAUDE.md is still there in the new session. the same costs page says that when you want a fresh start instead of continuity, "/clear costs nothing."&lt;/p&gt;

&lt;p&gt;the question i get most is whether &lt;code&gt;/clear&lt;/code&gt; is permanent. Anthropic's sources don't fully agree. the help center article on models and limits warns &lt;code&gt;/clear&lt;/code&gt; can't be undone. the command reference says you can get back to the previous conversation with &lt;code&gt;/resume&lt;/code&gt;, and that in the same Claude Code process the rewind menu shows a "previous session" entry. my read: the old transcript is still there to go back to, but nothing from it carries into the new session unless you bring it. if something matters, write it down first.&lt;/p&gt;

&lt;h2&gt;
  
  
  how to tell which one happened
&lt;/h2&gt;

&lt;p&gt;if you write hooks, they're easy to tell apart. &lt;code&gt;SessionStart&lt;/code&gt; fires with &lt;code&gt;source&lt;/code&gt; set to &lt;code&gt;compact&lt;/code&gt; after a compaction and &lt;code&gt;clear&lt;/code&gt; after &lt;code&gt;/clear&lt;/code&gt;, and &lt;code&gt;PreCompact&lt;/code&gt; fires first with a &lt;code&gt;manual&lt;/code&gt; or &lt;code&gt;auto&lt;/code&gt; trigger. that's how tools that manage context, mine included, know which boundary they just crossed.&lt;/p&gt;

&lt;h2&gt;
  
  
  which one should you use?
&lt;/h2&gt;

&lt;p&gt;Anthropic's own session management guide puts the trade off better than i can. compaction is "lossy, but you didn't have to write anything yourself." with &lt;code&gt;/clear&lt;/code&gt; you write down what matters and start clean, which is more work, but "the resulting context is what you decided was relevant." their rule of thumb: &lt;code&gt;/compact&lt;/code&gt; when you're mid task and the session is bloated, &lt;code&gt;/clear&lt;/code&gt; when you're starting something new.&lt;/p&gt;

&lt;p&gt;that leaves a gap for long tasks where you want both: a clean window plus the decisions from the last two hours. that's where most community tooling lives. some people do it by hand: ask for a handoff note, &lt;code&gt;/clear&lt;/code&gt;, paste it back. claude-auto-handoff automates that by having Haiku write the brief before running &lt;code&gt;/clear&lt;/code&gt;. claude-mem works from the memory side, capturing what your agent did and injecting relevant bits into later sessions. context-mode cuts how much tool output lands in your context at all, so you hit either command less often.&lt;/p&gt;

&lt;h2&gt;
  
  
  where my thing fits (i built this, so grain of salt)
&lt;/h2&gt;

&lt;p&gt;i built &lt;a href="https://github.com/wrg32786/aigent-os" rel="noopener noreferrer"&gt;aigent-OS&lt;/a&gt;, an MIT licensed, local only setup for Claude Code. it comes in two sizes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;the small one: the context-capsule plugin.&lt;/strong&gt; if you just want the handoff note thing without doing it by hand, this is it. run &lt;code&gt;/capsule&lt;/code&gt; (or &lt;code&gt;/refresh&lt;/code&gt;) and Claude writes a resume ready checkpoint file of your session. then run &lt;code&gt;/clear&lt;/code&gt; yourself, or let auto compact happen, and the next session gets a short pointer to the capsule so it picks up where you left off. plain Node scripts, zero npm dependencies, no network. install from inside Claude Code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;/plugin marketplace add wrg32786/aigent-os
/plugin &lt;span class="nb"&gt;install &lt;/span&gt;context-capsule@aigent-os
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;the full one: managed Auto-Refresh.&lt;/strong&gt; this automates the clean window path end to end. at a context threshold (80% by default, set with &lt;code&gt;AIGENT_PRESSURE_THRESHOLD_PCT&lt;/code&gt;) it asks Claude to write a capsule, waits for one exact acknowledgement, sends a single &lt;code&gt;/clear&lt;/code&gt;, confirms through &lt;code&gt;SessionStart&lt;/code&gt; that a fresh session really started, and resumes from the capsule. no acknowledgement, no clear. memory is plain markdown in git, so you can diff what the agent remembers. needs Claude Code, Node 18+ and bash (Git Bash on Windows):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/wrg32786/aigent-os.git &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cd &lt;/span&gt;aigent-os &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; bash install.sh &lt;span class="nt"&gt;--dry-run&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the dry run prints the planned changes and writes nothing. if it looks right, run &lt;code&gt;bash install.sh&lt;/code&gt;, open a new terminal and run &lt;code&gt;aigent&lt;/code&gt;. one heads up: if you install in the cloned folder, point &lt;code&gt;origin&lt;/code&gt; at your own private repo first, because it commits and pushes your memory folder at each capsule cycle when there's a remote.&lt;/p&gt;

&lt;p&gt;honest status: managed Auto-Refresh is stable as of v1.1.0. the public evidence is 11 of 11 clean cycles on one Windows machine during release testing, which is single seat evidence, not a reliability claim. the rc.1 bug where a long session could stall at the clear step, plus two ack edge cases (#90, #91), are fixed in v1.1.0. and i'm not claiming it beats compaction. it trades a model written summary for a checkpoint you can open and read.&lt;/p&gt;

&lt;p&gt;docs and getting started: &lt;a href="https://wrg32786.github.io/aigent-os/" rel="noopener noreferrer"&gt;https://wrg32786.github.io/aigent-os/&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;does /clear delete my CLAUDE.md or project files?&lt;/strong&gt;&lt;br&gt;
no. it clears the conversation. project memory loads again in the new session and your files aren't touched.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;can i get back to a conversation after /clear?&lt;/strong&gt;&lt;br&gt;
per the command reference, yes, through &lt;code&gt;/resume&lt;/code&gt; or the rewind menu's previous session entry in the same process.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;which is cheaper?&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;/clear&lt;/code&gt;. compacting has to read the whole conversation to summarize it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;does /compact keep my files in context?&lt;/strong&gt;&lt;br&gt;
it re-reads up to five recently modified files Claude worked on. any file over 5,000 tokens comes back as a path reference only.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;can i keep context across /clear without installing a whole framework?&lt;/strong&gt;&lt;br&gt;
yeah, that's what the context-capsule plugin is for. two commands to install, and it's manual trigger only, so nothing clears unless you do it.&lt;/p&gt;

</description>
      <category>claude</category>
      <category>ai</category>
      <category>productivity</category>
      <category>opensource</category>
    </item>
    <item>
      <title>How do I stop Claude Code from auto-compacting (and losing context)?</title>
      <dc:creator>Will Gwyn</dc:creator>
      <pubDate>Fri, 16 Oct 2026 19:15:40 +0000</pubDate>
      <link>https://dev.to/wrg32786/how-do-i-stop-claude-code-from-auto-compacting-and-losing-context-278l</link>
      <guid>https://dev.to/wrg32786/how-do-i-stop-claude-code-from-auto-compacting-and-losing-context-278l</guid>
      <description>&lt;p&gt;Turn off auto-compact in &lt;code&gt;/config&lt;/code&gt; (the Auto-compact toggle), or set &lt;code&gt;"autoCompactEnabled": false&lt;/code&gt; in your settings file, or launch with &lt;code&gt;DISABLE_AUTO_COMPACT=1&lt;/code&gt;. That stops the automatic summary, but it doesn't give you a bigger context window, so you still need a plan for the moment the window fills.&lt;/p&gt;

&lt;p&gt;I keep seeing this question on r/ClaudeCode and in Claude Code's GitHub issues, usually right after someone loses an afternoon of decisions to a summary. So here's what Claude Code actually does, what the switches change, and the ways people deal with it, mine included.&lt;/p&gt;

&lt;h4&gt;
  
  
  What Claude Code does by default
&lt;/h4&gt;

&lt;p&gt;Claude Code compacts on its own as you approach the context limit. Anthropic's context window docs put it plainly: "Claude Code compacts automatically as you approach the limit, so a full context window doesn't end your session." Compaction replaces the conversation history with a model-written summary and you keep going on top of that summary.&lt;/p&gt;

&lt;p&gt;Where it triggers depends on the model. The model configuration page says models with a native 1M window compact at about 967K tokens by default, and some setups, like Sonnet 4.6 and Opus 4.6 without extended context, compact at the 200K boundary. You can check yours with &lt;code&gt;/context&lt;/code&gt;, which shows what's filling the window.&lt;/p&gt;

&lt;p&gt;The part that matters most is what survives. The docs have a table for it. The system prompt still applies. Project-root CLAUDE.md, unscoped rules and auto memory get re-injected from disk. Claude Code re-reads up to five of the files Claude touched, most recently modified first. Invoked skills come back, capped at 5,000 tokens each. Path-scoped rules, nested CLAUDE.md files and anything a hook added earlier get summarized along with everything else. And anything you only ever said in chat is at the mercy of the summary. The memory docs say the same thing from the other side: if an instruction vanished after compaction, it probably lived only in the conversation.&lt;/p&gt;

&lt;h4&gt;
  
  
  The switches
&lt;/h4&gt;

&lt;p&gt;Anthropic documents several. &lt;code&gt;autoCompactEnabled&lt;/code&gt; (default &lt;code&gt;true&lt;/code&gt;) turns automatic compaction off, and &lt;code&gt;/config&lt;/code&gt; writes that key for you. &lt;code&gt;DISABLE_AUTO_COMPACT=1&lt;/code&gt; does the same for a session. In both cases manual &lt;code&gt;/compact&lt;/code&gt; still works. &lt;code&gt;DISABLE_COMPACT=1&lt;/code&gt; goes further and disables manual &lt;code&gt;/compact&lt;/code&gt; too. If you only want compaction to happen earlier, &lt;code&gt;/autocompact 500k&lt;/code&gt; or the &lt;code&gt;autoCompactWindow&lt;/code&gt; setting moves the trigger. &lt;code&gt;CLAUDE_AUTOCOMPACT_PCT_OVERRIDE&lt;/code&gt; can only lower the threshold, never raise it.&lt;/p&gt;

&lt;p&gt;There's also a hook-level option. The hooks reference says a &lt;code&gt;PreCompact&lt;/code&gt; hook can block compaction by exiting with code 2. If the compaction was proactive, the session continues uncompacted. If it was recovering from a context-limit error the API already returned, the error surfaces instead.&lt;/p&gt;

&lt;p&gt;One caution. In a long GitHub issue (anthropics/claude-code #42817), a user reports compaction firing even with the setting off. I couldn't reproduce that or confirm it either way, so if this matters to you, test it on your version.&lt;/p&gt;

&lt;h4&gt;
  
  
  So what do you do instead?
&lt;/h4&gt;

&lt;p&gt;The simplest fix is to leave compaction on and steer it. Put rules that have to survive in the project-root CLAUDE.md, add a "Compact Instructions" section there, and run &lt;code&gt;/compact focus on the auth refactor&lt;/code&gt; yourself before the automatic pass picks for you. That's free and it's built in.&lt;/p&gt;

&lt;p&gt;The most common workaround I see is a manual handoff. People turn auto-compact off, watch the status line, and somewhere around 70 to 75 percent ask Claude to write a handoff document, then &lt;code&gt;/clear&lt;/code&gt; and tell the new session to read it. It works well. Its cost is your attention, and it fails exactly when you're deep in the work and forget.&lt;/p&gt;

&lt;p&gt;Then there are tools that automate parts of this. claude-auto-handoff (alexknowshtml on GitHub) does the handoff for you: before the window fills it has Haiku write a structured brief, runs &lt;code&gt;/clear&lt;/code&gt;, and seeds the fresh session with one line telling it to read the brief. claude-mem takes a different angle: it captures what your agent does, compresses it, and injects relevant context into later sessions. context-mode attacks the input side by sandboxing tool output so less of it lands in your window, and it persists session memory too. Using subagents for big reads helps for the same reason. These overlap, and you can run more than one.&lt;/p&gt;

&lt;h4&gt;
  
  
  Where aigent-OS fits (I built this)
&lt;/h4&gt;

&lt;p&gt;Disclosure first: I built aigent-OS, so weigh this paragraph accordingly. It's an open-source Claude Code harness that refreshes its own context instead of compacting. At a threshold, 80% by default, it asks Claude to write a checkpoint I call a capsule. It waits for one exact acknowledgement, sends a single &lt;code&gt;/clear&lt;/code&gt;, confirms through the &lt;code&gt;SessionStart&lt;/code&gt; hook that a genuinely new session started, then resumes from the capsule. No acknowledgement, no clear. Memory is plain markdown in git, so you can read what it remembers with &lt;code&gt;git log&lt;/code&gt;. It's MIT licensed, runs locally and needs Node 18+.&lt;/p&gt;

&lt;p&gt;Here's what I can and can't tell you about it. Managed Auto-Refresh is in a release candidate, v1.1.0-rc.1. The public evidence is 11 of 11 clean refresh cycles on one machine, run at a deliberately low threshold so cycles came fast. On rc.1, a long session can still stall at the clear step and need a manual &lt;code&gt;/clear&lt;/code&gt;. The fixes for that are merged on master but not in a tagged release yet, and two narrower edge cases around the acknowledgement are still open (issues #90 and #91). I'm not claiming it beats compaction. It's a different trade-off: an inspectable checkpoint and a clean window instead of a summary. Each cycle also costs some tokens to write and read the capsule. The repo is at &lt;a href="https://github.com/wrg32786/aigent-os" rel="noopener noreferrer"&gt;https://github.com/wrg32786/aigent-os&lt;/a&gt; if you want to read the install script before running anything.&lt;/p&gt;

&lt;h4&gt;
  
  
  FAQ
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Does turning off auto-compact give me more room?&lt;/strong&gt;&lt;br&gt;
It doesn't change the model's context window. Some users say turning it off frees space that was held back for compaction. I couldn't confirm that in Anthropic's docs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Does &lt;code&gt;/compact&lt;/code&gt; still work with auto-compact off?&lt;/strong&gt;&lt;br&gt;
Yes. The settings reference says manual &lt;code&gt;/compact&lt;/code&gt; keeps working. Only &lt;code&gt;DISABLE_COMPACT&lt;/code&gt; turns it off.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What happens if I hit the limit with auto-compact off?&lt;/strong&gt;&lt;br&gt;
From what I can tell you get a context-limit error instead of a compaction, though the docs only spell that out in one place. At that point you &lt;code&gt;/compact&lt;/code&gt; or &lt;code&gt;/clear&lt;/code&gt; by hand.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Is a handoff file better than compaction?&lt;/strong&gt;&lt;br&gt;
Neither is better everywhere. A summary takes no effort. A handoff you control takes effort or tooling, but you decide what survives.&lt;/p&gt;

</description>
      <category>claudecode</category>
      <category>ai</category>
      <category>productivity</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
