Overview
The LS tool displays directory contents in a hierarchical tree structure, making it easy to understand project organization and file layout. It’s ideal for exploring unfamiliar codebases and verifying directory structure.Parameters
The directory path to list. Defaults to the current working directory.
List of glob patterns to ignore. Files and directories matching these patterns are excluded from the output.
Maximum depth to traverse. Limits how many levels deep the tree goes. Defaults to unlimited (or config setting).
Features
Tree Structure
Output is displayed as an indented tree:Automatic Filtering
LS automatically skips:- Hidden files and directories (starting with
.) - Common system directories (
__pycache__,node_modules, etc.) - Files matching .gitignore patterns
- Files matching .crushignore patterns
Depth Control
Limit traversal depth to avoid overwhelming output:Result Limits
- Maximum files: 1000 files per listing
- Truncation notice: Shown if limit exceeded
- Depth warning: Shown when depth limit is reached
Output Format
Standard Output
Truncated Output
Depth Limited Output
Usage Examples
List Current Directory
List Specific Directory
Limit Depth
Ignore Patterns
Large Project Exploration
Best Practices
When to Use LS
- Initial exploration - Understanding project structure
- Before editing - Verifying file locations
- After changes - Checking new files were created
- Navigation - Finding your way in unfamiliar code
Effective Usage
- Start at project root - Get overall structure first
- Use depth limits - Prevent overwhelming output
- Explore incrementally - Go deeper into specific areas
- Combine with Glob - LS for structure, Glob for specific files
Managing Large Directories
- Use specific paths - List subdirectories instead of root
- Set depth limits - Show only relevant levels
- Use ignore patterns - Skip irrelevant directories
- Use Glob instead - For finding specific file patterns
Common Patterns
Project Exploration
Verify File Creation
Exclude Common Directories
Permissions
Auto-Approved
- Listing directories within the working directory
Requires Permission
- Listing directories outside the working directory
Cross-Platform Notes
Path Separators
Results use forward slashes/ on all platforms:
- Windows:
C:/Users/name/project/ - Unix:
/home/user/project/
Hidden Files
Unix/Linux/macOS:- Files starting with
.are hidden - Automatically skipped by LS
- Files with hidden attribute are not automatically skipped
- Files starting with
.are skipped for consistency
Case Sensitivity
- Unix/Linux/macOS - Case-sensitive file system
- Windows - Case-insensitive file system
Troubleshooting
Directory Not Found
- Check path is correct
- Use absolute paths to avoid ambiguity
- Verify directory exists
- Check permissions
Too Many Files
- Use more specific path
- Increase depth limit if set too low
- Use ignore patterns to exclude directories
- Use Glob tool instead for specific patterns
Empty Output
- Check if directory is empty
- Verify files aren’t all hidden
- Check ignore patterns aren’t too broad
- Check .gitignore and .crushignore
Performance Issues
- Use depth limits
- Specify narrower paths
- Exclude large directories with ignore
- Use Glob for targeted searches
LS vs Other Tools
LS vs Glob
Use LS when:- Understanding directory structure
- Seeing file organization
- Exploring unfamiliar projects
- Hierarchical view needed
- Finding files by pattern
- Searching specific file types
- Working with specific extensions
- Targeting specific files
LS vs Bash ls
Use LS tool:- Tree view of directory structure
- Recursive listing with depth control
- Respects .gitignore automatically
- Cross-platform consistent output
- Integrated into Crush workflow
- Detailed file information (sizes, permissions)
- Sorting options
- Custom formatting
- Scripting with other commands
LS vs View
Use LS when:- Exploring directory structure
- Finding file locations
- Understanding project layout
- Multiple files at once
- Reading file contents
- Understanding code
- Checking file details
- Getting LSP diagnostics
Common Workflows
Project Exploration
- LS root directory with depth=2
- Identify key directories (src, tests, etc.)
- LS each directory for detailed structure
- Use Glob to find specific file types
- Use View to read relevant files
Verification After Changes
- Make changes with Edit or Write
- LS the affected directory to verify structure
- Use Glob to find the new files
- Use View to check file contents
Navigation
- LS current location to see available paths
- Identify target directory from tree
- LS target directory for details
- Use View to read files of interest
Configuration
LS behavior can be configured incrush.json:
Configuration Options
max_depth- Default maximum depth for traversalmax_files- Maximum files to return (default 1000)