// notes
patriola.com

From the field · May 2026

My First Claude Code Automation
(Step by Step)

From interactive session to scheduled automation — a real tutorial for someone who hasn't done this yet.


What we're building

Claude Code automations vs regular Claude

When most people use Claude, they have a conversation: type something, Claude responds, you continue. That's interactive mode. Useful, but manual. Every time you want output, you have to be there.

Claude Code can also run non-interactively. You supply a prompt via the command line, Claude executes it and exits, and the output goes wherever you send it — a file, an email, a Slack message, a log. No conversation. No human in the loop. This is what makes automations possible.

The automation we're building: a daily digest that summarizes yesterday's work from your git log. Every morning when you sit down, there's a plain-English summary of what was committed the day before. No digging through commit history. Claude has already read it and written the summary.

This is a good first automation because it's genuinely useful, it requires real Claude Code features (file I/O, shell commands), and the failure modes are instructive — you'll hit the same issues in every other automation you build.

Step 1

Write the Claude command

First, get this working interactively. Open a Claude Code session in your project directory and run:

the daily digest command — test it interactively first

Run this shell command and summarize the output in plain English:

git log --since="yesterday" --until="now" --pretty=format:"%h %s (%an, %ar)" --no-merges

Write a 3–5 sentence digest: what was worked on, any patterns you notice
across commits, and one sentence flagging anything that looks like it
needs follow-up (a commit message with "WIP", "fix", or "broken" in it).

Keep it readable — this is for a morning briefing, not a code review.
      

Run this in a session and verify the output makes sense. Adjust the prompt if needed. Once it's producing good output interactively, move to the next step.

Step 2

Run it non-interactively with --print

Claude Code's --print flag runs a prompt and exits without opening an interactive session. Test it from your terminal:

shell command — non-interactive run

claude --print "Run git log --since=yesterday --no-merges --pretty=format:'%h %s (%an, %ar)' and write a 3-5 sentence plain-English digest of what was worked on. Flag any commit with WIP, fix, or broken in the message."
      

The output prints to stdout. Redirect it to a file with > digest.txt or pipe it wherever you need it. Verify the output is what you expect before moving on. If it's blank or errors, check that you're running from the right directory — Claude Code uses the working directory to resolve git commands.

Step 3

Wrap it in a script

Create a script file — daily-digest.sh on Mac/Linux or daily-digest.ps1 on Windows — that runs the command and saves output to a dated file:

daily-digest.sh

#!/bin/bash
# Use absolute paths — the scheduler won't have your shell environment
REPO="/absolute/path/to/your/project"
OUTPUT_DIR="/absolute/path/to/digests"
DATE=$(date +%Y-%m-%d)

cd "$REPO" || exit 1

/usr/local/bin/claude --print \
  "Run git log --since=yesterday --no-merges \
  --pretty=format:'%h %s (%an, %ar)' \
  and write a 3-5 sentence plain-English digest of what was worked on. \
  Flag any commit with WIP, fix, or broken in the message." \
  > "$OUTPUT_DIR/digest-$DATE.txt"

echo "Digest written to $OUTPUT_DIR/digest-$DATE.txt"
      

Make it executable: chmod +x daily-digest.sh. Run it manually and confirm the output file appears. Use absolute paths for everything — this is the single most common source of failures when the script runs scheduled.

Step 4

Schedule it with cron or Task Scheduler

On Mac/Linux, add a cron entry to run the script each morning at 7am:

crontab entry (run crontab -e)

0 7 * * * /absolute/path/to/daily-digest.sh >> /absolute/path/to/cron.log 2>&1
      

On Windows, open Task Scheduler, create a Basic Task, set the trigger to Daily at 7:00 AM, set the action to run powershell.exe with the argument -File "C:\absolute\path\daily-digest.ps1". Run the task manually from Task Scheduler to verify before trusting the schedule.

What the digest output looks like

Yesterday's digest — 2026-05-27:

Work focused on the blog infrastructure: three commits added new post HTML files (inbox triage, daily workflow, task tracking) and one commit updated the blog index page to include the new entries. The changes are consistent in structure, following the established site template. One commit message to note: "fix: hero section spacing on mobile" suggests a layout issue that was corrected — worth checking that the fix renders correctly on actual devices before the next publish.

What breaks first

Three failure modes, in order of frequency

Path issues. The cron or Task Scheduler environment doesn't have your shell's PATH. claude isn't found. Fix: use the absolute path to the Claude binary everywhere (which claude gives you the path on Mac/Linux).

Auth issues. Claude Code stores credentials in your user profile. If the scheduler runs as a different user, or if the profile path isn't accessible, Claude will fail silently or prompt for auth — which it can't complete non-interactively. Fix: run the script manually as the same user the scheduler will use, and verify credentials are accessible before scheduling.

Empty output. git log --since=yesterday returns nothing if there were no commits, or if the working directory isn't set to the repo root. Fix: add a check for empty output and write a placeholder line ("No commits yesterday") so you know the script ran successfully and the repo was just idle.

Next step

Book 2: the full automation system

This automation runs Claude once a day on a schedule. Book 2 goes further: hooks that trigger Claude on file changes, multi-step automation chains, approval workflows, and how to build a full Claude Code setup that runs in the background without your involvement. It's in progress — subscribe to the newsletter for the launch date, or check out Book 1 if you want to get the foundations right first.

Read Book 1 →

Newsletter

More notes, when there are notes

No schedule. Just the things worth writing down — session memory, hooks, automations, multi-agent setups.