Developer Riccardo Bartoli released agent-usage-guard, a modification for Anthropic's Claude Code desktop app designed to prevent the AI from automatically closing during long-running tasks — first shared on Hacker News where it garnered 23 points and 9 comments.
Tool: agent-usage-guard | Target: Claude Code Desktop App | Price: Free
License: MIT | Available: GitHub
How the Mod Prevents Auto-Close
Claude Code, a dedicated desktop application for Anthropic's coding AI, includes an automatic shutdown mechanism to manage usage limits. The app will close after a period of inactivity, which can interrupt extended coding sessions or background tasks like running tests or installations.
The agent-usage-guard mod works by simulating user activity. It programmatically triggers a system event that resets the inactivity timer, effectively preventing the app from closing itself. The implementation is a direct modification of the application's source code, not a separate background process.
Bottom line: A surgical code modification that tricks Claude Code's inactivity timer, allowing for uninterrupted long sessions.
How to Install and Use It
Installation requires direct access to the Claude Code application bundle and involves patching its source JavaScript. The process is technical and assumes comfort with command-line operations and application file structures.
"Step-by-step installation"
/Applications on macOS).Resources directory to find the app.asar archive file.asar npm package: asar extract app.asar ./app.asar pack ./app app.asar.
The GitHub repository contains the patch file and detailed instructions. There is no configuration; the mod is either active or not.
Pros and Cons of Using the Mod
Advantages:
- Eliminates workflow interruption: The primary benefit for developers working on lengthy refactors or debugging sessions.
- Zero runtime overhead: The patch integrates directly into the app, consuming no additional system resources.
- Free and open-source: Available under a permissive MIT license for inspection and modification.
Drawbacks and Risks:
- Voids stability guarantees: Modifying the core app is unsupported and may cause unexpected crashes or conflicts with future updates.
- Update complexity: Each new version of Claude Code will likely overwrite the mod, requiring re-application.
- Potential TOS gray area: While affecting local app behavior, it circumvents an intended usage control mechanism.
Alternatives and Comparisons
For developers needing uninterrupted AI coding assistance, alternative platforms with different session models exist. agent-usage-guard solves a specific problem for a specific tool.
| Feature | Claude Code + agent-usage-guard | Cursor | Windsurf | GitHub Copilot |
|---|---|---|---|---|
| Session Limits | Effectively None (Local Mod) | None (Paid) / 50 (Free) | None (Paid) | None (Paid) |
| Primary Environment | Dedicated Desktop App | Modified VS Code | VS Code Extension | IDE Extension |
| Cost | Free (Mod) + Claude Subscription | Freemium | Freemium | Paid Subscription |
| Risk | High (Breaks on Updates) | Low (Official) | Low (Official) | Low (Official) |
The mod creates a unique offering: the Claude model family's reasoning strength in a potentially unlimited local desktop session. Competing tools like Cursor or Windsurf handle session persistence differently, often tying it to cloud quotas rather than local app inactivity timers.
Who Should Use This (And Who Shouldn't)
This mod is for: Advanced Claude Code users who consistently hit the inactivity limit during legitimate, extended work sessions. It's suited for those comfortable with manual software patching and troubleshooting potential instability.
Avoid this if: You value app stability and automatic updates, are not technically confident modifying applications, or use Claude Code for short, interactive bursts. The official Claude console or alternative AI coding assistants with more generous free tiers may be better, lower-friction options.
Early feedback on the Hacker News thread notes the utility but highlights the maintenance burden. One commenter pointed out the inevitable "cat-and-mouse game" with app updates, while others appreciated the straightforward solution to a common pain point.
Verdict: A Practical Hack with a Maintenance Cost
agent-usage-guard is a focused, effective utility that solves a clear problem for power users of Claude Code. Its value is direct: it transforms the app from a potentially interrupt-driven tool into a persistent coding environment. However, its nature as an unsupported patch makes it a temporary, high-maintenance solution. Its longevity is directly tied to the stability of Claude Code's internal codebase and the developer's willingness to update the patch.
For now, it serves a niche that official solutions have not addressed, demonstrating user demand for more flexible local session management in AI developer tools.

Top comments (0)