Let AI do daily jobs for you: build an AI automation workflow on a Mac

Run claude -p or codex exec by hand first, schedule it daily with launchd, send results to a file or chat app, and keep permissions and costs in check.

Updated Dec 2, 2026

Let AI do daily jobs for you: build an AI automation workflow on a Mac

01What an AI workflow is

A workflow lets AI do repetitive tasks on a schedule: put together a summary of your notes every morning, turn spreadsheets into a report every week, check a web page for updates every hour. You only need three things to set one up:

  • An AI that can “run once without opening its interface, then exit”: claude -p in Claude Code, or codex exec in Codex.
  • A timer: on a Mac, use launchd, which is built into the system.
  • An output: write the result to a file, or send it to your chat app.

02Step 1: Get it working once by hand

In Terminal, go into your working folder and ask the AI to do the task once in a single sentence. In Claude Code:

claude -p "Read the files added to the notes folder today and write a 200-word summary to summary.md" --allowedTools "Read,Write"

  • -p means do it just this once and exit when done.
  • --allowedTools approves the tools it will use in advance. In this mode nobody is there to click “Allow”, so any action that isn’t approved is simply refused. That’s why you need to list them up front.
  • In Codex, it’s codex exec "your instruction". It is read-only by default; to let it edit files, add --sandbox workspace-write. It also has to run inside a Git repository.

Run it by hand a few more times. Once the result is what you want, set it to run on a schedule.

03Step 2: Make it run every day

Apple recommends launchd for scheduled jobs (cron still works, but Apple no longer recommends it). You write a small script, then a config file that tells the system when to run it:

  1. Write a script, for example ~/bin/daily.sh: the first line goes into your working folder, the second runs the claude -p command above. Use the full path to claude (installed with the official command, it’s at ~/.local/bin/claude), because a scheduled job can’t find the paths your usual Terminal uses. When it’s written, run chmod +x ~/bin/daily.sh.
  2. Create a .plist file in ~/Library/LaunchAgents/: put the script’s path in ProgramArguments, set Hour to 8 and Minute to 0 in StartCalendarInterval (8 a.m. every day), and use StandardOutPath to write the output to a log file.
  3. Run launchctl load ~/Library/LaunchAgents/YOUR_FILE.plist to load it. When you change the config later, run launchctl unload first and then load again.
  • Your sign-in may not work inside a scheduled job: run claude setup-token to create a long-lived token (needs a Pro plan or higher) and set it as the environment variable CLAUDE_CODE_OAUTH_TOKEN in the script. Or use an API key instead.
  • According to Apple: if the Mac is asleep at the scheduled time, the job runs when it wakes up; if it’s shut down, the job is skipped. NexMini Macs are already set never to sleep, so you don’t need to worry about this.

04Step 3: Get the result in front of you

  • Simplest: write it to a file, then connect and read it, or sync it to cloud storage.
  • Send it to a chat app: many chat apps (Telegram, for example) offer a bot API. At the end of the script, use curl to send yourself a message.
  • Let the AI tidy up the result before sending: say it clearly in the instruction, for example “summarize in three bullet points and send it to me”.

05Safety and cost

  • Give it only the permissions this task needs: list them with --allowedTools in Claude Code. Codex is read-only by default; don’t open it up unless you have to.
  • Without --bare, claude -p uses the MCP config and hooks in the project folder directly and won’t ask whether you trust them. Only run scheduled jobs in your own project folders.
  • Set a usage limit on your API. When a scheduled job goes wrong it may retry again and again, and costs can grow faster than you expect.

For a workflow to run every day, the machine has to stay on. For how to keep a Mac from sleeping and restart things automatically after a crash, see the guide “How to keep an AI agent running 24/7 on a Mac”.