●BG SKILL — Claude Code 2.1.337 lets a running skill move to the background in Desktop and cloud sessions so the chat keeps going●API 10-21 — In API version 2026-10-21, setting temperature, top_p or top_k returns a 400. Check before you bump the version●OPUS 4.5 — claude-opus-4-5 retires on 2027/1/22, 47 days from now. A good week to find every place your config names it●CHROME — Several people report Claude in Chrome refusing all of amazon.com. The question is how to tell a block from a mistake●NEW — New: Before a sync, check where files land if the destination is empty●RETIRE — A retirement date and a "not sooner than" date mean different things on deprecation pages. Knowing which is which saves a scramble●BG SKILL — Claude Code 2.1.337 lets a running skill move to the background in Desktop and cloud sessions so the chat keeps going●API 10-21 — In API version 2026-10-21, setting temperature, top_p or top_k returns a 400. Check before you bump the version●OPUS 4.5 — claude-opus-4-5 retires on 2027/1/22, 47 days from now. A good week to find every place your config names it●CHROME — Several people report Claude in Chrome refusing all of amazon.com. The question is how to tell a block from a mistake●NEW — New: Before a sync, check where files land if the destination is empty●RETIRE — A retirement date and a "not sooner than" date mean different things on deprecation pages. Knowing which is which saves a scramble
Why I Stopped Borrowing a Stale Repo and Started Cloning Fresh After a Scheduled Task Couldn't Write to Shared /tmp
A scheduled task stopped because it could not create its clone directory under /tmp. Here is how I traced it, the borrowable clone that was about 9.6 hours behind, the cost of cloning fresh every run, and a script that picks a working directory.
On a Wednesday evening I opened the log of a scheduled task and found it had stopped at its first Git operation.
fatal: could not create work tree dir '/tmp/repos/site-repo': Permission denied
My runbook says to keep a persistent repository under /tmp/repos and git pull it next time. That one line told me there are days when the assumption does not hold. I've masked the repository name as site-repo here; every other line of output is exactly what I saw that day.
What follows is how I traced the cause, and why I stopped borrowing a clone that another run had left behind and decided to clone fresh every time. If you run Git against a repository from a Cowork scheduled task, I hope it saves you from stepping on the same spot.
The short version first: the fix was not "repair /tmp." It was two habits — never hard-code the working directory, and prove the checkout is current with a number before doing any work.
A triage table: from the error you see to the likely cause
The same Permission denied can come from several places. Here are the ones I actually hit, plus the neighbours I'd check next. Going top to bottom saves a detour.
Symptom (verbatim)
Likely cause
How to check
Fix
fatal: could not create work tree dir '/tmp/repos/…': Permission denied
The parent /tmp/repos belongs to another user with mode 755
Compare ls -ld /tmp/repos with id
Pick a parent you can write to (pick_base.sh below)
The clone you wanted to borrow has a .git owned by someone else
stat -c '%U %a' .git
Clone fresh instead. If you must borrow, copy first, then pull
fatal: detected dubious ownership in repository at …
Git's ownership check refused a repository owned by another user
Check the owner of the path in the message
Read it with a one-off -c safe.directory=… (this grants no write access)
No space left on device
Genuinely out of space
df -m /tmp "$HOME"
Delete only what you created. Leave other runs' directories alone
Mine was the first row. I started at the last row, though, and checked disk space first. That detour is the next section.
Four commands to trace it — /tmp is writable, /tmp/repos is not
My first suspect was /tmp itself. Was it out of space, or read-only? I checked in order.
id # who am Ils -ld /tmp /tmp/repos # owner and mode of parent and childmkdir /tmp/repos/x # can I create under the child?touch /tmp/_w_test && echo "tmp root writable" # can I write directly in /tmp?
Three things fall out of this. /tmp is drwxrwxrwt — world-writable with the sticky bit — so a touch directly inside it works. /tmp/repos, on the other hand, is owned by nobody with mode 755, so my user (uid 1079) can enter it but cannot create anything inside. And /tmp/repos was created at 01:16 the same day: another run had made it first.
Being able to write to /tmp is not the same as being able to write to someone else's directory under /tmp. I briefly reasoned "/tmp is writable, so the problem must be elsewhere" and went off to check disk space. There was 3,787 MB free on / and 7,229 MB on /sessions, so that wasn't it. Looking back, a single ls -ld would have settled it; I went to disk space because "anyone can write to /tmp" was sitting in my head ahead of the evidence.
✦
Thank you for reading this far.
Continue Reading
What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.
WHAT YOU'LL LEARN
✦You can tell whether a shared /tmp is 'writable but not for you' and find the cause with four commands
✦You can stop a run from appending to a stale clone that another run left behind, by comparing SHAs before you touch anything
✦You can put the choice of working directory into one script, so a scheduled task spends no time hunting for a place to work
Secure payment via Stripe · Cancel anytime
✦
Unlock This Article
Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.
There was a clone I could borrow — about 9.6 hours behind
Directly under /tmp sat a clone of the same repository, apparently left by another run (also owned by nobody). I could read it. The thought arrived: copy this, and skip the clone.
9296076 2026-10-20 23:06:43 +0000 ← the borrowable clone
3dd2738 2026-10-21 08:41:15 +0000 ← latest on origin/main
The borrowable clone was roughly 9.6 hours behind origin. And because I couldn't write to its .git (touch .git/probe gave Permission denied), I couldn't git pull it in place either. Using it would mean copying it, then pulling — two steps.
For any task that adds or rewrites files, this is a quietly dangerous position. Run a "does this filename already exist?" check or a "does the file I'm referencing exist?" check against a checkout that's nine hours stale, and you'll sometimes conclude "it doesn't exist" when it does, or the reverse. If it surfaces as a push conflict, you're lucky. If you only used the result of the check to make some other decision, the mistake is recorded nowhere.
The real cost of borrowing a stale clone isn't clone time. It's the chance of making a wrong call.
Three misconceptions I re-checked by hand
After this I went back over steps I'd written on assumption. Everything below I re-ran myself in November 2026 on Linux (kernel 6.8) with Git 2.34.1.
Misconception 1: "If mkdir -p succeeds, I can create things under it."
You can't count on that. On a directory that already exists, mkdir -p does nothing and reports success — even when you can't write to it.
The only honest way to know whether you can write somewhere is to create a child and remove it. That's exactly what the script below does.
Misconception 2: "The sticky bit on /tmp means 'this is shared.'"
What the sticky bit (the trailing t in the mode) protects is the opposite: other users can't delete or rename your files. Only the top level of /tmp is open to everyone. A directory someone created inside it with 755 is theirs. "It's a shared place, so what's inside is shared too" doesn't follow.
Misconception 3: "With safe.directory, I can use someone else's clone."
safe.directory decides whether Git will trust a repository owned by a different user. It doesn't widen filesystem permissions. You can read the repo, but you still can't write to its .git. I add -c safe.directory='*' only for the single read command. Writing it into a config file would switch the check off for every repository from then on, which I'd rather not do. How this setting is honoured has varied across Git versions, so if it seems to have no effect, check git --version first.
What cloning fresh every time actually costs
So what does giving up reuse cost? I measured.
Operation
Time
Disk
git clone --depth 1 (new)
2.8 s
50 MB working tree (13 MB of it .git)
git pull --rebase (my own existing clone)
0.7 s
Delta only
Whole script below, first run (find location + clone + SHA check)
3.7 s
50 MB
Whole script below, second run (pull + SHA check)
1.85 s
Delta only
Reuse saves about two seconds per run. For a once-a-day task, that's about twelve minutes a year. Trading that for "depends on another run's state" and "can't notice stale content" wasn't worth it for the way I work.
One caveat: $HOME was a differently named location each run (this time /sessions/rcw-…) and did not carry over to the next. So "keep it in $HOME/repos and pull next time" doesn't hold either; every run is a fresh clone. It's still 2.8 seconds.
Four ways to borrow — and when to pick each
I'd been thinking in terms of "borrow or don't." Laid out properly, there were four options.
Approach
Speed
Notices staleness?
Depends on other runs
Good for
A. Use someone else's clone as-is
Fastest
No (can't pull)
Heavily
Read-only lookups where staleness doesn't matter
B. Copy someone else's clone, then pull
Depends on the copy
Yes, if the pull succeeds
On the source's state
Big repos where a clone takes minutes
C. Borrow only objects with --reference-if-able + --dissociate
Somewhat faster
Yes (the clone itself comes from origin)
Only during the clone
Large repos with deep history, re-fetched every run
D. Clone fresh into a place you can write, every run
2.8 s (here)
Yes
None
Smaller repos touched a few times a day by a scheduled task
Around 50 MB, go with D; once a clone takes more than a few tens of seconds, look at C. That's where I draw the line.
C may be unfamiliar, so here's what I observed. --reference-if-able doesn't stop when the reference is missing.
info: Could not add alternate for '/nonexistent/x': path '/nonexistent/x' does not exist
exit=0
With --dissociate, no link to the reference (.git/objects/info/alternates) remains after the clone. Clone with --reference alone and that file records the path to the reference's objects — if the reference later disappears, your own repository may become unreadable. The official git-clone documentation carries a NOTE warning about this usage. Whatever another run left behind can vanish at any moment, so if you borrow, always pair it with --dissociate.
A script that picks a working directory, and a check after cloning
I narrowed the approach to two rules. Choose a location only after proving you can create a child in it. And before starting work, compare your local HEAD with the SHA of origin/main.
The first script picks the location. stat takes different format flags on Linux (GNU) and macOS (BSD), so it falls back between the two. I haven't run the macOS stat -f branch myself, so treat that part as unverified.
#!/usr/bin/env bash# pick_base.sh — walk the candidates and print the first writable parent directoryset -uCANDIDATES=("/tmp/repos" "${TMPDIR:-/nonexistent}/repos" "$HOME/repos")owner_mode() { # works with GNU stat and BSD (macOS) stat stat -c '%U %a' "$1" 2>/dev/null || stat -f '%Su %Lp' "$1" 2>/dev/null || echo "? ?"}for base in "${CANDIDATES[@]}"; do # mkdir -p succeeds even when the directory exists but isn't writable, # so actually create a child and remove it to prove we can write mkdir -p "$base" 2>/dev/null || { echo "skip(mkdir): $base" >&2; continue; } probe="$base/.probe.$$" if mkdir "$probe" 2>/dev/null; then rmdir "$probe" echo "$base" exit 0 fi set -- $(owner_mode "$base") echo "skip(owner=$1 mode=$2): $base" >&2doneecho "FATAL: no writable working location" >&2exit 1
In this environment it skipped /tmp/repos with a reason and chose a location under TMPDIR:
The fact that the line says skip(owner=…) rather than skip(mkdir) is Misconception 1 in action: mkdir -p passed, and only creating the child failed.
The second script clones and verifies.
#!/usr/bin/env bash# fresh_repo.sh <remote-url> <name> — prints the working directory pathset -euo pipefailREMOTE="$1"; NAME="$2"BASE=$("$(dirname "$0")/pick_base.sh")DIR="$BASE/$NAME"if [ -d "$DIR/.git" ]; then # Reuse an existing clone only if I can write to it AND it's current if [ -w "$DIR/.git" ] && git -C "$DIR" pull -q --rebase origin main 2>/dev/null; then : else echo "stale or read-only: $DIR → recreating" >&2 rm -rf "$DIR" 2>/dev/null || DIR="$BASE/$NAME.$$" fifi[ -d "$DIR/.git" ] || git clone -q --depth 1 --branch main "$REMOTE" "$DIR"# Always verify last: local HEAD must equal the remote main SHALOCAL=$(git -C "$DIR" rev-parse HEAD)REMOTE_SHA=$(git -C "$DIR" ls-remote origin main | cut -f1)[ "$LOCAL" = "$REMOTE_SHA" ] || { echo "FATAL: HEAD=$LOCAL origin/main=$REMOTE_SHA" >&2; exit 2; }echo "$DIR"
The check sits at the end because even after deciding not to borrow, there are paths where a pull fails silently — an expired credential, a dropped connection. Since 2>/dev/null swallows the message, the exit code alone would let you carry on with a stale tree. Don't hand back a working directory until the SHAs match, and you never start writing on stale state.
Drop the || exit 1 and a failed check leaves DIR empty; cd "" keeps you wherever you are, and the task carries on there. Please don't trim that line.
Three steps at the top of the scheduled task
I put the two scripts at the very start of the runbook, in this order:
Run pick_base.sh to settle where to work. If it fails, stop here and don't continue.
Call fresh_repo.sh and store the returned path in a variable. No path comes back until the SHAs match.
From then on, use only that variable. Don't leave fixed paths like /tmp/site-repo anywhere in the runbook text.
The third one is what I expect to matter most. If a single fixed path survives somewhere, an old step will go and read it right after you've tidied up the location logic. When you fix it, grep the whole runbook — the cleanup and failure sections at the end too, not just the top.
Pitfalls
Cleaning up with rm -rf /tmp/repos/* doesn't touch what other runs created. Deletion is governed by write permission on the parent directory, not the target, so under a nobody-owned 755 directory you can't remove anything. If your "out of space" procedure says "clear /tmp," change it to clear only the places you created.
Reading someone else's clone with git can trip the ownership check. As in Misconception 3, read it with a one-off -c and keep it out of config files.
The scripts here leave authentication to the REMOTE argument. How you carry credentials is a separate problem; I wrote up the token-in-URL setup that stopped working after a redirect. To keep tokens out of logs, I mask the output with sed before reading it.
Picking the wrong working location can also happen because you're looking at a different shell entirely. The morning WS came back empty is in the note on mixing up two shells. The cause there is different, but the remedy — one line that checks first — is the same idea.
When to stop reusing, and when not to
My decision assumes a repository of about 50 MB and no more than a few runs a day. Change those, and the conclusion may change.
If the repository is big enough that a clone takes tens of seconds or more (deep history, LFS), reuse starts to earn its keep. Even then, keep the two rules: put it somewhere you can write, and verify the SHA. Option C in the table above is worth a look.
If you clone every run, keep --depth 1. Pull the full history and it's no longer a 2.8-second story.
If runs execute in parallel, giving each its own name, like $BASE/$NAME.$$, avoids them fighting over one directory (the script above falls back to that form only when removal fails).
The next place you'll get stuck — two runs pushing to the same branch
Even with separate working locations and a fresh start every time, two runs that overlap can still push to the same main. The one that pushes second gets ! [rejected] main -> main (fetch first).
What I do there is insert one git pull --rebase origin main, push again, and then compare SHAs one more time.
git push origin main || { git pull --rebase origin main && git push origin main; }[ "$(git rev-parse HEAD)" = "$(git ls-remote origin main | cut -f1)" ] \ && echo "pushed: $(git rev-parse --short HEAD)" \ || { echo "FATAL: HEAD still differs from origin/main after push" >&2; exit 3; }
If the rebase hits a conflict, I don't resolve it automatically; the task stops there. How I get a stopped task back on its feet the next morning is in why scheduled tasks stop without a word, and how to make them recover. Judging a push by SHA rather than exit code is the same idea as with the clone. Choose the location fresh each run, and prove freshness with a number each run. Those two I keep even on days when I'm in a hurry.
One thing to try next: put pick_base.sh and the SHA check at the very top of your scheduled task. From that day on, you may find you no longer have to think about where today's work lives.
Share
Thank You for Reading
Claude Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.