Skip to content

scripts/doctor.sh has the same raw $PWD project-root fallback #743 fixed in write-handoff.sh #802

Closed

Description

@fdaviddpt

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

  1. added
    priority:medium
    filed-by-loop
    lane-diagnostics
    on Sep 26, 2026
  2. self-assigned this
    on Sep 26, 2026
  3. added 2 commits that reference this issue on Sep 26, 2026
  4. added a commit that references this issue on Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

filed-by-looplane-diagnosticspriority:medium

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions