Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

Write CI scratch files to $TMPDIR instead of the sandbox's read-only /tmp (#4063)

Worktrunk Botbdfee6a713c0
diff --git a/.claude/skills/running-tend/SKILL.md b/.claude/skills/running-tend/SKILL.md
index 03dccc51e..b89440fb7 100644
--- a/.claude/skills/running-tend/SKILL.md
+++ b/.claude/skills/running-tend/SKILL.md
@@ -46,7 +46,9 @@ Don't try to `cargo install` them in the sandbox — past attempts at
source-compiling installs cascaded into bash-tool interrupts that blocked
even `pwd` and `echo`. Instead, query Codecov directly, following
`tests/CLAUDE.md` → **Coverage Investigation** for the endpoints and their
-traps.
+traps. The sandbox also mounts root `/tmp` read-only, which is why the
+scratch paths there and below go to `${TMPDIR:-/tmp}` — write new ones the
+same way.
If the Codecov API markers aren't enough, download the `code-coverage-report`
artifact from the PR head's `coverage` workflow run — it contains a
@@ -58,8 +60,8 @@ REPO=$(gh repo view --json nameWithOwner --jq '.nameWithOwner')
CI_RUN=$(gh api "repos/$REPO/commits/<sha>/check-runs" --jq '.check_runs[] | select(.name == "code-coverage") | .details_url | capture("runs/(?<id>[0-9]+)") | .id')
# List artifacts, then download the coverage one:
gh api "repos/$REPO/actions/runs/$CI_RUN/artifacts" --jq '.artifacts[] | {name, id}'
-gh api "repos/$REPO/actions/artifacts/<id>/zip" > /tmp/coverage.zip
-unzip -q /tmp/coverage.zip -d /tmp/coverage
+gh api "repos/$REPO/actions/artifacts/<id>/zip" > "${TMPDIR:-/tmp}/coverage.zip"
+unzip -q "${TMPDIR:-/tmp}/coverage.zip" -d "${TMPDIR:-/tmp}/coverage"
```
## Test Commands
@@ -349,7 +351,7 @@ jq -n --arg cwd "$PWD" '{
workspace: {current_dir: $cwd},
model: {display_name: "Opus"},
context_window: {used_percentage: 42.0}
-}' > /tmp/statusline-input.json
+}' > "${TMPDIR:-/tmp}/statusline-input.json"
# Debug build on purpose. `tend-weekly` installs no `wt` and restores no Rust
# cache, so `--release` means a cold optimized build of the whole dependency
@@ -357,7 +359,7 @@ jq -n --arg cwd "$PWD" '{
# check reads are profile-independent; only the timing columns, which this
# section doesn't triage, would be worth a release build.
cargo run -- -vv list statusline --format=claude-code \
- < /tmp/statusline-input.json > /dev/null
+ < "${TMPDIR:-/tmp}/statusline-input.json" > /dev/null
cargo run -- config state logs profile --format=json | jq .cache
```
diff --git a/tests/CLAUDE.md b/tests/CLAUDE.md
index d3a7866cd..2f86e5f1c 100644
--- a/tests/CLAUDE.md
+++ b/tests/CLAUDE.md
@@ -61,17 +61,17 @@ For each uncovered function, either write a test (integration tests via `assert_
API=https://api.codecov.io/api/v2/github/max-sixty/repos/worktrunk
# Full SHAs throughout; an abbreviation 404s. `?pullid=N` compares the PR's
# *current* head, so name both SHAs to ask about an earlier commit.
-curl -sL "$API/compare/?base=<base-sha>&head=<head-sha>" > /tmp/codecov.json
+curl -sL "$API/compare/?base=<base-sha>&head=<head-sha>" > "${TMPDIR:-/tmp}/codecov.json"
# Patch coverage per file. `.name` is an object, and the files carrying patch
# lines are the ones with `has_diff`:
-jq '.files[] | select(.has_diff) | {name: .name.head, patch: .totals.patch}' /tmp/codecov.json
+jq '.files[] | select(.has_diff) | {name: .name.head, patch: .totals.patch}' "${TMPDIR:-/tmp}/codecov.json"
# The missed patch lines in one file. `.coverage.head` is a LineType enum
# (0=hit, 1=miss, 2=partial), and `.added` keeps context lines inside a hunk
# from reading as patch misses:
jq '.files[] | select(.name.head == "<path>") | .lines[]
- | select(.is_diff and .added and .coverage.head == 1) | {line: .number.head, code: .value}' /tmp/codecov.json
+ | select(.is_diff and .added and .coverage.head == 1) | {line: .number.head, code: .value}' "${TMPDIR:-/tmp}/codecov.json"
# Whole-file line coverage at one commit. No trailing slash after the path —
# the route swallows it and answers 404 "coverage info not found":