Repository navigation
Description
What
scripts/doctor.sh resolves CLAUDE_PROJECT_DIR with a raw $PWD fallback in two places, the
same shape #743 fixed in scripts/write-handoff.sh by preferring git rev-parse --show-toplevel.
If CLAUDE_PROJECT_DIR is unset and an earlier cd in the same shell/tool call has already moved
the cwd into a subdirectory, doctor.sh resolves project root as that subdirectory instead of the
real top level -- silent-wrong-directory, the exact failure #743's own issue named.
Location
scripts/doctor.sh:94-100:
if [ "${1:-}" = "--json" ]; then
_JSON_PROJECT_DIR_ASSUMED=0
if [ -z "${CLAUDE_PROJECT_DIR:-}" ]; then
CLAUDE_PROJECT_DIR="$PWD"
_JSON_PROJECT_DIR_ASSUMED=1
export CLAUDE_PROJECT_DIR
fi
fi
and scripts/doctor.sh:223-229, the non-JSON path's identical fallback.
Mechanism
Both sites assume $PWD already sits at the project root when CLAUDE_PROJECT_DIR is unset.
write-handoff.sh's own #743 fix established git rev-parse --show-toplevel as the safer
resolution for exactly this repo's own tooling (a subshell or tool call that already cded one
level down before doctor.sh runs would otherwise report a verdict scoped to that subdirectory,
not the real project).
Why not fixed in #743 itself
scripts/doctor.sh had three separate open PRs actively editing it at the time (#769, #770,
#771) -- touching it risked a live merge conflict, and #743's own issue text scoped the fix to
write-handoff.sh only. Logged as trap.d/743.doctor-pwd-fallback.md at the time (Class:
fails-to-preserve, non-blocking), found by the oss:auditor/Explore self-review spawned inside the
#742/#743 developer lane, 2026-09-25. Still true at HEAD as of this curation pass
(2026-09-26) -- neither fallback has been converted to the toplevel-based resolution.
What would settle it
Apply the same git rev-parse --show-toplevel preference write-handoff.sh now uses, at both
doctor.sh fallback sites, with a regression test on the same pattern #743's own test file uses
(construct a scenario where cwd is a subdirectory and CLAUDE_PROJECT_DIR is unset, assert the
resolved root is the real top level, not the subdirectory).
[AI-generated]
Activity
curate: 8 trap.d fragments -- 1 promote, 1 merge, 6 decline (#807)
fix(#827): carry doctor.sh's #776 subdirectory fix, correct two stale…
fix(Digital-Process-Tools#802,Digital-Process-Tools#808): doctor.sh g…