walkdir-rust

Implements recursive directory traversal in Rust using the walkdir crate.

2|Updated May 16, 2026
One-click install
npx skills add https://github.com/avbel/ai-skills --skill walkdir-rust-avbel
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: walkdir-rust
Source: https://github.com/avbel/ai-skills/tree/main/skills/walkdir-rust
Command: npx skills add https://github.com/avbel/ai-skills --skill walkdir-rust-avbel

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires walkdir.

What problem does it solve? Writing correct recursive directory traversal in Rust requires handling per-entry I/O errors, symlink cycles, depth limits, and efficient filtering, and this Skill encodes the idiomatic walkdir patterns so you avoid common mistakes like recursing into directories you meant to skip. ## Core Features & Use Cases - WalkDir Iterator Configuration: Set max_depth, min_depth, follow_links, sort_by, and contents_first to control traversal order and scope. - Efficient Filtering and Error Handling: Use filter_entry to prune entire subtrees, filter_map to skip permission errors, and DirEntry's cached file_type to avoid extra syscalls. - Use Case: You need to collect all .rs files in a project while skipping hidden directories like .git. Use filter_entry with a hidden-file check, filter_map to ignore I/O errors, and collect matching paths into a Vec<PathBuf>. ## Quick Start Use the walkdir-rust skill to write Rust code that recursively lists all files under a directory while skipping hidden folders and handling permission errors.

Frequently Asked Questions about walkdir-rust

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I recursively walk a directory in Rust?▼

Use the walkdir crate's WalkDir iterator: call WalkDir::new("path") and loop over the results, handling each Result<DirEntry, Error>. Add walkdir = "2" to Cargo.toml; it is a zero-dependency, cross-platform crate.

How do I skip directories like .git when walking files in Rust?▼

Use filter_entry on the WalkDir iterator with a closure that returns false for directories you want to skip. Unlike filter, filter_entry prunes the entire subtree so walkdir never recurses into skipped directories.

Does walkdir follow symbolic links by default?▼

No, walkdir does not follow symlinks by default; they appear as entries with is_symlink() true. Enable follow_links(true) to traverse them, and check Error::cycle_detected() since walkdir reports symlink cycles as errors.

Why is my walkdir traversal slow when checking file types?▼

Calling metadata() on every entry triggers a syscall per file. Use DirEntry::file_type() instead, which is cached from the directory read and costs no extra syscalls for is_dir, is_file, and is_symlink checks.

How do I handle permission denied errors during directory traversal?▼

WalkDir yields errors inline as Err entries without stopping iteration. Match on each result and inspect Error::io_error() and Error::path(), or use filter_map(|e| e.ok()) to silently skip entries that fail.