# Workspace Project Depth Indicator Claude Code workspace depth tracker showing monorepo navigation level, project root detection, and directory depth visualization for context awareness. --- ## Metadata **Title:** Workspace Project Depth Indicator **Category:** statuslines **Author:** JSONbored **Added:** October 2025 **Tags:** workspace-depth, monorepo-navigation, directory-depth, project-context, workspace-tracking **URL:** https://claudepro.directory/statuslines/workspace-project-depth-indicator ## Overview Claude Code workspace depth tracker showing monorepo navigation level, project root detection, and directory depth visualization for context awareness. ## Content #!/usr/bin/env bash WORKSPACE PROJECT DEPTH INDICATOR FOR CLAUDE CODE TRACKS DIRECTORY DEPTH AND PROJECT CONTEXT READ JSON FROM STDIN read -r input EXTRACT WORKSPACE INFO currentdir=$(echo "$input" | jq -r '.workspace.currentdir // ""') HANDLE EMPTY WORKSPACE if [ -z "$currentdir" ] || [ "$currentdir" = "null" ]; then echo "📂 No workspace" exit 0 fi CALCULATE DIRECTORY DEPTH (COUNT OF SLASHES) REMOVE LEADING SLASH TO AVOID OFF-BY-ONE dirpath="${currentdir#/}" depth=$(echo "$dir_path" | tr -cd '/' | wc -c | tr -d ' ') DETECT PROJECT ROOT INDICATORS project_indicators=( ".git" "package.json" "Cargo.toml" "go.mod" "pom.xml" "build.gradle" "pyproject.toml" "composer.json" ) CHECK IF CURRENT DIRECTORY IS PROJECT ROOT ISPROJECTROOT=false PROJECT_TYPE="" for indicator in "${project_indicators[@]}"; do if [ -f "${currentdir}/${indicator}" ] || [ -d "${currentdir}/${indicator}" ]; then ISPROJECTROOT=true case "$indicator" in ".git") PROJECT_TYPE="git" ;; "package.json") PROJECT_TYPE="node" ;; "Cargo.toml") PROJECT_TYPE="rust" ;; "go.mod") PROJECT_TYPE="go" ;; "pom.xml"|"build.gradle") PROJECT_TYPE="java" ;; "pyproject.toml") PROJECT_TYPE="python" ;; "composer.json") PROJECT_TYPE="php" ;; esac break fi done FIND PROJECT ROOT BY WALKING UP DIRECTORY TREE PROJECTROOT="$currentdir" checkdir="$currentdir" while [ "$check_dir" != "/" ]; do for indicator in "${project_indicators[@]}"; do if [ -f "${checkdir}/${indicator}" ] || [ -d "${checkdir}/${indicator}" ]; then PROJECTROOT="$checkdir" break 2 fi done checkdir=$(dirname "$checkdir") done CALCULATE DEPTH RELATIVE TO PROJECT ROOT (0 = AT ROOT) if [ "$PROJECTROOT" != "$currentdir" ]; then relativepath="${currentdir#$PROJECT_ROOT/}" relativedepth=$(echo "$relativepath" | tr -cd '/' | wc -c | tr -d ' ') relativedepth=$((relativedepth + 1)) # +1 because we're in a subdirectory else relative_depth=0 fi COLOR CODING BASED ON DEPTH if [ $relative_depth -eq 0 ]; then DEPTH_COLOR="\[38;5;46m" # Green: At project root DEPTH_ICON="📁" DEPTH_STATUS="ROOT" elif [ $relative_depth -le 2 ]; then DEPTH_COLOR="\[38;5;75m" # Blue: 1-2 levels deep (normal) DEPTH_ICON="📂" DEPTHSTATUS="L${relativedepth}" elif [ $relative_depth -le 4 ]; then DEPTH_COLOR="\[38;5;226m" # Yellow: 3-4 levels deep (moderate) DEPTH_ICON="📂" DEPTHSTATUS="L${relativedepth}" else DEPTH_COLOR="\[38;5;208m" # Orange: 5+ levels deep (deep nesting) DEPTH_ICON="📂" DEPTHSTATUS="L${relativedepth}+" fi PROJECT TYPE INDICATOR if [ "$ISPROJECTROOT" = true ] && [ -n "$PROJECT_TYPE" ]; then TYPEDISPLAY="${PROJECTTYPE}" else TYPE_DISPLAY="" fi EXTRACT DIRECTORY NAME FOR DISPLAY dirname=$(basename "$currentdir") MONOREPO DETECTION (APPS/, PACKAGES/, LIBS/ DIRECTORIES) if echo "$current_dir" | grep -qE '/(apps|packages|libs|services|modules)/'; then MONOREPO_INDICATOR="[monorepo]" else MONOREPO_INDICATOR="" fi BUILD BREADCRUMB VISUALIZATION (LAST 3 DIRECTORIES) if [ $relative_depth -gt 0 ]; then breadcrumb=$(echo "$current_dir" | awk -F'/' '{for(i=NF-2;i<=NF;i++) if($i) printf "%s/", $i}' | sed 's|/$||') else breadcrumb="$dir_name" fi RESET="\[0m" OUTPUT STATUSLINE if [ -n "$TYPE_DISPLAY" ]; then echo -e "${DEPTHICON} ${DEPTHCOLOR}${DEPTHSTATUS}${RESET} ${TYPEDISPLAY} | ${breadcrumb} ${MONOREPO_INDICATOR}" else echo -e "${DEPTHICON} ${DEPTHCOLOR}${DEPTHSTATUS}${RESET} | ${breadcrumb} ${MONOREPOINDICATOR}" fi KEY FEATURES ? Real-time workspace directory depth tracking relative to project root ? Project root detection via common indicators (.git, package.json, Cargo.toml, etc.) ? Project type identification (git, node, rust, go, java, python, php) ? Monorepo detection for apps/, packages/, libs/ directory patterns ? Breadcrumb visualization showing last 3 directory levels ? Color-coded depth indicators (green root, blue 1-2 levels, yellow 3-4, orange 5+) ? Context awareness for navigating deep directory structures ? Lightweight bash with no external dependencies beyond jq CONFIGURATION Format: bash Refresh Interval: 2000ms Position: left USE CASES ? Monorepo navigation awareness (knowing which package/app you're in) ? Preventing confusion when working in deeply nested directories ? Project context tracking across multiple workspaces ? Debugging file path issues in complex project structures ? Team onboarding for large codebases with deep hierarchies ? Identifying when you've navigated too deep into implementation details TROUBLESHOOTING 1) Workspace showing 'No workspace' despite active Claude Code session Solution: Verify workspace.currentdir field exists: echo '$input' | jq .workspace.currentdir. If field missing or null, Claude Code may not be tracking workspace. Check that session was started in a directory (not attached to running process without cwd). 2) Project root not being detected correctly Solution: Script checks for common project indicators: .git, package.json, Cargo.toml, go.mod, pom.xml, build.gradle, pyproject.toml, composer.json. If your project uses different marker (e.g., .project), add to projectindicators array. Verify indicator exists: ls -la $currentdir. 3) Relative depth showing incorrect level count Solution: Depth calculation: relativedepth = (number of slashes in path after project root) + 1. Example: project root /foo/bar, current /foo/bar/src/lib = 2 levels deep. Check PROJECTROOT detection: echo $PROJECTROOT. Verify currentdir: echo $currentdir. Path stripping: ${currentdir#$PROJECT_ROOT/}. 4) Monorepo indicator not appearing for monorepo projects Solution: Monorepo detection matches directories containing /apps/, /packages/, /libs/, /services/, or /modules/. Check path: echo '$current_dir' | grep -E '/(apps|packages|libs|services|modules)/'. Add custom monorepo patterns to grep: |(workspaces|projects)/. 5) Breadcrumb showing only current directory not last 3 levels Solution: Breadcrumb uses awk to extract last 3 path components: awk -F'/' '{for(i=NF-2;i<=NF;i++) if($i) printf "%s/", $i}'. Test: echo '/foo/bar/baz/qux' | awk -F'/' '{for(i=NF-2;i<=NF;i++) if($i) printf "%s/", $i}' (should show bar/baz/qux). Adjust NF-2 to NF-N for more/fewer levels. 6) Project type not displaying despite being at project root Solution: ISPROJECTROOT flag set to true when indicator found in currentdir. Check file exists: ls $currentdir/package.json (for node). Verify case statement assigns PROJECTTYPE correctly. Add debug: echo ISPROJECTROOT=$ISPROJECTROOT PROJECTTYPE=$PROJECT_TYPE to output. TECHNICAL DETAILS Documentation: https://docs.claude.com/en/docs/claude-code/statusline PREVIEW 📂 L2 node | apps/web/src [monorepo] --- Source: Claude Pro Directory Website: https://claudepro.directory URL: https://claudepro.directory/statuslines/workspace-project-depth-indicator This content is optimized for Large Language Models (LLMs). For full formatting and interactive features, visit the website.