# Claude Project Tracking Repository Name Fallback ## Goal Ensure the `claude` shell wrapper always adds a normalized `project.name` to `OTEL_RESOURCE_ATTRIBUTES`, including when the current directory is not inside a Git repository. ## Design The wrapper will determine a raw repository name before normalizing it: - Inside a Git work tree, use the existing Git-derived top-level directory name. - Outside a Git work tree, use the basename of the current working directory. Both paths will share one normalization step. It will lowercase the name, replace spaces with underscores, preserve letters, digits, underscores, and hyphens, and remove other characters. For example, `My Cool-Project!` becomes `my_cool-project`. The wrapper will then prepend `project.name=` to an existing `OTEL_RESOURCE_ATTRIBUTES` value or create the variable when it is empty. Finally, it will invoke the real Claude Code binary with all original arguments. ## Error Handling Git command failures outside a work tree are expected and will select the current-directory fallback. Existing behavior for invoking `command claude` remains unchanged. ## Verification Automated shell checks will source the wrapper with a stubbed `claude` executable and verify: - A non-Git directory with spaces and punctuation produces the expected normalized project name. - An existing OTel attribute string is retained after the project name is prepended. - The wrapper forwards all arguments to the real command. - Existing Git-repository naming behavior remains intact.