When you need to quickly locate all valid software project directories across a large, messy filesystem (e.g., ~ or ~/dev) without timing out or polluting results with dependencies, use this optimized find one-liner.
It prunes black-hole directories (node_modules, venv, hidden folders, dist, build) and looks for standard ecosystem manifests (package.json, Cargo.toml, etc.), then extracts and deduplicates their parent directories.
Optimized Bash Snippet:
# Finds project roots up to depth 3, aggressively pruning noise
find ~/dev ~ -maxdepth 3 \
-type d \( -name ".*" -o -name "node_modules" -o -name "venv" -o -name "dist" -o -name "build" \) -prune \
-o -type f \( -name "package.json" -o -name "pyproject.toml" -o -name "Cargo.toml" -o -name "go.mod" -o -name "wp-config.php" \) -print 2>/dev/null \
| awk -F'/[^/]*$' '{print $1}' \
| sort \
| uniq > /tmp/target_projects.txt
echo "Projects found: $(wc -l < /tmp/target_projects.txt)"
Use this whenever you need to map ecosystems, prepare a target list for multi-agent swarms, or conduct codebase audits across multiple repositories.