agentleFS
OdonnoOdonno/doc2skill/.agents/skills/notify/SKILL.md

notify

Skill1 starsChanged 4 months agoMITView on GitHub

Cross-platform filesystem notification library

6 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions6 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 6

    1. zjunlp/Mechanist★ 78same name
    2. jonhill90/skills★ 9same name
    3. yangwhale/CloseCrab★ 4same name
    4. jord0-cmd/jord0.skills★ 1same name
    5. JordanHood/claude-skills★ 0same name
    6. microsoft/IssueLens★ 0same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository3 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

3 rules. 0 are common, 2 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 5 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If you want debounced events (or don’t need them in-order), see notify-debouncer-mini or notify-debouncer-full.

    line 20
  2. Very specific:

    If you want to receive an event for a deletion of folder b for the path /a/b/.., you will have to watch its parent /a.

    line 67
  3. Distinctive:

    When watching a very large amount of files, notify may fail to receive all events.

    line 89

“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Cross-platform file system notification library

Installation

[dependencies]
notify = "9.0.0-rc.4"

If you want debounced events (or don’t need them in-order), see notify-debouncer-mini or notify-debouncer-full.

Features

List of compilation features, see below for details

  • serde for serialization of events
  • macos_fsevent enabled by default, for fsevent backend on macos
  • macos_kqueue for kqueue backend on macos
  • serialization-compat-6 restores the serialization behavior of notify 6, off by default

Serde

Events are serializable via serde if the serde feature is enabled:

notify = { version = "9.0.0-rc.4", features = ["serde"] }

Known Problems

Network filesystems

Network mounted filesystems like NFS may not emit any events for notify to listen to. This applies especially to WSL programs watching windows paths (issue #254).

A workaround is the PollWatcher backend.

Docker with Linux on macOS M1

Docker on macOS M1 throws Function not implemented (os error 38). You have to manually use the PollWatcher, as the native backend isn’t available inside the emulation.

macOS, FSEvents and unowned files

Due to the inner security model of FSEvents (see FileSystemEventSecurity), some events cannot be observed easily when trying to follow files that do not belong to you. In this case, reverting to the pollwatcher can fix the issue, with a slight performance cost.

macOS/APFS: std::fs::copy can trigger events on the source path

On APFS, std::fs::copy may use copy-on-write cloning (fclonefileat/clonefile). This can update inode metadata on the source file, and FSEvents may report a metadata change for the source path (see issue #259 and issue #465).

Workarounds are to avoid std::fs::copy (use std::io::copy or read/write instead), or filter out metadata-only events if they’re not relevant (e.g. don’t include EventKindMask::MODIFY_META in Config::with_event_kinds).

Editor Behaviour

If you rely on precise events (Write/Delete/Create..), you will notice that the actual events can differ a lot between file editors. Some truncate the file on save, some create a new one and replace the old one. See also this and this issues for example.

Parent folder deletion

If you want to receive an event for a deletion of folder b for the path /a/b/.., you will have to watch its parent /a. See here for more details.

Pseudo Filesystems like /proc, /sys

Some filesystems like /proc and /sys on *nix do not emit change events or use correct file change dates. To circumvent that problem you can use the PollWatcher with the compare_contents option.

Linux: Bad File Descriptor / No space left on device

This may be the case of running into the max-files watched limits of your user or system. (Files also includes folders.) Note that for recursive watched folders each file and folder inside counts towards the limit.

You may increase this limit in linux via

sudo sysctl fs.inotify.max_user_instances=8192 # example number
sudo sysctl fs.inotify.max_user_watches=524288 # example number
sudo sysctl -p

Note that the PollWatcher is not restricted by this limitation, so it may be an alternative if your users can’t increase the limit.

Watching large directories

When watching a very large amount of files, notify may fail to receive all events. For example the linux backend is documented to not be a 100% reliable source. See also issue #412.

Examples

For more examples visit the examples folder in the repository.

use notify::{Event, RecursiveMode, Result, Watcher};
use std::{path::Path, sync::mpsc};

fn main() -> Result<()> {
    let (tx, rx) = mpsc::channel::<Result<Event>>();

    // Use recommended_watcher() to automatically select the best implementation
    // for your platform. The `EventHandler` passed to this constructor can be a
    // closure, a `std::sync::mpsc::Sender`, a `crossbeam_channel::Sender`, or
    // another type the trait is implemented for.
    let mut watcher = notify::recommended_watcher(tx)?;

    // Add a path to be watched. All files and directories at that path and
    // below will be monitored for changes.
    watcher.watch(Path::new("."), RecursiveMode::Recursive)?;
    // Block forever, printing out events as they come in
    for res in rx {
        match res {
            Ok(event) => println!("event: {:?}", event),
            Err(e) => println!("watch error: {:?}", e),
        }
    }

    Ok(())
}

With different configurations

It is possible to create several watchers with different configurations or implementations that all call the same event function. This can accommodate advanced behaviour or work around limits.

      fn event_fn(res: Result<notify::Event>) {
          match res {
             Ok(event) => println!("event: {:?}", event),
             Err(e) => println!("watch error: {:?}", e),
          }
      }

      let mut watcher1 = notify::recommended_watcher(event_fn)?;
      // we will just use the same watcher kind again here
      let mut watcher2 = notify::recommended_watcher(event_fn)?;
      // dropping the watcher1/2 here (no loop etc) will end the program

References

Structs

  • Config
  • Error
  • Event
  • EventKindMask
  • UpdatePathsError
  • WatchPathConfig
  • event::Event
  • event::EventAttributes
  • event::EventKindMask
  • inotify::INotifyWatcher
  • null::NullWatcher
  • poll::PollWatcher

Enums

  • ErrorKind
  • EventKind
  • PathOp
  • RecursiveMode
  • WatcherKind
  • WindowsPathSeparatorStyle
  • event::AccessKind
  • event::AccessMode
  • event::CreateKind
  • event::DataChange
  • event::EventKind
  • event::Flag
  • event::MetadataKind
  • event::ModifyKind
  • event::RemoveKind
  • event::RenameMode

Traits

  • EventHandler
  • Watcher
  • poll::ScanEventHandler

Functions

  • recommended_watcher

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.