Skip to content

repo-fleet-hygiene:audit bare invocation hard-fails with no remedy when the project directory is not a Git tree #1771

Closed

Description

@kyle-sexton

Summary

A bare /repo-fleet-hygiene:audit invocation from a session whose project
directory is not a Git working tree hard-fails with a one-line error and no
actionable next step. The failure is correct behavior per the script's fallback,
but the skill's own documentation describes the no-argument default as a
discovery root, which it is not.

Reproduction

Session primary working directory C:\Users\KyleSexton (a home directory, not a
repository). No repo-fleet-hygiene.conf exists at any rung of the config
ladder. Invoke the skill with no arguments:

Error: not a Git working tree: /c/Users/KyleSexton

Exit code 2. Nothing audited, no guidance emitted.

Root cause

skills/audit/scripts/audit-fleet.sh applies the no-argument fallback as an
exact repository target, not as a discovery root:

if [[ ${#ROOT_ARGS[@]} -eq 0 && ${#REPO_ARGS[@]} -eq 0 ]]; then
  REPO_ARGS+=("${CLAUDE_PROJECT_DIR:-$PWD}")
  ...
  CLI_REPO_COUNT=$((CLI_REPO_COUNT + 1))

Because it is registered with cli origin, add_target hard-fails rather than
degrading per-entry:

top="$(run_git_probe -C "$candidate" rev-parse --show-toplevel 2>/dev/null ...)" || {
  [[ "$origin" == "config" ]] || fail "not a Git working tree: $candidate"

The documentation says otherwise

The skill body describes the same fallback in root terms:

If neither --root nor --repo is present, the script uses
C:/Users/KyleSexton.

and separately documents --root <dir> as "bounded recursive repository
discovery". A reader reasonably expects the default to be discovered
recursively — which would have worked here, since real repositories exist
elsewhere on the machine. Instead the default is treated as an exact target and
the run aborts.

This is a real fork in behavior, not a wording nit: as a root, a non-repository
home directory is a valid starting point that discovers nothing or discovers
plenty; as an exact --repo, it is a fatal error.

Impact

The very first invocation on a machine where the fleet does not live under the
project directory fails with no path forward. The error names the rejected path
but does not mention --root, --repo, --config, or
/repo-fleet-hygiene:setup apply. Recovering required reading the collector
source to discover that the fallback was a --repo, then locating the fleet root
by hand.

Suggested fix

Pick one and align the documentation to it:

  • Treat the no-argument fallback as a discovery root (matches the documented
    wording). A non-repository project directory then discovers whatever is beneath
    it, and "no Git working trees found in the requested scope" is the honest
    outcome.
  • Keep it an exact target but degrade with guidance. On failure, emit the
    prerequisite error plus the three ways to supply scope (--root, --repo,
    --config) and a pointer to /repo-fleet-hygiene:setup apply.

Either way the error should name the remedy. A read-only audit skill failing
closed is right; failing closed silently is not.

Environment

  • repo-fleet-hygiene 0.7.0
  • Claude Code on Windows 11 Pro 10.0.26200, Git 2.54.0.windows.1
  • No config present at explicit, project-scoped, or user-global rung
  • Observed 2026-07-29

Activity

  1. added
    needs-triage
    on Jul 30, 2026
  2. self-assigned this
    on Jul 30, 2026
  3. kyle-sexton commented on Jul 30, 2026

    @kyle-sexton
    MemberAuthor

    Verified — reproduces, and the cited root cause is exactly right

    One wrinkle worth recording: a bare run on this machine today does not reproduce, because a
    repo-fleet-hygiene.conf has since appeared on the project rung
    (~/.claude/repo-fleet-hygiene.conf), so the config ladder supplies scope before the fallback is
    reached. Neutralizing the ladder with an isolated HOME and a non-Git CLAUDE_PROJECT_DIR
    reproduces it exactly:

    Error: not a Git working tree: /tmp/tmp.XXXX/proj
    

    exit code 2, nothing else emitted.

    The cited code is unchanged and does what the issue says: the no-argument fallback appends
    ${CLAUDE_PROJECT_DIR:-$PWD} to REPO_ARGS and increments CLI_REPO_COUNT, so add_target takes
    the cli branch and hard-fails rather than degrading. The documentation fork is real too — the
    skill body's "the script uses ${CLAUDE_PROJECT_DIR}" sits beside --root documented as "bounded
    recursive repository discovery", which reads as a discovery root.

    Fix: the issue's second option

    Fixed in the linked PR by keeping the exact target and degrading with guidance, not by turning the
    default into a discovery root. Reason for that choice: as a root, a bare invocation from a home
    directory would recursively scan the entire home tree by default — slow, surprising, and it would
    surface every repository on the machine when the operator asked for nothing. It would also sit
    badly with the skill's own rule to "never guess a broader machine root from the current path".

    The implicit target now carries its own rejection origin, so it still fails closed but the failure
    names --root, --repo, and --config and points at /repo-fleet-hygiene:setup apply. An
    explicitly supplied bad path stays terse — repeating how to pass a scope to someone who just passed
    one is noise. The skill body now states that the default is an exact target and that nothing beneath
    it is searched.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

needs-triage

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions