Getting Back Into Writing (And AI Experiments)
It’s been a while since I last posted here, but this feels like a good time to pick it up again. Lately, like most developers in 2025, I’ve been experimenting heavily with LLMs and AI agents. I’ve tried Cursor, GitHub Copilot, Cline, Roo Code, and probably a few others I’ve already forgotten. But over the past few months, one tool has clearly stood out for me: Claude Code from Anthropic.
I first tried Claude Code shortly after it launched in February. It worked surprisingly well, but I burned through $10 worth of tokens in about 15 minutes. At that point, it simply wasn’t justifiable for my workflow. I moved on.
A couple of months later, Anthropic introduced Claude Max and later Pro plans with flat-fee usage. That changed everything. I came back, and this time, I stayed.
Not a Vibecoder, But It Helps
I’m not much of a vibecoder. I still like to think through structure and architecture myself. But Claude Code has been incredibly helpful for overcoming what I call “blank page syndrome.” When starting a new project or implementing a large feature, that initial friction can be real. Prompting first, even if I refactor heavily afterward, often gets me moving faster.
Sometimes I completely rewrite Claude’s output. Sometimes I only keep 30% of it. But even then, it saves me mental energy. That alone makes it worth using.
The Annoying Sleep Problem
There was one persistent annoyance, though.
When Claude works on something substantial, it can take time — especially if you’re letting it reason through a larger refactor or generate multiple files. I often leave it running while I grab coffee or take a short break. More than once, I’ve come back to my Mac only to find that it went to sleep halfway through the task, pausing the agent entirely.
It’s a small problem, but it breaks flow.
When Claude Code introduced hooks support, I immediately thought: “Perfect. I’ll just run caffeinate when Claude starts working and stop it when it finishes.” The idea was simple, keep the Mac awake only while Claude is actively running.
There was just one problem: at the time, there wasn’t a hook that triggered when a prompt was submitted.
Until recently.
The Hook That Made It Possible
In version 1.0.54, Claude Code introduced the UserPromptSubmit hook. That was exactly what I needed. Now I could trigger a script whenever Claude started processing, and another script when it stopped.
So I built two small shell scripts and wired them into Claude’s hooks.
The first script prevents sleep by starting caffeinate for up to one hour and safely killing any previous instance started by the script:
#!/bin/bash# Prevent Mac from sleeping while Claude Code is running (for upto 1 hour)
# Kill any previously running caffeinate process started by this scriptif [ -f /tmp/claude_caffeinate.pid ]; then
old_pid=$(cat /tmp/claude_caffeinate.pid)
if ps -p "$old_pid" > /dev/null 2>&1; then
# Ensure the process is caffeinate (full command line check)
if ps -p "$old_pid" -o args= | grep -q '^caffeinate'; then
kill "$old_pid" 2>/dev/null
fi
fi
rm -f /tmp/claude_caffeinate.pid
finohup caffeinate -i -t 3600 > /dev/null 2>&1 &
echo $! > /tmp/claude_caffeinate.pid
The second script restores normal sleep behavior by killing the caffeinate process and cleaning up the PID file:
#!/bin/bash# Re-enable Mac sleep by killing the caffeinate process and cleanup the PID fileif [ -f /tmp/claude_caffeinate.pid ]; then
kill $(cat /tmp/claude_caffeinate.pid) 2>/dev/null
rm /tmp/claude_caffeinate.pid
fi
Then I added the hooks to .claude/settings.json:
"hooks": {
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "$HOME/.claude/hooks/allow-sleep.sh"
}
]
}
],
"UserPromptSubmit": [
{
"hooks": [
{
"type": "command",
"command": "$HOME/.claude/hooks/prevent-sleep.sh"
}
]
}
]
}
Small Automation, Big Flow Improvement
Since adding this, the experience has been smooth. I can start a prompt, walk away, and trust that Claude will keep running without interruption. And once it’s done, my Mac returns to normal sleep behavior automatically.
It’s a small quality-of-life improvement, but these are the kinds of tweaks that compound over time. When AI becomes part of your daily workflow, friction matters. Removing even small interruptions helps maintain development flow.
If you’re using Claude Code regularly on macOS, this setup might save you a few frustrating moments.
And if you’ve built other workflow tweaks around AI agents, I’d love to hear about them.