Claude Code Scheduled Tasks: End the Bedtime Prompt Loop

Key takeaways
- Why bedtime instructions turn into a loop, and what the lost sleep costs
- Cloud scheduled tasks let you close the laptop and go to sleep
- Companies should fix the scope of overnight runs and the morning review time
On November 21, 2026 I posted on X about a trap I kept falling into with AI. You hand Claude Code a batch of instructions before bed, head for the bedroom, remember another job on the way, and walk back to the computer. Do that a few times a night and you end up short on sleep, which quietly costs you focus the next day. Anthropic’s own analysis found that 79% of Claude Code conversations fall into “automation,” where the AI carries out the work instead of the person*1. The wider the range of work you can hand off, the stronger the pull of “let me throw that in too” — that is how I read it.
In this article I look at why that loop forms and what losing sleep actually costs. Then I go through Claude Code scheduled tasks — cloud scheduled tasks, desktop scheduled tasks and /loop — and how to use them to turn a bedtime instruction into a next-morning booking, plus the rules a company needs before it lets agents run overnight. The conclusion first: do not run the job you thought of at night; book it as a cloud scheduled task that keeps running after you close the laptop, and go to sleep. That is the most realistic way to break the cycle.
I also shared this on X.
Masahiro Chaen@masahirochaenAI悪循環あるある①寝る前にめっちゃ指示しよう!
②依頼完了。ベットに行くかぁ〜
③あ!そういえばこの仕事も指示したい…
④再びパソコンに戻りClaude Codeを開く
…以降無限ループ
結局、寝不足になり日中の生産性が落ちる本末転倒に… https://t.co/ZZnrgqxMISView on X ↗
The AI loop: why bedtime instructions never stop

The four steps I described in the post
In the post I described it as an infinite loop with four steps: (1) decide to fire off a lot of instructions before bed, (2) finish the requests and head for the bedroom, (3) remember another job, (4) go back to the computer and open Claude Code. It got more of a response than I expected, which tells me a lot of people are living the same night.
A few years ago, a job that occurred to me at night went into a note for the next morning and that was the end of it. Now a single line of instruction means the AI can make progress while I sleep, so letting an idea sit overnight starts to feel like a loss. That feeling, I think, is where the loop begins.
Why it is so hard to stop
In the analysis Anthropic published in April 2025, “directive” conversations — where Claude completes a task with almost no human involvement — accounted for 43.8% of Claude Code usage, above the 27.5% seen on Claude.ai*1. Precisely because it is a tool you can leave alone, the act of tossing work into it becomes hard to stop. In my experience the loop runs on three kinds of fuel.
- Instant dispatch of every idea — it only takes one line, so you want to run it the moment it occurs to you
- Checking whether it finished — you open the screen because you are curious about the result, and while you are there you issue the next instruction
- Empty parallel slots — when you keep several sessions running side by side, an idle slot starts to feel wasteful
All three come from wanting to be more productive, which is exactly why willpower alone rarely stops them. So rather than “resist the urge,” this article looks at how to replace nighttime execution with a booking, structurally.
The cost of cutting sleep is large when you put numbers on it
Sleep in Japan is already short
Japan’s Cabinet Office publishes an annual White Paper on Gender Equality, and the FY2023 edition cites the OECD’s international comparison of time use: Japan has the shortest sleep duration of the 11 countries covered, for both men and women*8. The white paper suggests that long working hours are what shorten sleep*8. When nighttime instructions to an AI get added on top of an already short night, there is very little slack left to cut.
The Ministry of Health, Labour and Welfare, Japan’s health ministry, sets a guideline of six hours or more of sleep for adults in its Sleep Guide for Health Promotion 2023, while noting that needs vary by individual*7. A public-relations article from the same ministry also lists caffeine from late afternoon onward and heavy drinking as factors that lower sleep quality*7. A habit of issuing instructions to an AI late at night with a coffee in hand looks like it is eating into both the quantity and the quality of sleep.
Sleep loss is a cost to the company too
A report published by RAND Europe in November 2016 estimated the economic loss to Japan from insufficient sleep at up to $138 billion a year, or 1.86–2.92% of GDP*6. The same report found that people sleeping under six hours have a 10% higher mortality risk than those sleeping seven to nine hours*6. The estimate dates from 2016 and its assumptions are old, but the point still stands: deciding to cut your sleep is not purely a personal matter.
- 179%Share of Claude Code conversations classified as "automation"*1
- 243.8%Share of directive conversations in Claude Code, completed with almost no human involvement*1
- 32.92%Upper estimate of Japan's economic loss from insufficient sleep, as a share of GDP*6
- 46+ hoursSleep guideline for adults from Japan's Ministry of Health, Labour and Welfare*7
Claude Code scheduled tasks: comparing the three options
Claude Code has three ways to run a prompt at a set time or interval*3: “scheduled tasks” that run in Anthropic’s cloud (formerly called routines), local scheduled tasks that run on your own machine through the desktop app, and “/loop,” which repeats a prompt inside an open session*3. For breaking the bedtime loop, the difference that matters most is whether your computer has to be powered on.
| Aspect | Cloud | Desktop | /loop |
|---|---|---|---|
| Where it runs | Anthropic-managed cloud*3 | Your own computer*3 | Your own computer*3 |
| Computer powered on | Not required*3 | Required*3 | Required*3 |
| Open session | Not required*3 | Not required*3 | Required*3 |
| Local files | Not available (fresh clone each run)*3 | Available*3 | Available*3 |
| Permission handling | auto mode by default*3 | Set per task*3 | Inherits the session*3 |
| Shortest interval | 1 hour*3 | 1 minute if Claude sets it; 1 hour via the form*3 | 1 minute*3 |
Cloud scheduled tasks
A cloud scheduled task saves a prompt, a repository and connectors as one unit, and starts on a schedule, an API call or a GitHub event*2. Because it runs in Anthropic-managed cloud infrastructure, it keeps going with your laptop closed*2. It is available on Pro, Max, Ultra, Team and Enterprise, and you create one at claude.ai/code/routines or with /schedule in the CLI*2. The docs state clearly that it is currently a research preview, so behaviour and limits may change*2.
In the CLI you can also book a one-off run in plain language, for example “/schedule tomorrow at 9am, summarize yesterday’s merged PRs”*2. Runs set exactly on the hour can start a few minutes late, so the docs suggest offsetting the time — 9:07 rather than 9:00*2. If the job you thought of before bed is booked for 6:07 the next morning, you have one fewer reason to walk back to the desk.
Desktop tasks and /loop assume the machine is awake
Local desktop tasks run only while the app is open and the computer is awake; anything scheduled during sleep is skipped*4. On launch there is a catch-up mechanism that runs missed tasks from the past seven days once, and a “Keep computer awake” setting prevents idle sleep — but closing a laptop lid still sends it to sleep*4. /loop runs only while the session is open, and recurring tasks expire automatically seven days after they are created*3.
Remote Control lets you continue a local session from your phone, but it still requires your computer to stay powered on with the claude process running*5. Being able to add instructions from bed is convenient, and also, I think, just moves the loop from the desk into the bed. For nighttime use, a cloud task — the kind that lets you close the lid — is the better fit.
Turning bedtime instructions into scheduled Claude Code runs
What I would suggest is switching what you do at night from “execute” to “book.” When you execute, you want to check the result; when you book, the result arrives in the morning, so there is no reason to open the screen in the middle of the night.
- 1Write the idea downStart no new runs in the 30 minutes before bed. Leave the job as a one-line note
- 2Book it for the morningUse /schedule to book a one-off cloud task for a time the next morning*2
- 3Close the laptopDo not check whether it finished. Cloud tasks keep running with the computer closed*2
- 4Review in the morningOpen the run's session from History, check the changes, then open a pull request*2
Write prompts that work without you there
Because cloud tasks run autonomously, the official docs ask you to make the prompt self-contained and to state clearly what counts as success*2. Late-night ideas tend to be under-specified, so adding these four things before you book the task saves rework in the morning.
| Item | What to write | Example |
|---|---|---|
| Target | The repository and the branch to start from | Start from main in the internal tools repo |
| The job | A single task, narrowed down | Add labels to unhandled issues from last week onward |
| Definition of done | Your criterion for success | Every issue is labelled and a summary is posted to Slack |
| Out of scope | What must not be touched | Do not change config files or the main branch |
Save the urge to check for the morning
Each cloud task run is recorded in History as its own session, and from there you can review the changes and open a pull request*2. Keep in mind that a “success” label only means the session ended normally; to know whether the work you asked for actually got done, you have to read the transcript*2. Opening results at 1 a.m. rarely leaves you able to judge them properly, so reading them together in the morning is the more efficient habit.
I run several sessions in parallel myself, so I know the pull of an empty slot well. I wrote about how I made the state of each session visible at a glance in the article below.
Related articleClaude Code Session Management with Emoji Status Prefixes
Scheduled tasks consume your subscription usage the same way ordinary sessions do*2. I wrote about plans and changes to usage limits in the article below.
Related articleClaude Ultra Plan: Max Renamed, 5-Hour Limit Removed
For companies: make overnight Claude Code scheduling a written rule
When one person’s loop spreads to a team, you can end up inventing a new kind of overtime: “review what the AI produced overnight before the morning meeting.” Overnight automation is useful, but you need to decide in advance whose account runs what, and when a human checks the output.
Points to check before rollout
- Permissions belong to the individual — scheduled tasks live in a personal claude.ai account and are not shared with the team; commits and Slack posts go out under that person’s name*2
- Connectors are all included by default — every connected connector is included at creation time, with write access, so remove the ones you do not need*2
- Admins can switch it off — on Team and Enterprise, an owner can turn scheduled tasks off across the organisation in settings, which also stops existing tasks*2
- Branch protection — Claude pushes to branches beginning with claude/ by default, so pair this with GitHub branch protection rules*2
- Run limits — separate from usage, scheduled runs are capped per account, for example at 100 runs per hour*2
Deciding what to run overnight and what not to
| Type of work | Suitability | Reason |
|---|---|---|
| Triaging and labelling issues | Suitable | The official docs present this as an example of a weeknight evening run*2 |
| Finding gaps between docs and implementation | Suitable | The docs show a weekly run with a human reviewing the fix pull request*2 |
| Routine pull request reviews | Suitable | It can be triggered by GitHub events, leaving people free to focus on design review*2 |
| Changes to production | Not suitable | Nobody can verify them overnight, which delays any rollback |
| Anything that sends messages to customers | Not suitable | It goes out externally under the person's own name and is hard to retract |
How this lands in Japan, and what it means for overseas companies
In Japan, “delegated but still not resting” is easy to fall into
Sleep in Japan is short by international comparison*8, and once an AI agent you can run at any hour is added to that, the freed-up time tends to get filled with the next request. When I run corporate training sessions, I meet plenty of people who take the time AI saved them and pour it straight into more work.
For anyone driving AI adoption at a Japanese company, my advice is to hand out the usage pattern along with the tool: book at night, review in the morning. Give people a powerful tool with no model for how to use it, and in my experience the most conscientious ones are the ones who end up running it past midnight.
What this suggests for AI companies outside Japan
If you want your product to land in the Japanese market, I think showing a design that lets people rest will do more for you than showing a longer feature list. Scheduled execution, a history you can review in one sitting in the morning, an off switch an administrator controls — these are the things IT and HR departments weigh when they decide whether to adopt a tool.
I wrote about choosing between cloud-run agents and locally-run agents in the article below.
Related articlePersonal AI Agents vs Claude Code: How I Split the Work
Summary
- What the loop really is — being able to delegate in one line, plus the urge to check the result, is what makes bedtime instructions so hard to stop
- The cost of sleep — Japan’s sleep duration is short by international comparison, and the loss from insufficient sleep is estimated at up to 2.92% of GDP*6*8
- Choosing a method — if you want to close the laptop and sleep, use cloud scheduled tasks; desktop tasks and /loop assume the machine stays awake*3
- Company rules — check account ownership, connectors and branch protection, then fix the scope of overnight work and the time someone reviews it
My suggestion, starting tonight: start no new runs in the 30 minutes before bed, and book anything that occurs to you for the next morning with /schedule. The first few nights you may feel restless wanting to check, but reading the results together in the morning produces better judgement. If you want to run AI faster, start by getting a proper night’s sleep yourself.
Sources
- *1Anthropic Economic Index: AI's Impact on Software Development (Anthropic, April 28, 2025)
- *2Automate work with scheduled tasks (Claude Code Docs)
- *3Run prompts on a schedule (Claude Code Docs)
- *4Schedule recurring tasks in Claude Code Desktop (Claude Code Docs)
- *5Continue local sessions from any device with Remote Control (Claude Code Docs)
- *6Why sleep matters — the economic costs of insufficient sleep (RAND Europe, November 2016)
- *7Good-quality sleep for a healthy mind and body (Ministry of Health, Labour and Welfare public relations magazine)
- *8White Paper on Gender Equality 2023, Column 1: International Comparison of Time Use (Gender Equality Bureau, Cabinet Office)
FAQ
Do Claude Code scheduled tasks run with my laptop closed?
Yes. Cloud scheduled tasks (formerly called routines) run in Anthropic-managed cloud infrastructure, so they keep going with the laptop closed. Local tasks in the desktop app and /loop only run while your computer is awake and the app or session is open.
Which plans include cloud scheduled tasks?
The official docs list Pro, Max, Ultra, Team and Enterprise. On Team and Enterprise, an owner can switch them off across the organisation in settings. The feature is currently a research preview, so behaviour and limits may change.
What is the difference between /loop and cloud scheduled tasks?
/loop repeats a prompt inside an open session: close the session and it stops, and recurring tasks expire seven days after creation. A cloud task runs without an open session and survives a restart, but it clones the repository fresh each time, so it never touches your local files.
Where do I check the results of an overnight run?
From History on the task detail page, where each run opens as its own session. There you can review the changes and open a pull request. Note that a "success" label only means the session ended normally — to confirm the work was done, read the transcript.
Based on a post on XOriginal post ↗