TimZander / TimZander/claude

standards: subagents share the scratchpad — don't hand them a script you depend on

Open Beginner friendly
#192 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
0
Forks
1
Avg merge
1d 3h
Merged PRs (30d)
7

Description

Problem

On TimZander/AudioClassifier #195, a /deep-review subagent was asked to run mutation testing. It wrote its own version of mutate.sh over the same scratchpad path the main session was already using. Its version restored sw.js from a backup captured before the main session's edits.

Re-running that script later silently reverted ~15 lines of finished-but-uncommitted work. The tell was inverted: git status showed sw.js as unmodified, which looked like a clean tree rather than a wiped file. It was caught only by an unrelated grep that noticed a deleted comment had reappeared — otherwise the next commit would have shipped a reverted file with a message describing changes that were no longer in it.

Why this is generic

  • Subagents inherit the same scratchpad directory and choose paths independently. Any script, fixture, or backup there is fair game to be overwritten.
  • Nothing tells a subagent which files the parent session depends on.
  • The failure is silent. A file restored from a stale backup produces no error, and git diff reporting no change is indistinguishable from "I haven't edited it yet".
  • It scales with parallelism — this session ran 3-4 subagents concurrently, which is now routine for /deep-review.

Proposed rule for standards/CLAUDE.md

Under Tool Usage, or as a new Working with subagents subsection:

Treat the scratchpad as shared, mutable state whenever subagents are running. Subagents write to the same scratchpad directory and will overwrite files at paths they pick independently. Do not give a subagent a task that writes to a script, fixture, or backup the main session depends on. Do not re-run a scratchpad script after a subagent has run without re-reading it first — it may not be the script you wrote.

Namespace anything a subagent writes: scratchpad/<purpose>-<agent-id>/. Keep backups of tracked working-tree files outside the scratchpad entirely, or better, use git (a WIP commit) rather than a file copy.

Any script that mutates tracked files and restores them afterwards must verify the restore rather than assume it. Guarantee it with trap ... EXIT so an interrupt cannot leave the tree mutated, and check the result:

git diff --stat <file>   # after you edited <file>, NO diff means the restore ate your work

A clean git diff on a file you know you edited is evidence of a failed restore, not of a clean run.

Acceptance criteria

  • Rule states that subagents share the scratchpad and can clobber parent files
  • Guidance to namespace subagent scratch paths by purpose/agent
  • Guidance to keep backups of tracked files outside the scratchpad (prefer a WIP commit)
  • The "verify the restore" rule, including the inverted git diff --stat tell
  • trap ... EXIT named as the way to guarantee restore on interrupt

Notes

The existing Tool Usage section covers avoiding temp files for CLI input, and the scratchpad is documented as session-isolated — which is true between sessions but not between a session and its own subagents. That gap is what bit here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Update standards/CLAUDE.md under Tool Usage or a new Working with subagents section. Include the shared scratchpad warning, namespaced paths, backup guidance, restore verification with git diff --stat, and trap ... EXIT. Confirm every acceptance criterion is covered and that the wording distinguishes subagents within a session from separate sessions.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash, git
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
90/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.