Lily

Posted on Jul 28

• Originally published at dev.to

Log files never announce themselves. They just sit there growing until something breaks. This is part of my "Claude Code environment" series — the previous post, "Trimming agent logs", touched on log bloat in general. This time it's the concrete implementation: a tail-truncation script that runs every night at 3:45 via launchd.

Left alone, ~/.claude/logs/ swells quietly. Recently agentmemory.err.log hit 5.3MB in a single week, and the week before that hook-latency.jsonl and vault-auto-ingest.log both blew past 5MB at the same time, pushing the whole directory to 20M. Because monitoring scripts hold onto files with tail -f, the logrotate approach of creating a new file is off the table. That's exactly why I picked a method that keeps the file path fixed and only shaves the contents.