Claude Code Mastery
16 partsTL;DR
Claude Opus 4.5 ran autonomously for 4 hours 49 minutes using stop hooks and the Ralph Loop pattern. Walk away, come back to completed work. Here's how it works.
Claude Opus 4.5 just ran for 4 hours and 49 minutes straight - autonomously, without human intervention. This isn't a typo. It's a fundamental shift in what's possible with AI-assisted coding.
For context: GPT-4 managed 5 minutes. We've gone from a parlor trick to actual, practical work in less than two years.
The catch? You can't just run claude code and walk away. You need stop hooks.
Claude Code is powerful, but it's not a self-driving car by default. You get permission prompts. You get questions. It asks for confirmation. This is good - you want guardrails when an AI can commit to git, delete files, and push code.
But for long-running tasks - refactors, test-driven development, processing todo lists - these interruptions kill productivity. You're back at your desk every few minutes, babysitting prompts.
Stop hooks solve this. They're deterministic checkpoints that fire when Claude finishes a thought, allowing you to inject logic, run tests, and loop back without stopping.

Hooks are shell commands that execute at specific points in Claude's workflow. Think git hooks, but for AI.
When Claude finishes a task and tries to exit, the stop hook intercepts it. Instead of returning a message to you, it:
This creates a deterministic loop around Claude's non-deterministic agent behavior.
The power is in the timing. By running tests after edits are complete, Claude immediately sees what broke and can fix it iteratively. It's not guessing - it has real feedback.
"He's determined to get it done. So he'll just keep trying until it actually works."
That's the Ralph Loop philosophy, named after the Simpsons character who embodied persistence through repetition.

The Ralph Loop works like this:
You pass Claude a task plus a completion_promise - a condition that must be met. Claude executes. On stop, the hook checks the promise. If unmet, Claude loops back and tries again. This repeats until either:
Example: Give Claude a todo list. Tell it to mark each item complete as it goes. Add unit tests after each step. Claude runs through the list without stopping, fixing failures before moving on.
/ralph-loop \
--prompt "Complete all tasks in tasks.md" \
--completion-promise "All checkboxes marked" \
--max-iterations 50
Get the weekly deep dive
Tutorials on Claude Code, AI agents, and dev tools - delivered free every week.
Boris Cherny, Claude Code's creator, published his usage stats:
This isn't theoretical anymore. This is production code at scale.

Test-driven development: Write tests first. Tell Claude to pass them. Hook runs tests after each attempt. Claude fixes failures iteratively.
Long refactors: List changes in a markdown file. Claude works through them step-by-step, validating with tests between each change. No babysitting.
Migrations: Database schema changes, dependency upgrades, API migrations. Chunk them into a todo list. Claude runs through it.
Batch tasks: Process hundreds of files, regenerate assets, scaffold scaffolding. One prompt, multiple iterations, deterministic validation at each step.
The common thread: You define success criteria, Claude pursues them relentlessly.
The fastest way in is the official Ralph Wiggum plugin:
claude code --install-plugin ralph-wiggum
This gives you:
/ralph-loop commandThen define your todo list in markdown:
- [ ] Implement authentication
- Unit tests: `npm test -- auth.test.js`
- Integration test: `npm run test:integration`
- [ ] Add user dashboard
- Tests: `npm test -- dashboard.test.js`
- [ ] Deploy to staging
- Smoke tests: `npm run test:smoke`
Point Claude at it:
/ralph-loop \
--prompt "Complete every todo in tasks.md, marking each done as you finish. Run all associated tests. Fix failures before moving on." \
--completion-promise "All items marked complete and all tests passing" \
--max-iterations 100
Then walk away.
Always set max-iterations and completion-promise. Otherwise you get an infinite loop burning tokens forever. This is the guardrail that keeps the Ralph Loop from going rogue.
The hook can't know when to stop unless you tell it. Be explicit.
This pattern inverts the developer-AI dynamic. Instead of:
You get:
The model's capability to stay on task for hours - especially with Opus 4.5's long context window - turns "AI assistants" into "AI workers."
4 hours and 49 minutes. That's a full workday's worth of focused engineering, no breaks, no context switching, deterministic validation at every step.
We're not there yet universally. 80% completion rate drops significantly, and 4:49 is a best-case benchmark. But the trajectory is undeniable. Each model generation gets better at staying focused, following chains of logic, and recovering from dead ends.
Stop hooks are the infrastructure that makes it practical.
Technical content at the intersection of AI and development. Building with AI agents, Claude Code, and modern dev tools - then showing you exactly how it works.
Anthropic's agentic coding CLI. Runs in your terminal, edits files autonomously, spawns sub-agents, and maintains memory...
View ToolCodeium's AI-native IDE. Cascade agent mode handles multi-file edits autonomously. Free tier with generous limits. Stron...
View Tool
New tutorials, open-source projects, and deep dives on coding agents - delivered weekly.
Cognition Labs' autonomous software engineer. Handles full tasks end-to-end - reads docs, writes code, runs tests, and...
Configure Claude Code for maximum productivity -- CLAUDE.md, sub-agents, MCP servers, and autonomous workflows.
AI AgentsInstall Claude Code, configure your first project, and start shipping code with AI in under 5 minutes.
Getting StartedInstall Ollama, pull your first model, and run AI locally for coding, chat, and automation - with zero cloud dependency.
Getting Started
Setting up Claude Code to Run Autonomously with Stop Hooks In this video, we dive into the setup and configuration of Claude Code to enable autonomous long-running scripts. We explore the...

Anthropic has released Channels for Claude Code, enabling external events (CI alerts, production errors, PR comments, Discord/Telegram messages, webhooks, cron jobs, logs, and monitoring signals) to b

Claude Code “Loop” Scheduling: Recurring AI Tasks in Your Session The script explains Claude Code’s new “Loop” feature (an evolution of the Ralph Wiggins technique) for running recurring prompts that

Claude Code now has a native Loop feature for scheduling recurring prompts - from one-minute intervals to three-day wi...

Anthropic dropped a batch of updates across Claude Code and Cowork - remote control from your phone, scheduled tasks,...

MCP servers and function calling both let AI tools interact with external systems. They solve different problems. Here i...